# hub: operator CLI One static Go binary (standard library only) for the operator of a Security Hub fleet. It reads fleet status over the read-only fleet API and adds host adoption: probe, suggest, diff, plus `hub self-update`. It never changes the hub: the fleet API is GET-only, `hub profile` is a read-only probe over ssh. License: GPL-3.0-or-later. ## Install Download `hub---` and its `.sha256` from the release page, or build from source: ``` make hub-darwin-arm64 # the Mac; make hub-linux-amd64 for a Linux host; make hub for this machine cp bin/hub-darwin-arm64 ~/bin/hub hub version ``` Builds use `CGO_ENABLED=0 -trimpath`; `VERSION=x.y.z make hub` stamps the version (no `VERSION`: `hub version` prints `hub 0.0.0-dev+` when Go recorded the commit, else `hub 0.0.0-dev`). `bin/` is gitignored. Needs Go 1.27, no modules. `make test` runs `go vet`, `go test` and the Python probe tests. ## Self-update ``` hub self-update --check # current vs newest published release; exit 0 up to date, 1 update available hub self-update # verify and install the newest release hub self-update --version v0.1.0 # install that release (the only way to downgrade) ``` The forge defaults to the public release repository (`update_url` / `update_repo` in hub.json override it; https only, no token). Verification and replacement order is in `docs/releasing.md`. It needs the `gpg` CLI (`--check` does not). Exit codes: 0 ok, 1 update available (`--check`), 2 refused (bad signature, hash, version, downgrade, no gpg), 3 forge unreachable. Progress: on an interactive terminal `hub self-update` prints its steps (checking releases, verifying signature, downloading with bytes and percent, verifying sha256, replacing binary) and the fleet commands show a spinner after 400 ms on slow API calls. It goes to stderr only; stdout, `--json` output and exit codes are unchanged. Nothing is drawn when stderr is not a terminal, with `--json`, `HUB_NO_PROGRESS=1` or `TERM=dumb`. ## Config `~/.config/security-hub/hub.json` (optional; `HUB_CONFIG` picks another path): ```json {"fleet_url": "http://100.64.0.1:8092", "token_file": "~/.config/security-hub/fleet-token", "repo_path": "~/ops", "inventory": "~/ops/hosts", "managed_paths_file": "~/ops/managed-paths.txt"} ``` | Setting | Default | Env override | |---|---|---| | fleet_url | none: fleet commands fail with `set fleet_url` until it is configured | `SECURITY_HUB_FLEET_URL`, `--url` | | token_file | `~/.config/security-hub/fleet-token` (mode 0600) | `HUB_TOKEN_FILE`; `SECURITY_HUB_FLEET_TOKEN` holds the token itself | | repo_path | found by walking up from the current directory to a directory holding `hosts` and `salt-security-hub/` | `HUB_REPO` | | inventory | `/hosts` | `HUB_INVENTORY` | | managed_paths_file | none: the built-in list | `HUB_MANAGED_PATHS` | | update_url, update_repo | the public release repository | none | `repo_path` is the repository root (the directory with `hosts`, `local/`, `salt-security-hub/`). Profiles go to `/local/profiles/` (gitignored). The token is read from the environment or the file and is never printed. Exit codes: `0` ok, `1` drift / stale snapshot / rebuild or drift in `profile-diff`, `2` configuration (bad token, 401, unknown host, missing profile, bad arguments), `3` transport (unreachable, HTTP error, ssh failure). `--json` goes before the command (it is also accepted after it). ## Fleet commands ``` $ hub status # exit 1 when stale, the oldest intel feed is missing or older than 36h, or a feed is failing snapshot 2026-11-08T12:00:00Z age 30s alpha publish rc=0 60s failed24h=0 highstate 0/118 3600s server publish rc=0 90s failed24h=0 highstate 0/131 3600s intel oldest feed 4h0m (2026-11-08T08:00:00Z) $ hub status # a failing feed (server with per-feed refresh status) intel oldest feed 35h0m (2026-11-07T21:00:00Z) failing: ubuntu-noble x3 (refresh_failed:URLError) $ hub drift # repo module hashes vs deployed; exit 1 on any mismatch or stale snapshot match /srv/salt/_modules/security_hub_audit.py repo=0123456789ab live=0123456789ab $ hub jobs --host server --fun test.ping --limit 5 $ hub backups # backup jobs from /v1/backups; exit 1 when a job is failed, never_succeeded or overdue alpha ok last_success=2026-11-08T11:00:00Z age_h=1.0 max_age_h=26 pool/home -> backup/alpha/home rc=0 snapshot=2026-11-08T10:59:00Z alpha-files running last_success=2026-11-07T11:00:00Z age_h=25.0 max_age_h=26 progress pool/home 1/2 received=1.2 GiB previous ok finished 2026-11-07T11:00:00Z $ hub edr [--host H] # strawberry (EDR) per host from /v1/edr; exit 1 on stale rules, status not ok or a high/critical finding alpha strawberry 0.2.5 ok rules 23h feed ok findings 1 (1 low) low Example finding last_seen 2026-11-14T08:00:00Z $ hub findings [--host H] # ranked flags per host; exit 1 when any flag or stale host, 2 unknown host fleet-wide: third_party_updates_pending (w3) on 2 hosts -- apply package updates (update playbook, human-run) beta critical_priority score=23 ssh_root_login_not_disabled w4 open 2d4h queue remediate-ssh-root-login-host disk_space_low w2 open 3h12m find what grew: du / docker system df backup nightly failed reason=disk full actions: remediate-ssh-root-login-host (aq-0006 failed), security-harden-host gamma STALE last_report=2026-10-01T18:51:56Z $ hub host alpha [--since 7d] # one screen per host from /v1/telemetry, /v1/history, /v1/series; exit 1 on culprits, reboot > 2d, failed app update run $ hub trend [--metric score] [--since 7d] # one sparkline row per host from /v1/series $ hub --json status # the API envelope, sorted keys, indent 2 ``` `hub findings` joins `/v1/posture` (required), `/v1/alerts?state=open&limit=200`, `/v1/queue` and `/v1/backups`. Hosts are sorted by severity (critical_priority, high_priority, stale_audit, others), score descending, name. Flags are ranked by weight descending, then name (weights copied from the triage script; `backup_failed:` weighs 3, unknown flags 1). A flag present on every non-stale host (at least two hosts) is printed once as `fleet-wide:` and left out of the host blocks. `open` is the age of the open alert for that host and flag (`-` without one); the last column is a short next step. `actions:` lists the host's suggested actions except `security-audit-host` and `security-validate-host`, with the newest queue entry for that action and host as `(id status)`. Flagged backup jobs (failed, never_succeeded, overdue; not running) are listed under the host that reports them. A stale host prints `STALE last_report=` only. A 404 on alerts, queue or backups drops that part and adds one `note:` line; a 404 on posture exits 3. Exit codes: 0 no flag and no stale host, 1 otherwise, 2 config or unknown `--host`, 3 transport. `hub --json findings` prints the model with sorted-by-struct keys: `generated_at`, `fleet_wide` (`flag`, `weight`, `hosts`, `hint`), `hosts` (`host`, `severity`, `score`, `stale`, `last_report_at`, `flags` (`flag`, `weight`, `opened_at`, `open_seconds`, `hint`; the first two timing keys are omitted without an alert), `actions` (`action_id`, `queue` {`id`, `status`} when queued), `backups` (`job`, `state`, `overdue`, `reason`)), `notes`. `hub edr` prints one block per host with strawberry enabled: ` strawberry rules h feed findings ()`, then up to 5 ` last_seen <ts>` lines. `feed` is `stale` when the API reports `rules_stale` or a failed feed. Exit codes: 0 all hosts healthy (or section unavailable, or no host has edr), 1 any host with `rules_stale`, a status other than `ok`, or a high/critical finding in the lookback window, 3 transport (including HTTP 404 from an older controller: `/v1/edr` is missing). `--json` prints the API envelope. `edr_*` hints in `hub findings` point at `hub edr`. `hub host <host> [--since 7d]` prints, from the routes added by the fleet telemetry release: the running kernel; the reboot state (`no`, or `REQUIRED since <time> (<age>) by <packages>`); the blog application's installed and latest version with its last maintenance run (status, phase, time); pending update counts; vulnerability counts and, for each known-exploited finding, `<source> <installed> -> <fixed> <CVE> <advisory>`; the age of the last report; then `changes`, the newest 15 of these events from `/v1/history` for the host (kernel change, reboot required or cleared, application version change, maintenance run finished) in the window; then `trend`, a 24-character sparkline of `score`, `vuln_findings`, `vuln_kev` and `updates_apt_pending_count` with the last value. Sparklines draw one character per sample, or 24 averaged buckets of consecutive samples when there are more; fewer samples are padded on the left, a flat series is drawn at the lowest level. When the host's collector reports the kernel/module guard fields (`kernel_modules`, `reboot_outcome`), `hub host` adds a `boot` line after `kernel` and appends the last reboot decision to the `reboot` line; older collectors send neither and the lines are omitted. The `boot` line joins up to three parts with `; `: `next boot 7.2.15 ok`, `next boot 7.3.4 MISSING zfs` (the kernel the next boot will use lacks a DKMS module the running kernel has), or `next boot unknown, cannot confirm zfs` (the next boot kernel could not be determined while the running kernel has DKMS modules); `kernel held: zfs supports <=7.2, candidate 7.3` (the guard holds the kernel packages on purpose); `dpkg interrupted: <packages>` (packages left half-configured, unpacked, half-installed or awaiting triggers). A Debian `+debNN-arch` suffix is dropped from the kernel in this line. The `reboot` line gains `; last attempt <status> (<reason>) <time>`: `requested`, `deferred` (`load`, `unit`, `process` or `hold_file`) or `blocked` (for example `boot_kernel_missing_modules`, `dpkg_interrupted`, `kernel_facts_unreadable`). The new `findings` flags and weights: `boot_kernel_missing_modules` 4, `dpkg_interrupted` 4, `reboot_deferred_long` 2, `kernel_held_for_module` 1. `--since` takes `12h` or `7d` style values, before or after the host name. Exit codes: 1 when the host has known-exploited culprits, a reboot pending for more than 2 days, a last maintenance run that failed (status `failed` or a systemd failure result), missing modules for the next boot kernel, or an interrupted dpkg run; 0 otherwise; 2 for an unknown host, bad arguments, or a server without `/v1/telemetry`, `/v1/series` or `/v1/history` (`server does not provide /v1/telemetry (upgrade the fleet collector/API)`); 3 transport, or telemetry status not ok. A failure of the history or series requests (HTTP 503) keeps the rest and adds a `note:` line. `--json` prints `host`, `generated_at`, `since`, `telemetry` (the host object as served), `events`, `series` (points per metric), `attention` and `notes`. `hub trend` prints `<host> <sparkline> min <n> max <n> last <n>` per host for one metric (default `score`; one of the server's 13 names: score, flags_open, vuln_findings, vuln_fixable, vuln_high_urgency, vuln_kev, vuln_open_unrated, updates_apt_pending_count, updates_security_pending_count, updates_third_party_pending_count, updates_kept_back_count, reboot_required, intel_age_hours). Hosts come from `/v1/telemetry`; `intel_age_hours` is the one fleet-wide series (host `_fleet`). An unknown metric or bad `--since` is exit 2 without a request. Exit 0 otherwise. `hub status` ends with `intel oldest feed <age> (<time>)` from the `intel` member of `/v1/summary`; it prints `intel STALE ... older than 36h` or `intel MISSING` and exits 1 when the feed is older than 36 hours or the server reports no age (an older server has no `intel` member). When the `intel` member lists failing feeds (`failing`, `failing_detail`) the line ends with ` failing: <feed> x<consecutive failures> (<error label>), ...` and the exit code is 1 even for a fresh feed. A server without those fields behaves as before. Under a `known_exploited_vulnerable_package` flag `hub findings` prints up to 3 `culprit <source> <installed> -> <fixed> <CVE> <advisory>` lines from `/v1/telemetry` (one extra request, only when a non-stale host has that flag). If that request fails, the lines are left out, a `note: culprits: telemetry unavailable (...)` line is added, and the exit code is unchanged. `--json` adds `culprits` to the host. `backups` against an older controller (HTTP 404) prints that `/v1/backups` is missing and exits 3. `status` appends `accepted but silent: a, b` if the API returns a `silent_hosts` list (forward compatible; today it does not). `drift --repo-root DIR` overrides `<repo_path>/salt-security-hub`. ## Adopting a host ``` hub profile <host> # ssh BatchMode, probe on stdin, 90 s, 2 MiB; writes local/profiles/<host>-<UTC>.json and <host>-latest.json (0600) hub suggest <host> # from <host>-latest.json + inventory hub profile-diff <host> # two newest dated profiles ``` `hub profile` resolves `ansible_host`, `ansible_user` and `ansible_port` from the inventory (hosts without `ansible_host` use their name, so an ssh alias works), then runs `ssh -o BatchMode=yes -o ConnectTimeout=10 -p PORT USER@ADDR python3 -` with `probe/hostprobe.py` (embedded, byte for byte) on stdin. Address and user must be plain values (no leading `-`, no spaces). The profile is checked against schema 1 before anything is stored; a failed probe leaves no file. Contract: `docs/adopting-a-host.md`. `hub suggest` prints four parts (`--json` gives the same data): - GROUPS: apt/yum, `ci` (forgejo-runner unit), `protected_services` (Forgejo image), `managed_admin`; `ok` marks groups the host is already in. - PILLAR: `compose_projects` from containers with a compose project label (containers without one, such as `FORGEJO-ACTIONS-TASK-*`, are ignored). `services`: the service named like the project first, then alphabetical. `allowed_ports`: distinct non-loopback published host ports (IPv4 and IPv6 collapse), `[]` when a project publishes nothing, omitted with a comment above 16 ports (open lab). `forbid_root: true` when every compose container has a non-root user. `expected_nopasswd_users` is rendered for the per-host pillar file (`pillar/security_hub/<host>.sls`, dashes become underscores) when `sudo -n` works. Nothing is written; review and paste. - BLOCKERS: inventory address not on tailscale0, no `sudo -n`, sshd AllowUsers/AllowGroups set (or unreadable), salt-minion id differs from the inventory name, hostname differs from `syslog_hostname`. - CANDIDATES: hand-made scripts (path, owner:group, mode, sha256, unit) and units, non-loopback listening ports (consecutive ports collapsed), sshd `PasswordAuthentication yes` / `PermitRootLogin yes`, fail2ban missing or inactive, no active firewall, privileged containers, anything the probe could not read. Paths that Salt already installs are left out. They come from `managed_paths_file`: a text file with one absolute path per line (blank lines and `#` comments ignored; any other line, or a file without paths, is an error). Without that setting a built-in list of the paths a Security Hub rollout installs is used (`suggest.DefaultManagedPaths`); a configured file replaces it. `hub profile-diff` prints `REBUILD:` lines when the machine-id prefix or the host key set changed, then drift: containers, listening sockets, units, candidate hashes and a few sshd/sudo settings (`+` added, `-` removed, `~` changed). Exit 1 on a rebuild or any drift. ## Layout `cmd/hub` (command registry), `internal/{config,fleet,inventory,probe,suggest,pillar}`, `internal/{selfupdate,version}`, `probe/embed.go` (go:embed of `probe/hostprobe.py`, the single source of truth). New views add a route and a renderer to `internal/fleet` and one entry in `commands()`; transport, auth and exit codes are shared. Tests use httptest servers and a fake `ssh` first on `PATH`; no host or Forgejo is contacted.