@@ -4,6 +4,7 @@ import codeql.actions.DataFlow
4
4
import codeql.actions.dataflow.FlowSources
5
5
import codeql.actions.security.PoisonableSteps
6
6
import codeql.actions.security.UntrustedCheckoutQuery
7
+ import codeql.actions.security.ControlChecks
7
8
8
9
string unzipRegexp ( ) { result = "(unzip|tar)\\s+.*" }
9
10
@@ -292,6 +293,16 @@ class ArtifactPoisoningSink extends DataFlow::Node {
292
293
string getPath ( ) { result = download .getPath ( ) }
293
294
}
294
295
296
+ /**
297
+ * Gets the event that is relevant for the given node in the context of artifact poisoning.
298
+ *
299
+ * This is used to highlight the event in the query results when an alert is raised.
300
+ */
301
+ Event getRelevantEventInPrivilegedContext ( DataFlow:: Node node ) {
302
+ inPrivilegedContext ( node .asExpr ( ) , result ) and
303
+ not exists ( ControlCheck check | check .protects ( node .asExpr ( ) , result , "artifact-poisoning" ) )
304
+ }
305
+
295
306
/**
296
307
* A taint-tracking configuration for unsafe artifacts
297
308
* that is used may lead to artifact poisoning
@@ -318,6 +329,16 @@ private module ArtifactPoisoningConfig implements DataFlow::ConfigSig {
318
329
exists ( run .getScript ( ) .getAFileReadCommand ( ) )
319
330
)
320
331
}
332
+
333
+ predicate observeDiffInformedIncrementalMode ( ) { any ( ) }
334
+
335
+ Location getASelectedSourceLocation ( DataFlow:: Node source ) { none ( ) }
336
+
337
+ Location getASelectedSinkLocation ( DataFlow:: Node sink ) {
338
+ result = sink .getLocation ( )
339
+ or
340
+ result = getRelevantEventInPrivilegedContext ( sink ) .getLocation ( )
341
+ }
321
342
}
322
343
323
344
/** Tracks flow of unsafe artifacts that is used in an insecure way. */
0 commit comments