Skip to content

Commit

Permalink
Array cast pass taints
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah committed Nov 3, 2021
1 parent 73fb04f commit 24137bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -2182,6 +2182,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 24137bd

Please sign in to comment.