Skip to content

Commit 90d1ae4

Browse files
author
Alvaro Muñoz
committed
fix: simplify Ast
1 parent 494fb24 commit 90d1ae4

File tree

2 files changed

+5
-31
lines changed

2 files changed

+5
-31
lines changed

ql/lib/codeql/actions/Ast.qll

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class JobStmt extends Statement instanceof Actions::Job {
149149
* out1: ${steps.foo.bar}
150150
* out2: ${steps.foo.baz}
151151
*/
152-
JobOutputStmt getOutputStmt() { result = this.(Actions::Job).lookup("outputs") }
152+
OutputsStmt getOutputsStmt() { result = this.(Actions::Job).lookup("outputs") }
153153

154154
/**
155155
* Reusable workflow jobs may have Uses children
@@ -166,28 +166,6 @@ class JobStmt extends Statement instanceof Actions::Job {
166166
}
167167
}
168168

169-
/**
170-
* Declaration of the outputs for the job.
171-
* eg:
172-
* out1: ${steps.foo.bar}
173-
* out2: ${steps.foo.baz}
174-
*/
175-
class JobOutputStmt extends Statement instanceof YamlMapping {
176-
JobStmt job;
177-
178-
JobOutputStmt() { job.(YamlMapping).lookup("outputs") = this }
179-
180-
YamlMapping asYamlMapping() { result = this }
181-
182-
/**
183-
* Gets a specific value expression
184-
* eg: ${steps.foo.bar}
185-
*/
186-
Expression getOutputExpr(string id) {
187-
this.(YamlMapping).maps(any(YamlScalar s | s.getValue() = id), result)
188-
}
189-
}
190-
191169
/**
192170
* A Step is a single task that can be executed as part of a job.
193171
*/
@@ -435,9 +413,9 @@ class NeedsCtxAccessExpr extends CtxAccessExpr {
435413
job.getLocation().getFile() = this.getLocation().getFile() and
436414
(
437415
// regular jobs
438-
job.getOutputStmt().getOutputExpr(fieldName) = result
416+
job.getOutputsStmt() = result
439417
or
440-
// jobs calling reusable workflows
418+
// reusable workflow calling jobs
441419
job.getUsesExpr() = result
442420
)
443421
}
@@ -464,7 +442,7 @@ class JobsCtxAccessExpr extends CtxAccessExpr {
464442
exists(JobStmt job |
465443
job.getId() = jobId and
466444
job.getLocation().getFile() = this.getLocation().getFile() and
467-
job.getOutputStmt().getOutputExpr(fieldName) = result
445+
job.getOutputsStmt() = result
468446
)
469447
}
470448
}

ql/lib/codeql/actions/controlflow/internal/Cfg.qll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ private class JobTree extends StandardPreOrderTree instanceof JobStmt {
231231
rank[i](Expression child, Location l |
232232
(
233233
child = super.getAStepStmt() or
234-
child = super.getOutputStmt() or
234+
child = super.getOutputsStmt() or
235235
child = super.getUsesExpr()
236236
) and
237237
l = child.getLocation()
@@ -243,10 +243,6 @@ private class JobTree extends StandardPreOrderTree instanceof JobStmt {
243243
}
244244
}
245245

246-
private class JobOutputTree extends StandardPreOrderTree instanceof JobOutputStmt {
247-
override ControlFlowTree getChildNode(int i) { result = super.asYamlMapping().getValueNode(i) }
248-
}
249-
250246
private class StepUsesTree extends StandardPreOrderTree instanceof StepUsesExpr {
251247
override ControlFlowTree getChildNode(int i) {
252248
result =

0 commit comments

Comments
 (0)