Skip to content

Commit 22e7b9a

Browse files
committed
Convert trusted actions list to data extension
1 parent 0258ce7 commit 22e7b9a

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

actions/ql/lib/codeql/actions/security/UseOfUnversionedImmutableAction.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ class UnversionedImmutableAction extends UsesStep {
99
}
1010
}
1111

12+
// The following predicate is extended in data extensions under actions/ql/lib/codeql/actions/security/owner/
13+
// and can be extended with custom model packs as necessary.
14+
15+
/** Holds for actions owner defined in data extensions */
16+
extensible predicate trustedActionsOwner(string owner);
17+
1218
bindingset[version]
1319
predicate isSemVer(string version) {
1420
// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string with optional v prefix
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: trustedActionsOwner
5+
data:
6+
- ["actions"]
7+
- ["github"]
8+
- ["advanced-security"]

actions/ql/lib/qlpack.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ dataExtensions:
1414
- ext/manual/*.model.yml
1515
- ext/generated/**/*.model.yml
1616
- ext/config/*.yml
17+
- codeql/actions/security/owner/**/*.model.yml

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+
trustedActionsOwner(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)