From 29e1fee5f5913549187cd1242068c9bbc765a394 Mon Sep 17 00:00:00 2001 From: Matt Brown Date: Sun, 21 Jun 2020 18:15:07 -0400 Subject: [PATCH] Add Taint Analysis test --- src/Stubs/DBFacade.stubphp | 16 ++++++++++++ src/Stubs/InteractsWithInput.stubphp | 2 ++ src/Stubs/QueryBuilder.phphp | 24 +++++++++++++++++ tests/acceptance/TaintAnalysis.feature | 36 ++++++++++++++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 src/Stubs/DBFacade.stubphp create mode 100644 src/Stubs/QueryBuilder.phphp create mode 100644 tests/acceptance/TaintAnalysis.feature diff --git a/src/Stubs/DBFacade.stubphp b/src/Stubs/DBFacade.stubphp new file mode 100644 index 0000000..6cdaedd --- /dev/null +++ b/src/Stubs/DBFacade.stubphp @@ -0,0 +1,16 @@ + + + + + + + + + + + """ + + Scenario: input returns various types + Given I have the following code + """ + input('foo', false); + DB::raw($input); + } + """ + When I run Psalm with taint analysis + Then I see these errors + | TaintedInput | Detected tainted sql in path: Illuminate\Http\Request::input (/Users/brownma/Desktop/git/laravel-psalm-plugin/src/Stubs/InteractsWithInput.stubphp:22:21) -> $input (somefile.php:9:3) -> Illuminate\Support\Facades\DB::raw#1 (/Users/brownma/Desktop/git/laravel-psalm-plugin/src/Stubs/DBFacade.stubphp:15:25) |