Skip to content

feat(danger): classify gh like git — subcommands are network egress - #126

Merged
jkyberneees merged 1 commit into
mainfrom
feat/gh-network-classification
Jul 29, 2026
Merged

feat(danger): classify gh like git — subcommands are network egress#126
jkyberneees merged 1 commit into
mainfrom
feat/gh-network-classification

Conversation

@jkyberneees

Copy link
Copy Markdown
Contributor

Problem

The GitHub CLI (gh) matched no prefix set in the danger classifier, so every invocation — including gh pr view or gh api — fell through to unknown (deny-by-default), while git's remote-contacting subcommands classify as network_egress (prompt per policy).

Changes

  • internal/danger/classifier.gogh added to networkPrefixes (also making it a recognized command via isKnownCommandName), with a subcommand-aware isNetworkEgress branch mirroring the git handling:
    • Real subcommands (gh pr, gh api, gh repo delete, gh auth login, …) → network_egress — the same class git push/git clone get.
    • Meta invocations (bare gh, --version, --help, help, completion) → safe.
    • -R/--repo consumes its separate value token so it isn't mistaken for the subcommand — parity with the documented git -C regression.
  • AGENTS.md — documented in the Security Architecture section.

Test coverage

TestClassify_NetworkEgress_Gh: 9 egress cases (incl. /usr/local/bin/gh basename and -R/--repo forms) + 7 safe cases. go vet and the full internal/danger suite pass.

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.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

@jkyberneees
jkyberneees merged commit ba5ce2c into main Jul 29, 2026
10 checks passed
@jkyberneees
jkyberneees deleted the feat/gh-network-classification branch July 29, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant