1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Preserve reconciled taints for all but non-string scalar types

This commit is contained in:
Matt Brown 2020-11-08 10:27:58 -05:00 committed by Daniil Gentili
parent 6095800fc5
commit b68995582e
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 16 additions and 1 deletions

View File

@ -309,7 +309,7 @@ class Reconciler
}
if (($statements_analyzer->data_flow_graph instanceof \Psalm\Internal\Codebase\TaintFlowGraph
&& $result_type->hasString())
&& (!$result_type->hasScalarType()) || $result_type->hasString())
|| $statements_analyzer->data_flow_graph instanceof \Psalm\Internal\Codebase\VariableUseGraph
) {
if ($before_adjustment && $before_adjustment->parent_nodes) {

View File

@ -1534,6 +1534,21 @@ class TaintTest extends TestCase
}',
'error_message' => 'TaintedInput',
],
'taintReturnedArray' => [
'<?php
function processParams(array $params) : array {
if (isset($params["foo"])) {
return $params;
}
return [];
}
$params = processParams($_GET);
echo $params["foo"];',
'error_message' => 'TaintedInput',
],
/*
// 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.