Skip to content

Commit 7a96fec

Browse files
authored
Merge pull request #281 from microsoft/do-not-warn-on-inputfile
PS: Do not alert on `inputfile` in the SQL injection query
2 parents 42104ec + 84c3df2 commit 7a96fec

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

powershell/ql/lib/semmle/code/powershell/security/SqlInjectionCustomizations.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ module SqlInjection {
5757
exists(DataFlow::CallNode call | call.matchesName("Invoke-Sqlcmd") |
5858
this = call.getNamedArgument(query())
5959
or
60-
this = call.getNamedArgument(inputfile())
61-
or
60+
// If the input is not provided as a query parameter or an input file
61+
// parameter then it's the first argument.
6262
not call.hasNamedArgument(query()) and
6363
not call.hasNamedArgument(inputfile()) and
6464
this = call.getArgument(0)

powershell/ql/test/query-tests/security/cwe-089/test.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,6 @@ function TakesTypedParameters([int]$i, [long]$l, [float]$f, [double]$d, [decimal
109109
TakesTypedParameters $userinput $userinput $userinput $userinput $userinput $userinput $userinput $userinput
110110

111111
$query = "SELECT * FROM MyTable WHERE MyColumn = '$userinput'"
112-
Invoke-Sqlcmd -unknown $userinput -ServerInstance "MyServer" -Database "MyDatabase" -q "SELECT * FROM MyTable" # GOOD
112+
Invoke-Sqlcmd -unknown $userinput -ServerInstance "MyServer" -Database "MyDatabase" -q "SELECT * FROM MyTable" # GOOD
113+
114+
Invoke-Sqlcmd -ServerInstance "MyServer" -Database "MyDatabase" -InputFile $userinput # GOOD # this is not really what this query is about.

0 commit comments

Comments
 (0)