Skip to content

Commit 31f6e71

Browse files
committed
Fix "The variable event is only used in one side of disjunct."
1 parent e2347a5 commit 31f6e71

1 file changed

Lines changed: 29 additions & 25 deletions

File tree

actions/ql/lib/codeql/actions/security/ControlChecks.qll

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -88,34 +88,38 @@ abstract class ControlCheck extends AstNode {
8888
* Holds if this control check must execute and pass before `node` can run.
8989
*/
9090
predicate dominates(AstNode node, Event event) {
91-
// Step-level: the check is an `if:` on the step containing `node`,
92-
// or on the enclosing job, or on a needed job/step.
93-
this instanceof If and
94-
(
95-
node.getEnclosingStep().getIf() = this or
96-
node.getEnclosingJob().getIf() = this or
97-
node.getEnclosingJob().getANeededJob().(LocalJob).getAStep().getIf() = this or
98-
node.getEnclosingJob().getANeededJob().(LocalJob).getIf() = this
99-
)
100-
or
101-
// Job-level: the check is an environment on the enclosing job or a needed job.
102-
this instanceof Environment and
91+
// Same-workflow dominance: bind event to this check's trigger event.
92+
this.getATriggerEvent() = event and
10393
(
104-
node.getEnclosingJob().getEnvironment() = this
94+
// Step-level: the check is an `if:` on the step containing `node`,
95+
// or on the enclosing job, or on a needed job/step.
96+
this instanceof If and
97+
(
98+
node.getEnclosingStep().getIf() = this or
99+
node.getEnclosingJob().getIf() = this or
100+
node.getEnclosingJob().getANeededJob().(LocalJob).getAStep().getIf() = this or
101+
node.getEnclosingJob().getANeededJob().(LocalJob).getIf() = this
102+
)
105103
or
106-
node.getEnclosingJob().getANeededJob().getEnvironment() = this
107-
)
108-
or
109-
// Step-level: the check is a Run/UsesStep that precedes `node`'s step
110-
// in the same job, or is a step in a needed job.
111-
(
112-
this instanceof Run or
113-
this instanceof UsesStep
114-
) and
115-
(
116-
this.(Step).getAFollowingStep() = node.getEnclosingStep()
104+
// Job-level: the check is an environment on the enclosing job or a needed job.
105+
this instanceof Environment and
106+
(
107+
node.getEnclosingJob().getEnvironment() = this
108+
or
109+
node.getEnclosingJob().getANeededJob().getEnvironment() = this
110+
)
117111
or
118-
node.getEnclosingJob().getANeededJob().(LocalJob).getAStep() = this
112+
// Step-level: the check is a Run/UsesStep that precedes `node`'s step
113+
// in the same job, or is a step in a needed job.
114+
(
115+
this instanceof Run or
116+
this instanceof UsesStep
117+
) and
118+
(
119+
this.(Step).getAFollowingStep() = node.getEnclosingStep()
120+
or
121+
node.getEnclosingJob().getANeededJob().(LocalJob).getAStep() = this
122+
)
119123
)
120124
or
121125
// When the node is inside a reusable workflow,

0 commit comments

Comments
 (0)