@@ -133,9 +133,9 @@ 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
137
name = any ( StepsCtxAccessExpr a ) .getFieldName ( ) or
137
- name = any ( NeedsCtxAccessExpr a ) .getFieldName ( ) or
138
- name = any ( JobsCtxAccessExpr a ) .getFieldName ( )
138
+ name = any ( NeedsCtxAccessExpr a ) .getFieldName ( )
139
139
}
140
140
141
141
/**
@@ -188,11 +188,12 @@ class ArgumentPosition extends string {
188
188
predicate parameterMatch ( ParameterPosition ppos , ArgumentPosition apos ) { ppos = apos }
189
189
190
190
/**
191
- * Holds if there is a local flow step between a ${{}} expression accesing a step output variable and the step output itself
192
- * But only for those cases where the step output is defined externally in a MaD specification.
193
- * The reason for this is that we don't currently have a way to specify that a source starts with a non-empty access
194
- * path so the easiest thing is to add the corresponding read steps of that field as local flow steps as well.
195
- * e.g. ${{ steps.step1.output.foo }}
191
+ * Holds if there is a local flow step between a ${{ steps.xxx.outputs.yyy }} expression accesing a step output field
192
+ * and the step output itself. But only for those cases where the step output is defined externally in a MaD Source
193
+ * specification. The reason for this is that we don't currently have a way to specify that a source starts with a
194
+ * non-empty access path so we cannot write a Source that stores the taint in a Content, we can only do that for steps
195
+ * (storeStep). The easiest thing is to add this local flow step that simulates a read step from the source node for a specific
196
+ * field name.
196
197
*/
197
198
predicate stepsCtxLocalStep ( Node nodeFrom , Node nodeTo ) {
198
199
exists ( StepStmt astFrom , StepsCtxAccessExpr astTo |
@@ -204,19 +205,6 @@ predicate stepsCtxLocalStep(Node nodeFrom, Node nodeTo) {
204
205
)
205
206
}
206
207
207
- /**
208
- * Holds if there is a local flow step between a ${{}} expression accesing a job output variable and the job output itself
209
- * e.g. ${{ needs.job1.output.foo }} or ${{ jobs.job1.output.foo }}
210
- */
211
- predicate jobsCtxLocalStep ( Node nodeFrom , Node nodeTo ) {
212
- exists ( Expression astFrom , CtxAccessExpr astTo |
213
- astFrom = nodeFrom .asExpr ( ) and
214
- astTo = nodeTo .asExpr ( ) and
215
- astTo .getRefExpr ( ) = astFrom and
216
- ( astTo instanceof NeedsCtxAccessExpr or astTo instanceof JobsCtxAccessExpr )
217
- )
218
- }
219
-
220
208
/**
221
209
* Holds if there is a local flow step between a ${{}} expression accesing an input variable and the input itself
222
210
* e.g. ${{ inputs.foo }}
@@ -252,7 +240,6 @@ predicate envCtxLocalStep(Node nodeFrom, Node nodeTo) {
252
240
pragma [ nomagic]
253
241
predicate localFlowStep ( Node nodeFrom , Node nodeTo ) {
254
242
stepsCtxLocalStep ( nodeFrom , nodeTo ) or
255
- jobsCtxLocalStep ( nodeFrom , nodeTo ) or
256
243
inputsCtxLocalStep ( nodeFrom , nodeTo ) or
257
244
envCtxLocalStep ( nodeFrom , nodeTo )
258
245
}
@@ -272,17 +259,12 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) { localFlowStep(nodeFr
272
259
*/
273
260
predicate jumpStep ( Node nodeFrom , Node nodeTo ) { none ( ) }
274
261
275
- /**
276
- * A read step to read the value of a ReusableWork uses step and connect it to its
277
- * corresponding JobOutputAccessExpr
278
- */
279
- predicate reusableWorkflowReturnReadStep ( Node node1 , Node node2 , ContentSet c ) {
280
- exists ( NeedsCtxAccessExpr expr , string fieldName |
281
- expr .usesReusableWorkflow ( ) and
282
- expr .getRefExpr ( ) = node1 .asExpr ( ) and
283
- expr .getFieldName ( ) = fieldName and
284
- expr = node2 .asExpr ( ) and
285
- c = any ( FieldContent ct | ct .getName ( ) = fieldName )
262
+ predicate ctxFieldReadStep ( Node node1 , Node node2 , ContentSet c ) {
263
+ exists ( CtxAccessExpr access |
264
+ ( access instanceof NeedsCtxAccessExpr or access instanceof StepsCtxAccessExpr ) and
265
+ c = any ( FieldContent ct | ct .getName ( ) = access .getFieldName ( ) ) and
266
+ node1 .asExpr ( ) = access .getRefExpr ( ) and
267
+ node2 .asExpr ( ) = access
286
268
)
287
269
}
288
270
@@ -291,24 +273,14 @@ predicate reusableWorkflowReturnReadStep(Node node1, Node node2, ContentSet c) {
291
273
* `node1` references an object with a content `c.getAReadContent()` whose
292
274
* value ends up in `node2`.
293
275
*/
294
- predicate readStep ( Node node1 , ContentSet c , Node node2 ) {
295
- // TODO: Extract to its own predicate
296
- exists ( StepsCtxAccessExpr access |
297
- c = any ( FieldContent ct | ct .getName ( ) = access .getFieldName ( ) ) and
298
- node1 .asExpr ( ) = access .getRefExpr ( ) and
299
- node2 .asExpr ( ) = access
300
- )
301
- or
302
- reusableWorkflowReturnReadStep ( node1 , node2 , c )
303
- }
276
+ predicate readStep ( Node node1 , ContentSet c , Node node2 ) { ctxFieldReadStep ( node1 , node2 , c ) }
304
277
305
278
/**
306
- * A store step to store the value of a ReusableWorkflowStmt output expr into the return node (node2)
279
+ * A store step to store an output expression (node1) into its OutputsStm node (node2)
307
280
* with a given access path (fieldName)
308
281
*/
309
- predicate reusableWorkflowReturnStoreStep ( Node node1 , Node node2 , ContentSet c ) {
310
- exists ( ReusableWorkflowStmt stmt , OutputsStmt out , string fieldName |
311
- out = stmt .getOutputsStmt ( ) and
282
+ predicate fieldStoreStep ( Node node1 , Node node2 , ContentSet c ) {
283
+ exists ( OutputsStmt out , string fieldName |
312
284
node1 .asExpr ( ) = out .getOutputExpr ( fieldName ) and
313
285
node2 .asExpr ( ) = out and
314
286
c = any ( FieldContent ct | ct .getName ( ) = fieldName )
@@ -321,13 +293,9 @@ predicate reusableWorkflowReturnStoreStep(Node node1, Node node2, ContentSet c)
321
293
* contains the value of `node1`.
322
294
*/
323
295
predicate storeStep ( Node node1 , ContentSet c , Node node2 ) {
324
- reusableWorkflowReturnStoreStep ( node1 , node2 , c )
325
- or
326
- // TODO: rename to xxxxStoreStep
327
- externallyDefinedSummary ( node1 , node2 , c )
328
- or
329
- // TODO: rename to xxxxStoreStep
330
- runEnvToScriptstep ( node1 , node2 , c )
296
+ fieldStoreStep ( node1 , node2 , c ) or
297
+ externallyDefinedStoreStep ( node1 , node2 , c ) or
298
+ runEnvToScriptStoreStep ( node1 , node2 , c )
331
299
}
332
300
333
301
/**
0 commit comments