Skip to content

Commit

Permalink
Refactor trusted actions owner model
Browse files Browse the repository at this point in the history
- use existing data extensions config and yml folder
- rename from trustedActionsOwner to trustedActionsOwnerDataModel
- update related predicates
  • Loading branch information
felickz committed Jan 7, 2025
1 parent 35587ed commit 3e94a4c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
category: feature
---
* Trusted Action owner list can now be expanded using data extensions for `trustedActionsOwner` on the query `actions/unpinned-tag`
* Trusted Action owner list can now be expanded using data extensions for `trustedActionsOwnerDataModel` on the query `actions/unpinned-tag`
7 changes: 7 additions & 0 deletions actions/ql/lib/codeql/actions/config/Config.qll
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ predicate vulnerableActionsDataModel(
*/
predicate immutableActionsDataModel(string action) { Extensions::immutableActionsDataModel(action) }

/**
* MaD models for trusted actions owners
* Fields:
* - owner: owner name
*/
predicate trustedActionsOwnerDataModel(string owner) { Extensions::trustedActionsOwnerDataModel(owner) }

/**
* MaD models for untrusted git commands
* Fields:
Expand Down
6 changes: 6 additions & 0 deletions actions/ql/lib/codeql/actions/config/ConfigExtensions.qll
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ extensible predicate vulnerableActionsDataModel(
*/
extensible predicate immutableActionsDataModel(string action);


/**
* Holds for trusted Actions owners.
*/
extensible predicate trustedActionsOwnerDataModel(string owner);

/**
* Holds for git commands that may introduce untrusted data when called on an attacker controlled branch.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ class UnversionedImmutableAction extends UsesStep {
}
}

// The following predicate is extended in data extensions under actions/ql/lib/codeql/actions/security/owner/
// and can be extended with custom model packs as necessary.
/** Holds for actions owner defined in data extensions */
extensible predicate trustedActionsOwner(string owner);

bindingset[version]
predicate isSemVer(string version) {
// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string with optional v prefix
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extensions:
- addsTo:
pack: codeql/actions-all
extensible: trustedActionsOwner
extensible: trustedActionsOwnerDataModel
data:
- ["actions"]
- ["github"]
Expand Down
1 change: 0 additions & 1 deletion actions/ql/lib/qlpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ dataExtensions:
- ext/manual/*.model.yml
- ext/generated/**/*.model.yml
- ext/config/*.yml
- codeql/actions/security/owner/**/*.model.yml
2 changes: 1 addition & 1 deletion actions/ql/src/Security/CWE-829/UnpinnedActionsTag.ql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private predicate isPinnedCommit(string version) { version.regexpMatch("^[A-Fa-f
bindingset[nwo]
private predicate isTrustedOwner(string nwo) {
// Gets the segment before the first '/' in the name with owner(nwo) string
trustedActionsOwner(nwo.substring(0, nwo.indexOf("/")))
trustedActionsOwnerDataModel(nwo.substring(0, nwo.indexOf("/")))
}

from UsesStep uses, string nwo, string version, Workflow workflow, string name
Expand Down

0 comments on commit 3e94a4c

Please sign in to comment.