@@ -4,6 +4,7 @@ import codeql.actions.DataFlow
44import codeql.actions.dataflow.FlowSources
55import codeql.actions.security.PoisonableSteps
66import codeql.actions.security.UntrustedCheckoutQuery
7+ import codeql.actions.security.ControlChecks
78
89string unzipRegexp ( ) { result = "(unzip|tar)\\s+.*" }
910
@@ -292,6 +293,16 @@ class ArtifactPoisoningSink extends DataFlow::Node {
292293 string getPath ( ) { result = download .getPath ( ) }
293294}
294295
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+
295306/**
296307 * A taint-tracking configuration for unsafe artifacts
297308 * that is used may lead to artifact poisoning
@@ -318,6 +329,16 @@ private module ArtifactPoisoningConfig implements DataFlow::ConfigSig {
318329 exists ( run .getScript ( ) .getAFileReadCommand ( ) )
319330 )
320331 }
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+ }
321342}
322343
323344/** Tracks flow of unsafe artifacts that is used in an insecure way. */
0 commit comments