Repository navigation
π fix: apply repository scope to GraphQL writes without restricting reads - #19072
Conversation
Resolve mutation targets from operation arguments and upstream node-to-repo mappings, and reuse the REST per-agent scope refusal. Preserve unrestricted queries and document fail-open scope attribution for unresolved IDs. Keep streaming responses bounded and publish lookup mappings before the final bytes reach clients. Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com> Hive-Run: hivecommons#19058 Hive-Plan: issue-19058/graphql-write-repo-scope Hive-Spec: issue-19058#acceptance-criteria Signed-off-by: mendezr <mendezr@users.noreply.github.com>
|
/ok-to-test |
|
@hivecommons-hive[bot]: Cannot trigger testing until a trusted user reviews the PR and leaves an DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
needs-human: Prow has not run this fork PR's presubmits. Its author is not one of Prow's trusted users, so the trigger plugin waits for A maintainer can comment |
|
@mendezr this PR is back in your court ( Failing checks:
Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path. Your relay could not take this as a |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
Signed-off-by: mendezr <mendezr@users.noreply.github.com>
1640e31
|
β¦ EOF Signed-off-by: mendezr <mendezr@users.noreply.github.com>
Use the existing test-scoped autonomy registration helper so these tests do not leak a global override into later GraphQL replay tests. Preserve the concurrent signed-off replay fixture fix. Signed-off-by: mendezr <mendezr@users.noreply.github.com>
|
Follow-up on the contributor nudge: it targets the older head 1640e31. The current head is 05edefa, after the GraphQL fixture/read-denial isolation and autonomy-override cleanup fixes. The current coverage check is passing; no current checks are failing (golangci-lint and the hive image build are still in progress, and tide is pending). GitHub reports this head mergeable, not DIRTY or BEHIND. No additional code change is indicated by the outstanding comments. Leaving the sensitive-path review/approval controls intact; this follow-up does not grant approval or attempt to bypass the Prow trust gate. π Hive Agent: |
There was a problem hiding this comment.
Style review at head 05edefa. Read the diff, issue #19058, and the existing GraphQL classifier in rules.go. No in-scope blocker; advisory notes only, all minor.
- Two GraphQL parsers now coexist.
graphql_repo_scope.goaddsgqlparser/v2plusparseScopedGraphQL, whilerules.gokeeps the hand-rolled scanner (graphQLIdentRe,isGitHubGraphQLMutation,skipGraphQLString) for mode, write-surface and auto-merge gating. The two can disagree on what counts as a mutation or which operation is selected. Consider a short comment ingraphQLAgentRepoScopeRefusalsaying the gqlparser path is scope-only and why it was not folded into the existing classifier. - Unreadable one-line key list. The
case "id", "repositoryId", ...list ingraphQLAgentRepoScopeRefusalis a single very long line. Hoist it to a package-levelvar graphQLTargetIDKeys = map[string]struct{}{...}, one key per line, so additions diff cleanly. - Redundant internal-caller check.
graphQLAgentRepoScopeRefusalalready returns early forinternalCallerName, but the call site ingithub_proxy_mitm.gorepeatsagentName != internalCallerNameafter the call. That is harmless but is a double guard with no comment, and the function runs first. Keep one guard (the function-internal one) and drop the call-site copy, or addagentName != internalCallerName &&before the call so parsing is skipped. - Cache eviction wording.
graphQLRepoCache.putwipes the whole map when it reachesgraphQLRepoCacheLimit. The doc comment says "bound", which is true, but "reset when full" would set maintainers' expectations correctly, since the docs describe evicted mappings.
NOTICE, the changelog fragment (security-19058-...md) and the docs are in the repo's usual shape. Out-of-scope: none that I could verify.
-- hive: agent=adjudicator-4 backend=claude model=claude-sonnet-5-5 claude=2.1.327
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from Docs-currency review at head 05edefa: the new security-model.md section, changelog fragment, NOTICE entry and rules.go comment are accurate. Two operator-facing pages still state the opposite of what this PR ships, and #19058 item 5 asks for docs to match.
Suggested fix for per-repo-agents.md: -- **Cover GraphQL writes whose target repo is only in the request body.** Repo
- attribution reads the request *path*, so `POST /graphql` is not matched β the
- same blind spot the pre-existing repo-scope filter has. Those mutations stay
- gated by ACMM mode.
+- **Guarantee GraphQL write scope.** GraphQL mutations whose target resolves from
+ arguments or cached node IDs are scope-checked like REST. Unresolved targets
+ (cold cache, unseen IDs) are fail-open and stay gated by ACMM mode only; see
+ [GraphQL repository scope](security-model.md#graphql-repository-scope).Similarly reword redteam.md's bullet to name the unresolved-ID residual gap and link the same section. Advisory (out of scope): design/authorization-decision-point.md:83 and its github_proxy_mitm.go line refs are stale. Findings not on a changed line
Review follow-ups: 2 open of 2 (below
|
|
Needs a decision, not a merge:
Head: verdict requires_human @05edefa, 66/66 checks green, DCO yes, soak 10m0s elapsed. How to release it:
Clear the cause and the hive re-evaluates on its next pass; the stage moves to |
|
/hive decision Accept that the GraphQL repository scope does not refuse a mutation whose target repository cannot be resolved (for example a cold-cache node id or an unsupported encoding): log it and pass it through, as the PR proposes, because refusing would break normal gh writes. Make sure that behavior and its limits are stated plainly in the security model. Apply the adjudicator's docs-currency findings: update src/docs/per-repo-agents.md (the lines saying GraphQL writes are not covered by the scope) and src/docs/redteam.md (the lines listing GraphQL writes as an uncovered area) so they match what this PR ships, keeping the residual gap described accurately. Keep the rest unchanged. |
clubanderson
left a comment
There was a problem hiding this comment.
Approving head 05edefa. The swarm's open question is decided: a mutation whose target repository cannot be resolved is logged and passed through rather than refused, because refusing would break normal gh writes, and the security model states the limit. The two docs-currency items (per-repo-agents.md and redteam.md) will be handled as a small follow-up so they do not hold this change. Thank you for the thorough work.
|
LGTM label has been added. DetailsGit tree hash: 7e3629f1e3c53edffc2682fc2509f43b5628ecd0 |
|
/lgtm |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: clubanderson The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Summary
Fixes #19058
Unresolved-target policy
Repository attribution is explicitly fail-open when unresolved, while existing mode, write-surface and auto-merge gates remain in force. Cold-cache ID-only
gh api graphqlcalls, unsupported response shapes/encodings and evicted mappings must not become blanket write denials. This is best-effort scope enforcement, not a complete boundary against deliberately unseen IDs; token repository permissions remain necessary. Repository pause and the hive-wide REST allowlist are unchanged.Validation
ghGraphQL lookup/write document flows: issue create/comment/edit/close and PR create/comment/edit/close/merge. Tests use fresh connections and gzip responses, asserting unrestricted reads, in-scope writes, REST-shaped out-of-scope refusals that never reach upstream, and cold-cache compatibility.gofmt -lon changed Go files: clean.AGENTS.md; CI is the test verdict. No claim of a local test pass.Implementation plan/spec references:
issue-19058/graphql-write-repo-scope;issue-19058#acceptance-criteria(no separate plan or Spektacular clause supplied).-- hive: backend=pi model=openai/gpt-6.1-sol
π Hive Agent:
contributor| SHA:02434bff3