Skip to content

Commit a2bbf70

Browse files
author
Alvaro Muñoz
committed
fix: triggering events for artifact poisoning
1 parent 2a1226c commit a2bbf70

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

ql/src/Security/CWE-829/ArtifactPoisoning.ql

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,27 @@
1414
import actions
1515
import codeql.actions.security.ArtifactPoisoningQuery
1616

17-
from LocalJob job, ArtifactDownloadStep download, Step run
17+
predicate isSingleTriggerWorkflow(Workflow w, string trigger) {
18+
w.getATriggerEvent() = trigger and
19+
count(string t | w.getATriggerEvent() = t | t) = 1
20+
}
21+
22+
from Workflow w, LocalJob job, ArtifactDownloadStep download, Step run
1823
where
19-
job.getWorkflow().getATriggerEvent() = ["workflow_run", "workflow_dispatch"] and
24+
w = job.getWorkflow() and
25+
(
26+
// The Workflow is triggered by an event other than `pull_request`
27+
not isSingleTriggerWorkflow(w, "pull_request")
28+
or
29+
// The Workflow is only triggered by `workflow_call` and there is
30+
// a caller workflow triggered by an event other than `pull_request`
31+
isSingleTriggerWorkflow(w, "workflow_call") and
32+
exists(ExternalJob call, Workflow caller |
33+
call.getCallee() = w.getLocation().getFile().getRelativePath() and
34+
caller = call.getWorkflow() and
35+
not isSingleTriggerWorkflow(caller, "pull_request")
36+
)
37+
) and
2038
(run instanceof Run or run instanceof UsesStep) and
2139
exists(int i, int j |
2240
job.getStep(i) = download and

0 commit comments

Comments
 (0)