Skip to content

Validate mirrored source changes in pull requests - #6160

Open
max-charlamb wants to merge 1 commit into
dotnet:mainfrom
max-charlamb:dev/max-charlamb/validate-mirrors
Open

max-charlamb wants to merge 1 commit into
dotnet:mainfrom
max-charlamb:dev/max-charlamb/validate-mirrors

Conversation

@max-charlamb

Copy link
Copy Markdown
Member

Summary

  • Add a Validate mirrored sources PR check using GitHub's official actions/github-script action, pinned to a commit.
  • Keep allowed branches, mirrored directories, and commit-marker files in explicit lists at the top of the script.
  • Allow the automation/sync-cdac and automation/sync-dbi branches only when they belong to the same repository; a fork cannot bypass validation by reusing those names.
  • Reject other PRs that modify either mirror or its commit marker, including renames out of protected paths. Fail if the changed-file response is incomplete.
  • No checkout, runtime download, GitHub App token, or additional secrets are required. The sync branches are trusted; this does not verify snapshot contents against runtime.

Validation

  • Exercised 20 policy cases covering branch exceptions, fork spoofing, protected paths, metadata, renames, incomplete responses, and API errors.
  • Checked 312 branch/path/rename combinations after refactoring to explicit lists; behavior matches the previous policy.

Repository configuration

After merging, make Validate mirrored sources a required status check in the ruleset for main. This PR only adds the workflow and does not change repository settings.

Allow mirror updates from the same-repository automation/sync-cdac and automation/sync-dbi branches. Reject mirrored source and commit-marker edits from other PRs using the official GitHub Script action, without checking out either repository.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6155adde-0566-4a88-8914-7e11146c2997
@max-charlamb
max-charlamb requested a review from hoyosjs October 27, 2026 14:56
name: Validate mirrored sources

on:
pull_request:

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.

Can we run this metadata-only validator with pull_request_target, keeping the read-only permissions and no-checkout design? With pull_request, a PR can change both a mirrored file and this validator to make the required check pass. We should also add code ownership for /.github/workflows/ and /.github/CODEOWNERS, and require code-owner approval in the main ruleset. That protects changes to the enforcement logic itself.

name: Validate mirrored sources

on:
pull_request:

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.

Please include edited alongside opened, synchronize, and reopened so retargeting an existing PR to main runs validation. Otherwise retargeting alone won't trigger it, potentially leaving the required check missing and blocking the PR until another push.

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