Skip to content

Commit

Permalink
Merge pull request #6810 from orklah/castArrayTaints
Browse files Browse the repository at this point in the history
Array cast pass taints
  • Loading branch information
orklah committed Nov 4, 2021
2 parents c2b14e2 + 24137bd commit bf99345
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Expand Up @@ -232,8 +232,7 @@ public static function analyze(
$type = Type::getArray();
}

if ($statements_analyzer->data_flow_graph instanceof \Psalm\Internal\Codebase\VariableUseGraph
) {
if ($statements_analyzer->data_flow_graph) {
$type->parent_nodes = $stmt_expr_type->parent_nodes ?? [];
}

Expand Down
10 changes: 10 additions & 0 deletions tests/TaintTest.php
Expand Up @@ -2190,6 +2190,16 @@ function foo(array $arr) : void {
'error_message' => 'TaintedHtml',
],
*/
'castToArrayPassTaints' => [
'<?php
$args = $_POST;
$args = (array) $args;
pg_query($connection, "SELECT * FROM tableA where key = " .$args["key"]);
',
'error_message' => 'TaintedSql',
],
];
}

Expand Down

0 comments on commit bf99345

Please sign in to comment.