-
Notifications
You must be signed in to change notification settings - Fork 1.9k
actions: add MaD model for permissions needed by actions #19166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
adityasharad
merged 10 commits into
github:main
from
yoff:actions/add-actions-permissions-MaD-model
Apr 2, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e7bb47f
ruby: add MaD model for permissions needed by actions
yoff 1ec3e87
Apply suggestions from code review
yoff 3cdd641
actions: fix typo
yoff bd7c684
actions: add test with empty permissions
yoff ee1eb19
actions: add description of `actionsPermissionsDataModel`
yoff 6fd8aba
actions: simplify using existing `UsesStep`
yoff d83f35f
actions: remove unneded API
yoff 80ae879
actions: update test expectations
yoff 7bf4a47
Apply suggestions from code review
yoff c185290
actions: add change note
yoff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| extensions: | ||
| - addsTo: | ||
| pack: codeql/actions-all | ||
| extensible: actionsPermissionsDataModel | ||
| data: | ||
| - ["actions/checkout", "contents: read"] | ||
| - ["actions/setup-node", "contents: read"] | ||
| - ["actions/setup-python", "contents: read"] | ||
| - ["actions/setup-java", "contents: read"] | ||
| - ["actions/setup-go", "contents: read"] | ||
| - ["actions/setup-dotnet", "contents: read"] | ||
| - ["actions/labeler", "contents: read"] | ||
| - ["actions/labeler", "pull-requests: write"] | ||
| - ["actions/attest", "id-token: write"] | ||
| - ["actions/attest", "attestations: write"] | ||
| # No permissions needed for actions/add-to-project | ||
| - ["actions/dependency-review-action", "contents: read"] | ||
| - ["actions/attest-sbom", "id-token: write"] | ||
| - ["actions/attest-sbom", "attestations: write"] | ||
| - ["actions/stale", "contents: write"] | ||
| - ["actions/stale", "issues: write"] | ||
| - ["actions/stale", "pull-requests: write"] | ||
| - ["actions/attest-build-provenance", "id-token: write"] | ||
| - ["actions/attest-build-provenance", "attestations: write"] | ||
| - ["actions/jekyll-build-pages", "contents: read"] | ||
| - ["actions/jekyll-build-pages", "pages: write"] | ||
| - ["actions/jekyll-build-pages", "id-token: write"] | ||
| - ["actions/publish-action", "contents: write"] | ||
| - ["actions/versions-package-tools", "contents: read"] | ||
| - ["actions/versions-package-tools", "actions: read"] | ||
| - ["actions/reusable-workflows", "contents: read"] | ||
| - ["actions/reusable-workflows", "actions: read"] | ||
| # TODO: Add permissions for actions/download-artifact | ||
| # TODO: Add permissions for actions/upload-artifact | ||
| # TODO: Add permissions for actions/cache | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
actions/ql/src/change-notes/2025-02-04-suggest-actions-permissions.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: fix | ||
| --- | ||
| * Alerts produced by the query `actions/missing-workflow-permissions` now include a minimal set of recommended permissions in the alert message, based on well-known actions seen within the workflow file. |
13 changes: 13 additions & 0 deletions
13
actions/ql/test/query-tests/Security/CWE-275/.github/workflows/perms6.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| on: | ||
| workflow_call: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build and test | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: actions/jekyll-build-pages | ||
|
|
||
|
|
10 changes: 10 additions & 0 deletions
10
actions/ql/test/query-tests/Security/CWE-275/.github/workflows/perms7.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| on: | ||
| workflow_call: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build and test | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/add-to-project@v2 |
8 changes: 5 additions & 3 deletions
8
actions/ql/test/query-tests/Security/CWE-275/MissingActionsPermissions.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| | .github/workflows/perms1.yml:6:5:9:32 | Job: build | Actions Job or Workflow does not set permissions | | ||
| | .github/workflows/perms2.yml:6:5:10:2 | Job: build | Actions Job or Workflow does not set permissions | | ||
| | .github/workflows/perms5.yml:7:5:10:32 | Job: build | Actions Job or Workflow does not set permissions | | ||
| | .github/workflows/perms1.yml:6:5:9:32 | Job: build | Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read} | | ||
| | .github/workflows/perms2.yml:6:5:10:2 | Job: build | Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read} | | ||
| | .github/workflows/perms5.yml:7:5:10:32 | Job: build | Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read} | | ||
| | .github/workflows/perms6.yml:7:5:11:39 | Job: build | Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read, id-token: write, pages: write} | | ||
| | .github/workflows/perms7.yml:7:5:10:38 | Job: build | Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {} | |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.