Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/repository-policy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Repository Policy

on:
pull_request_target:
# This gate reads changed-file metadata through GitHub's API and never checks
# out PR code. `pull_request` keeps the token read-only for external forks
# and permits release-please's GitHub App PRs to run without approval.
pull_request:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep the policy gate outside the untrusted merge ref

For an external PR that edits repository-policy.yml, the pull_request event executes the workflow definition from the PR's merge ref, so the contributor can remove the changed-file rejection or replace it with a successful step while still producing the required Repository Policy / gate check. This defeats the external control-plane protection enforced below; keep this enforcement in a trusted base-branch context such as pull_request_target, or use another policy mechanism that the PR cannot modify.

Useful? React with 👍 / 👎.

types: [opened, reopened, synchronize, ready_for_review]

permissions: {}
Expand Down
15 changes: 15 additions & 0 deletions packages/extended-data/tests/core/test_release_hygiene.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,21 @@ def test_automerge_workflow_uses_org_ci_token_without_checkout() -> None:
assert step.get("uses") != "actions/checkout"


def test_repository_policy_gate_uses_read_only_pr_context_without_checkout() -> None:
"""External control-plane checks must not need target-context credentials."""
policy_workflow = (WORKFLOW_ROOT / "repository-policy.yml").read_text(encoding="utf-8")
workflow = yaml.load(policy_workflow, Loader=yaml.BaseLoader)
policy_steps = workflow["jobs"]["gate"]["steps"]

assert "pull_request" in workflow["on"]
assert "pull_request_target" not in workflow["on"]
assert workflow["jobs"]["gate"]["permissions"] == {
"contents": "read",
"pull-requests": "read",
}
assert all(step.get("uses") != "actions/checkout" for step in policy_steps)


def test_dependabot_covers_workspace_package_directories() -> None:
"""Dependabot should check each uv workspace package, plus root workflow files."""
dependabot = yaml.safe_load(DEPENDABOT_CONFIG.read_text(encoding="utf-8"))
Expand Down