fix: run required labels on pull_request_target#151
fix: run required labels on pull_request_target#151Kaiser-Wu wants to merge 1 commit intocoze-dev:mainfrom
Conversation
|
|
📝 WalkthroughWalkthroughUpdated the GitHub Actions workflow trigger in the required-labels configuration from Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/required-labels.yml:
- Line 5: The workflow currently uses the mutable tag
mheap/github-action-required-labels@v5; replace that mutable ref with a full
commit SHA to pin the action and mitigate supply-chain risk. Locate the step
that references mheap/github-action-required-labels@v5 and update the uses value
to mheap/github-action-required-labels@<full-commit-sha> (obtain the SHA from
the action repo’s commit history or the release you intend to pin), then commit
the change so the workflow references the immutable commit SHA instead of the v5
tag.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d8f0728c-af15-4ba1-bf15-aed75a753cb3
📒 Files selected for processing (1)
.github/workflows/required-labels.yml
| pull_request: | ||
| # Run on the base repository context so fork PRs can still post label reminders. | ||
| # This workflow does not check out or execute PR code; it only inspects PR metadata. | ||
| pull_request_target: |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify whether workflow actions are pinned to full commit SHAs.
# Expected: no matches after remediation.
rg -nP --type=yaml '^\s*-\s*uses:\s*[^@]+@(?!(?:[a-f0-9]{40})$).+' .github/workflowsRepository: coze-dev/coze-java
Length of output: 431
🏁 Script executed:
cat -n .github/workflows/required-labels.ymlRepository: coze-dev/coze-java
Length of output: 1035
Pin the action to a commit SHA to mitigate supply-chain risk.
This workflow uses pull_request_target with write permissions on line 5. The action at line 14 (mheap/github-action-required-labels@v5) is pinned to a mutable ref, which creates a supply-chain vulnerability. Pin to a full commit SHA instead.
Suggested fix
- - uses: mheap/github-action-required-labels@v5
+ - uses: mheap/github-action-required-labels@<full_commit_sha>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/required-labels.yml at line 5, The workflow currently uses
the mutable tag mheap/github-action-required-labels@v5; replace that mutable ref
with a full commit SHA to pin the action and mitigate supply-chain risk. Locate
the step that references mheap/github-action-required-labels@v5 and update the
uses value to mheap/github-action-required-labels@<full-commit-sha> (obtain the
SHA from the action repo’s commit history or the release you intend to pin),
then commit the change so the workflow references the immutable commit SHA
instead of the v5 tag.
What changed
pull_requesttopull_request_targetWhy
Fork-based PRs currently fail the
labelcheck withResource not accessible by integrationbecause the workflow tries to comment on the PR while running under the restrictedpull_requesttoken.This workflow only inspects PR metadata and does not check out or execute PR code, so
pull_request_targetis the appropriate trigger.Validation
ruby -e 'require "yaml"; YAML.load_file(".github/workflows/required-labels.yml"); puts "ok"'