[Repo Assist] fix(guard): add coverage for rebuild_codespace and update_codespace_port_visibility - #10533
Conversation
…ort_visibility Closes #10519 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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 visibilityupdates 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 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@copilot address review feedback |
…date_codespace_port_visibility
Done. Updated the endpoint annotations in both files:
Commit: fix(guard): correct endpoint annotations for rebuild_codespace and update_codespace_port_visibility |
🔒 mcpg Read-Only Stress — gVisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS Run: §30721774646
|
🔒 mcpg Read-Only Stress — default AWFSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS
References: §30721774640
|
🔒 mcpg Read-Only Stress — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS Run: §30721774643
|
🤖 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 rebuild→rebuild_codespace(recreates a codespace container)gh codespace ports visibility→update_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 inapply_tool_labels.Fix
rebuild_codespaceandupdate_codespace_port_visibilitytoWRITE_OPERATIONSintools.rs(kept alphabetically sorted, required forbinary_search).tool_rules.rs(apply_tool_labels), so they getsecrecy = private:userandintegrity = writer(user)just likecreate_codespace/update_codespace/delete_codespace/stop_codespace.test_cli_gap_operations_are_write_operations(tools.rs) andapply_tool_labels_codespace_lifecycle_is_user_private_write(tool_rules.rs) tests to cover the two new tool names.Trade-offs
publicport 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.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
Add this agentic workflow to your repo
To install this agentic workflow, run