Skip to content

Commit 92e83f9

Browse files
authored
Merge pull request #300 from microsoft/never-hide-string-interpolate-args-in-paths
PS: Never hide string interpolate argument in path graphs
2 parents fe4dc76 + 78384ca commit 92e83f9

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

powershell/ql/lib/semmle/code/powershell/dataflow/internal/DataFlowPrivate.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,10 @@ predicate neverSkipInPathGraph(Node n) {
437437
isReturned(n.(AstNode).getCfgNode())
438438
or
439439
n = any(SsaDefinitionNodeImpl def | not def.nodeIsHidden())
440+
or
441+
n.asExpr() instanceof CfgNodes::ExprNodes::ExpandableStringExprCfgNode
442+
or
443+
n.asExpr() instanceof CfgNodes::ExprNodes::ExpandableSubExprCfgNode
440444
}
441445

442446
/** An SSA node. */

powershell/ql/test/query-tests/security/cwe-078/CommandInjection/CommandInjection.expected

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ edges
66
| test.ps1:27:11:27:20 | userinput | test.ps1:28:38:28:67 | Get-Process -Name $UserInput | provenance | Sink:MaD:106 |
77
| test.ps1:33:11:33:20 | userinput | test.ps1:34:14:34:46 | public class Foo { $UserInput } | provenance | |
88
| test.ps1:39:11:39:20 | userinput | test.ps1:40:30:40:62 | public class Foo { $UserInput } | provenance | |
9-
| test.ps1:45:11:45:20 | userinput | test.ps1:47:5:47:9 | code | provenance | |
9+
| test.ps1:45:11:45:20 | userinput | test.ps1:47:13:47:45 | public class Foo { $UserInput } | provenance | |
1010
| test.ps1:47:5:47:9 | code | test.ps1:48:30:48:34 | code | provenance | |
11+
| test.ps1:47:13:47:45 | public class Foo { $UserInput } | test.ps1:47:5:47:9 | code | provenance | |
1112
| test.ps1:73:11:73:20 | userinput | test.ps1:75:25:75:54 | Get-Process -Name $UserInput | provenance | |
1213
| test.ps1:80:11:80:20 | userinput | test.ps1:82:16:82:45 | Get-Process -Name $UserInput | provenance | |
1314
| test.ps1:87:11:87:20 | userinput | test.ps1:89:12:89:28 | ping $UserInput | provenance | |
@@ -86,6 +87,7 @@ nodes
8687
| test.ps1:40:30:40:62 | public class Foo { $UserInput } | semmle.label | public class Foo { $UserInput } |
8788
| test.ps1:45:11:45:20 | userinput | semmle.label | userinput |
8889
| test.ps1:47:5:47:9 | code | semmle.label | code |
90+
| test.ps1:47:13:47:45 | public class Foo { $UserInput } | semmle.label | public class Foo { $UserInput } |
8991
| test.ps1:48:30:48:34 | code | semmle.label | code |
9092
| test.ps1:73:11:73:20 | userinput | semmle.label | userinput |
9193
| test.ps1:75:25:75:54 | Get-Process -Name $UserInput | semmle.label | Get-Process -Name $UserInput |

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
edges
2-
| test.ps1:1:1:1:10 | userinput | test.ps1:4:1:4:6 | query | provenance | |
2+
| test.ps1:1:1:1:10 | userinput | test.ps1:4:10:4:62 | SELECT * FROM MyTable WHERE MyColumn = '$userinput' | provenance | |
33
| test.ps1:1:1:1:10 | userinput | test.ps1:8:1:8:6 | query | provenance | |
44
| test.ps1:1:1:1:10 | userinput | test.ps1:17:24:17:76 | SELECT * FROM MyTable WHERE MyColumn = '$userinput' | provenance | |
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:59 | SELECT * FROM Customers WHERE id = $userinput | provenance | |
77
| test.ps1:1:1:1:10 | userinput | test.ps1:128:28:128:37 | userinput | provenance | |
88
| test.ps1:1:14:1:45 | Call to read-host | test.ps1:1:1:1:10 | userinput | provenance | Src:MaD:0 |
99
| test.ps1:4:1:4:6 | query | test.ps1:5:72:5:77 | query | provenance | |
10+
| test.ps1:4:10:4:62 | SELECT * FROM MyTable WHERE MyColumn = '$userinput' | test.ps1:4:1:4:6 | query | provenance | |
1011
| test.ps1:8:1:8:6 | query | test.ps1:9:72:9:77 | query | provenance | |
1112
| test.ps1:72:1:72:11 | QueryConn2 [element Query] | test.ps1:81:15:81:25 | QueryConn2 | provenance | |
1213
| test.ps1:72:15:79:1 | ${...} [element Query] | test.ps1:72:1:72:11 | QueryConn2 [element Query] | provenance | |
1314
| test.ps1:78:13:78:59 | SELECT * FROM Customers WHERE id = $userinput | test.ps1:72:15:79:1 | ${...} [element Query] | provenance | |
14-
| test.ps1:121:9:121:56 | unvalidated | test.ps1:125:92:125:143 | SELECT * FROM Customers where id = $($unvalidated) | provenance | |
15+
| test.ps1:121:9:121:56 | unvalidated | test.ps1:125:128:125:142 | $(...) | provenance | |
16+
| test.ps1:125:128:125:142 | $(...) | test.ps1:125:92:125:143 | SELECT * FROM Customers where id = $($unvalidated) | provenance | |
1517
| test.ps1:128:28:128:37 | userinput | test.ps1:121:9:121:56 | unvalidated | provenance | |
1618
nodes
1719
| test.ps1:1:1:1:10 | userinput | semmle.label | userinput |
1820
| test.ps1:1:14:1:45 | Call to read-host | semmle.label | Call to read-host |
1921
| test.ps1:4:1:4:6 | query | semmle.label | query |
22+
| test.ps1:4:10:4:62 | SELECT * FROM MyTable WHERE MyColumn = '$userinput' | semmle.label | SELECT * FROM MyTable WHERE MyColumn = '$userinput' |
2023
| test.ps1:5:72:5:77 | query | semmle.label | query |
2124
| test.ps1:8:1:8:6 | query | semmle.label | query |
2225
| test.ps1:9:72:9:77 | query | semmle.label | query |
@@ -28,6 +31,7 @@ nodes
2831
| test.ps1:81:15:81:25 | QueryConn2 | semmle.label | QueryConn2 |
2932
| test.ps1:121:9:121:56 | unvalidated | semmle.label | unvalidated |
3033
| test.ps1:125:92:125:143 | SELECT * FROM Customers where id = $($unvalidated) | semmle.label | SELECT * FROM Customers where id = $($unvalidated) |
34+
| test.ps1:125:128:125:142 | $(...) | semmle.label | $(...) |
3135
| test.ps1:128:28:128:37 | userinput | semmle.label | userinput |
3236
subpaths
3337
#select

0 commit comments

Comments
 (0)