Merged
Conversation
Comment on lines
+44
to
+47
| - name: Validate PR commits with commitlint | ||
| run: | | ||
| git fetch origin pull/${{ github.event.pull_request.number }}/head:pr_branch | ||
| npx commitlint --from ${{ github.event.pull_request.base.sha }} --to pr_branch --verbose |
Check warning
Code scanning / CodeQL
Checkout of untrusted code in trusted context Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 7 months ago
To fix the problem, you should prevent the checkout and execution of untrusted PR code in a privileged context. The best practice is to separate the untrusted PR handling from privileged workflows. Specifically:
- Remove any direct fetching or checking out of PR HEAD code in a privileged workflow.
- Instead, perform commit linting in a workflow triggered by
pull_request(unprivileged) rather than viaworkflow_callorpull_request_target. - If you need to communicate results to privileged workflows, use artifacts and the
workflow_runpattern as described in the background. - For the workflow in question, you should remove the step that fetches and checks out the PR branch and instead run commitlint only on trusted code or in an unprivileged context.
Specifically, in .github/workflows/commitlint.yml, you should remove or adjust the step:
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr_branch
and not run commitlint on untrusted PR code when triggered from a privileged context.
Suggested changeset
1
.github/workflows/commitlint.yml
| @@ -41,7 +41,7 @@ | ||
| run: | | ||
| echo "export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js | ||
|
|
||
| - name: Validate PR commits with commitlint | ||
| run: | | ||
| git fetch origin pull/${{ github.event.pull_request.number }}/head:pr_branch | ||
| npx commitlint --from ${{ github.event.pull_request.base.sha }} --to pr_branch --verbose | ||
| # Removed unsafe checkout and validation of untrusted PR branch. | ||
| # To safely lint PR commits, run this workflow from a 'pull_request' trigger and only on trusted refs. | ||
| # If needed, use artifacts to communicate results to privileged workflows. | ||
| # See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request for safe patterns. |
Copilot is powered by AI and may make mistakes. Always verify output.
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup uv | ||
| uses: astral-sh/setup-uv@v5 |
Check warning
Code scanning / CodeQL
Unpinned tag for a non-immutable Action in workflow Medium
cristipufu
reviewed
Jul 21, 2025
cristipufu
approved these changes
Jul 21, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Development Package