Skip to content
Permalink
Browse files

Remove false-positive for callmap function arg

  • Loading branch information...
muglug committed Aug 13, 2019
1 parent 55cfbdc commit d6e084ec9cb63db8131ba880fa2541abf491ef00
@@ -417,7 +417,8 @@ public static function taintBuiltinFunctionReturn(
case 'strtolower':
case 'strtoupper':
case 'print_r':
case 'sprintf':
case 'preg_quote':
case 'substr':
if (isset($call_args[0]->value->inferredType)
&& $call_args[0]->value->inferredType->tainted
@@ -783,6 +783,7 @@ private static function handleArrayAddition(
return false;
}
$context->inside_call = true;
if (isset($array_arg->inferredType) && $array_arg->inferredType->hasArray()) {
/** @var TArray|ObjectLike */
$array_type = $array_arg->inferredType->getTypes()['array'];
@@ -843,6 +844,8 @@ private static function handleArrayAddition(
);
}
$context->inside_call = false;
return;
}
@@ -304,9 +304,12 @@ public function isCallMapFunctionPure(Codebase $codebase, string $function_id, a
'newrelic_add_custom_tracer', 'newrelic_background_job', 'newrelic_end_transaction',
'newrelic_set_appname',
// execution
'shell_exec', 'exec', 'system', 'passthru',
// well-known functions
'libxml_use_internal_errors', 'array_map', 'curl_exec', 'shell_exec',
'mt_srand', 'openssl_pkcs7_sign', 'mysqli_select_db',
'libxml_use_internal_errors', 'array_map', 'curl_exec',
'mt_srand', 'openssl_pkcs7_sign', 'mysqli_select_db', 'preg_replace_callback',
// php environment
'ini_set', 'sleep', 'usleep', 'register_shutdown_function',
@@ -336,13 +336,21 @@ public function getMethodParams(
}
if ($context && $source instanceof \Psalm\Internal\Analyzer\StatementsAnalyzer) {
$was_inside_call = $context->inside_call;
$context->inside_call = true;
foreach ($args as $arg) {
\Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer::analyze(
$source,
$arg->value,
$context
);
}
if (!$was_inside_call) {
$context->inside_call = false;
}
}
$matching_callable = CallMap::getMatchingCallableFromCallMapOptions(
@@ -1056,6 +1056,13 @@ function foo(array $row, string $s) : array {
return $row;
}',
],
'pureWithReflectionMethodSetValue' => [
'<?php
function foo(object $mock) : void {
$m = new \ReflectionProperty($mock, "bar");
$m->setValue([get_class($mock) => "hello"]);
}'
],
];
}

0 comments on commit d6e084e

Please sign in to comment.
You can’t perform that action at this time.