@@ -31,11 +31,9 @@ class Expression extends Statement { }
31
31
* A Github Actions Workflow
32
32
*/
33
33
class WorkflowStmt extends Statement instanceof Actions:: Workflow {
34
- JobStmt getAJob ( ) { result = super .getJob ( _) }
34
+ JobStmt getAJobStmt ( ) { result = super .getJob ( _) }
35
35
36
- JobStmt getJob ( string id ) { result = super .getJob ( id ) }
37
-
38
- predicate isReusable ( ) { this instanceof ReusableWorkflowStmt }
36
+ JobStmt getJobStmt ( string id ) { result = super .getJob ( id ) }
39
37
}
40
38
41
39
class ReusableWorkflowStmt extends WorkflowStmt {
@@ -45,15 +43,19 @@ class ReusableWorkflowStmt extends WorkflowStmt {
45
43
this .( Actions:: Workflow ) .getOn ( ) .getNode ( "workflow_call" ) = workflow_call
46
44
}
47
45
48
- InputsStmt getInputs ( ) { result = workflow_call .( YamlMapping ) .lookup ( "inputs" ) }
46
+ ReusableWorkflowInputsStmt getInputsStmt ( ) {
47
+ result = workflow_call .( YamlMapping ) .lookup ( "inputs" )
48
+ }
49
49
50
- OutputsStmt getOutputs ( ) { result = workflow_call .( YamlMapping ) .lookup ( "outputs" ) }
50
+ ReusableWorkflowOutputsStmt getOutputsStmt ( ) {
51
+ result = workflow_call .( YamlMapping ) .lookup ( "outputs" )
52
+ }
51
53
52
54
string getName ( ) { result = this .getLocation ( ) .getFile ( ) .getRelativePath ( ) }
53
55
}
54
56
55
- class InputsStmt extends Statement instanceof YamlMapping {
56
- InputsStmt ( ) {
57
+ class ReusableWorkflowInputsStmt extends Statement instanceof YamlMapping {
58
+ ReusableWorkflowInputsStmt ( ) {
57
59
exists ( Actions:: On on | on .getNode ( "workflow_call" ) .( YamlMapping ) .lookup ( "inputs" ) = this )
58
60
}
59
61
@@ -70,16 +72,16 @@ class InputsStmt extends Statement instanceof YamlMapping {
70
72
* token:
71
73
* required: true
72
74
*/
73
- InputExpr getInputExpr ( string name ) {
75
+ ReusableWorkflowInputExpr getInputExpr ( string name ) {
74
76
result .( YamlString ) .getValue ( ) = name and
75
77
this .( YamlMapping ) .maps ( result , _)
76
78
}
77
79
}
78
80
79
- class InputExpr extends Expression instanceof YamlString { }
81
+ class ReusableWorkflowInputExpr extends Expression instanceof YamlString { }
80
82
81
- class OutputsStmt extends Statement instanceof YamlMapping {
82
- OutputsStmt ( ) {
83
+ class ReusableWorkflowOutputsStmt extends Statement instanceof YamlMapping {
84
+ ReusableWorkflowOutputsStmt ( ) {
83
85
exists ( Actions:: On on | on .getNode ( "workflow_call" ) .( YamlMapping ) .lookup ( "outputs" ) = this )
84
86
}
85
87
@@ -96,12 +98,12 @@ class OutputsStmt extends Statement instanceof YamlMapping {
96
98
* description: "The second output string"
97
99
* value: ${{ jobs.example_job.outputs.output2 }}
98
100
*/
99
- OutputExpr getOutputExpr ( string name ) {
101
+ ReusableWorkflowOutputExpr getOutputExpr ( string name ) {
100
102
this .( YamlMapping ) .lookup ( name ) .( YamlMapping ) .lookup ( "value" ) = result
101
103
}
102
104
}
103
105
104
- class OutputExpr extends Expression instanceof YamlString { }
106
+ class ReusableWorkflowOutputExpr extends Expression instanceof YamlString { }
105
107
106
108
/**
107
109
* A Job is a collection of steps that run in an execution environment.
@@ -114,10 +116,10 @@ class JobStmt extends Statement instanceof Actions::Job {
114
116
string getId ( ) { result = super .getId ( ) }
115
117
116
118
/** Gets the step at the given index within this job. */
117
- StepStmt getStep ( int index ) { result = super .getStep ( index ) }
119
+ StepStmt getStepStmt ( int index ) { result = super .getStep ( index ) }
118
120
119
121
/** Gets any steps that are defined within this job. */
120
- StepStmt getAStep ( ) { result = super .getStep ( _) }
122
+ StepStmt getAStepStmt ( ) { result = super .getStep ( _) }
121
123
122
124
/**
123
125
* Gets a needed job.
@@ -147,7 +149,7 @@ class JobStmt extends Statement instanceof Actions::Job {
147
149
* with:
148
150
* arg1: value1
149
151
*/
150
- JobUsesExpr getUsesExpr ( ) { result .getJob ( ) = this }
152
+ JobUsesExpr getUsesExpr ( ) { result .getJobStmt ( ) = this }
151
153
}
152
154
153
155
/**
@@ -178,7 +180,7 @@ class JobOutputStmt extends Statement instanceof YamlMapping {
178
180
class StepStmt extends Statement instanceof Actions:: Step {
179
181
string getId ( ) { result = super .getId ( ) }
180
182
181
- JobStmt getJob ( ) { result = super .getJob ( ) }
183
+ JobStmt getJobStmt ( ) { result = super .getJob ( ) }
182
184
}
183
185
184
186
/**
@@ -189,7 +191,7 @@ abstract class UsesExpr extends Expression {
189
191
190
192
abstract string getVersion ( ) ;
191
193
192
- abstract Expression getArgument ( string key ) ;
194
+ abstract Expression getArgumentExpr ( string key ) ;
193
195
}
194
196
195
197
/**
@@ -204,7 +206,7 @@ class StepUsesExpr extends StepStmt, UsesExpr {
204
206
205
207
override string getVersion ( ) { result = uses .getVersion ( ) }
206
208
207
- override Expression getArgument ( string key ) {
209
+ override Expression getArgumentExpr ( string key ) {
208
210
exists ( Actions:: With with |
209
211
with .getStep ( ) = this and
210
212
result = with .lookup ( key )
@@ -220,7 +222,7 @@ class JobUsesExpr extends UsesExpr instanceof YamlMapping {
220
222
this instanceof JobStmt and this .maps ( any ( YamlString s | s .getValue ( ) = "uses" ) , _)
221
223
}
222
224
223
- JobStmt getJob ( ) { result = this }
225
+ JobStmt getJobStmt ( ) { result = this }
224
226
225
227
/**
226
228
* Gets a regular expression that parses an `owner/repo@version` reference within a `uses` field in an Actions job step.
@@ -255,7 +257,7 @@ class JobUsesExpr extends UsesExpr instanceof YamlMapping {
255
257
)
256
258
}
257
259
258
- override Expression getArgument ( string key ) {
260
+ override Expression getArgumentExpr ( string key ) {
259
261
this .( YamlMapping ) .lookup ( "with" ) .( YamlMapping ) .lookup ( key ) = result
260
262
}
261
263
}
@@ -290,8 +292,7 @@ class ExprAccessExpr extends Expression instanceof YamlString {
290
292
291
293
string getExpression ( ) { result = expr }
292
294
293
- JobStmt getJob ( ) { result .getAChildNode * ( ) = this }
294
- //override string toString() { result = expr }
295
+ JobStmt getJobStmt ( ) { result .getAChildNode * ( ) = this }
295
296
}
296
297
297
298
/**
@@ -313,7 +314,7 @@ class StepOutputAccessExpr extends ExprAccessExpr {
313
314
314
315
string getVarName ( ) { result = varName }
315
316
316
- StepStmt getStep ( ) { result .getId ( ) = stepId }
317
+ StepStmt getStepStmt ( ) { result .getId ( ) = stepId }
317
318
}
318
319
319
320
/**
@@ -368,7 +369,7 @@ class ReusableWorkflowInputAccessExpr extends ExprAccessExpr {
368
369
Expression getInputExpr ( ) {
369
370
exists ( ReusableWorkflowStmt w |
370
371
w .getLocation ( ) .getFile ( ) = this .getLocation ( ) .getFile ( ) and
371
- w .getInputs ( ) .getInputExpr ( paramName ) = result
372
+ w .getInputsStmt ( ) .getInputExpr ( paramName ) = result
372
373
)
373
374
}
374
375
}
0 commit comments