Skip to content

Commit 0eabdd9

Browse files
author
Alvaro Muñoz
committed
Rename classes
1 parent e979f51 commit 0eabdd9

22 files changed

+285
-333
lines changed

ql/lib/codeql/actions/Ast.qll

Lines changed: 135 additions & 126 deletions
Large diffs are not rendered by default.

ql/lib/codeql/actions/controlflow/BasicBlocks.qll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,4 +442,3 @@ class ConditionBlock extends BasicBlock {
442442
*/
443443
predicate controls(BasicBlock controlled, BooleanSuccessor s) { controls(this, controlled, s) }
444444
}
445-

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

Lines changed: 52 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ module Completion {
8383
module CfgScope {
8484
abstract class CfgScope extends AstNode { }
8585

86-
class WorkflowScope extends CfgScope instanceof WorkflowStmt { }
86+
class WorkflowScope extends CfgScope instanceof Workflow { }
8787

88-
class CompositeActionScope extends CfgScope instanceof CompositeActionStmt { }
88+
class CompositeActionScope extends CfgScope instanceof CompositeAction { }
8989
}
9090

9191
private module Implementation implements CfgShared::InputSig<Location> {
@@ -119,13 +119,13 @@ private module Implementation implements CfgShared::InputSig<Location> {
119119
int maxSplits() { result = 0 }
120120

121121
predicate scopeFirst(CfgScope scope, AstNode e) {
122-
first(scope.(WorkflowStmt), e) or
123-
first(scope.(CompositeActionStmt), e)
122+
first(scope.(Workflow), e) or
123+
first(scope.(CompositeAction), e)
124124
}
125125

126126
predicate scopeLast(CfgScope scope, AstNode e, Completion c) {
127-
last(scope.(WorkflowStmt), e, c) or
128-
last(scope.(CompositeActionStmt), e, c)
127+
last(scope.(Workflow), e, c) or
128+
last(scope.(CompositeAction), e, c)
129129
}
130130

131131
predicate successorTypeIsSimple(SuccessorType t) { t instanceof NormalSuccessor }
@@ -143,14 +143,14 @@ private import CfgImpl
143143
private import Completion
144144
private import CfgScope
145145

146-
private class CompositeActionTree extends StandardPreOrderTree instanceof CompositeActionStmt {
146+
private class CompositeActionTree extends StandardPreOrderTree instanceof CompositeAction {
147147
override ControlFlowTree getChildNode(int i) {
148148
result =
149-
rank[i](Expression child, Location l |
149+
rank[i](AstNode child, Location l |
150150
(
151-
child = this.(CompositeActionStmt).getInputsStmt() or
152-
child = this.(CompositeActionStmt).getOutputsStmt() or
153-
child = this.(CompositeActionStmt).getRunsStmt()
151+
child = this.(CompositeAction).getInputs() or
152+
child = this.(CompositeAction).getOutputs() or
153+
child = this.(CompositeAction).getRuns()
154154
) and
155155
l = child.getLocation()
156156
|
@@ -161,21 +161,21 @@ private class CompositeActionTree extends StandardPreOrderTree instanceof Compos
161161
}
162162
}
163163

164-
private class RunsTree extends StandardPreOrderTree instanceof RunsStmt {
165-
override ControlFlowTree getChildNode(int i) { result = super.getStepStmt(i) }
164+
private class RunsTree extends StandardPreOrderTree instanceof Runs {
165+
override ControlFlowTree getChildNode(int i) { result = super.getStep(i) }
166166
}
167167

168-
private class WorkflowTree extends StandardPreOrderTree instanceof WorkflowStmt {
168+
private class WorkflowTree extends StandardPreOrderTree instanceof Workflow {
169169
override ControlFlowTree getChildNode(int i) {
170-
if this instanceof ReusableWorkflowStmt
170+
if this instanceof ReusableWorkflow
171171
then
172172
result =
173-
rank[i](Expression child, Location l |
173+
rank[i](AstNode child, Location l |
174174
(
175-
child = this.(ReusableWorkflowStmt).getInputsStmt() or
176-
child = this.(ReusableWorkflowStmt).getOutputsStmt() or
177-
child = this.(ReusableWorkflowStmt).getStrategyStmt() or
178-
child = this.(ReusableWorkflowStmt).getAJobStmt()
175+
child = this.(ReusableWorkflow).getInputs() or
176+
child = this.(ReusableWorkflow).getOutputs() or
177+
child = this.(ReusableWorkflow).getStrategy() or
178+
child = this.(ReusableWorkflow).getAJob()
179179
) and
180180
l = child.getLocation()
181181
|
@@ -185,10 +185,10 @@ private class WorkflowTree extends StandardPreOrderTree instanceof WorkflowStmt
185185
)
186186
else
187187
result =
188-
rank[i](Expression child, Location l |
188+
rank[i](AstNode child, Location l |
189189
(
190-
child = super.getAJobStmt() or
191-
child = super.getStrategyStmt()
190+
child = super.getAJob() or
191+
child = super.getStrategy()
192192
) and
193193
l = child.getLocation()
194194
|
@@ -199,10 +199,10 @@ private class WorkflowTree extends StandardPreOrderTree instanceof WorkflowStmt
199199
}
200200
}
201201

202-
private class InputsTree extends StandardPreOrderTree instanceof InputsStmt {
202+
private class InputsTree extends StandardPreOrderTree instanceof Inputs {
203203
override ControlFlowTree getChildNode(int i) {
204204
result =
205-
rank[i](Expression child, Location l |
205+
rank[i](AstNode child, Location l |
206206
child = super.getInputExpr(_) and l = child.getLocation()
207207
|
208208
child
@@ -212,12 +212,10 @@ private class InputsTree extends StandardPreOrderTree instanceof InputsStmt {
212212
}
213213
}
214214

215-
private class InputExprTree extends LeafTree instanceof InputExpr { }
216-
217-
private class OutputsTree extends StandardPreOrderTree instanceof OutputsStmt {
215+
private class OutputsTree extends StandardPreOrderTree instanceof Outputs {
218216
override ControlFlowTree getChildNode(int i) {
219217
result =
220-
rank[i](Expression child, Location l |
218+
rank[i](AstNode child, Location l |
221219
child = super.getOutputExpr(_) and l = child.getLocation()
222220
|
223221
child
@@ -227,12 +225,10 @@ private class OutputsTree extends StandardPreOrderTree instanceof OutputsStmt {
227225
}
228226
}
229227

230-
private class OutputExprTree extends LeafTree instanceof OutputExpr { }
231-
232-
private class StrategyTree extends StandardPreOrderTree instanceof StrategyStmt {
228+
private class StrategyTree extends StandardPreOrderTree instanceof Strategy {
233229
override ControlFlowTree getChildNode(int i) {
234230
result =
235-
rank[i](Expression child, Location l |
231+
rank[i](AstNode child, Location l |
236232
child = super.getMatrixVariableExpr(_) and l = child.getLocation()
237233
|
238234
child
@@ -242,17 +238,15 @@ private class StrategyTree extends StandardPreOrderTree instanceof StrategyStmt
242238
}
243239
}
244240

245-
private class MatrixVariableExprTree extends LeafTree instanceof MatrixVariableExpr { }
246-
247-
private class JobTree extends StandardPreOrderTree instanceof JobStmt {
241+
private class JobTree extends StandardPreOrderTree instanceof Job {
248242
override ControlFlowTree getChildNode(int i) {
249243
result =
250-
rank[i](Expression child, Location l |
244+
rank[i](AstNode child, Location l |
251245
(
252-
child = super.getAStepStmt() or
253-
child = super.getOutputsStmt() or
254-
child = super.getStrategyStmt() or
255-
child = super.getUsesExpr()
246+
child = super.getAStep() or
247+
child = super.getOutputs() or
248+
child = super.getStrategy() or
249+
child = super.getUses()
256250
) and
257251
l = child.getLocation()
258252
|
@@ -263,12 +257,10 @@ private class JobTree extends StandardPreOrderTree instanceof JobStmt {
263257
}
264258
}
265259

266-
private class UsesExprTree extends LeafTree instanceof UsesExpr { }
267-
268-
private class UsesTree extends StandardPreOrderTree instanceof UsesExpr {
260+
private class UsesTree extends StandardPreOrderTree instanceof Uses {
269261
override ControlFlowTree getChildNode(int i) {
270262
result =
271-
rank[i](Expression child, Location l |
263+
rank[i](AstNode child, Location l |
272264
(child = super.getArgumentExpr(_) or child = super.getEnvExpr(_)) and
273265
l = child.getLocation()
274266
|
@@ -279,11 +271,10 @@ private class UsesTree extends StandardPreOrderTree instanceof UsesExpr {
279271
}
280272
}
281273

282-
private class RunTree extends StandardPreOrderTree instanceof RunExpr {
283-
//override ControlFlowTree getChildNode(int i) { result = super.getScriptExpr() and i = 0 }
274+
private class RunTree extends StandardPreOrderTree instanceof Run {
284275
override ControlFlowTree getChildNode(int i) {
285276
result =
286-
rank[i](Expression child, Location l |
277+
rank[i](AstNode child, Location l |
287278
(child = super.getEnvExpr(_) or child = super.getScriptExpr()) and
288279
l = child.getLocation()
289280
|
@@ -294,4 +285,16 @@ private class RunTree extends StandardPreOrderTree instanceof RunExpr {
294285
}
295286
}
296287

297-
private class ExprAccessTree extends LeafTree instanceof ExprAccessExpr { }
288+
private class UsesLeaf extends LeafTree instanceof Uses { }
289+
290+
private class InputExprTree extends LeafTree instanceof InputExpr { }
291+
292+
private class OutputExprTree extends LeafTree instanceof OutputExpr { }
293+
294+
private class MatrixVariableExprTree extends LeafTree instanceof MatrixVariableExpr { }
295+
296+
private class EnvExprTree extends LeafTree instanceof EnvExpr { }
297+
298+
private class ExprAccessTree extends LeafTree instanceof ContextExpression { }
299+
300+
private class AstNodeLeaf extends LeafTree instanceof Expression { }

ql/lib/codeql/actions/dataflow/ExternalFlow.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ predicate sinkModel(string action, string version, string input, string kind) {
4242
predicate externallyDefinedSource(
4343
DataFlow::Node source, string sourceType, string fieldName, string trigger
4444
) {
45-
exists(UsesExpr uses, string action, string version, string kind |
45+
exists(Uses uses, string action, string version, string kind |
4646
sourceModel(action, version, fieldName, trigger, kind) and
4747
uses.getCallee() = action.toLowerCase() and
4848
(
@@ -65,7 +65,7 @@ predicate externallyDefinedSource(
6565
predicate externallyDefinedStoreStep(
6666
DataFlow::Node pred, DataFlow::Node succ, DataFlow::ContentSet c
6767
) {
68-
exists(UsesExpr uses, string action, string version, string input, string output |
68+
exists(Uses uses, string action, string version, string input, string output |
6969
summaryModel(action, version, input, output, "taint") and
7070
c = any(DataFlow::FieldContent ct | ct.getName() = output.replaceAll("output.", "")) and
7171
uses.getCallee() = action.toLowerCase() and
@@ -87,7 +87,7 @@ predicate externallyDefinedStoreStep(
8787
}
8888

8989
predicate externallyDefinedSink(DataFlow::ExprNode sink, string kind) {
90-
exists(UsesExpr uses, string action, string version, string input |
90+
exists(Uses uses, string action, string version, string input |
9191
(
9292
if input.trim().matches("env.%")
9393
then sink.asExpr() = uses.getEnvExpr(input.trim().replaceAll("env.", ""))

ql/lib/codeql/actions/dataflow/FlowSources.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private class EventSource extends RemoteFlowSource {
114114
string trigger;
115115

116116
EventSource() {
117-
exists(ExprAccessExpr e, string context | this.asExpr() = e and context = e.getExpression() |
117+
exists(Expression e, string context | this.asExpr() = e and context = e.getExpression() |
118118
trigger = ["issues", "issue_comment"] and isExternalUserControlledIssue(context)
119119
or
120120
trigger = ["pull_request_target", "pull_request_review", "pull_request_review_comment"] and
@@ -158,9 +158,9 @@ private class ExternallyDefinedSource extends RemoteFlowSource {
158158
* An input for a Composite Action
159159
*/
160160
private class CompositeActionInputSource extends RemoteFlowSource {
161-
CompositeActionStmt c;
161+
CompositeAction c;
162162

163-
CompositeActionInputSource() { c.getInputsStmt().getInputExpr(_) = this.asExpr() }
163+
CompositeActionInputSource() { c.getInputs().getInputExpr(_) = this.asExpr() }
164164

165165
override string getSourceType() { result = "Composite action input" }
166166

ql/lib/codeql/actions/dataflow/FlowSteps.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class AdditionalTaintStep extends Unit {
3434
* echo "foo=$(echo $BODY)" >> "$GITHUB_OUTPUT"
3535
*/
3636
predicate runEnvToScriptStoreStep(DataFlow::Node pred, DataFlow::Node succ, DataFlow::ContentSet c) {
37-
exists(RunExpr r, string varName, string output |
37+
exists(Run r, string varName, string output |
3838
c = any(DataFlow::FieldContent ct | ct.getName() = output.replaceAll("output\\.", "")) and
3939
r.getEnvExpr(varName) = pred.asExpr() and
4040
exists(string script, string line |

0 commit comments

Comments
 (0)