Skip to content

Commit

Permalink
feat(php): improve input sanitizer (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
gotbadger authored Feb 12, 2024
1 parent 7a20965 commit f572b83
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions rules/php/shared/lang/user_input_sanitizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ type: shared
languages:
- php
patterns:
- (int)$<_>
- count($<_>)
- filter_var($<!>$<_>$<...>)
metadata:
Expand Down
2 changes: 2 additions & 0 deletions tests/php/lang/raw_html_using_user_input/testdata/ok.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
$html = "<h1>{$_GET['x'] * $_GET['y']}</h1>";

$html = "<h1>{$ok}</h1>";
$foo = (int)$_GET['x']
$html = "<h1>{$foo}</h1>";
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
echo "<h1>" . filter_var($_GET["ok"], FILTER_SANITIZE_STRING) . "</h1>";
echo strip_tags($_GET["ok"]);
echo $_GET["x"] + $_GET["y"];
echo (int)$_GET["x"];

// FIXME: Add support for $this
$this->Oops = $_POST["oops"];
Expand Down

0 comments on commit f572b83

Please sign in to comment.