Add use-pr-linker workflow to auto-link PRs to issues#331
Conversation
WalkthroughA new GitHub Actions workflow is added that triggers on pull request lifecycle events, declares explicit permissions for contents/issues/pull-requests, and delegates PR-to-issue linking to a reusable workflow by passing a workflow token via the ChangesPR-to-Issue Linking Workflow
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/use-pr-linker.yml:
- Line 14: Replace the floating reusable-workflow reference in the uses
statement (currently
"mosip/kattu/.github/workflows/link-pr-to-issue.yml@develop") with a fixed
commit SHA to avoid supply-chain risk; update the uses line to reference the
provided commit SHA "ab3a7a4bbbd97097acafbcafc11780be9c038766" while preserving
the existing secrets.ACTION_PAT input so the workflow behavior and token
forwarding (GH_TOKEN) remain unchanged.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 328a3323-d5da-4371-b13d-a2224ed1203b
📒 Files selected for processing (1)
.github/workflows/use-pr-linker.yml
15c93fa to
3c5ced9
Compare
Signed-off-by: Ivanmeneges <ivan.anil016@gmail.com>
3c5ced9 to
2e6ae19
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/use-pr-linker.yml:
- Around line 3-10: The workflow currently uses pull_request_target and exposes
the write-capable secret ACTION_PAT to PR events; restrict exposure by guarding
usage of ACTION_PAT and any steps that run with pull_request_target: either
switch the trigger to pull_request (safe default) or keep pull_request_target
but add a runtime guard that only sets/exports ACTION_PAT and runs the
authenticated/commenting steps when the PR originates from the same repo (e.g.
check github.event.pull_request.head.repo.owner == github.repository_owner or
github.event.pull_request.head.repo.fork == false) — locate references to
pull_request_target and the ACTION_PAT environment/secret and wrap the job/steps
that call the downstream workflow or perform comments/edits with this
conditional so forks cannot receive ACTION_PAT.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fa7f49a4-1b76-47b4-8419-67af27d94dc4
📒 Files selected for processing (1)
.github/workflows/use-pr-linker.yml
| on: | ||
| pull_request_target: | ||
| types: | ||
| - opened | ||
| - edited | ||
| - synchronize | ||
| - reopened | ||
| - closed |
There was a problem hiding this comment.
Guard pull_request_target before exposing ACTION_PAT.
This workflow forwards a write-capable secret on pull_request_target, which can run on fork-originated PR events. Since the called workflow performs authenticated write/delete issue-comment operations, this is a high-risk secret exposure path.
🔒 Minimal hardening diff
jobs:
call-linker:
+ if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
uses: mosip/kattu/.github/workflows/link-pr-to-issue.yml@develop
secrets:
ACTION_PAT: ${{ secrets.ACTION_PAT }}Also applies to: 20-21
🧰 Tools
🪛 zizmor (1.25.2)
[error] 3-10: use of fundamentally insecure workflow trigger (dangerous-triggers): pull_request_target is almost always used insecurely
(dangerous-triggers)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/use-pr-linker.yml around lines 3 - 10, The workflow
currently uses pull_request_target and exposes the write-capable secret
ACTION_PAT to PR events; restrict exposure by guarding usage of ACTION_PAT and
any steps that run with pull_request_target: either switch the trigger to
pull_request (safe default) or keep pull_request_target but add a runtime guard
that only sets/exports ACTION_PAT and runs the authenticated/commenting steps
when the PR originates from the same repo (e.g. check
github.event.pull_request.head.repo.owner == github.repository_owner or
github.event.pull_request.head.repo.fork == false) — locate references to
pull_request_target and the ACTION_PAT environment/secret and wrap the job/steps
that call the downstream workflow or perform comments/edits with this
conditional so forks cannot receive ACTION_PAT.
Adds use-pr-linker.yml workflow calling mosip/kattu link-pr-to-issue.yml@develop
Made with Cursor
Summary by CodeRabbit