Skip to content

[Repo Assist] fix(guard): add coverage for rebuild_codespace and update_codespace_port_visibility - #10533

Merged
lpcox merged 2 commits into
mainfrom
repo-assist/fix-issue-10519-codespace-guard-coverage-008cf3bebd495bdb
Aug 2, 2026
Merged

[Repo Assist] fix(guard): add coverage for rebuild_codespace and update_codespace_port_visibility#10533
lpcox merged 2 commits into
mainfrom
repo-assist/fix-issue-10519-codespace-guard-coverage-008cf3bebd495bdb

Conversation

@github-actions

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

Copy link
Copy Markdown
Contributor

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

Closes #10519

Root cause

The automated Guard Coverage Checker identified two CLI-only mutating Codespaces operations that were not modeled in the guard's tool tables:

  • gh codespace rebuildrebuild_codespace (recreates a codespace container)
  • gh codespace ports visibilityupdate_codespace_port_visibility (changes forwarded port exposure, can make a service public)

Neither name existed in WRITE_OPERATIONS, so calls to these synthetic tool names would not be treated as writes by the guard, and they had no explicit DIFC label rule in apply_tool_labels.

Fix

  • Added rebuild_codespace and update_codespace_port_visibility to WRITE_OPERATIONS in tools.rs (kept alphabetically sorted, required for binary_search).
  • Added both names to the existing user-private Codespaces lifecycle arm in tool_rules.rs (apply_tool_labels), so they get secrecy = private:user and integrity = writer(user) just like create_codespace/update_codespace/delete_codespace/stop_codespace.
  • Extended the existing test_cli_gap_operations_are_write_operations (tools.rs) and apply_tool_labels_codespace_lifecycle_is_user_private_write (tool_rules.rs) tests to cover the two new tool names.

Trade-offs

  • As noted in the issue, whether transitions to public port visibility should be allowed at all is a policy question left for a follow-up; this PR only ensures the operation is guard-covered and correctly labeled as a private user-scoped write, consistent with the rest of the Codespaces lifecycle rule.

Test Status

  • cargo test (rust-guard): 615 passed, 0 failed (including the 2 tests extended for this change).
  • cargo clippy -- -D warnings: clean.
  • cargo fmt --check: no new formatting issues introduced by this change (pre-existing repo-wide fmt diffs unrelated to these files/edits were confirmed present before this change).

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 · 107.8 AIC · ⊞ 18.1K ·
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

…ort_visibility

Closes #10519

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

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

Adds guard coverage for two mutating GitHub Codespaces CLI operations.

Changes:

  • Classifies both operations as writes.
  • Applies private user-scoped secrecy and writer integrity labels.
  • Extends classification and labeling tests.
Show a summary per file
File Description
guards/github-guard/rust-guard/src/tools.rs Adds write classifications and tests.
guards/github-guard/rust-guard/src/labels/tool_rules.rs Adds DIFC rules and tests.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Suppressed comments (2)

guards/github-guard/rust-guard/src/tools.rs:102

  • This does not match the current CLI implementation: gh codespace ports visibility updates the Codespaces dev tunnel (get/delete/re-create tunnel port), rather than issuing a PUT to this GitHub REST path. Please identify the tunnel operation instead of documenting an incorrect endpoint.
    "update_codespace_port_visibility", // gh codespace ports visibility — PUT /user/codespaces/{codespace_name}/ports/{port}

guards/github-guard/rust-guard/src/labels/tool_rules.rs:891

  • The CLI implements this via Codespaces dev-tunnel port operations, not the stated GitHub REST PUT. Please correct the operation summary so future guard audits trace the right API surface.
        //   `gh codespace ports visibility` → PUT /user/codespaces/{codespace_name}/ports/{port}
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Balanced

"pin_issue", // gh issue pin
"projects_write",
"push_files",
"rebuild_codespace", // gh codespace rebuild — POST /user/codespaces/{codespace_name}/rebuild (recreates container)
// `gh codespace edit` → PATCH /user/codespaces/{codespace_name}
// `gh codespace delete` → DELETE /user/codespaces/{name} or /orgs/{org}/members/{user}/codespaces/{name}
// `gh codespace stop` → POST /user|/orgs/.../codespaces/.../stop
// `gh codespace rebuild` → POST /user/codespaces/{codespace_name}/rebuild
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@lpcox

lpcox commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

Copilot AI commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Done. Updated the endpoint annotations in both files:

  • tools.rs lines 80 and 102: replaced the false REST paths with Codespaces session RebuildContainer RPC and Codespaces session UpdatePortVisibility RPC respectively.
  • tool_rules.rs lines 890–891: updated the matching lines in the Codespaces lifecycle comment block to reflect the same session-RPC descriptions.

Commit: fix(guard): correct endpoint annotations for rebuild_codespace and update_codespace_port_visibility

Copilot AI requested a review from lpcox August 1, 2026 22:40
@github-actions

github-actions Bot commented Aug 2, 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 (list_issues/list_prs/get_file/list_commits) data returned ALLOWED
B MCP writes (reaction/star/issue/comment/branch/file/PR) Error [-32602]: unknown tool BLOCKED
C CLI reads (list_issues/get_file_contents) data returned ALLOWED
D CLI REST writes (reaction/star/issue/comment/file) gh: GH_TOKEN not set BLOCKED
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh: GH_TOKEN not set BLOCKED

Overall: PASS

Run: §30721774646

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

@github-actions

github-actions Bot commented Aug 2, 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 (list_issues, get_file_contents) data returned ALLOWED
D CLI REST writes (reaction/star/issue/comment/file) gh unauthenticated BLOCKED
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh unauthenticated BLOCKED

Overall: PASS

Part B refusals are gateway-enforced: the MCP gateway omits all write tools, returning MCP error -32602 (unknown tool) — a gateway-specific error.

References: §30721774640

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

@github-actions

github-actions Bot commented Aug 2, 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) unknown tool [-32602] refused BLOCKED
C CLI reads (issues/file) data returned ALLOWED
D CLI REST writes (reaction/star/issue/comment/file) gh unauthenticated (exit 4) BLOCKED
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh unauthenticated (exit 4) BLOCKED

Overall: PASS

Run: §30721774643

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

@lpcox
lpcox merged commit 6e01568 into main Aug 2, 2026
37 checks passed
@lpcox
lpcox deleted the repo-assist/fix-issue-10519-codespace-guard-coverage-008cf3bebd495bdb branch August 2, 2026 00:24
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.

[guard-coverage] Guard coverage gap: 2 operations from GitHub CLI not fully covered

3 participants