@@ -184,26 +184,6 @@ class StepStmt extends Statement instanceof Actions::Step {
184
184
string getId ( ) { result = super .getId ( ) }
185
185
186
186
JobStmt getJobStmt ( ) { result = super .getJob ( ) }
187
-
188
- /**
189
- * Gets a environment variable expression by name in the scope of the current step.
190
- */
191
- Expression getEnvExpr ( string name ) {
192
- exists ( Actions:: StepEnv env |
193
- env .getStep ( ) = this and
194
- env .( YamlMapping ) .maps ( any ( YamlScalar s | s .getValue ( ) = name ) , result )
195
- )
196
- or
197
- exists ( Actions:: JobEnv env |
198
- env .getJob ( ) = this .getJobStmt ( ) and
199
- env .( YamlMapping ) .maps ( any ( YamlScalar s | s .getValue ( ) = name ) , result )
200
- )
201
- or
202
- exists ( Actions:: WorkflowEnv env |
203
- env .getWorkflow ( ) = this .getJobStmt ( ) .getWorkflowStmt ( ) and
204
- env .( YamlMapping ) .maps ( any ( YamlScalar s | s .getValue ( ) = name ) , result )
205
- )
206
- }
207
187
}
208
188
209
189
/**
@@ -238,7 +218,25 @@ class StepUsesExpr extends StepStmt, UsesExpr {
238
218
)
239
219
}
240
220
241
- override Expression getEnvExpr ( string name ) { result = this .( StepStmt ) .getEnvExpr ( name ) }
221
+ /**
222
+ * Gets a environment variable expression by name in the scope of the current step.
223
+ */
224
+ override Expression getEnvExpr ( string name ) {
225
+ exists ( Actions:: StepEnv env |
226
+ env .getStep ( ) = this and
227
+ env .( YamlMapping ) .maps ( any ( YamlScalar s | s .getValue ( ) = name ) , result )
228
+ )
229
+ or
230
+ exists ( Actions:: JobEnv env |
231
+ env .getJob ( ) = this .getJobStmt ( ) and
232
+ env .( YamlMapping ) .maps ( any ( YamlScalar s | s .getValue ( ) = name ) , result )
233
+ )
234
+ or
235
+ exists ( Actions:: WorkflowEnv env |
236
+ env .getWorkflow ( ) = this .getJobStmt ( ) .getWorkflowStmt ( ) and
237
+ env .( YamlMapping ) .maps ( any ( YamlScalar s | s .getValue ( ) = name ) , result )
238
+ )
239
+ }
242
240
}
243
241
244
242
/**
@@ -317,6 +315,26 @@ class RunExpr extends StepStmt, Expression {
317
315
Expression getScriptExpr ( ) { result = scriptExpr }
318
316
319
317
string getScript ( ) { result = scriptExpr .getValue ( ) }
318
+
319
+ /**
320
+ * Gets a environment variable expression by name in the scope of the current node.
321
+ */
322
+ Expression getEnvExpr ( string name ) {
323
+ exists ( Actions:: StepEnv env |
324
+ env .getStep ( ) = this and
325
+ env .( YamlMapping ) .maps ( any ( YamlScalar s | s .getValue ( ) = name ) , result )
326
+ )
327
+ or
328
+ exists ( Actions:: JobEnv env |
329
+ env .getJob ( ) = this .getJobStmt ( ) and
330
+ env .( YamlMapping ) .maps ( any ( YamlScalar s | s .getValue ( ) = name ) , result )
331
+ )
332
+ or
333
+ exists ( Actions:: WorkflowEnv env |
334
+ env .getWorkflow ( ) = this .getJobStmt ( ) .getWorkflowStmt ( ) and
335
+ env .( YamlMapping ) .maps ( any ( YamlScalar s | s .getValue ( ) = name ) , result )
336
+ )
337
+ }
320
338
}
321
339
322
340
/**
@@ -420,5 +438,11 @@ class EnvAccessExpr extends ExprAccessExpr {
420
438
421
439
EnvAccessExpr ( ) { varName = this .getExpression ( ) .regexpCapture ( "env\\.([A-Za-z0-9_-]+)" , 1 ) }
422
440
423
- override Expression getRefExpr ( ) { exists ( RunExpr s | s .getEnvExpr ( varName ) = result ) }
441
+ override Expression getRefExpr ( ) {
442
+ exists ( JobUsesExpr s | s .getEnvExpr ( varName ) = result )
443
+ or
444
+ exists ( StepUsesExpr s | s .getEnvExpr ( varName ) = result )
445
+ or
446
+ exists ( RunExpr s | s .getEnvExpr ( varName ) = result )
447
+ }
424
448
}
0 commit comments