Skip to content

Add the gh gateway for publishing audit findings (operator audits step 6a) - #4555

Open
evanchooly wants to merge 1 commit into
audits-documented-collectionsfrom
audits-gh-gateway
Open

evanchooly wants to merge 1 commit into
audits-documented-collectionsfrom
audits-gh-gateway

Conversation

@evanchooly

Copy link
Copy Markdown
Member

Step 6 of the operator audits (plan), part a. Stacked on #4554.

Problem

Step 6 publishes audit findings as GitHub issues, but there was no GitHub transport left. The legacy Java client is already gone. The plan calls for gh, wrapped so that ordinary tests never need the binary, credentials or network, and so that report-only runs can never write to GitHub. gh api has no dry run of its own, so that guarantee has to live in the wrapper.

Changes

  • GhGateway, over a fakeable ProcessExecutor:
    • How it runs gh: as argument arrays with an explicit --hostname and repository. Inherited GH_HOST, GH_REPO, GITHUB_TOKEN and the debug variables are removed from the child's environment, a chosen token goes in GH_TOKEN, and prompts, pagers and update notices are off. The wait and the captured output are both bounded.
    • Version check: gh must be in the tested range, 2.40 to 2.x.
    • Command policy: a REPORT_ONLY gateway never spawns a mutating command. A PUBLISH gateway may only create an issue or edit one in its target repository.
    • Reads: they paginate with --paginate --slurp and flatten the pages in Kotlin, since --slurp can't be combined with --jq. Pull requests are filtered out of the issues endpoint, and issues, labels and milestones are normalized. A milestone is identified by its number, not its global id.
    • Failures: they're classified (missing binary, unsupported version, authentication, permission, not found, rate limit, timeout, server error, invalid JSON). Reads retry rate limits, timeouts and server errors with bounded backoff. Creates are never replayed.
  • GhGatewayTest has 9 cases on recorded process results: pagination, PR filtering, milestone number versus id, the report-only refusal, stdin payloads, no create replay, backoff, failure classification, the version range and the child environment.
  • GhGatewaySandboxTest runs only with -Daudits.sandbox=OWNER/REPO. It reuses one marked issue across runs.

Decisions for review

  • The sandbox repository. As you approved, it's the private evanchooly/morphia-audits-sandbox, with an audit label and a sandbox milestone, and the tests reuse it. Two runs left exactly one issue, which the second run only edited.
  • The publisher logic comes next (6b): finding markers, the durable publication journal with possibly-created reconciliation, and metadata validation.

Review note

The independent local reviewer is at its weekly limit until Nov 26, and Codex and Copilot are out of quota, so I reviewed this myself.

GhGateway runs gh as argument arrays with an explicit host, repository
and environment. Report-only gateways never spawn a mutating command,
reads paginate and filter pull requests, and transient read failures are
retried while creates are never replayed. An opt-in test exercises it
against a designated disposable repository.

This branch has not been deployed

No deployments
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