diff --git a/powershell/ql/test/library-tests/ast/Arrays/Arrays.ps1 b/powershell/ql/test/library-tests/ast/Arrays/Arrays.ps1 new file mode 100644 index 00000000000..fe0b980c568 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Arrays/Arrays.ps1 @@ -0,0 +1,15 @@ +$array1 = 1,2,"a",$true,$false,$null # 1-D array +$array1[1] = 3 +$array1[2] = "b" + +$array2 = New-Object 'object[,]' 2,2 # 2-D array +$array2[0,0] = "key1" +$array2[1,0] = "key1" +$array2[0,1] = "value1" +$array2[1,1] = $null + +$array3 = @("a","b","c") +$array3.count + +$array4 = [System.Collections.ArrayList]@() +$array4.Add(1) \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Arrays/arrays.expected b/powershell/ql/test/library-tests/ast/Arrays/arrays.expected new file mode 100644 index 00000000000..d8930c0ed0e --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Arrays/arrays.expected @@ -0,0 +1,23 @@ +arrayExpr +| Arrays.ps1:11:11:11:25 | ArrayExpression at: Arrays.ps1:11:11:11:25 | Arrays.ps1:11:13:11:24 | StatementBlock at: Arrays.ps1:11:13:11:24 | +| Arrays.ps1:14:41:14:44 | ArrayExpression at: Arrays.ps1:14:41:14:44 | Arrays.ps1:0:0:0:0 | StatementBlock at: Arrays.ps1:0:0:0:0 | +arrayLiteral +| Arrays.ps1:1:11:1:37 | ArrayLiteral at: Arrays.ps1:1:11:1:37 | 0 | Arrays.ps1:1:11:1:12 | ConstantExpression at: Arrays.ps1:1:11:1:12 | +| Arrays.ps1:1:11:1:37 | ArrayLiteral at: Arrays.ps1:1:11:1:37 | 1 | Arrays.ps1:1:13:1:14 | ConstantExpression at: Arrays.ps1:1:13:1:14 | +| Arrays.ps1:1:11:1:37 | ArrayLiteral at: Arrays.ps1:1:11:1:37 | 2 | Arrays.ps1:1:15:1:18 | a | +| Arrays.ps1:1:11:1:37 | ArrayLiteral at: Arrays.ps1:1:11:1:37 | 3 | Arrays.ps1:1:19:1:24 | true | +| Arrays.ps1:1:11:1:37 | ArrayLiteral at: Arrays.ps1:1:11:1:37 | 4 | Arrays.ps1:1:25:1:31 | false | +| Arrays.ps1:1:11:1:37 | ArrayLiteral at: Arrays.ps1:1:11:1:37 | 5 | Arrays.ps1:1:32:1:37 | null | +| Arrays.ps1:5:34:5:37 | ArrayLiteral at: Arrays.ps1:5:34:5:37 | 0 | Arrays.ps1:5:34:5:35 | ConstantExpression at: Arrays.ps1:5:34:5:35 | +| Arrays.ps1:5:34:5:37 | ArrayLiteral at: Arrays.ps1:5:34:5:37 | 1 | Arrays.ps1:5:36:5:37 | ConstantExpression at: Arrays.ps1:5:36:5:37 | +| Arrays.ps1:6:9:6:12 | ArrayLiteral at: Arrays.ps1:6:9:6:12 | 0 | Arrays.ps1:6:9:6:10 | ConstantExpression at: Arrays.ps1:6:9:6:10 | +| Arrays.ps1:6:9:6:12 | ArrayLiteral at: Arrays.ps1:6:9:6:12 | 1 | Arrays.ps1:6:11:6:12 | ConstantExpression at: Arrays.ps1:6:11:6:12 | +| Arrays.ps1:7:9:7:12 | ArrayLiteral at: Arrays.ps1:7:9:7:12 | 0 | Arrays.ps1:7:9:7:10 | ConstantExpression at: Arrays.ps1:7:9:7:10 | +| Arrays.ps1:7:9:7:12 | ArrayLiteral at: Arrays.ps1:7:9:7:12 | 1 | Arrays.ps1:7:11:7:12 | ConstantExpression at: Arrays.ps1:7:11:7:12 | +| Arrays.ps1:8:9:8:12 | ArrayLiteral at: Arrays.ps1:8:9:8:12 | 0 | Arrays.ps1:8:9:8:10 | ConstantExpression at: Arrays.ps1:8:9:8:10 | +| Arrays.ps1:8:9:8:12 | ArrayLiteral at: Arrays.ps1:8:9:8:12 | 1 | Arrays.ps1:8:11:8:12 | ConstantExpression at: Arrays.ps1:8:11:8:12 | +| Arrays.ps1:9:9:9:12 | ArrayLiteral at: Arrays.ps1:9:9:9:12 | 0 | Arrays.ps1:9:9:9:10 | ConstantExpression at: Arrays.ps1:9:9:9:10 | +| Arrays.ps1:9:9:9:12 | ArrayLiteral at: Arrays.ps1:9:9:9:12 | 1 | Arrays.ps1:9:11:9:12 | ConstantExpression at: Arrays.ps1:9:11:9:12 | +| Arrays.ps1:11:13:11:24 | ArrayLiteral at: Arrays.ps1:11:13:11:24 | 0 | Arrays.ps1:11:13:11:16 | a | +| Arrays.ps1:11:13:11:24 | ArrayLiteral at: Arrays.ps1:11:13:11:24 | 1 | Arrays.ps1:11:17:11:20 | b | +| Arrays.ps1:11:13:11:24 | ArrayLiteral at: Arrays.ps1:11:13:11:24 | 2 | Arrays.ps1:11:21:11:24 | c | diff --git a/powershell/ql/test/library-tests/ast/Arrays/arrays.ql b/powershell/ql/test/library-tests/ast/Arrays/arrays.ql new file mode 100644 index 00000000000..18aa9ea5988 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Arrays/arrays.ql @@ -0,0 +1,7 @@ +import powershell + +query predicate arrayExpr(ArrayExpr arrayExpr, StmtBlock subExpr) { subExpr = arrayExpr.getStatementBlock() } + +query predicate arrayLiteral(ArrayLiteral arrayLiteral, int i, Expr e) { + e = arrayLiteral.getElement(i) +} diff --git a/powershell/ql/test/library-tests/ast/Blocks/ParamBlock.ps1 b/powershell/ql/test/library-tests/ast/Blocks/ParamBlock.ps1 new file mode 100644 index 00000000000..79ff9379f09 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Blocks/ParamBlock.ps1 @@ -0,0 +1,5 @@ +[CmdletBinding()] +param( + [Parameter()] + [string]$Parameter +) \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Blocks/blocks.expected b/powershell/ql/test/library-tests/ast/Blocks/blocks.expected new file mode 100644 index 00000000000..b2116a0389b --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Blocks/blocks.expected @@ -0,0 +1 @@ +| ParamBlock.ps1:2:1:5:2 | ParamBlock | 0 | ParamBlock.ps1:3:5:4:23 | Parameter | diff --git a/powershell/ql/test/library-tests/ast/Blocks/blocks.ql b/powershell/ql/test/library-tests/ast/Blocks/blocks.ql new file mode 100644 index 00000000000..9c4288d3560 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Blocks/blocks.ql @@ -0,0 +1,5 @@ +import powershell + +query predicate paramBlockHasParam(ParamBlock block, int i, Parameter p) { + p = block.getParameter(i) +} \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Dynamic/DynamicExecution.ps1 b/powershell/ql/test/library-tests/ast/Dynamic/DynamicExecution.ps1 new file mode 100644 index 00000000000..0baac441a31 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Dynamic/DynamicExecution.ps1 @@ -0,0 +1,5 @@ +$foo = 'cmd.exe' +Invoke-Expression $foo +[scriptblock]::Create($foo) +& ([scriptblock]::Create($foo)) +&"$foo" \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Dynamic/DynamicExecutionWithFunc.ps1 b/powershell/ql/test/library-tests/ast/Dynamic/DynamicExecutionWithFunc.ps1 new file mode 100644 index 00000000000..15ca86a939a --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Dynamic/DynamicExecutionWithFunc.ps1 @@ -0,0 +1,11 @@ +function ExecuteAThing { + param ( + $userInput + ) + $foo = 'cmd.exe' + $userInput; + Invoke-Expression $foo + [scriptblock]::Create($foo) + & ([scriptblock]::Create($foo)) + &"$foo" + & 'cmd.exe' @($userInput) +} \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Expressions/BinaryExpression.ps1 b/powershell/ql/test/library-tests/ast/Expressions/BinaryExpression.ps1 new file mode 100644 index 00000000000..11dd2df588e --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Expressions/BinaryExpression.ps1 @@ -0,0 +1,4 @@ +$val1 = 1 +$val2 = 2 +$result = $val1 + $val2 +$result \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Expressions/ConvertWithSecureString.ps1 b/powershell/ql/test/library-tests/ast/Expressions/ConvertWithSecureString.ps1 new file mode 100644 index 00000000000..761eb817a1d --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Expressions/ConvertWithSecureString.ps1 @@ -0,0 +1,2 @@ +$UserInput = Read-Host "Please enter your secure code" +$EncryptedInput = ConvertTo-SecureString -String $UserInput -AsPlainText -Force \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Expressions/ExpandableString.ps1 b/powershell/ql/test/library-tests/ast/Expressions/ExpandableString.ps1 new file mode 100644 index 00000000000..844f0c958e3 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Expressions/ExpandableString.ps1 @@ -0,0 +1 @@ +"Name: $name`nDate: $([DateTime]::Now)" \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Expressions/SubExpression.ps1 b/powershell/ql/test/library-tests/ast/Expressions/SubExpression.ps1 new file mode 100644 index 00000000000..b381ca3e7e8 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Expressions/SubExpression.ps1 @@ -0,0 +1,2 @@ +$(Get-Date).AddDays(10) +$(Get-Date).AddDays() \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Expressions/TernaryExpression.ps1 b/powershell/ql/test/library-tests/ast/Expressions/TernaryExpression.ps1 new file mode 100644 index 00000000000..481e78df2a2 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Expressions/TernaryExpression.ps1 @@ -0,0 +1 @@ +$var = (6 -gt 7) ? 1:2 \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Expressions/expressions.expected b/powershell/ql/test/library-tests/ast/Expressions/expressions.expected new file mode 100644 index 00000000000..a34db679319 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Expressions/expressions.expected @@ -0,0 +1,19 @@ +binaryExpr +| BinaryExpression.ps1:3:11:3:24 | ...+... | BinaryExpression.ps1:3:11:3:16 | val1 | BinaryExpression.ps1:3:19:3:24 | val2 | +| TernaryExpression.ps1:1:9:1:16 | ...+... | TernaryExpression.ps1:1:9:1:10 | ConstantExpression at: TernaryExpression.ps1:1:9:1:10 | TernaryExpression.ps1:1:15:1:16 | ConstantExpression at: TernaryExpression.ps1:1:15:1:16 | +cmdExpr +| BinaryExpression.ps1:1:9:1:10 | CommandExpression at: BinaryExpression.ps1:1:9:1:10 | BinaryExpression.ps1:1:9:1:10 | ConstantExpression at: BinaryExpression.ps1:1:9:1:10 | +| BinaryExpression.ps1:2:9:2:10 | CommandExpression at: BinaryExpression.ps1:2:9:2:10 | BinaryExpression.ps1:2:9:2:10 | ConstantExpression at: BinaryExpression.ps1:2:9:2:10 | +| BinaryExpression.ps1:3:11:3:24 | CommandExpression at: BinaryExpression.ps1:3:11:3:24 | BinaryExpression.ps1:3:11:3:24 | ...+... | +| BinaryExpression.ps1:4:1:4:8 | CommandExpression at: BinaryExpression.ps1:4:1:4:8 | BinaryExpression.ps1:4:1:4:8 | result | +| ExpandableString.ps1:1:1:1:40 | CommandExpression at: ExpandableString.ps1:1:1:1:40 | ExpandableString.ps1:1:1:1:40 | ExpandableStringExpression at: ExpandableString.ps1:1:1:1:40 | +| ExpandableString.ps1:1:23:1:38 | CommandExpression at: ExpandableString.ps1:1:23:1:38 | file://:0:0:0:0 | (no string representation) | +| SubExpression.ps1:1:1:1:24 | CommandExpression at: SubExpression.ps1:1:1:1:24 | SubExpression.ps1:1:1:1:24 | ArrayExpression at: SubExpression.ps1:1:1:1:24 | +| SubExpression.ps1:2:1:2:22 | CommandExpression at: SubExpression.ps1:2:1:2:22 | SubExpression.ps1:2:1:2:22 | ArrayExpression at: SubExpression.ps1:2:1:2:22 | +| TernaryExpression.ps1:1:8:1:23 | CommandExpression at: TernaryExpression.ps1:1:8:1:23 | TernaryExpression.ps1:1:8:1:23 | ...?...:... | +| TernaryExpression.ps1:1:9:1:16 | CommandExpression at: TernaryExpression.ps1:1:9:1:16 | TernaryExpression.ps1:1:9:1:16 | ...+... | +invokeMemoryExpression +| SubExpression.ps1:1:1:1:24 | ArrayExpression at: SubExpression.ps1:1:1:1:24 | file://:0:0:0:0 | (no string representation) | 0 | SubExpression.ps1:1:21:1:23 | ConstantExpression at: SubExpression.ps1:1:21:1:23 | +expandableString +| ExpandableString.ps1:1:1:1:40 | ExpandableStringExpression at: ExpandableString.ps1:1:1:1:40 | 0 | ExpandableString.ps1:1:8:1:13 | name | +| ExpandableString.ps1:1:1:1:40 | ExpandableStringExpression at: ExpandableString.ps1:1:1:1:40 | 1 | file://:0:0:0:0 | (no string representation) | diff --git a/powershell/ql/test/library-tests/ast/Expressions/expressions.ql b/powershell/ql/test/library-tests/ast/Expressions/expressions.ql new file mode 100644 index 00000000000..a3aee8e22d5 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Expressions/expressions.ql @@ -0,0 +1,19 @@ +import powershell + +query predicate binaryExpr(BinaryExpr e, Expr e1, Expr e2) { + e1 = e.getLeft() and + e2 = e.getRight() +} + +query predicate cmdExpr(CmdExpr cmd, Expr e) { + e = cmd.getExpression() +} + +query predicate invokeMemoryExpression(InvokeMemberExpression invoke, Expr e, int i, Expr arg) { + e = invoke.getExpression() and + arg = invoke.getArgument(i) +} + +query predicate expandableString(ExpandableStringExpression expandable, int i, Expr e) { + e = expandable.getExpr(i) +} diff --git a/powershell/ql/test/library-tests/ast/Loops/DoUntil.ps1 b/powershell/ql/test/library-tests/ast/Loops/DoUntil.ps1 new file mode 100644 index 00000000000..3d3e502673b --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Loops/DoUntil.ps1 @@ -0,0 +1,7 @@ +DO +{ + “Starting Loop $a” + $a + $a++ + “Now `$a is $a” +} Until ($a -le 5) \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Loops/DoWhile.ps1 b/powershell/ql/test/library-tests/ast/Loops/DoWhile.ps1 new file mode 100644 index 00000000000..38794ad9ec7 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Loops/DoWhile.ps1 @@ -0,0 +1,7 @@ +DO +{ + “Starting Loop $a” + $a + $a++ + “Now `$a is $a” +} While ($a -le 5) \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Loops/While.ps1 b/powershell/ql/test/library-tests/ast/Loops/While.ps1 new file mode 100644 index 00000000000..588abe3c868 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Loops/While.ps1 @@ -0,0 +1,13 @@ +$var = 1 +while ($var -le 5) +{ + Write-Host The value of Var is: $var + $var++ + if ($var -le 3){ + continue; + } + else + { + break; + } +} \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Loops/loops.ql b/powershell/ql/test/library-tests/ast/Loops/loops.ql new file mode 100644 index 00000000000..55c750da7cb --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Loops/loops.ql @@ -0,0 +1,16 @@ +import powershell + +query predicate doUntil(DoUntilStmt s, PipelineBase e, StmtBlock body) { + e = s.getCondition() and + body = s.getBody() +} + +query predicate doWhile(DoWhileStmt s, PipelineBase e, StmtBlock body) { + e = s.getCondition() and + body = s.getBody() +} + +query predicate while(WhileStmt s, PipelineBase e, StmtBlock body) { + e = s.getCondition() and + body = s.getBody() +} diff --git a/powershell/ql/test/library-tests/ast/Redirections/FileRedirection.ps1 b/powershell/ql/test/library-tests/ast/Redirections/FileRedirection.ps1 new file mode 100644 index 00000000000..701de90cc75 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Redirections/FileRedirection.ps1 @@ -0,0 +1,3 @@ +$( + Here is your current script +) *>&1 > output.txt \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Redirections/redirections.expected b/powershell/ql/test/library-tests/ast/Redirections/redirections.expected new file mode 100644 index 00000000000..968fcee62ee --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Redirections/redirections.expected @@ -0,0 +1,2 @@ +| FileRedirection.ps1:3:3:3:7 | MergingRedirection | +| FileRedirection.ps1:3:8:3:20 | FileRedirection | diff --git a/powershell/ql/test/library-tests/ast/Redirections/redirections.ql b/powershell/ql/test/library-tests/ast/Redirections/redirections.ql new file mode 100644 index 00000000000..b94f8807235 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Redirections/redirections.ql @@ -0,0 +1,3 @@ +import powershell + +query predicate redirection(Redirection r) { any() } diff --git a/powershell/ql/test/library-tests/ast/Statements/ExitStatement.ps1 b/powershell/ql/test/library-tests/ast/Statements/ExitStatement.ps1 new file mode 100644 index 00000000000..a4046370b8f --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Statements/ExitStatement.ps1 @@ -0,0 +1 @@ +exit -1 \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Statements/IfStatement.ps1 b/powershell/ql/test/library-tests/ast/Statements/IfStatement.ps1 new file mode 100644 index 00000000000..3572c369f38 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Statements/IfStatement.ps1 @@ -0,0 +1,8 @@ +$x = 4 + +if ($x -ge 3) { + "$x is greater than or equal to 3" +} +else { + "$x is less than 3" +} \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Statements/TrapStatement.ps1 b/powershell/ql/test/library-tests/ast/Statements/TrapStatement.ps1 new file mode 100644 index 00000000000..6eeb40d34b7 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Statements/TrapStatement.ps1 @@ -0,0 +1,6 @@ +function TrapTest { + trap {"Error found."} + nonsenseString +} + +TrapTest \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Statements/Try.ps1 b/powershell/ql/test/library-tests/ast/Statements/Try.ps1 new file mode 100644 index 00000000000..1f203269efb --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Statements/Try.ps1 @@ -0,0 +1,13 @@ +try { + $Exception = New-Object System.Xaml.XamlException -ArgumentList ("Bad XAML!", $null, 10, 2) + throw $Exception +} +catch [System.Net.WebException],[System.IO.IOException] { + "Unable to download MyDoc.doc from http://www.contoso.com." +} +catch { + "An error occurred that could not be resolved." +} +finally { + "The finally block is executed." +} \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Statements/UseProcessBlockForPipelineCommand.ps1 b/powershell/ql/test/library-tests/ast/Statements/UseProcessBlockForPipelineCommand.ps1 new file mode 100644 index 00000000000..f11969e0672 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Statements/UseProcessBlockForPipelineCommand.ps1 @@ -0,0 +1,11 @@ +Function Get-Number +{ + [CmdletBinding()] + Param( + [Parameter(ValueFromPipeline)] + [int] + $Number + ) + + $Number +} \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ast/Statements/statements.expected b/powershell/ql/test/library-tests/ast/Statements/statements.expected new file mode 100644 index 00000000000..35288e5bc58 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Statements/statements.expected @@ -0,0 +1,38 @@ +| ExitStatement.ps1:1:1:1:8 | exit ... | +| ExitStatement.ps1:1:6:1:8 | ...\|... | +| ExitStatement.ps1:1:6:1:8 | CommandExpression at: ExitStatement.ps1:1:6:1:8 | +| IfStatement.ps1:1:1:1:7 | AssignmentStatement at: IfStatement.ps1:1:1:1:7 | +| IfStatement.ps1:1:6:1:7 | CommandExpression at: IfStatement.ps1:1:6:1:7 | +| IfStatement.ps1:3:1:8:2 | if (...) {...} else {...} | +| IfStatement.ps1:3:5:3:13 | ...\|... | +| IfStatement.ps1:3:5:3:13 | CommandExpression at: IfStatement.ps1:3:5:3:13 | +| IfStatement.ps1:4:2:4:36 | ...\|... | +| IfStatement.ps1:4:2:4:36 | CommandExpression at: IfStatement.ps1:4:2:4:36 | +| IfStatement.ps1:7:2:7:21 | ...\|... | +| IfStatement.ps1:7:2:7:21 | CommandExpression at: IfStatement.ps1:7:2:7:21 | +| TrapStatement.ps1:1:1:4:2 | FunctionDefinition at: TrapStatement.ps1:1:1:4:2 | +| TrapStatement.ps1:2:5:2:26 | TrapStatement at: TrapStatement.ps1:2:5:2:26 | +| TrapStatement.ps1:2:11:2:25 | ...\|... | +| TrapStatement.ps1:2:11:2:25 | CommandExpression at: TrapStatement.ps1:2:11:2:25 | +| TrapStatement.ps1:3:5:3:19 | ...\|... | +| TrapStatement.ps1:3:5:3:19 | nonsenseString | +| TrapStatement.ps1:6:1:6:9 | ...\|... | +| TrapStatement.ps1:6:1:6:9 | TrapTest | +| Try.ps1:1:1:13:2 | try {...} | +| Try.ps1:2:4:2:95 | AssignmentStatement at: Try.ps1:2:4:2:95 | +| Try.ps1:2:17:2:95 | ...\|... | +| Try.ps1:2:17:2:95 | New-Object | +| Try.ps1:2:69:2:94 | ...\|... | +| Try.ps1:2:69:2:94 | CommandExpression at: Try.ps1:2:69:2:94 | +| Try.ps1:3:11:3:21 | ...\|... | +| Try.ps1:3:11:3:21 | CommandExpression at: Try.ps1:3:11:3:21 | +| Try.ps1:6:5:6:64 | ...\|... | +| Try.ps1:6:5:6:64 | CommandExpression at: Try.ps1:6:5:6:64 | +| Try.ps1:9:5:9:52 | ...\|... | +| Try.ps1:9:5:9:52 | CommandExpression at: Try.ps1:9:5:9:52 | +| Try.ps1:12:5:12:37 | ...\|... | +| Try.ps1:12:5:12:37 | CommandExpression at: Try.ps1:12:5:12:37 | +| UseProcessBlockForPipelineCommand.ps1:1:1:11:2 | FunctionDefinition at: UseProcessBlockForPipelineCommand.ps1:1:1:11:2 | +| UseProcessBlockForPipelineCommand.ps1:10:5:10:12 | ...\|... | +| UseProcessBlockForPipelineCommand.ps1:10:5:10:12 | CommandExpression at: UseProcessBlockForPipelineCommand.ps1:10:5:10:12 | +| file://:0:0:0:0 | (no string representation) | diff --git a/powershell/ql/test/library-tests/ast/Statements/statements.ql b/powershell/ql/test/library-tests/ast/Statements/statements.ql new file mode 100644 index 00000000000..ab8eb5b6fc6 --- /dev/null +++ b/powershell/ql/test/library-tests/ast/Statements/statements.ql @@ -0,0 +1,3 @@ +import powershell + +query predicate stmt(Stmt s) { any() } \ No newline at end of file diff --git a/powershell/ql/test/qlpack.yml b/powershell/ql/test/qlpack.yml new file mode 100644 index 00000000000..c60137dd510 --- /dev/null +++ b/powershell/ql/test/qlpack.yml @@ -0,0 +1,8 @@ +name: microsoft-sdl/powershell-tests +groups: + - powershell + - test +dependencies: + microsoft-sdl/powershell-all: ${workspace} +extractor: powershell +tests: . \ No newline at end of file