mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Taint through reset call
This commit is contained in:
parent
f24ef253e3
commit
f41deeab0a
@ -3,6 +3,7 @@ namespace Psalm\Internal\Provider\ReturnTypeProvider;
|
||||
|
||||
use PhpParser;
|
||||
use Psalm\Plugin\EventHandler\Event\FunctionReturnTypeProviderEvent;
|
||||
use Psalm\Internal\Analyzer\Statements\Expression\Fetch\ArrayFetchAnalyzer;
|
||||
use Psalm\Type;
|
||||
|
||||
class ArrayPointerAdjustmentReturnTypeProvider implements \Psalm\Plugin\EventHandler\FunctionReturnTypeProviderInterface
|
||||
@ -77,6 +78,14 @@ class ArrayPointerAdjustmentReturnTypeProvider implements \Psalm\Plugin\EventHan
|
||||
}
|
||||
}
|
||||
|
||||
ArrayFetchAnalyzer::taintArrayFetch(
|
||||
$statements_source,
|
||||
$first_arg,
|
||||
null,
|
||||
$value_type,
|
||||
Type::getMixed()
|
||||
);
|
||||
|
||||
return $value_type;
|
||||
}
|
||||
}
|
||||
|
@ -2122,6 +2122,17 @@ class TaintTest extends TestCase
|
||||
doTheMagic([(string)$_GET["bad"] => "foo"]);',
|
||||
'error_message' => 'TaintedHtml',
|
||||
],
|
||||
'taintThroughReset' => [
|
||||
'<?php
|
||||
function foo(array $arr) : void {
|
||||
if ($arr) {
|
||||
echo reset($arr);
|
||||
}
|
||||
}
|
||||
|
||||
foo([$_GET["a"]]);',
|
||||
'error_message' => 'TaintedHtml',
|
||||
],
|
||||
/*
|
||||
// TODO: Stubs do not support this type of inference even with $this->message = $message.
|
||||
// Most uses of getMessage() would be with caught exceptions, so this is not representative of real code.
|
||||
|
Loading…
x
Reference in New Issue
Block a user