<?php
$get = $_GET;
echo $get["test"];
gives an error (OK):
ERROR: TaintedInput - src/index.php:5:6 - Detected tainted html in path: $_GET -> $get (src/index.php:3:1) -> $get['test'] (src/index.php:5:6) -> call to echo (src/index.php:5:6) -> echo#1 (see https://psalm.dev/205)
echo $get["test"];
<?php
$get = array_map('trim', $_GET);
echo $get["test"];
gives no tainting error (FAIL)
version used: psalm 3.12.1
Hey @thomasbley, can you reproduce the issue on https://psalm.dev ?
can you reproduce the issue on https://psalm.dev ?
No, seems taint-analysis is not enabled there and settings have no option to enable it.
also:
<?php
$get = filter_var($_GET, FILTER_CALLBACK, ['options' => 'trim']);
echo $get["test"];
gives no tainting error (FAIL)
FYI you can append a comment to the header on psalm.dev: https://psalm.dev/r/cb40a74129
I found these snippets:
https://psalm.dev/r/cb40a74129
<?php // --taint-analysis
$get = array_map('trim', $_GET);
echo $get["test"];
Psalm output (using commit f458959):
No issues!
Most helpful comment
FYI you can append a comment to the header on psalm.dev: https://psalm.dev/r/cb40a74129