|
1 | 1 | /** |
2 | | - * @name Unpinned tag for a non-immutable Action in workflow |
| 2 | + * @name Unpinned tag for a non-immutable Action in workflow or composite action |
3 | 3 | * @description Using a tag for a non-immutable Action that is not pinned to a commit can lead to executing an untrusted Action through a supply chain attack. |
4 | 4 | * @kind problem |
5 | 5 | * @security-severity 5.0 |
@@ -31,15 +31,26 @@ private predicate isPinnedContainer(string version) { |
31 | 31 | bindingset[nwo] |
32 | 32 | private predicate isContainerImage(string nwo) { nwo.regexpMatch("^docker://.+") } |
33 | 33 |
|
34 | | -from UsesStep uses, string nwo, string version, Workflow workflow, string name |
| 34 | +private predicate getStepContainerName(UsesStep uses, string name) { |
| 35 | + exists(Workflow workflow | |
| 36 | + uses.getEnclosingWorkflow() = workflow and |
| 37 | + ( |
| 38 | + workflow.getName() = name |
| 39 | + or |
| 40 | + not exists(workflow.getName()) and workflow.getLocation().getFile().getBaseName() = name |
| 41 | + ) |
| 42 | + ) |
| 43 | + or |
| 44 | + exists(CompositeAction action | |
| 45 | + uses.getEnclosingCompositeAction() = action and |
| 46 | + name = action.getLocation().getFile().getBaseName() |
| 47 | + ) |
| 48 | +} |
| 49 | + |
| 50 | +from UsesStep uses, string nwo, string version, string name |
35 | 51 | where |
36 | 52 | uses.getCallee() = nwo and |
37 | | - uses.getEnclosingWorkflow() = workflow and |
38 | | - ( |
39 | | - workflow.getName() = name |
40 | | - or |
41 | | - not exists(workflow.getName()) and workflow.getLocation().getFile().getBaseName() = name |
42 | | - ) and |
| 53 | + getStepContainerName(uses, name) and |
43 | 54 | uses.getVersion() = version and |
44 | 55 | not isTrustedOwner(nwo) and |
45 | 56 | not (if isContainerImage(nwo) then isPinnedContainer(version) else isPinnedCommit(version)) and |
|
0 commit comments