Skip to content

Commit 74e6d34

Browse files
committed
Actions: Correctly check permissions in actions/missing-workflow-permissions
1 parent 5866bcc commit 74e6d34

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

actions/ql/src/Security/CWE-275/MissingActionsPermissions.ql

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,23 @@ string permissionsForJob(Job job) {
2626
"{" + concat(string permission | permission = jobNeedsPermission(job) | permission, ", ") + "}"
2727
}
2828

29+
predicate jobHasPermissions(Job job) {
30+
exists(job.getPermissions())
31+
or
32+
exists(job.getEnclosingWorkflow().getPermissions())
33+
or
34+
// The workflow is reusable and cannot be triggered in any other way; check callers
35+
exists(ReusableWorkflow r | r = job.getEnclosingWorkflow() |
36+
not exists(Event e | e = r.getOn().getAnEvent() | e.getName() != "workflow_call") and
37+
forall(Job caller | caller = job.getEnclosingWorkflow().(ReusableWorkflow).getACaller() |
38+
jobHasPermissions(caller)
39+
)
40+
)
41+
}
42+
2943
from Job job, string permissions
3044
where
31-
not exists(job.getPermissions()) and
32-
not exists(job.getEnclosingWorkflow().getPermissions()) and
45+
not jobHasPermissions(job) and
3346
// exists a trigger event that is not a workflow_call
3447
exists(Event e |
3548
e = job.getATriggerEvent() and

0 commit comments

Comments
 (0)