hub/AGENTS.md
trvon 0d7a219c5d
Some checks failed
release / build (push) Failing after 2m13s
hub: operator CLI with signed self-update
2026-11-10 20:32:32 -07:00

3.1 KiB

AGENTS.md

hub is the operator CLI for a Security Hub fleet, in its own public repository. Go, standard library only. This file holds the map, the guardrails and the per-change checks; keep it lean.

Map

Path What
cmd/hub/ command registry and main (exit codes 0 ok, 1 drift/stale/update available, 2 config or refused, 3 transport)
internal/config ~/.config/security-hub/hub.json + environment; no default fleet address
internal/{fleet,inventory,probe,suggest,pillar} fleet API client, Ansible INI inventory, probe runner and profile contract, adoption suggestions, pillar rendering
internal/selfupdate hub self-update: signed-tag + sha256 verification, atomic replace; pinned fingerprints, embedded signers.asc
internal/version the one version source (Version, stamped by -ldflags)
internal/hygiene the public-repo guard: denylist scan of the whole tree
probe/ hostprobe.py (stdlib Python 3.8, read-only, runs on the target over stdin), its Go embed file, unit tests, fixtures/
docs/ cli.md, adopting-a-host.md, releasing.md
.forgejo/workflows/release.yml, scripts/release.sh CI test lane and tag release lane; tag cutting

Guardrails

  • Public repository: no real site data. No real IPs, hostnames, usernames, domains, tokens or inventory anywhere, including fixtures and docs. Use 192.0.2.0/24, 198.51.100.0/24, 100.64.0.x, example.org, hosts alpha/beta, user admin. internal/hygiene enforces it; do not weaken it to make a change pass.
  • Read-only by default: the fleet API is GET-only, hub profile only reads the host. hub never mutates a fleet.
  • Never print the fleet token. Tests never touch the network or real hosts (httptest, fake ssh on PATH); real gpg is used only for signature tests in a temporary GNUPGHOME and those skip when gpg is absent.
  • Self-update trust is fixed in source: pinned fingerprints and the embedded key are not configurable. Changing them is a reviewed change that also updates docs/releasing.md.
  • One version source: internal/version.Version. No literal release number in code or tests of the binary's own version.
  • Standard library only: go list -m all must stay at one line.
  • Never run git init/commit/push for the human, never sudo.

Per-change checks

Change touches Run
Go go vet ./... && go test -count=1 ./..., gofmt -l . empty, go list -m all | wc -l = 1
probe/hostprobe.py or fixtures python3 -m unittest discover -s probe -p "test_*.py"; regenerate expected-*.json from the probe, never edit by hand
self-update the whole internal/selfupdate suite with gpg installed (it skips without it)
build or release make hub-linux-amd64 hub-darwin-arm64 VERSION=9.9.9 then bin/hub-darwin-arm64 version; bash -n scripts/release.sh; parse the workflow YAML
anything go test ./internal/hygiene
a new test mutation-check it: break the guarded line, the test fails, restore

License: GPL-3.0-or-later; every Go and Python source file starts with an SPDX header.