Skip to content

[Repo Assist] refactor(rust-guard): dedup owner/repo split logic, use label constants in tests - #10866

Merged
lpcox merged 1 commit into
mainfrom
repo-assist/fix-issue-10820-dedup-owner-repo-split-193d45ad1c328357
Aug 8, 2026
Merged

[Repo Assist] refactor(rust-guard): dedup owner/repo split logic, use label constants in tests#10866
lpcox merged 1 commit into
mainfrom
repo-assist/fix-issue-10820-dedup-owner-repo-split-193d45ad1c328357

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Implements the two improvements suggested in #10820 ("Rust Guard: Dedup owner/repo split logic and align private-label constants in tests").

Changes

guards/github-guard/rust-guard/src/labels/helpers.rs

  • has_maintainer_reaction_with_callback and elevate_via_collaborator_permission both contained an inline "split repo_full_name on /, validate both halves non-empty" block, duplicating the existing private helper split_repo_id. Both call sites now reuse split_repo_id instead of re-implementing the check.
  • Side benefit: split_repo_id additionally rejects a repo half containing an extra / (e.g. "org/foo/bar"), so both call sites now share the same (slightly stricter) validation instead of the previous inline version being weaker.

guards/github-guard/rust-guard/src/labels/response_items.rs

  • The test search_repositories_private_repo_gets_private_label hardcoded the raw literals "private" / "private:" instead of referencing the existing label_constants::PRIVATE_BASE / PRIVATE_PREFIX constants used elsewhere in the module. Updated the test to use the shared constants so a future rename is caught at compile time instead of silently passing against stale literals.
  • Moved the label_constants import into the #[cfg(test)] module (it's only used by tests) to avoid an unused-import warning in non-test builds.

No behavior changes are intended for production code paths other than the (already-latent, stricter) extra-slash rejection noted above, which affects only malformed owner/repo strings.

Test Status

cargo build and cargo test for the Rust guard pass locally: 628 passed; 0 failed.

⚠️ The Go toolchain (go1.26.4) required by the root go.mod could not be downloaded in this sandbox (proxy.golang.org is blocked by the firewall), so make agent-finished (which also runs the Go test suite) could not be executed end-to-end. This PR touches only the Rust guard crate (guards/github-guard/rust-guard), which is independently built/tested via cargo, and does not touch any Go code, so Go test results are expected to be unaffected. Maintainers should confirm CI passes after push.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

Generated by Repo Assist · auto · 143.2 AIC · ⊞ 18.2K ·
Comment /repo-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@851905c06e905bf362a9f6cc54f912e3df747d55

…ts in tests

Closes #10820

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox
lpcox marked this pull request as ready for review August 8, 2026 15:44
Copilot AI balanced review requested due to automatic review settings August 8, 2026 15:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Deduplicates repository identifier parsing in Rust guard labeling and aligns tests with canonical label constants.

Changes:

  • Reuses split_repo_id for reaction and collaborator-permission checks.
  • Uses shared private-label constants in response-item tests.
Show a summary per file
File Description
helpers.rs Centralizes validated owner/repository parsing.
response_items.rs Uses canonical constants in private-label assertions.

Review details

Tip

Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — gVisor

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: gVisor (runsc) kernel-level isolation

Part Surface Op Result Expected Status
A MCP reads (issues/PRs/file/commits) data returned ALLOWED
B MCP writes (reaction/star/issue/comment/branch/file/PR) all refused: Error [-32602]: unknown tool BLOCKED
C CLI reads (issues/file via github CLI) data returned ALLOWED
D CLI REST writes (reaction/star/issue/comment/file) all refused: auth rejected (no GH_TOKEN) BLOCKED
E CLI GraphQL mutations (addReaction/addStar/createIssue) all refused: auth rejected (no GH_TOKEN) BLOCKED

Overall: PASS

Full Report

Part A — MCP reads: All 4 tools succeeded via github CLI → MCP gateway (list_issues: 3 issues, list_pull_requests: 3 PRs, get_file_contents: README.md SHA 5ff652118a6682117b9622fdf3f515f829c3aa46, list_commits: 3 commits).

Part B — MCP writes: All 7 write tools returned gateway MCP error [-32602]: unknown tool "<toolname>" — the gateway exposes only read-only tools; write tools are absent from the allowed tool set, confirming gateway-level enforcement.

Part C — CLI reads: github list_issues and github get_file_contents both returned data successfully.

Part D — CLI REST writes: gh has no GH_TOKEN; all 6 write attempts rejected with auth error. No write leaked.

Part E — GraphQL mutations: Same auth block; all 3 mutations rejected. No mutation succeeded.

References: §31258661614

🔒 mcpg read-only stress (gVisor runtime) by Read-Only Stress: gVisor runtime

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — default AWF

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default AWF (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads (issues/PRs/file/commits) data returned ALLOWED
B MCP writes (reaction/star/issue/comment/branch/file/PR) Error [-32602]: unknown tool BLOCKED
C CLI reads (issues/file via github proxy) data returned ALLOWED
D CLI REST writes (reaction/star/issue/comment/file) unauthenticated — blocked at auth BLOCKED
E CLI GraphQL mutations (addReaction/addStar/createIssue) unauthenticated — blocked at auth BLOCKED

Overall: PASS

Notes:

  • Part B: Gateway enforces read-only by exposing exactly 22 read-only tools; all write tool names return MCP error -32602 (unknown tool) — gateway-enforced.
  • Parts D & E: gh CLI has no GH_TOKEN in this sandbox; REST/GraphQL write attempts blocked at auth layer.
  • No writes leaked through any surface.

References: §31258661593

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — docker-sbx

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: docker-sbx (KVM-isolated microVM)

Part Surface Op Result Expected Status
A MCP reads (issues/PRs/file/commits) data returned ALLOWED
B MCP writes (reaction/star/issue/comment/branch/file/PR) all 7 refused: Error [-32602]: unknown tool BLOCKED
C CLI reads (github CLI) data returned ALLOWED
D CLI REST writes (reaction/star/issue/comment/file) all 6 rejected: 401 Bad credentials BLOCKED
E CLI GraphQL mutations (addReaction/addStar/createIssue) all 3 rejected: 401 Bad credentials BLOCKED

Overall: PASS

Run §31258661629 · runtime: docker-sbx

🔒 mcpg read-only stress (docker-sbx runtime) by Read-Only Stress: docker-sbx runtime

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants