Skip to content

Commit 25d94fa

Browse files
committed
PS: Add false positive to 'ps/sql-injection'.
1 parent 0912cc3 commit 25d94fa

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,23 @@ edges
33
| test.ps1:1:14:1:45 | Call to read-host | test.ps1:9:72:9:77 | query | provenance | Src:MaD:0 |
44
| test.ps1:1:14:1:45 | Call to read-host | test.ps1:17:24:17:76 | SELECT * FROM MyTable WHERE MyColumn = '$userinput' | provenance | Src:MaD:0 |
55
| test.ps1:1:14:1:45 | Call to read-host | test.ps1:28:24:28:76 | SELECT * FROM MyTable WHERE MyColumn = '$userinput' | provenance | Src:MaD:0 |
6+
| test.ps1:58:11:58:30 | server_instance | test.ps1:63:22:63:28 | server | provenance | |
7+
| test.ps1:61:14:68:1 | ${...} [element ServerInstance] | test.ps1:70:15:70:24 | QueryConn | provenance | |
8+
| test.ps1:63:22:63:28 | server | test.ps1:61:14:68:1 | ${...} [element ServerInstance] | provenance | |
69
nodes
710
| test.ps1:1:14:1:45 | Call to read-host | semmle.label | Call to read-host |
811
| test.ps1:5:72:5:77 | query | semmle.label | query |
912
| test.ps1:9:72:9:77 | query | semmle.label | query |
1013
| test.ps1:17:24:17:76 | SELECT * FROM MyTable WHERE MyColumn = '$userinput' | semmle.label | SELECT * FROM MyTable WHERE MyColumn = '$userinput' |
1114
| test.ps1:28:24:28:76 | SELECT * FROM MyTable WHERE MyColumn = '$userinput' | semmle.label | SELECT * FROM MyTable WHERE MyColumn = '$userinput' |
15+
| test.ps1:58:11:58:30 | server_instance | semmle.label | server_instance |
16+
| test.ps1:61:14:68:1 | ${...} [element ServerInstance] | semmle.label | ${...} [element ServerInstance] |
17+
| test.ps1:63:22:63:28 | server | semmle.label | server |
18+
| test.ps1:70:15:70:24 | QueryConn | semmle.label | QueryConn |
1219
subpaths
1320
#select
1421
| 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 | user-provided value |
1522
| test.ps1:9:72:9:77 | query | test.ps1:1:14:1:45 | Call to read-host | test.ps1:9:72:9:77 | query | This SQL query depends on a $@. | test.ps1:1:14:1:45 | Call to read-host | user-provided value |
1623
| test.ps1:17:24:17:76 | SELECT * FROM MyTable WHERE MyColumn = '$userinput' | test.ps1:1:14:1:45 | Call to read-host | test.ps1:17:24:17:76 | SELECT * FROM MyTable WHERE MyColumn = '$userinput' | This SQL query depends on a $@. | test.ps1:1:14:1:45 | Call to read-host | user-provided value |
1724
| 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 | user-provided value |
25+
| test.ps1:70:15:70:24 | QueryConn | test.ps1:58:11:58:30 | server_instance | test.ps1:70:15:70:24 | QueryConn | This SQL query depends on a $@. | test.ps1:58:11:58:30 | server_instance | user-provided value |

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,15 @@ $reader.Close()
5656
$connection.Close()
5757

5858
$server = $Env:SERVER_INSTANCE
59-
Invoke-Sqlcmd -ServerInstance $server -Database "MyDatabase" -InputFile "Foo/Bar/query.sql" # GOOD
59+
Invoke-Sqlcmd -ServerInstance $server -Database "MyDatabase" -InputFile "Foo/Bar/query.sql" # GOOD
60+
61+
$QueryConn = @{
62+
Database = "MyDB"
63+
ServerInstance = $server
64+
Username = "MyUserName"
65+
Password = "MyPassword"
66+
ConnectionTimeout = 0
67+
Query = ""
68+
}
69+
70+
Invoke-Sqlcmd @QueryConn # GOOD [FALSE POSITIVE]

0 commit comments

Comments
 (0)