feat(danger): classify gh like git — subcommands are network egress - #126
Merged
Conversation
gh was unrecognized and fell through to unknown (deny-by-default). Every real gh subcommand contacts the GitHub API, so it now sits in networkPrefixes with a subcommand-aware isNetworkEgress branch: pr/api/repo/auth/... -> network_egress (same class as git push/clone), meta invocations (--version/--help/help/completion/bare gh) stay safe. -R/--repo consumes its value token, parity with git -C.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
odek | 1b077fa | Commit Preview URL Branch Preview URL |
Jul 29 2026, 10:16 AM |
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.
Problem
The GitHub CLI (
gh) matched no prefix set in the danger classifier, so every invocation — includinggh pr vieworgh api— fell through tounknown(deny-by-default), whilegit's remote-contacting subcommands classify asnetwork_egress(prompt per policy).Changes
internal/danger/classifier.go—ghadded tonetworkPrefixes(also making it a recognized command viaisKnownCommandName), with a subcommand-awareisNetworkEgressbranch mirroring the git handling:gh pr,gh api,gh repo delete,gh auth login, …) →network_egress— the same classgit push/git cloneget.gh,--version,--help,help,completion) →safe.-R/--repoconsumes its separate value token so it isn't mistaken for the subcommand — parity with the documentedgit -Cregression.AGENTS.md— documented in the Security Architecture section.Test coverage
TestClassify_NetworkEgress_Gh: 9 egress cases (incl./usr/local/bin/ghbasename and-R/--repoforms) + 7 safe cases.go vetand the fullinternal/dangersuite pass.