@@ -133,9 +133,10 @@ predicate typeStrongerThan(DataFlowType t1, DataFlowType t2) { none() }
133
133
134
134
newtype TContent =
135
135
TFieldContent ( string name ) {
136
- // We only use field flow for steps and jobs outputs, not for accessing other context fields such as jobs, env or inputs
136
+ // We only use field flow for steps and jobs outputs, not for accessing other context fields such as env or inputs
137
137
name = any ( StepsCtxAccessExpr a ) .getFieldName ( ) or
138
- name = any ( NeedsCtxAccessExpr a ) .getFieldName ( )
138
+ name = any ( NeedsCtxAccessExpr a ) .getFieldName ( ) or
139
+ name = any ( JobsCtxAccessExpr a ) .getFieldName ( )
139
140
}
140
141
141
142
/**
@@ -196,9 +197,8 @@ predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) { ppos =
196
197
* field name.
197
198
*/
198
199
predicate stepsCtxLocalStep ( Node nodeFrom , Node nodeTo ) {
199
- exists ( StepStmt astFrom , StepsCtxAccessExpr astTo |
200
+ exists ( UsesExpr astFrom , StepsCtxAccessExpr astTo |
200
201
externallyDefinedSource ( nodeFrom , _, "output." + astTo .getFieldName ( ) ) and
201
- astFrom instanceof UsesExpr and
202
202
astFrom = nodeFrom .asExpr ( ) and
203
203
astTo = nodeTo .asExpr ( ) and
204
204
astTo .getRefExpr ( ) = astFrom
@@ -259,9 +259,16 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) { localFlowStep(nodeFr
259
259
*/
260
260
predicate jumpStep ( Node nodeFrom , Node nodeTo ) { none ( ) }
261
261
262
+ /**
263
+ * Holds if a CtxAccessExpr reads a field from a job (needs/jobs), step (steps) output via a read of `c` (fieldname)
264
+ */
262
265
predicate ctxFieldReadStep ( Node node1 , Node node2 , ContentSet c ) {
263
266
exists ( CtxAccessExpr access |
264
- ( access instanceof NeedsCtxAccessExpr or access instanceof StepsCtxAccessExpr ) and
267
+ (
268
+ access instanceof NeedsCtxAccessExpr or
269
+ access instanceof StepsCtxAccessExpr or
270
+ access instanceof JobsCtxAccessExpr
271
+ ) and
265
272
c = any ( FieldContent ct | ct .getName ( ) = access .getFieldName ( ) ) and
266
273
node1 .asExpr ( ) = access .getRefExpr ( ) and
267
274
node2 .asExpr ( ) = access
@@ -272,12 +279,13 @@ predicate ctxFieldReadStep(Node node1, Node node2, ContentSet c) {
272
279
* Holds if data can flow from `node1` to `node2` via a read of `c`. Thus,
273
280
* `node1` references an object with a content `c.getAReadContent()` whose
274
281
* value ends up in `node2`.
282
+ * Store steps without corresponding reads are pruned aggressively very early, since they can never contribute to a complete path.
275
283
*/
276
284
predicate readStep ( Node node1 , ContentSet c , Node node2 ) { ctxFieldReadStep ( node1 , node2 , c ) }
277
285
278
286
/**
279
- * A store step to store an output expression (node1) into its OutputsStm node (node2)
280
- * with a given access path (fieldName)
287
+ * Stores an output expression (node1) into its OutputsStm node (node2)
288
+ * using the output variable name as the access path
281
289
*/
282
290
predicate fieldStoreStep ( Node node1 , Node node2 , ContentSet c ) {
283
291
exists ( OutputsStmt out , string fieldName |
@@ -291,6 +299,7 @@ predicate fieldStoreStep(Node node1, Node node2, ContentSet c) {
291
299
* Holds if data can flow from `node1` to `node2` via a store into `c`. Thus,
292
300
* `node2` references an object with a content `c.getAStoreContent()` that
293
301
* contains the value of `node1`.
302
+ * Store steps without corresponding reads are pruned aggressively very early, since they can never contribute to a complete path.
294
303
*/
295
304
predicate storeStep ( Node node1 , ContentSet c , Node node2 ) {
296
305
fieldStoreStep ( node1 , node2 , c ) or
0 commit comments