From 220ca96d3c6b5f4a6761c09e0a9e8f0dbb282440 Mon Sep 17 00:00:00 2001 From: Alies Lapatsin Date: Sun, 17 Mar 2024 17:09:58 +0100 Subject: [PATCH] Replace TaintAnalysis test by .phpt --- .../acceptance/TaintAnalysis.feature | 47 ------------------- .../Type/tests/TaintAnalysis/TaintedHtml.phpt | 13 +++++ .../Type/tests/TaintAnalysis/TaintedSql.phpt | 14 ++++++ 3 files changed, 27 insertions(+), 47 deletions(-) delete mode 100644 tests/Acceptance/acceptance/TaintAnalysis.feature create mode 100644 tests/Type/tests/TaintAnalysis/TaintedHtml.phpt create mode 100644 tests/Type/tests/TaintAnalysis/TaintedSql.phpt diff --git a/tests/Acceptance/acceptance/TaintAnalysis.feature b/tests/Acceptance/acceptance/TaintAnalysis.feature deleted file mode 100644 index a407a897..00000000 --- a/tests/Acceptance/acceptance/TaintAnalysis.feature +++ /dev/null @@ -1,47 +0,0 @@ -Feature: Taint Analysis - Want to check that taint analysis works properly - - Background: - Given I have the following config - """ - - - - - - - - - - - """ - - Scenario: request input is taint for Builder::raw - Given I have the following code - """ - input('foo'); - $query_builder->raw($user_input); - } - """ - When I run Psalm with taint analysis - Then I see these errors - | Type | Message | - | TaintedSql | Detected tainted SQL | - - Scenario: request input is taint for HTTP Response content - Given I have the following code - """ - input('foo'); - - return new \Illuminate\Http\Response($taint_input); - } - """ - When I run Psalm with taint analysis - Then I see these errors - | Type | Message | - | TaintedHtml | Detected tainted HTML | diff --git a/tests/Type/tests/TaintAnalysis/TaintedHtml.phpt b/tests/Type/tests/TaintAnalysis/TaintedHtml.phpt new file mode 100644 index 00000000..2f71f53a --- /dev/null +++ b/tests/Type/tests/TaintAnalysis/TaintedHtml.phpt @@ -0,0 +1,13 @@ +--ARGS-- +--no-progress --no-diff --config=./tests/Type/psalm.xml --taint-analysis +--FILE-- +input('foo'); + + return new \Illuminate\Http\Response($taint_input); +} +?> +--EXPECTF-- +TaintedHtml on line %d: Detected tainted HTML diff --git a/tests/Type/tests/TaintAnalysis/TaintedSql.phpt b/tests/Type/tests/TaintAnalysis/TaintedSql.phpt new file mode 100644 index 00000000..d57fceb8 --- /dev/null +++ b/tests/Type/tests/TaintAnalysis/TaintedSql.phpt @@ -0,0 +1,14 @@ +--ARGS-- +--no-progress --no-diff --config=./tests/Type/psalm.xml --taint-analysis +--FILE-- +input('foo'); + + $query_builder->raw($user_input); +} +?> +--EXPECTF-- +TaintedSql on line %d: Detected tainted SQL