mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
exclude Plus on arrays too
This commit is contained in:
parent
3b01713257
commit
9fb74a4f28
@ -378,6 +378,7 @@ class BinaryOpAnalyzer
|
||||
&& $stmt instanceof PhpParser\Node\Expr\BinaryOp
|
||||
&& !$stmt instanceof PhpParser\Node\Expr\BinaryOp\Concat
|
||||
&& !$stmt instanceof PhpParser\Node\Expr\BinaryOp\Coalesce
|
||||
&& (!$stmt instanceof PhpParser\Node\Expr\BinaryOp\Plus || !$result_type->hasArray())
|
||||
) {
|
||||
//among BinaryOp, only Concat and Coalesce can pass tainted value to the result
|
||||
return;
|
||||
|
@ -650,6 +650,12 @@ class TaintTest extends TestCase
|
||||
$var = $input === "x";
|
||||
var_dump($var);'
|
||||
],
|
||||
'resultOfPlusIsNotTainted' => [
|
||||
'<?php
|
||||
$input = $_GET["foo"];
|
||||
$var = $input + 1;
|
||||
var_dump($var);'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -2159,6 +2165,16 @@ class TaintTest extends TestCase
|
||||
takesArray([$_GET["bad"] => "good"]);',
|
||||
'error_message' => 'TaintedHtml',
|
||||
],
|
||||
'resultOfPlusIsTaintedOnArrays' => [
|
||||
'<?php
|
||||
scope($_GET["foo"]);
|
||||
function scope(array $foo)
|
||||
{
|
||||
$var = $foo + [];
|
||||
var_dump($var);
|
||||
}',
|
||||
'error_message' => 'TaintedHtml',
|
||||
],
|
||||
'taintArrayKeyWithExplicitSink' => [
|
||||
'<?php
|
||||
/** @psalm-taint-sink html $values */
|
||||
|
Loading…
x
Reference in New Issue
Block a user