Skip to content

Commit 6da1c01

Browse files
committed
PS: Add false positive with GUID.
1 parent 9bafbaf commit 6da1c01

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

powershell/ql/test/query-tests/security/cwe-089/SqlInjection.expected

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,20 @@ edges
1919
| test.ps1:78:49:78:58 | userinput | test.ps1:78:13:78:59 | SELECT * FROM Customers WHERE id = $userinput | provenance | Config |
2020
| test.ps1:78:49:78:58 | userinput | test.ps1:111:51:111:60 | userinput | provenance | |
2121
| test.ps1:111:51:111:60 | userinput | test.ps1:128:28:128:37 | userinput | provenance | |
22+
| test.ps1:111:51:111:60 | userinput | test.ps1:150:10:150:19 | userinput | provenance | |
2223
| test.ps1:121:9:121:56 | unvalidated | test.ps1:125:130:125:141 | unvalidated | provenance | |
2324
| test.ps1:125:128:125:142 | $(...) | test.ps1:125:92:125:143 | SELECT * FROM Customers where id = $($unvalidated) | provenance | |
2425
| test.ps1:125:128:125:142 | $(...) | test.ps1:125:92:125:143 | SELECT * FROM Customers where id = $($unvalidated) | provenance | Config |
2526
| test.ps1:125:130:125:141 | unvalidated | test.ps1:125:128:125:142 | $(...) | provenance | |
2627
| test.ps1:125:130:125:141 | unvalidated | test.ps1:125:128:125:142 | $(...) | provenance | Config |
2728
| test.ps1:128:28:128:37 | userinput | test.ps1:121:9:121:56 | unvalidated | provenance | |
29+
| test.ps1:144:11:144:50 | r | test.ps1:146:55:146:56 | r | provenance | |
30+
| test.ps1:146:5:146:10 | query | test.ps1:147:72:147:77 | query | provenance | |
31+
| test.ps1:146:5:146:10 | query | test.ps1:147:72:147:77 | query | provenance | |
32+
| test.ps1:146:14:146:58 | SELECT * FROM MyTable WHERE MyColumn = '$r' | test.ps1:146:5:146:10 | query | provenance | |
33+
| test.ps1:146:14:146:58 | SELECT * FROM MyTable WHERE MyColumn = '$r' | test.ps1:146:5:146:10 | query | provenance | |
34+
| test.ps1:146:55:146:56 | r | test.ps1:146:14:146:58 | SELECT * FROM MyTable WHERE MyColumn = '$r' | provenance | Config |
35+
| test.ps1:150:10:150:19 | userinput | test.ps1:144:11:144:50 | r | provenance | |
2836
nodes
2937
| test.ps1:1:1:1:10 | userinput | semmle.label | userinput |
3038
| test.ps1:1:14:1:45 | Call to read-host | semmle.label | Call to read-host |
@@ -52,6 +60,13 @@ nodes
5260
| test.ps1:125:128:125:142 | $(...) | semmle.label | $(...) |
5361
| test.ps1:125:130:125:141 | unvalidated | semmle.label | unvalidated |
5462
| test.ps1:128:28:128:37 | userinput | semmle.label | userinput |
63+
| test.ps1:144:11:144:50 | r | semmle.label | r |
64+
| test.ps1:146:5:146:10 | query | semmle.label | query |
65+
| test.ps1:146:5:146:10 | query | semmle.label | query |
66+
| test.ps1:146:14:146:58 | SELECT * FROM MyTable WHERE MyColumn = '$r' | semmle.label | SELECT * FROM MyTable WHERE MyColumn = '$r' |
67+
| test.ps1:146:55:146:56 | r | semmle.label | r |
68+
| test.ps1:147:72:147:77 | query | semmle.label | query |
69+
| test.ps1:150:10:150:19 | userinput | semmle.label | userinput |
5570
subpaths
5671
#select
5772
| test.ps1:5:72:5:77 | query | test.ps1:1:14:1:45 | Call to read-host | test.ps1:5:72:5:77 | query | This SQL query depends on a $@. | test.ps1:1:14:1:45 | Call to read-host | read from stdin |
@@ -60,3 +75,4 @@ subpaths
6075
| test.ps1:28:24:28:76 | SELECT * FROM MyTable WHERE MyColumn = '$userinput' | test.ps1:1:14:1:45 | Call to read-host | test.ps1:28:24:28:76 | SELECT * FROM MyTable WHERE MyColumn = '$userinput' | This SQL query depends on a $@. | test.ps1:1:14:1:45 | Call to read-host | read from stdin |
6176
| test.ps1:81:15:81:25 | QueryConn2 | test.ps1:1:14:1:45 | Call to read-host | test.ps1:81:15:81:25 | QueryConn2 | This SQL query depends on a $@. | test.ps1:1:14:1:45 | Call to read-host | read from stdin |
6277
| test.ps1:125:92:125:143 | SELECT * FROM Customers where id = $($unvalidated) | test.ps1:1:14:1:45 | Call to read-host | test.ps1:125:92:125:143 | SELECT * FROM Customers where id = $($unvalidated) | This SQL query depends on a $@. | test.ps1:1:14:1:45 | Call to read-host | read from stdin |
78+
| test.ps1:147:72:147:77 | query | test.ps1:1:14:1:45 | Call to read-host | test.ps1:147:72:147:77 | query | This SQL query depends on a $@. | test.ps1:1:14:1:45 | Call to read-host | read from stdin |

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,13 @@ $QueryConn3 = @{
138138

139139
Invoke-Sqlcmd @QueryConn3 # GOOD
140140

141-
&sqlcmd -e -S $userinput -U "Login" -P "MyPassword" -d "MyDBName" -i "input_file.sql" # GOOD
141+
&sqlcmd -e -S $userinput -U "Login" -P "MyPassword" -d "MyDBName" -i "input_file.sql" # GOOD
142+
143+
function WithGuid {
144+
PARAM([Parameter(Mandatory = $true)] [guid] $r)
145+
146+
$query = "SELECT * FROM MyTable WHERE MyColumn = '$r'"
147+
Invoke-Sqlcmd -ServerInstance "MyServer" -Database "MyDatabase" -q $query # GOOD [FALSE POSITIVE]
148+
}
149+
150+
WithGuid $userinput

0 commit comments

Comments
 (0)