-
Notifications
You must be signed in to change notification settings - Fork 2k
Actions: Fix dominates() false positive in reusable workflows #21986
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
Open
JarLob
wants to merge
5
commits into
github:main
Choose a base branch
from
JarLob:userpermissions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2eed6c1
Fix dominates() false positive in reusable workflows
JarLob 048884b
Remove redundant cast
JarLob d51a9a3
Support nested reusable workflows
JarLob 2d6feb1
Fix false negatives when one of the jobs had proper checks and the ot…
JarLob 7f16853
Remove trailing white space
JarLob 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: fix | ||
| --- | ||
| * GitHub Actions queries now better account for permission checks on jobs that call reusable workflows. |
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
17 changes: 17 additions & 0 deletions
17
.../Security/CWE-829/.github/workflows/external/TestOrg/TestRepo/.github/workflows/build.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,17 @@ | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| COMMIT_SHA: | ||
| type: string | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ inputs.COMMIT_SHA }} | ||
| - run: | | ||
| npm install | ||
| npm run lint | ||
|
|
13 changes: 13 additions & 0 deletions
13
...ty/CWE-829/.github/workflows/external/TestOrg/TestRepo/.github/workflows/build_nested.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: | ||
| inputs: | ||
| COMMIT_SHA: | ||
| type: string | ||
|
|
||
| jobs: | ||
| build: | ||
| uses: TestOrg/TestRepo/.github/workflows/build.yml@main | ||
| with: | ||
| COMMIT_SHA: ${{ inputs.COMMIT_SHA }} | ||
|
|
||
|
|
31 changes: 31 additions & 0 deletions
31
...ns/ql/test/query-tests/Security/CWE-829/.github/workflows/untrusted_checkout_no_needs.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,31 @@ | ||
| on: | ||
| pull_request_target: | ||
|
|
||
| jobs: | ||
| is-collaborator: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Get User Permission | ||
| id: checkAccess | ||
| uses: actions-cool/check-user-permission@cd622002ff25c2311d2e7fb82107c0d24be83f9b | ||
| with: | ||
| require: write | ||
| username: ${{ github.actor }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Check User Permission | ||
| if: steps.checkAccess.outputs.require-result == 'false' | ||
| run: | | ||
| echo "${{ github.actor }} does not have permissions on this repo." | ||
| echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}" | ||
| exit 1 | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| #needs: is-collaborator Mistake, doesn't wait for the collaborator - no security check | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@4 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} # should alert | ||
| fetch-depth: 2 | ||
| - run: yarn test |
26 changes: 26 additions & 0 deletions
26
...tests/Security/CWE-829/.github/workflows/untrusted_checkout_permission_check_reusable.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,26 @@ | ||
| on: | ||
| pull_request_target: | ||
|
|
||
| jobs: | ||
| is-collaborator: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Get User Permission | ||
| id: checkAccess | ||
| uses: actions-cool/check-user-permission@cd622002ff25c2311d2e7fb82107c0d24be83f9b | ||
| with: | ||
| require: write | ||
| username: ${{ github.actor }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Check User Permission | ||
| if: steps.checkAccess.outputs.require-result == 'false' | ||
| run: | | ||
| echo "${{ github.actor }} does not have permissions on this repo." | ||
| echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}" | ||
| exit 1 | ||
| build: | ||
| needs: is-collaborator | ||
| uses: TestOrg/TestRepo/.github/workflows/build.yml@main | ||
| with: | ||
| COMMIT_SHA: ${{ github.event.pull_request.head.sha }} # shouldn't alert since permission check | ||
31 changes: 31 additions & 0 deletions
31
...ests/Security/CWE-829/.github/workflows/untrusted_checkout_permission_check_reusable2.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,31 @@ | ||
| on: | ||
| pull_request_target: | ||
|
|
||
| jobs: | ||
| is-collaborator: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Get User Permission | ||
| id: checkAccess | ||
| uses: actions-cool/check-user-permission@cd622002ff25c2311d2e7fb82107c0d24be83f9b | ||
| with: | ||
| require: write | ||
| username: ${{ github.actor }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Check User Permission | ||
| if: steps.checkAccess.outputs.require-result == 'false' | ||
| run: | | ||
| echo "${{ github.actor }} does not have permissions on this repo." | ||
| echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}" | ||
| exit 1 | ||
| build_unsafe: | ||
| # needs: is-collaborator | ||
| uses: TestOrg/TestRepo/.github/workflows/build.yml@main | ||
| with: | ||
| COMMIT_SHA: ${{ github.event.pull_request.head.sha }} # should alert since no permission check | ||
| build_safe: | ||
| needs: is-collaborator | ||
| uses: TestOrg/TestRepo/.github/workflows/build.yml@main | ||
| with: | ||
| COMMIT_SHA: ${{ github.event.pull_request.head.sha }} # shouldn't alert since permission check |
26 changes: 26 additions & 0 deletions
26
...ecurity/CWE-829/.github/workflows/untrusted_checkout_permission_check_reusable_level2.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,26 @@ | ||
| on: | ||
| pull_request_target: | ||
|
|
||
| jobs: | ||
| is-collaborator: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Get User Permission | ||
| id: checkAccess | ||
| uses: actions-cool/check-user-permission@cd622002ff25c2311d2e7fb82107c0d24be83f9b | ||
| with: | ||
| require: write | ||
| username: ${{ github.actor }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Check User Permission | ||
| if: steps.checkAccess.outputs.require-result == 'false' | ||
| run: | | ||
| echo "${{ github.actor }} does not have permissions on this repo." | ||
| echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}" | ||
| exit 1 | ||
| build: | ||
| needs: is-collaborator | ||
| uses: TestOrg/TestRepo/.github/workflows/build_nested.yml@main | ||
| with: | ||
| COMMIT_SHA: ${{ github.event.pull_request.head.sha }} # shouldn't alert since permission check |
26 changes: 26 additions & 0 deletions
26
...urity/CWE-829/.github/workflows/untrusted_checkout_permission_check_reusable_no_needs.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,26 @@ | ||
| on: | ||
| pull_request_target: | ||
|
|
||
| jobs: | ||
| is-collaborator: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Get User Permission | ||
| id: checkAccess | ||
| uses: actions-cool/check-user-permission@cd622002ff25c2311d2e7fb82107c0d24be83f9b | ||
| with: | ||
| require: write | ||
| username: ${{ github.actor }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Check User Permission | ||
| if: steps.checkAccess.outputs.require-result == 'false' | ||
| run: | | ||
| echo "${{ github.actor }} does not have permissions on this repo." | ||
| echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}" | ||
| exit 1 | ||
| build: | ||
| # needs: is-collaborator | ||
| uses: TestOrg/TestRepo/.github/workflows/build_nested.yml@main | ||
| with: | ||
| COMMIT_SHA: ${{ github.event.pull_request.head.sha }} |
41 changes: 41 additions & 0 deletions
41
...t/query-tests/Security/CWE-829/.github/workflows/untrusted_checkout_permissions_check.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,41 @@ | ||
| on: | ||
| pull_request_target: | ||
|
|
||
| jobs: | ||
| is-collaborator: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Get User Permission | ||
| id: checkAccess | ||
| uses: actions-cool/check-user-permission@cd622002ff25c2311d2e7fb82107c0d24be83f9b | ||
| with: | ||
| require: write | ||
| username: ${{ github.actor }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Check User Permission | ||
| if: steps.checkAccess.outputs.require-result == 'false' | ||
| run: | | ||
| echo "${{ github.actor }} does not have permissions on this repo." | ||
| echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}" | ||
| exit 1 | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| needs: is-collaborator | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@4 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} # shouldn't alert since permission check | ||
| fetch-depth: 2 | ||
| - run: yarn test | ||
| build_unsafe: | ||
| runs-on: ubuntu-latest | ||
| # needs: is-collaborator | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@4 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} # should alert since no permission check | ||
| fetch-depth: 2 | ||
| - run: yarn test |
Oops, something went wrong.
Oops, something went wrong.
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.