Skip to content

Commit 5b5f6ec

Browse files
authored
Merge pull request #140 from microsoft/powershell-storestep-avoid-cp
PS: Remove accidental CP
2 parents 86a40b9 + 446b3ea commit 5b5f6ec

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

powershell/ql/lib/semmle/code/powershell/Command.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ private predicate parseCommandName(Cmd cmd, string namespace, string name) {
1414

1515
/** A call to a command. */
1616
class Cmd extends @command, CmdBase {
17-
override string toString() { result = "call to " + this.getQualifiedCommandName() }
17+
override string toString() {
18+
exists(string name | name = this.getQualifiedCommandName() |
19+
if name = "" then result = "call" else result = "call to " + name
20+
)
21+
or
22+
not exists(this.getQualifiedCommandName()) and
23+
result = "call"
24+
}
1825

1926
override SourceLocation getLocation() { command_location(this, result) }
2027

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ predicate storeStep(Node node1, ContentSet c, Node node2) {
842842
c.isAnyElement()
843843
)
844844
or
845+
c.isAnyElement() and
845846
exists(
846847
CfgNodes::ExprNodes::ArrayExprCfgNode arrayExpr, EscapeContainer::EscapeContainer container
847848
|
@@ -857,9 +858,9 @@ predicate storeStep(Node node1, ContentSet c, Node node2) {
857858
node2.(ReturnNodeImpl).getCfgScope() = cfgNode.getScope()
858859
)
859860
or
861+
c.isAnyElement() and
860862
exists(CfgNode cfgNode |
861863
node1 = TImplicitWrapNode(cfgNode, true) and
862-
c.isAnyElement() and
863864
node2.(ReturnNodeImpl).getCfgScope() = cfgNode.getScope()
864865
)
865866
or

powershell/ql/test/library-tests/ast/parent.expected

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@
106106
| Dynamic/DynamicExecution.ps1:3:1:3:28 | call to Create | Dynamic/DynamicExecution.ps1:3:1:3:28 | call to Create |
107107
| Dynamic/DynamicExecution.ps1:3:16:3:22 | Create | Dynamic/DynamicExecution.ps1:3:1:3:28 | call to Create |
108108
| Dynamic/DynamicExecution.ps1:3:23:3:27 | foo | Dynamic/DynamicExecution.ps1:3:1:3:28 | call to Create |
109-
| Dynamic/DynamicExecution.ps1:4:1:4:32 | call to | Dynamic/DynamicExecution.ps1:1:1:5:8 | {...} |
110-
| Dynamic/DynamicExecution.ps1:4:3:4:32 | (...) | Dynamic/DynamicExecution.ps1:4:1:4:32 | call to |
109+
| Dynamic/DynamicExecution.ps1:4:1:4:32 | call | Dynamic/DynamicExecution.ps1:1:1:5:8 | {...} |
110+
| Dynamic/DynamicExecution.ps1:4:3:4:32 | (...) | Dynamic/DynamicExecution.ps1:4:1:4:32 | call |
111111
| Dynamic/DynamicExecution.ps1:4:4:4:17 | scriptblock | Dynamic/DynamicExecution.ps1:4:4:4:31 | call to Create |
112112
| Dynamic/DynamicExecution.ps1:4:4:4:31 | call to Create | Dynamic/DynamicExecution.ps1:4:3:4:32 | (...) |
113113
| Dynamic/DynamicExecution.ps1:4:4:4:31 | call to Create | Dynamic/DynamicExecution.ps1:4:4:4:31 | call to Create |
114114
| Dynamic/DynamicExecution.ps1:4:19:4:25 | Create | Dynamic/DynamicExecution.ps1:4:4:4:31 | call to Create |
115115
| Dynamic/DynamicExecution.ps1:4:26:4:30 | foo | Dynamic/DynamicExecution.ps1:4:4:4:31 | call to Create |
116-
| Dynamic/DynamicExecution.ps1:5:1:5:8 | call to | Dynamic/DynamicExecution.ps1:1:1:5:8 | {...} |
117-
| Dynamic/DynamicExecution.ps1:5:2:5:8 | $foo | Dynamic/DynamicExecution.ps1:5:1:5:8 | call to |
116+
| Dynamic/DynamicExecution.ps1:5:1:5:8 | call | Dynamic/DynamicExecution.ps1:1:1:5:8 | {...} |
117+
| Dynamic/DynamicExecution.ps1:5:2:5:8 | $foo | Dynamic/DynamicExecution.ps1:5:1:5:8 | call |
118118
| Dynamic/DynamicExecution.ps1:5:3:5:7 | foo | Dynamic/DynamicExecution.ps1:5:2:5:8 | $foo |
119119
| Dynamic/DynamicExecutionWithFunc.ps1:1:1:11:2 | ExecuteAThing | Dynamic/DynamicExecutionWithFunc.ps1:1:1:11:2 | {...} |
120120
| Dynamic/DynamicExecutionWithFunc.ps1:1:1:11:2 | {...} | Dynamic/DynamicExecutionWithFunc.ps1:1:1:11:2 | DynamicExecutionWithFunc.ps1 |
@@ -136,15 +136,15 @@
136136
| Dynamic/DynamicExecutionWithFunc.ps1:7:5:7:32 | call to Create | Dynamic/DynamicExecutionWithFunc.ps1:7:5:7:32 | call to Create |
137137
| Dynamic/DynamicExecutionWithFunc.ps1:7:20:7:26 | Create | Dynamic/DynamicExecutionWithFunc.ps1:7:5:7:32 | call to Create |
138138
| Dynamic/DynamicExecutionWithFunc.ps1:7:27:7:31 | foo | Dynamic/DynamicExecutionWithFunc.ps1:7:5:7:32 | call to Create |
139-
| Dynamic/DynamicExecutionWithFunc.ps1:8:5:8:36 | call to | Dynamic/DynamicExecutionWithFunc.ps1:2:5:10:30 | {...} |
140-
| Dynamic/DynamicExecutionWithFunc.ps1:8:7:8:36 | (...) | Dynamic/DynamicExecutionWithFunc.ps1:8:5:8:36 | call to |
139+
| Dynamic/DynamicExecutionWithFunc.ps1:8:5:8:36 | call | Dynamic/DynamicExecutionWithFunc.ps1:2:5:10:30 | {...} |
140+
| Dynamic/DynamicExecutionWithFunc.ps1:8:7:8:36 | (...) | Dynamic/DynamicExecutionWithFunc.ps1:8:5:8:36 | call |
141141
| Dynamic/DynamicExecutionWithFunc.ps1:8:8:8:21 | scriptblock | Dynamic/DynamicExecutionWithFunc.ps1:8:8:8:35 | call to Create |
142142
| Dynamic/DynamicExecutionWithFunc.ps1:8:8:8:35 | call to Create | Dynamic/DynamicExecutionWithFunc.ps1:8:7:8:36 | (...) |
143143
| Dynamic/DynamicExecutionWithFunc.ps1:8:8:8:35 | call to Create | Dynamic/DynamicExecutionWithFunc.ps1:8:8:8:35 | call to Create |
144144
| Dynamic/DynamicExecutionWithFunc.ps1:8:23:8:29 | Create | Dynamic/DynamicExecutionWithFunc.ps1:8:8:8:35 | call to Create |
145145
| Dynamic/DynamicExecutionWithFunc.ps1:8:30:8:34 | foo | Dynamic/DynamicExecutionWithFunc.ps1:8:8:8:35 | call to Create |
146-
| Dynamic/DynamicExecutionWithFunc.ps1:9:5:9:12 | call to | Dynamic/DynamicExecutionWithFunc.ps1:2:5:10:30 | {...} |
147-
| Dynamic/DynamicExecutionWithFunc.ps1:9:6:9:12 | $foo | Dynamic/DynamicExecutionWithFunc.ps1:9:5:9:12 | call to |
146+
| Dynamic/DynamicExecutionWithFunc.ps1:9:5:9:12 | call | Dynamic/DynamicExecutionWithFunc.ps1:2:5:10:30 | {...} |
147+
| Dynamic/DynamicExecutionWithFunc.ps1:9:6:9:12 | $foo | Dynamic/DynamicExecutionWithFunc.ps1:9:5:9:12 | call |
148148
| Dynamic/DynamicExecutionWithFunc.ps1:9:7:9:11 | foo | Dynamic/DynamicExecutionWithFunc.ps1:9:6:9:12 | $foo |
149149
| Dynamic/DynamicExecutionWithFunc.ps1:10:5:10:30 | call to cmd.exe | Dynamic/DynamicExecutionWithFunc.ps1:2:5:10:30 | {...} |
150150
| Dynamic/DynamicExecutionWithFunc.ps1:10:7:10:16 | cmd.exe | Dynamic/DynamicExecutionWithFunc.ps1:10:5:10:30 | call to cmd.exe |

0 commit comments

Comments
 (0)