Skip to content

Commit 0e4725b

Browse files
authored
Merge pull request #18435 from felickz/felickz/actions-trusted-owner-data-extensions
Convert trusted actions list to data extension
2 parents 42562b5 + fd404bc commit 0e4725b

File tree

6 files changed

+36
-9
lines changed

6 files changed

+36
-9
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: feature
3+
---
4+
* The "Unpinned tag for a non-immutable Action in workflow" query (`actions/unpinned-tag`) now supports expanding the trusted action owner list using data extensions (`extensible: trustedActionsOwnerDataModel`). If you trust an Action publisher, you can include the owner name/organization in a model pack to add it to the allow list for this query. This addition will prevent security alerts when using unpinned tags for Actions published by that owner. For more information on creating a model pack, see [Creating a CodeQL Model Pack](https://docs.github.com/en/code-security/codeql-cli/using-the-advanced-functionality-of-the-codeql-cli/creating-and-working-with-codeql-packs#creating-a-codeql-model-pack).

actions/ql/lib/codeql/actions/config/Config.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ predicate vulnerableActionsDataModel(
126126
*/
127127
predicate immutableActionsDataModel(string action) { Extensions::immutableActionsDataModel(action) }
128128

129+
/**
130+
* MaD models for trusted actions owners
131+
* Fields:
132+
* - owner: owner name
133+
*/
134+
predicate trustedActionsOwnerDataModel(string owner) {
135+
Extensions::trustedActionsOwnerDataModel(owner)
136+
}
137+
129138
/**
130139
* MaD models for untrusted git commands
131140
* Fields:

actions/ql/lib/codeql/actions/config/ConfigExtensions.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ extensible predicate vulnerableActionsDataModel(
6363
*/
6464
extensible predicate immutableActionsDataModel(string action);
6565

66+
/**
67+
* Holds for trusted Actions owners.
68+
*/
69+
extensible predicate trustedActionsOwnerDataModel(string owner);
70+
6671
/**
6772
* Holds for git commands that may introduce untrusted data when called on an attacker controlled branch.
6873
*/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
extensions:
2+
- addsTo:
3+
pack: codeql/actions-all
4+
extensible: trustedActionsOwnerDataModel
5+
data:
6+
- ["actions"]
7+
- ["github"]
8+
- ["advanced-security"]

actions/ql/src/Security/CWE-829/UnpinnedActionsTag.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ Pinning an action to a full length commit SHA is currently the only way to use a
2424
2525
## References
2626
27-
- [Using third-party actions](https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#using-third-party-actions)
27+
- [Using third-party actions](https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#using-third-party-actions)

actions/ql/src/Security/CWE-829/UnpinnedActionsTag.ql

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,25 @@ import codeql.actions.security.UseOfUnversionedImmutableAction
1717
bindingset[version]
1818
private predicate isPinnedCommit(string version) { version.regexpMatch("^[A-Fa-f0-9]{40}$") }
1919

20-
bindingset[repo]
21-
private predicate isTrustedOrg(string repo) {
22-
repo.matches(["actions", "github", "advanced-security"] + "/%")
20+
bindingset[nwo]
21+
private predicate isTrustedOwner(string nwo) {
22+
// Gets the segment before the first '/' in the name with owner(nwo) string
23+
trustedActionsOwnerDataModel(nwo.substring(0, nwo.indexOf("/")))
2324
}
2425

25-
from UsesStep uses, string repo, string version, Workflow workflow, string name
26+
from UsesStep uses, string nwo, string version, Workflow workflow, string name
2627
where
27-
uses.getCallee() = repo and
28+
uses.getCallee() = nwo and
2829
uses.getEnclosingWorkflow() = workflow and
2930
(
3031
workflow.getName() = name
3132
or
3233
not exists(workflow.getName()) and workflow.getLocation().getFile().getBaseName() = name
3334
) and
3435
uses.getVersion() = version and
35-
not isTrustedOrg(repo) and
36+
not isTrustedOwner(nwo) and
3637
not isPinnedCommit(version) and
37-
not isImmutableAction(uses, repo)
38+
not isImmutableAction(uses, nwo)
3839
select uses.getCalleeNode(),
39-
"Unpinned 3rd party Action '" + name + "' step $@ uses '" + repo + "' with ref '" + version +
40+
"Unpinned 3rd party Action '" + name + "' step $@ uses '" + nwo + "' with ref '" + version +
4041
"', not a pinned commit hash", uses, uses.toString()

0 commit comments

Comments
 (0)