Skip to content

chore: harden pull request check workflow#28

Open
wallyxjh wants to merge 1 commit into
labring:fix/v0.9.3from
wallyxjh:fix/pr-check-workflow-security
Open

chore: harden pull request check workflow#28
wallyxjh wants to merge 1 commit into
labring:fix/v0.9.3from
wallyxjh:fix/pr-check-workflow-security

Conversation

@wallyxjh

Copy link
Copy Markdown
Collaborator

Summary

  • remove the global PERSONAL_ACCESS_TOKEN from the pull request check workflow
  • drop checkout from the pull_request_target job so it does not execute repository scripts in a privileged context
  • limit workflow permissions to read-only PR/issue metadata
  • inline the branch-name and issue-link checks using environment variables for user-controlled PR data

Verification

  • ruby YAML parse for .github/workflows/pull-request-check.yml
  • bash -n for the inline workflow scripts
  • git diff --check

@wallyxjh wallyxjh force-pushed the fix/pr-check-workflow-security branch from 7517dcc to 9b199b9 Compare May 13, 2026 06:21
@dinoallo dinoallo requested a review from Copilot May 13, 2026 08:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Hardens the pull_request_target PR check workflow by removing privileged token usage and avoiding executing repository code in a privileged context.

Changes:

  • Replaces a third-party branch name action with an inline bash check using github.head_ref
  • Removes the PAT-based global token and scopes workflow permissions to read-only issue/PR metadata
  • Removes actions/checkout and inlines the issue-link check via GitHub CLI GraphQL API

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
permissions:
${{ github.repository_owner }} \
${{ github.event.pull_request.number }} \
"${{ github.event.pull_request.title }}"
if [[ "$PR_TITLE" == chore* || "$PR_TITLE" == docs* ]]; then
Comment on lines +66 to +82
closingIssuesReferences(first: 10) {
edges {
node {
title
number
}
}
}
}
}
}' \
--jq '.data.repository.pullRequest.closingIssuesReferences.edges'
)"

echo "Closing Issues References: $closing_issues_references"

if [[ "$closing_issues_references" == "[]" ]]; then

env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
permissions:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need add contents read permission?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants