Skip to content

Commit 655cb8e

Browse files
committed
PS: Fix 'getEnclosingScope' and add 'getEnclosingFunction'.
1 parent 43c7550 commit 655cb8e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ class Ast extends @ast {
88

99
Location getLocation() { none() }
1010

11-
final Scope getEnclosingScope() { result = scopeOf(this) }
11+
Scope getEnclosingScope() { result = scopeOf(this) }
12+
13+
final Function getEnclosingFunction() { this.getEnclosingScope() = result.getBody() }
1214
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import powershell
2+
private import semmle.code.powershell.controlflow.internal.Scope
23

34
class ScriptBlock extends @script_block, Ast {
45
predicate isTopLevel() { not exists(this.getParent()) }
@@ -48,4 +49,6 @@ class ScriptBlock extends @script_block, Ast {
4849
}
4950

5051
ModuleSpecification getAModuleSpecification() { result = this.getModuleSpecification(_) }
52+
53+
final override Scope getEnclosingScope() { result = this }
5154
}

0 commit comments

Comments
 (0)