Skip to content

[no-ci] CI: stop trusting public read permission in restricted paths guard#2105

Merged
rwgk merged 5 commits into
NVIDIA:mainfrom
rwgk:restricted-paths-guard_do_not_trust_collaborator_read
May 19, 2026
Merged

[no-ci] CI: stop trusting public read permission in restricted paths guard#2105
rwgk merged 5 commits into
NVIDIA:mainfrom
rwgk:restricted-paths-guard_do_not_trust_collaborator_read

Conversation

@rwgk
Copy link
Copy Markdown
Contributor

@rwgk rwgk commented May 18, 2026

Reference: #2104

Summary

This PR fixes the restricted-paths guard trust check so public repository read permission is no longer treated as a collaborator/trust signal.

The guard now:

  • queries the live pull request API for author_association on restricted-path PRs
  • trusts live MEMBER and OWNER author associations
  • falls back to the collaborator permission API only when the live author association is not trusted
  • trusts collaborator permissions triage, write, maintain, and admin
  • treats collaborator permission read as untrusted, because public repositories can report read for any GitHub user

Background

Earlier versions of restricted-paths-guard.yml used github.event.pull_request.author_association from the workflow event payload. That value turned out to be stale or unreliable for some fork PRs, so PR #1930 switched the workflow to the collaborator permission API.

PR #2010 later expanded the trusted collaborator permissions to include read, after seeing a false positive for an internal/collaborator author whose permission was reported as read.

Issue #2104 captures the follow-up discovery: on a public repository, the collaborator permission API can return read for users who are not repository collaborators. For example, a first-time external contributor can get effective read access simply because the repository is public.

This PR keeps the useful part of the previous workaround, but tightens the trust model:

  • live author_association is queried from GET /repos/{owner}/{repo}/pulls/{pull_number} instead of using the event payload
  • read from GET /repos/{owner}/{repo}/collaborators/{username}/permission is no longer trusted

Testing via reverted temporary commits

  • 5ede772 — TEMPORARY: Switch to pull_request trigger for testing
  • 5226846 — TEMPORARY: Exclude write permission from trusted collaborators

rwgk added 2 commits May 18, 2026 15:14
…guard

Use the live pull request API for author association and treat collaborator read permission as untrusted because public repositories report read access for any GitHub user.
This commit is for testing the collaborator permission check and must be
reverted before merge:

1. Changes trigger from pull_request_target to pull_request so this
   branch's workflow definition runs instead of main's.

2. Adds a dummy change to cuda_bindings/pyproject.toml to trigger the
   restricted-paths detection.

REVERT THIS COMMIT BEFORE MERGE.

Made-with: Cursor
@rwgk rwgk added this to the cuda.bindings next milestone May 18, 2026
@rwgk rwgk self-assigned this May 18, 2026
@rwgk rwgk added bug Something isn't working P0 High priority - Must do! CI/CD CI/CD infrastructure labels May 18, 2026
@github-actions github-actions Bot added the cuda.bindings Everything related to the cuda.bindings module label May 18, 2026
rwgk added 3 commits May 18, 2026 15:31
This commit is for testing the label-and-comment path and must be reverted
before merge. It temporarily treats write access as untrusted so the current
PR will exercise Needs-Restricted-Paths-Review assignment again.
@rwgk rwgk requested review from kkraus14 and leofang May 18, 2026 22:39
Copy link
Copy Markdown
Member

@leofang leofang left a comment

Choose a reason for hiding this comment

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

Trust model tightening looks correct and well-reasoned. Walked through the key edge cases (org MEMBER with read-only perm, outside COLLABORATOR with write, FIRST_TIME_CONTRIBUTOR) — all handled properly by the two-tier check. One minor inline note, otherwise LGTM.

Comment thread .github/workflows/restricted-paths-guard.yml
@rwgk
Copy link
Copy Markdown
Contributor Author

rwgk commented May 19, 2026

Thanks @leofang!

@rwgk rwgk merged commit 42eecda into NVIDIA:main May 19, 2026
20 checks passed
@rwgk rwgk deleted the restricted-paths-guard_do_not_trust_collaborator_read branch May 19, 2026 22:01
@rwgk
Copy link
Copy Markdown
Contributor Author

rwgk commented May 19, 2026

Tested via this dummy PR:

The workflow worked as intended:

Copy-pasting the Summary view:


Restricted Paths Guard Completed

Author: rwgkunplugged

Author association: NONE

Collaborator permission: read

Touches restricted paths: true

Restricted paths: cuda_bindings/, cuda_python/

Trusted signals: (none)

Label action: added

Comment action: posted

Matched restricted paths:

cuda_bindings/pyproject.toml

Manual follow-up: No trusted signal was found, so Needs-Restricted-Paths-Review is required.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions
Copy link
Copy Markdown

Doc Preview CI
Preview removed because the pull request was closed or merged.

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

Labels

bug Something isn't working CI/CD CI/CD infrastructure cuda.bindings Everything related to the cuda.bindings module P0 High priority - Must do!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants