hub/internal/fleet/hints.go
trvon c100f89cad
All checks were successful
release / build (push) Successful in 4m8s
hub edr: strawberry summary per host from /v1/edr
One block per host: version, status, rule age, feed state and finding counts,
then up to five findings. Exit 1 when rules are stale, status is not ok or a
high/critical finding is open. A 404 says the controller needs the update
(exit 3). edr_* hints in hub findings point here.
2026-11-14 13:20:20 -07:00

54 lines
2.7 KiB
Go

// SPDX-License-Identifier: GPL-3.0-or-later
package fleet
import "strings"
// flagHints is one short imperative line per known flag. Generic wording only.
var flagHints = map[string]string{
"security_updates_pending": "apply package updates (update playbook, human-run)",
"third_party_updates_pending": "apply package updates (update playbook, human-run)",
"updates_kept_back": "review held-back packages, then update (human-run)",
"auto_updates_not_enabled": "enable unattended security updates",
"disk_space_low": "find what grew: du / docker system df",
"disk_space_critical": "free space now: du / docker system df",
"edr_rules_stale": "check the rule feed timer (hub edr)",
"edr_daemon_down": "restart the EDR daemon, then check its log (hub edr)",
"edr_backend_degraded": "check the EDR backend and its log (hub edr)",
"edr_finding_high": "review the EDR finding on the host (hub edr)",
"edr_finding_critical": "review the EDR finding on the host now (hub edr)",
"ssh_root_login_not_disabled": "queue remediate-ssh-root-login-host",
"ssh_password_auth_enabled": "disable ssh password login (hardening action)",
"firewall_not_detected": "enable and verify the host firewall",
"fail2ban_missing_or_inactive": "install or start fail2ban",
"extra_uid0_accounts_present": "inspect accounts with uid 0 and remove extras",
"nopasswd_sudo_present": "review sudoers for NOPASSWD entries",
"backup_stale": "check the backup job (hub backups)",
"vulnerable_package_detected": "update the affected package",
"known_exploited_vulnerable_package": "update the affected package now",
"vulnerability_coverage_incomplete": "check the vulnerability scan coverage",
"tls_cert_expiring": "renew the certificate",
"collector_failed": "see the host report: a collector failed",
}
// flagHintPrefixes cover flag families that share a hint.
var flagHintPrefixes = []struct{ prefix, hint string }{
{"backup_failed:", "check the backup job (hub backups)"},
{"compose_", "check the compose services on the host (docker compose ps)"},
{"ctf_", "check the lab watcher on the host"},
{"ci_runner_", "check the CI runner service on the host"},
{"forgejo_", "check the Forgejo update timer and status"},
}
// FlagHint returns the next-step hint for a flag.
func FlagHint(flag string) string {
if h, ok := flagHints[flag]; ok {
return h
}
for _, p := range flagHintPrefixes {
if strings.HasPrefix(flag, p.prefix) {
return p.hint
}
}
return "see the host report"
}