Skip to content

Commit 656969e

Browse files
committed
Ruby: Restrict CfgScope
1 parent 1bd504b commit 656969e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ruby/ql/lib/codeql/ruby/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,16 @@ abstract class CfgScopeImpl extends AstNode {
7676
}
7777

7878
private class ToplevelScope extends CfgScopeImpl, Toplevel {
79+
ToplevelScope() { exists(this.getAStmt()) }
80+
7981
final override predicate entry(AstNode first) { first(this, first) }
8082

8183
final override predicate exit(AstNode last, Completion c) { last(this, last, c) }
8284
}
8385

8486
private class EndBlockScope extends CfgScopeImpl, EndBlock {
87+
EndBlockScope() { exists(this.getAStmt()) }
88+
8589
final override predicate entry(AstNode first) {
8690
first(this.(Trees::EndBlockTree).getBodyChild(0, _), first)
8791
}
@@ -95,6 +99,8 @@ private class EndBlockScope extends CfgScopeImpl, EndBlock {
9599
}
96100

97101
private class BodyStmtCallableScope extends CfgScopeImpl, AstInternal::TBodyStmt, Callable {
102+
BodyStmtCallableScope() { exists(this.getAStmt()) }
103+
98104
final override predicate entry(AstNode first) { this.(Trees::BodyStmtTree).firstInner(first) }
99105

100106
final override predicate exit(AstNode last, Completion c) {
@@ -103,6 +109,8 @@ private class BodyStmtCallableScope extends CfgScopeImpl, AstInternal::TBodyStmt
103109
}
104110

105111
private class BraceBlockScope extends CfgScopeImpl, BraceBlock {
112+
BraceBlockScope() { exists(this.getAStmt()) }
113+
106114
final override predicate entry(AstNode first) {
107115
first(this.(Trees::BraceBlockTree).getBodyChild(0, _), first)
108116
}

0 commit comments

Comments
 (0)