1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

New sinks for TaintedCallable #10117

This commit is contained in:
cgocast 2023-08-22 13:41:47 +02:00
parent 8bfcf473b9
commit 72c9bf8575
2 changed files with 19 additions and 0 deletions

View File

@ -15,6 +15,7 @@ class ReflectionClass implements Reflector {
/** /**
* @param T|class-string<T>|interface-string<T>|trait-string|enum-string<T> $argument * @param T|class-string<T>|interface-string<T>|trait-string|enum-string<T> $argument
* @psalm-pure * @psalm-pure
* @psalm-taint-sink callable $argument
*/ */
public function __construct($argument) {} public function __construct($argument) {}
@ -411,6 +412,11 @@ abstract class ReflectionFunctionAbstract implements Reflector
/** @psalm-pure */ /** @psalm-pure */
public function getClosure(): Closure {} public function getClosure(): Closure {}
/**
* @psalm-taint-sink callable $function
*/
public function __construct(callable $function) {}
/** /**
* @since 8.0 * @since 8.0
* @template TClass as object * @template TClass as object

View File

@ -2488,6 +2488,19 @@ class TaintTest extends TestCase
'code' => '<?php 'code' => '<?php
echo pg_escape_string($conn, $_GET["a"]);', echo pg_escape_string($conn, $_GET["a"]);',
'error_message' => 'TaintedHtml', 'error_message' => 'TaintedHtml',
'taintedReflectionClass' => [
'code' => '<?php
$name = $_GET["name"];
$reflector = new ReflectionClass($name);
$reflector->newInstance();',
'error_message' => 'TaintedCallable',
],
'taintedReflectionFunction' => [
'code' => '<?php
$name = $_GET["name"];
$function = new ReflectionFunction($name);
$function->invoke();',
'error_message' => 'TaintedCallable',
], ],
]; ];
} }