Skip to content

Commit 655d80e

Browse files
committed
PS: Repair tests and accept test changes in syntax tests.
1 parent 7551cce commit 655d80e

File tree

12 files changed

+462
-461
lines changed

12 files changed

+462
-461
lines changed

powershell/ql/test/TestUtilities/InlineFlowTestUtil.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ import powershell
66
import semmle.code.powershell.dataflow.DataFlow
77

88
predicate defaultSource(DataFlow::Node src) {
9-
src.asStmt().getStmt().(Cmd).getCommandName() = ["Source", "Taint"]
9+
src.asExpr().getExpr().(CmdCall).getName() = ["Source", "Taint"]
1010
or
1111
src.asParameter().getName().matches(["Source%", "Taint%"])
1212
}
1313

1414
predicate defaultSink(DataFlow::Node sink) {
15-
exists(Cmd cmd | cmd.getCommandName() = "Sink" | sink.asExpr().getExpr() = cmd.getAnArgument())
15+
exists(CmdCall cmd | cmd.getName() = "Sink" | sink.asExpr().getExpr() = cmd.getAnArgument())
1616
}
1717

1818
string getSourceArgString(DataFlow::Node src) {
1919
defaultSource(src) and
2020
(
21-
src.asStmt().getStmt().(Cmd).getAnArgument().(StringConstExpr).getValue().getValue() = result
21+
src.asExpr().getExpr().(CmdCall).getAnArgument().(StringConstExpr).getValue().getValue() = result
2222
or
2323
src.asParameter().getName().regexpCapture(["Source(.+)", "Taint(.+)"], 1) = result
2424
)
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
arrayExpr
2-
| Arrays.ps1:11:11:11:25 | @(...) | Arrays.ps1:11:13:11:24 | {...} |
3-
| Arrays.ps1:14:41:14:44 | @(...) | Arrays.ps1:0:0:0:0 | {...} |
2+
| Arrays.ps1:11:11:11:24 | @(...) | Arrays.ps1:11:13:11:23 | {...} |
3+
| Arrays.ps1:14:41:14:43 | @(...) | Arrays.ps1:0:0:0:-1 | {...} |
44
arrayLiteral
5-
| Arrays.ps1:1:11:1:37 | ...,... | 0 | Arrays.ps1:1:11:1:12 | 1 |
6-
| Arrays.ps1:1:11:1:37 | ...,... | 1 | Arrays.ps1:1:13:1:14 | 2 |
7-
| Arrays.ps1:1:11:1:37 | ...,... | 2 | Arrays.ps1:1:15:1:18 | a |
8-
| Arrays.ps1:1:11:1:37 | ...,... | 3 | Arrays.ps1:1:19:1:24 | true |
9-
| Arrays.ps1:1:11:1:37 | ...,... | 4 | Arrays.ps1:1:25:1:31 | false |
10-
| Arrays.ps1:1:11:1:37 | ...,... | 5 | Arrays.ps1:1:32:1:37 | null |
11-
| Arrays.ps1:5:34:5:37 | ...,... | 0 | Arrays.ps1:5:34:5:35 | 2 |
12-
| Arrays.ps1:5:34:5:37 | ...,... | 1 | Arrays.ps1:5:36:5:37 | 2 |
13-
| Arrays.ps1:6:9:6:12 | ...,... | 0 | Arrays.ps1:6:9:6:10 | 0 |
14-
| Arrays.ps1:6:9:6:12 | ...,... | 1 | Arrays.ps1:6:11:6:12 | 0 |
15-
| Arrays.ps1:7:9:7:12 | ...,... | 0 | Arrays.ps1:7:9:7:10 | 1 |
16-
| Arrays.ps1:7:9:7:12 | ...,... | 1 | Arrays.ps1:7:11:7:12 | 0 |
17-
| Arrays.ps1:8:9:8:12 | ...,... | 0 | Arrays.ps1:8:9:8:10 | 0 |
18-
| Arrays.ps1:8:9:8:12 | ...,... | 1 | Arrays.ps1:8:11:8:12 | 1 |
19-
| Arrays.ps1:9:9:9:12 | ...,... | 0 | Arrays.ps1:9:9:9:10 | 1 |
20-
| Arrays.ps1:9:9:9:12 | ...,... | 1 | Arrays.ps1:9:11:9:12 | 1 |
21-
| Arrays.ps1:11:13:11:24 | ...,... | 0 | Arrays.ps1:11:13:11:16 | a |
22-
| Arrays.ps1:11:13:11:24 | ...,... | 1 | Arrays.ps1:11:17:11:20 | b |
23-
| Arrays.ps1:11:13:11:24 | ...,... | 2 | Arrays.ps1:11:21:11:24 | c |
5+
| Arrays.ps1:1:11:1:36 | ...,... | 0 | Arrays.ps1:1:11:1:11 | 1 |
6+
| Arrays.ps1:1:11:1:36 | ...,... | 1 | Arrays.ps1:1:13:1:13 | 2 |
7+
| Arrays.ps1:1:11:1:36 | ...,... | 2 | Arrays.ps1:1:15:1:17 | a |
8+
| Arrays.ps1:1:11:1:36 | ...,... | 3 | Arrays.ps1:1:19:1:23 | true |
9+
| Arrays.ps1:1:11:1:36 | ...,... | 4 | Arrays.ps1:1:25:1:30 | false |
10+
| Arrays.ps1:1:11:1:36 | ...,... | 5 | Arrays.ps1:1:32:1:36 | null |
11+
| Arrays.ps1:5:34:5:36 | ...,... | 0 | Arrays.ps1:5:34:5:34 | 2 |
12+
| Arrays.ps1:5:34:5:36 | ...,... | 1 | Arrays.ps1:5:36:5:36 | 2 |
13+
| Arrays.ps1:6:9:6:11 | ...,... | 0 | Arrays.ps1:6:9:6:9 | 0 |
14+
| Arrays.ps1:6:9:6:11 | ...,... | 1 | Arrays.ps1:6:11:6:11 | 0 |
15+
| Arrays.ps1:7:9:7:11 | ...,... | 0 | Arrays.ps1:7:9:7:9 | 1 |
16+
| Arrays.ps1:7:9:7:11 | ...,... | 1 | Arrays.ps1:7:11:7:11 | 0 |
17+
| Arrays.ps1:8:9:8:11 | ...,... | 0 | Arrays.ps1:8:9:8:9 | 0 |
18+
| Arrays.ps1:8:9:8:11 | ...,... | 1 | Arrays.ps1:8:11:8:11 | 1 |
19+
| Arrays.ps1:9:9:9:11 | ...,... | 0 | Arrays.ps1:9:9:9:9 | 1 |
20+
| Arrays.ps1:9:9:9:11 | ...,... | 1 | Arrays.ps1:9:11:9:11 | 1 |
21+
| Arrays.ps1:11:13:11:23 | ...,... | 0 | Arrays.ps1:11:13:11:15 | a |
22+
| Arrays.ps1:11:13:11:23 | ...,... | 1 | Arrays.ps1:11:17:11:19 | b |
23+
| Arrays.ps1:11:13:11:23 | ...,... | 2 | Arrays.ps1:11:21:11:23 | c |

powershell/ql/test/library-tests/ast/Arrays/arrays.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import powershell
33
query predicate arrayExpr(ArrayExpr arrayExpr, StmtBlock subExpr) { subExpr = arrayExpr.getStmtBlock() }
44

55
query predicate arrayLiteral(ArrayLiteral arrayLiteral, int i, Expr e) {
6-
e = arrayLiteral.getElement(i)
6+
e = arrayLiteral.getExpr(i)
77
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
| ParamBlock.ps1:2:1:5:2 | param(...) | 0 | ParamBlock.ps1:3:5:4:23 | Parameter |
1+
| ParamBlock.ps1:1:1:5:1 | {...} | 0 | ParamBlock.ps1:1:1:5:1 | Parameter |
2+
| ParamBlock.ps1:1:1:5:1 | {...} | 1 | ParamBlock.ps1:1:1:5:1 | [synth] pipeline |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import powershell
22

3-
query predicate paramBlockHasParam(ParamBlock block, int i, Parameter p) {
3+
query predicate paramBlockHasParam(ScriptBlock block, int i, Parameter p) {
44
p = block.getParameter(i)
55
}
Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
binaryExpr
2-
| BinaryExpression.ps1:3:11:3:24 | ...+... | BinaryExpression.ps1:3:11:3:16 | val1 | BinaryExpression.ps1:3:19:3:24 | val2 |
3-
| TernaryExpression.ps1:1:9:1:16 | ... -gt ... | TernaryExpression.ps1:1:9:1:10 | 6 | TernaryExpression.ps1:1:15:1:16 | 7 |
2+
| BinaryExpression.ps1:3:11:3:23 | ...+... | BinaryExpression.ps1:3:11:3:15 | val1 | BinaryExpression.ps1:3:19:3:23 | val2 |
3+
| TernaryExpression.ps1:1:9:1:15 | ... -gt ... | TernaryExpression.ps1:1:9:1:9 | 6 | TernaryExpression.ps1:1:15:1:15 | 7 |
44
cmdExpr
5-
| BinaryExpression.ps1:1:9:1:10 | 1 | BinaryExpression.ps1:1:9:1:10 | 1 |
6-
| BinaryExpression.ps1:2:9:2:10 | 2 | BinaryExpression.ps1:2:9:2:10 | 2 |
7-
| BinaryExpression.ps1:3:11:3:24 | ...+... | BinaryExpression.ps1:3:11:3:24 | ...+... |
8-
| BinaryExpression.ps1:4:1:4:8 | result | BinaryExpression.ps1:4:1:4:8 | result |
9-
| ExpandableString.ps1:1:1:1:40 | Date: $([DateTime]::Now)\nName: $name | ExpandableString.ps1:1:1:1:40 | Date: $([DateTime]::Now)\nName: $name |
10-
| ExpandableString.ps1:1:23:1:38 | Now | ExpandableString.ps1:1:23:1:38 | Now |
11-
| SubExpression.ps1:1:1:1:24 | call to AddDays | SubExpression.ps1:1:1:1:24 | call to AddDays |
12-
| SubExpression.ps1:2:1:2:22 | call to AddDays | SubExpression.ps1:2:1:2:22 | call to AddDays |
13-
| TernaryExpression.ps1:1:8:1:23 | ...?...:... | TernaryExpression.ps1:1:8:1:23 | ...?...:... |
14-
| TernaryExpression.ps1:1:9:1:16 | ... -gt ... | TernaryExpression.ps1:1:9:1:16 | ... -gt ... |
5+
| BinaryExpression.ps1:4:1:4:7 | [Stmt] result | BinaryExpression.ps1:4:1:4:7 | result |
6+
| ExpandableString.ps1:1:1:1:39 | [Stmt] Date: $([DateTime]::Now)\nName: $name | ExpandableString.ps1:1:1:1:39 | Date: $([DateTime]::Now)\nName: $name |
7+
| ExpandableString.ps1:1:23:1:37 | [Stmt] Now | ExpandableString.ps1:1:23:1:37 | Now |
8+
| SubExpression.ps1:1:1:1:23 | [Stmt] Call to AddDays | SubExpression.ps1:1:1:1:23 | Call to AddDays |
9+
| SubExpression.ps1:1:3:1:10 | [Stmt] Call to Get-Date | SubExpression.ps1:1:3:1:10 | Call to Get-Date |
10+
| SubExpression.ps1:2:1:2:21 | [Stmt] Call to AddDays | SubExpression.ps1:2:1:2:21 | Call to AddDays |
11+
| SubExpression.ps1:2:3:2:10 | [Stmt] Call to Get-Date | SubExpression.ps1:2:3:2:10 | Call to Get-Date |
1512
invokeMemoryExpression
16-
| SubExpression.ps1:1:1:1:24 | call to AddDays | SubExpression.ps1:1:1:1:12 | $(...) | 0 | SubExpression.ps1:1:21:1:23 | 10 |
13+
| SubExpression.ps1:1:1:1:23 | Call to AddDays | SubExpression.ps1:1:1:1:11 | $(...) | 0 | SubExpression.ps1:1:21:1:22 | 10 |
1714
expandableString
18-
| ExpandableString.ps1:1:1:1:40 | Date: $([DateTime]::Now)\nName: $name | 0 | ExpandableString.ps1:1:8:1:13 | name |
19-
| ExpandableString.ps1:1:1:1:40 | Date: $([DateTime]::Now)\nName: $name | 1 | ExpandableString.ps1:1:21:1:39 | $(...) |
15+
| ExpandableString.ps1:1:1:1:39 | Date: $([DateTime]::Now)\nName: $name | 1 | ExpandableString.ps1:1:21:1:38 | $(...) |

powershell/ql/test/library-tests/ast/Expressions/expressions.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ query predicate binaryExpr(BinaryExpr e, Expr e1, Expr e2) {
55
e2 = e.getRight()
66
}
77

8-
query predicate cmdExpr(CmdExpr cmd, Expr e) {
9-
e = cmd.getExpr()
8+
query predicate cmdExpr(ExprStmt exprStmt, Expr e) {
9+
e = exprStmt.getExpr()
1010
}
1111

1212
query predicate invokeMemoryExpression(InvokeMemberExpr invoke, Expr e, int i, Expr arg) {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
doUntil
2-
| DoUntil.ps1:1:1:7:19 | DoUntil | DoUntil.ps1:7:10:7:18 | ... -le ... | DoUntil.ps1:2:1:7:2 | {...} |
2+
| DoUntil.ps1:1:1:7:18 | do...until... | DoUntil.ps1:7:10:7:17 | ... -le ... | DoUntil.ps1:2:1:7:1 | {...} |
33
doWhile
4-
| DoWhile.ps1:1:1:7:19 | DoWhile | DoWhile.ps1:7:10:7:18 | ... -le ... | DoWhile.ps1:2:1:7:2 | {...} |
4+
| DoWhile.ps1:1:1:7:18 | do...while... | DoWhile.ps1:7:10:7:17 | ... -le ... | DoWhile.ps1:2:1:7:1 | {...} |
55
while
6-
| While.ps1:2:1:13:2 | while(...) {...} | While.ps1:2:8:2:18 | ... -le ... | While.ps1:3:1:13:2 | {...} |
6+
| While.ps1:2:1:13:1 | while(...) {...} | While.ps1:2:8:2:17 | ... -le ... | While.ps1:3:1:13:1 | {...} |
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import powershell
22

3-
query predicate doUntil(DoUntilStmt s, PipelineBase e, StmtBlock body) {
3+
query predicate doUntil(DoUntilStmt s, Expr e, StmtBlock body) {
44
e = s.getCondition() and
55
body = s.getBody()
66
}
77

8-
query predicate doWhile(DoWhileStmt s, PipelineBase e, StmtBlock body) {
8+
query predicate doWhile(DoWhileStmt s, Expr e, StmtBlock body) {
99
e = s.getCondition() and
1010
body = s.getBody()
1111
}
1212

13-
query predicate while(WhileStmt s, PipelineBase e, StmtBlock body) {
13+
query predicate while(WhileStmt s, Expr e, StmtBlock body) {
1414
e = s.getCondition() and
1515
body = s.getBody()
1616
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| FileRedirection.ps1:3:3:3:7 | MergingRedirection |
2-
| FileRedirection.ps1:3:8:3:20 | FileRedirection |
1+
| FileRedirection.ps1:3:3:3:6 | MergingRedirection |
2+
| FileRedirection.ps1:3:8:3:19 | FileRedirection |

0 commit comments

Comments
 (0)