Open
Conversation
…vate repos When GITHUB_WRITE_PRIVATE_ONLY=true (or --write-private-only flag), all write tool handlers are wrapped with a visibility guard that: - Checks repo.Private via Repositories.Get() before each write (no cache) - Fails closed on any API error (blocks the write) - Blocks create_repository if private!=true (param pre-flight, no API call) - Blocks fork_repository entirely (GitHub API can't guarantee private output) - Logs WARN on each blocked write for audit trail Architecture: decorator pattern in pkg/github/write_guard.go wraps ToolHandlerFunc at InitToolsetsWithConfig() time. Zero changes to toolsets.go or individual tool implementations. 19 write tools across 3 toolsets (repos, issues, pull_requests) are all covered. 13 new unit tests verify guard behavior.
Viper's AutomaticEnv() doesn't automatically replace hyphens with underscores when looking up env vars. Without an explicit BindEnv, the GITHUB_WRITE_PRIVATE_ONLY env var would not be recognized. This is the same gap that exists for --read-only (which also lacks a BindEnv), but since our feature name implies env var usage, we add the explicit binding.
- Test_WritePrivateOnlyGuard_GetClientFailure: verifies fail-closed behavior when getClient returns an error - TestWritePrivateOnlyGuardWiring: integration test verifying that writePrivateOnly=true wraps all write tools and that fork_repository is blocked. Tests the InitToolsetsWithConfig wiring path. Total: 15 tests covering all guard paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Restricts write operations to private repos when enabled. Env var:
GITHUB_WRITE_PRIVATE_ONLY, CLI:--write-private-only.Decorator wraps all 19 write tool handlers at registration time — no changes to individual tools.
create_repositoryrequiresprivate=true;fork_repositoryis blocked (can't guarantee visibility). Fails closed on any visibility check error.