Skip to content

Commit b3de6a2

Browse files
committed
PS: Add tests.
1 parent 40cf8dd commit b3de6a2

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
edges
2+
| test.ps1:1:8:1:10 | x | test.ps1:3:28:3:48 | Get-Process -Id $x | provenance | |
3+
| test.ps1:5:10:5:21 | Env:MY_VAR | test.ps1:7:3:7:20 | $code --enabled | provenance | |
4+
nodes
5+
| test.ps1:1:8:1:10 | x | semmle.label | x |
6+
| test.ps1:3:28:3:48 | Get-Process -Id $x | semmle.label | Get-Process -Id $x |
7+
| test.ps1:5:10:5:21 | Env:MY_VAR | semmle.label | Env:MY_VAR |
8+
| test.ps1:7:3:7:20 | $code --enabled | semmle.label | $code --enabled |
9+
subpaths
10+
#select
11+
| test.ps1:3:28:3:48 | Get-Process -Id $x | test.ps1:1:8:1:10 | x | test.ps1:3:28:3:48 | Get-Process -Id $x | This command depends on a $@. | test.ps1:1:8:1:10 | x | user-provided value |
12+
| test.ps1:7:3:7:20 | $code --enabled | test.ps1:5:10:5:21 | Env:MY_VAR | test.ps1:7:3:7:20 | $code --enabled | This command depends on a $@. | test.ps1:5:10:5:21 | Env:MY_VAR | user-provided value |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
queries/security/cwe-078/CommandInjection.ql
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
param ($x)
2+
3+
Invoke-Expression -Command "Get-Process -Id $x" # BAD
4+
5+
$code = "$Env:MY_VAR"
6+
7+
& "$code --enabled" # BAD

0 commit comments

Comments
 (0)