From 8c077d7824e6cb14dd60a6503e8fb66513e3e8b9 Mon Sep 17 00:00:00 2001 From: timglabisch Date: Mon, 22 Nov 2021 09:32:43 +0100 Subject: [PATCH 1/2] add Connection::executeStatement to stubs --- stubs/Connection.phpstub | 9 +++++++++ tests/acceptance/Tainting.feature | 12 +++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/stubs/Connection.phpstub b/stubs/Connection.phpstub index 38b06ed..af438a6 100644 --- a/stubs/Connection.phpstub +++ b/stubs/Connection.phpstub @@ -68,6 +68,15 @@ class Connection implements DriverConnection */ public function executeUpdate(string $query, array $params = [], array $types = []): int {} + /** + * @psalm-param scalar[] $params The query parameters. + * @psalm-param int[]|string[] $types The parameter types. + * + * @throws DBALException + * @psalm-taint-sink sql $query + */ + public function executeStatement($sql, array $params = [], array $types = []): int {} + /** * @psalm-pure * diff --git a/tests/acceptance/Tainting.feature b/tests/acceptance/Tainting.feature index 7971501..f017bf8 100644 --- a/tests/acceptance/Tainting.feature +++ b/tests/acceptance/Tainting.feature @@ -24,6 +24,7 @@ Feature: Tainting @Connection::exec @Connection::query @Connection::executeUpdate + @Connection::executeStatement Scenario Outline: Using user input on Connection's query methods Given I have the following code """ @@ -36,11 +37,12 @@ Feature: Tainting | /TaintedInput\|TaintedSql/ | /Detected tainted (sql\|SQL)/ | And I see no other errors Examples: - | method | - | prepare | - | exec | - | query | - | executeUpdate | + | method | + | prepare | + | exec | + | query | + | executeUpdate | + | executeStatement | @Connection::quote Scenario: Using Connection's quote method on user input From 1858d2f0833963bcb035da4cf1b7f98bca9051e3 Mon Sep 17 00:00:00 2001 From: Tim Glabisch Date: Mon, 22 Nov 2021 10:10:12 +0100 Subject: [PATCH 2/2] Update Connection.phpstub --- stubs/Connection.phpstub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/Connection.phpstub b/stubs/Connection.phpstub index af438a6..49eb7cc 100644 --- a/stubs/Connection.phpstub +++ b/stubs/Connection.phpstub @@ -73,7 +73,7 @@ class Connection implements DriverConnection * @psalm-param int[]|string[] $types The parameter types. * * @throws DBALException - * @psalm-taint-sink sql $query + * @psalm-taint-sink sql $sql */ public function executeStatement($sql, array $params = [], array $types = []): int {}