Skip to content

Commit e8df3cc

Browse files
committed
PS: Add another FP test.
1 parent 9af1306 commit e8df3cc

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ edges
55
| test.ps1:1:1:1:10 | userinput | test.ps1:28:24:28:76 | SELECT * FROM MyTable WHERE MyColumn = '$userinput' | provenance | |
66
| test.ps1:1:1:1:10 | userinput | test.ps1:78:13:78:22 | userinput | provenance | |
77
| test.ps1:1:1:1:10 | userinput | test.ps1:128:28:128:37 | userinput | provenance | |
8+
| test.ps1:1:1:1:10 | userinput | test.ps1:136:17:136:26 | userinput | provenance | |
89
| test.ps1:1:14:1:45 | Call to read-host | test.ps1:1:1:1:10 | userinput | provenance | Src:MaD:0 |
910
| test.ps1:4:1:4:6 | query | test.ps1:5:72:5:77 | query | provenance | |
1011
| test.ps1:8:1:8:6 | query | test.ps1:9:72:9:77 | query | provenance | |
@@ -13,6 +14,9 @@ edges
1314
| test.ps1:78:13:78:22 | userinput | test.ps1:72:15:79:1 | ${...} [element Query] | provenance | |
1415
| test.ps1:121:9:121:56 | unvalidated | test.ps1:125:92:125:103 | unvalidated | provenance | |
1516
| test.ps1:128:28:128:37 | userinput | test.ps1:121:9:121:56 | unvalidated | provenance | |
17+
| test.ps1:130:1:130:11 | QueryConn3 [element inputfile] | test.ps1:139:15:139:25 | QueryConn3 | provenance | |
18+
| test.ps1:130:15:137:1 | ${...} [element inputfile] | test.ps1:130:1:130:11 | QueryConn3 [element inputfile] | provenance | |
19+
| test.ps1:136:17:136:26 | userinput | test.ps1:130:15:137:1 | ${...} [element inputfile] | provenance | |
1620
nodes
1721
| test.ps1:1:1:1:10 | userinput | semmle.label | userinput |
1822
| test.ps1:1:14:1:45 | Call to read-host | semmle.label | Call to read-host |
@@ -29,6 +33,10 @@ nodes
2933
| test.ps1:121:9:121:56 | unvalidated | semmle.label | unvalidated |
3034
| test.ps1:125:92:125:103 | unvalidated | semmle.label | unvalidated |
3135
| test.ps1:128:28:128:37 | userinput | semmle.label | userinput |
36+
| test.ps1:130:1:130:11 | QueryConn3 [element inputfile] | semmle.label | QueryConn3 [element inputfile] |
37+
| test.ps1:130:15:137:1 | ${...} [element inputfile] | semmle.label | ${...} [element inputfile] |
38+
| test.ps1:136:17:136:26 | userinput | semmle.label | userinput |
39+
| test.ps1:139:15:139:25 | QueryConn3 | semmle.label | QueryConn3 |
3240
subpaths
3341
#select
3442
| 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 |
@@ -37,3 +45,4 @@ subpaths
3745
| 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 |
3846
| 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 |
3947
| test.ps1:125:92:125:103 | unvalidated | test.ps1:1:14:1:45 | Call to read-host | test.ps1:125:92:125:103 | unvalidated | This SQL query depends on a $@. | test.ps1:1:14:1:45 | Call to read-host | read from stdin |
48+
| test.ps1:139:15:139:25 | QueryConn3 | test.ps1:1:14:1:45 | Call to read-host | test.ps1:139:15:139:25 | QueryConn3 | 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: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,15 @@ function With-Validation() {
125125
Invoke-Sqlcmd -unknown $userinput -ServerInstance "MyServer" -Database "MyDatabase" -q $unvalidated # BAD
126126
}
127127

128-
With-Validation $userinput $userinput
128+
With-Validation $userinput $userinput
129+
130+
$QueryConn3 = @{
131+
Database = "MyDB"
132+
ServerInstance = "MyServer"
133+
Username = "MyUserName"
134+
Password = "MyPassword"
135+
ConnectionTimeout = 0
136+
inputfile = $userinput
137+
}
138+
139+
Invoke-Sqlcmd @QueryConn3 # GOOD [FALSE POSITIVE]

0 commit comments

Comments
 (0)