diff --git a/powershell/ql/test/library-tests/ssa/explicit.ps1 b/powershell/ql/test/library-tests/ssa/explicit.ps1 new file mode 100644 index 00000000000..1efb3d323c3 --- /dev/null +++ b/powershell/ql/test/library-tests/ssa/explicit.ps1 @@ -0,0 +1,8 @@ +$glo_a = 42 +$glob_b = $glob_a + +function f() { + $a = 43 + $b = $a + return $b +} \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ssa/parameters.ps1 b/powershell/ql/test/library-tests/ssa/parameters.ps1 new file mode 100644 index 00000000000..eebe0b54661 --- /dev/null +++ b/powershell/ql/test/library-tests/ssa/parameters.ps1 @@ -0,0 +1,11 @@ +function function-param([int]$n1, [int]$n2) { + return $n1 + $n2 +} + +function param-block { + param( + [int]$a, + [int]$b + ) + return $a + $b +} \ No newline at end of file diff --git a/powershell/ql/test/library-tests/ssa/ssa.expected b/powershell/ql/test/library-tests/ssa/ssa.expected new file mode 100644 index 00000000000..502bf79ccb5 --- /dev/null +++ b/powershell/ql/test/library-tests/ssa/ssa.expected @@ -0,0 +1,2 @@ +| explicit.ps1:1:1:8:2 | glob_a | explicit.ps1:2:11:2:18 | glob_a | +| explicit.ps1:5:5:5:7 | a | explicit.ps1:5:5:5:7 | a | diff --git a/powershell/ql/test/library-tests/ssa/ssa.ql b/powershell/ql/test/library-tests/ssa/ssa.ql new file mode 100644 index 00000000000..4d81f221188 --- /dev/null +++ b/powershell/ql/test/library-tests/ssa/ssa.ql @@ -0,0 +1,4 @@ +import powershell +import semmle.code.powershell.dataflow.Ssa + +query predicate definition(Ssa::Definition def, Variable v) { def.getSourceVariable() = v }