Skip to content

Gate extended PR validation dispatch - #601

Open
Akshay Sonawane (apsonawane) wants to merge 3 commits into
mainfrom
fix/gate-extended-pr-validation
Open

Akshay Sonawane (apsonawane) wants to merge 3 commits into
mainfrom
fix/gate-extended-pr-validation

Conversation

@apsonawane

Copy link
Copy Markdown

This pull request updates the extended-pr-validation.yml workflow to improve security and validation checks for pull request events. The main changes are focused on tightening permissions, refining the workflow trigger conditions, and ensuring the correctness of the referenced commit.

Workflow trigger and permissions improvements:

  • The workflow now only triggers on pull_request_target events if the pull request is not a draft and originates from the same repository, reducing the risk of running untrusted code from forks.
  • The id-token: write permission is moved to the job level, ensuring it's only granted when necessary and not globally.

Validation enhancements:

  • Added a step to resolve the actual commit SHA for the source ref and verify that it matches the provided commit, preventing mismatches and potential errors in downstream steps. If the ref does not exist or the commit does not match, the workflow fails early with a clear error message.
  • The output for source_commit is now set to the resolved commit SHA, ensuring downstream jobs use the correct commit.

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.

🟡 Changes recommended

Ref resolution can select the wrong branch or return an annotated tag’s object SHA instead of its commit SHA, causing incorrect expected-commit validation or forwarding an invalid downstream commit ID.

1 open issue
What changed in this PR

Hardens the workflow that dispatches extended PR validation to the private pipeline, tightening automatic execution and checking manually selected revisions.

Changes:

  • Limits automatic dispatch to non-draft PRs from the same repository while retaining manual dispatch.
  • Scopes id-token: write permission to the dispatch job.
  • Adds remote-ref resolution and commit comparison before forwarding the resolved SHA.
File Description
.github/​workflows/​extended-pr-validation.yml Updates dispatch conditions, job permissions, and manual revision validation.

Review effort: Max

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.

🟡 Changes recommended

The workflow rejects previously supported same-repository PR refs and can dispatch blob or tree IDs as source commits without verifying that they resolve to commits.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity Verify selected refs resolve to commits before dispatch

.github/​workflows/​extended-pr-validation.yml:106

git ls-remote can return a blob or tree ID for a lightweight or annotated tag, which this code then dispatches as source_commit. Fetch the selected ref and verify that it resolves with ^{commit} so invalid revisions fail before reaching the private pipeline.

1 resolved since last review

Review effort: Max

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants