Skip to content

Commit 5d3412c

Browse files
committed
feat(cfg): Update CFG
1 parent 81c6abc commit 5d3412c

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

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

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,19 @@ class InfrastructureScopeTree extends StandardTree, PreOrderTree, PostOrderTree,
6767
override AstNode getChildNode(int i) { result = super.getStatement(i) }
6868
}
6969

70+
class StmtsTree extends StandardPostOrderTree instanceof Stmts {
71+
override AstNode getChildNode(int i) {
72+
//
73+
i = 0 and result = super.getAChild()
74+
}
75+
}
76+
77+
class ExprTree extends StandardPostOrderTree instanceof Expr {
78+
override AstNode getChildNode(int i) {
79+
i = 0 and result = super.getAChild()
80+
}
81+
}
82+
7083
/**
7184
* A literal value in a Bicep program.
7285
*/
@@ -95,13 +108,18 @@ class StringContentLiteralTree extends LeafTree instanceof StringContentLiteral
95108
/**
96109
* ParameterDeclarationTree represents a parameter declaration in a Bicep program.
97110
*/
98-
class ParameterDeclarationTree extends StandardPostOrderTree instanceof ParameterDeclaration {
99-
override AstNode getChildNode(int i) {
100-
i = 0 and result = super.getIdentifier()
101-
or
102-
i = 1 and result = super.getType()
111+
class ParameterDeclarationTree extends PreOrderTree instanceof ParameterDeclaration {
112+
final override predicate propagatesAbnormal(AstNode child) { child = super.getIdentifier() }
113+
114+
override predicate succ(AstNode pred, AstNode succ, Completion c) {
115+
// Start with the identifier
116+
pred = this and first(super.getIdentifier(), succ) and completionIsSimple(c)
103117
or
104-
i = 2 and result = super.getDefaultValue()
118+
last(super.getIdentifier(), pred, c) and first(super.getDefaultValue(), succ) and completionIsNormal(c)
119+
}
120+
121+
override predicate last(AstNode node, Completion c) {
122+
node = super.getDefaultValue() and completionIsNormal(c)
105123
}
106124
}
107125

@@ -117,12 +135,17 @@ class UserDefinedFunctionTree extends StandardPostOrderTree instanceof UserDefin
117135
}
118136
}
119137

120-
class OutputDeclarationTree extends StandardPostOrderTree instanceof OutputDeclaration {
121-
override AstNode getChildNode(int i) {
122-
i = 0 and result = super.getIdentifier()
123-
or
124-
i = 1 and result = super.getType()
138+
class OutputDeclarationTree extends PreOrderTree instanceof OutputDeclaration {
139+
final override predicate propagatesAbnormal(AstNode child) { child = super.getIdentifier() }
140+
141+
override predicate succ(AstNode pred, AstNode succ, Completion c) {
142+
// Start with the identifier
143+
pred = this and first(super.getIdentifier(), succ) and completionIsSimple(c)
125144
or
126-
i = 2 and result = super.getValue()
145+
last(super.getIdentifier(), pred, c) and first(super.getValue(), succ) and completionIsNormal(c)
146+
}
147+
148+
override predicate last(AstNode node, Completion c) {
149+
node = super.getValue() and completionIsNormal(c)
127150
}
128151
}

0 commit comments

Comments
 (0)