mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 13:51:54 +01:00
Fix #4620 - reconciled literal strings cannot carry taints
This commit is contained in:
parent
f969b01db4
commit
43187a0e19
@ -309,7 +309,8 @@ class Reconciler
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (($statements_analyzer->data_flow_graph instanceof \Psalm\Internal\Codebase\TaintFlowGraph
|
if (($statements_analyzer->data_flow_graph instanceof \Psalm\Internal\Codebase\TaintFlowGraph
|
||||||
&& (!$result_type->hasScalarType()) || $result_type->hasString())
|
&& (!$result_type->hasScalarType())
|
||||||
|
|| ($result_type->hasString() && !$result_type->hasLiteralString()))
|
||||||
|| $statements_analyzer->data_flow_graph instanceof \Psalm\Internal\Codebase\VariableUseGraph
|
|| $statements_analyzer->data_flow_graph instanceof \Psalm\Internal\Codebase\VariableUseGraph
|
||||||
) {
|
) {
|
||||||
if ($before_adjustment && $before_adjustment->parent_nodes) {
|
if ($before_adjustment && $before_adjustment->parent_nodes) {
|
||||||
|
@ -544,6 +544,19 @@ class TaintTest extends TestCase
|
|||||||
$a = new A("bar");
|
$a = new A("bar");
|
||||||
echo $a->getTaint();',
|
echo $a->getTaint();',
|
||||||
],
|
],
|
||||||
|
'literalStringCannotCarryTaint' => [
|
||||||
|
'<?php
|
||||||
|
$file = $_GET["foo"];
|
||||||
|
|
||||||
|
if ($file !== "") {
|
||||||
|
/**
|
||||||
|
* @psalm-taint-escape input
|
||||||
|
*/
|
||||||
|
$file = basename($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $file;'
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user