Documentation
¶
Overview ¶
Package paths owns the single source of truth for "where does the agent put its files." It resolves a base directory (the install dir) from a layered set of sources so callers can stop deriving ~/.stepsecurity independently:
- --install-dir CLI flag (set by main via SetOverride / SetDisabled)
- install_dir config field (loaded by internal/config)
- $STEPSECURITY_HOME environment variable (fallback only)
- ~/.stepsecurity (legacy default)
Why config beats env: the install_dir field in config.json is the canonical source of truth — the loader scripts (agent-api) write to it on every run, and operators can hand-edit it. Service installers (launchd / systemd / schtasks) bake STEPSECURITY_HOME into their unit files at install time, but that snapshot becomes stale the moment the operator edits config.json. Letting config win means scheduler- invoked runs immediately reflect a config change without requiring the operator to re-run `install`. The env var stays as a defensive fallback for the rare case where config.json is unreadable.
config.json itself stays at the legacy location regardless — see internal/config.LegacyDir — so the agent can always bootstrap. All other files (logs, hook errors, the binary placed by the loader) live under Home().
Index ¶
Constants ¶
const HomeEnvVar = "STEPSECURITY_HOME"
HomeEnvVar is the environment variable consulted as a defensive fallback when both the CLI override and config.InstallDir are unset. Service installers bake this into their unit files but its precedence is intentionally below config so that an edited install_dir wins.
Variables ¶
This section is empty.
Functions ¶
func HeartbeatFile ¶ added in v1.13.0
func HeartbeatFile() string
HeartbeatFile returns the absolute path to last-run.json, or "" when Home() is disabled. Callers must treat "" as "heartbeat unavailable" and skip writing it (same contract as ScanStateFile). Besides the start-of-run breadcrumb, this file also holds the run gate's offline cache (see heartbeat.RunGate / internal/rungate) — one file for the same "last run" data rather than a separate run-gate-state.json.
func Home ¶
func Home() string
Home returns the resolved install dir. Falls back to LegacyHome when nothing else is set. Returns "" when SetDisabled() was called or when the home directory itself cannot be resolved. A leading $HOME or ~ token in any source is expanded via expandHome so the returned path is canonical for the current OS; the result is run through filepath.Clean so trailing slashes and "." / ".." components don't cause spurious mismatches in the migration-warning equality check.
func LegacyHome ¶
func LegacyHome() string
LegacyHome returns ~/.stepsecurity. Exposed for the migration check in main and for ShowConfigure displays. Mirrors config.LegacyDir but kept here so callers can grab the legacy path without taking a package dependency on config.
func ScanStateFile ¶ added in v1.13.0
func ScanStateFile() string
ScanStateFile returns the absolute path to scan-state.json, or "" when Home() is disabled. Callers must treat "" as "state tracking unavailable".
func SetDisabled ¶ added in v1.11.4
func SetDisabled()
SetDisabled marks the install dir as explicitly disabled for this run. After this call Home() returns "" regardless of env/config/ legacy values, so no on-disk artifact is written under the resolved install dir. Used by main when the operator passes --install-dir= (empty) to silence per-run file logging.
func SetOverride ¶
func SetOverride(s string)
SetOverride installs the CLI-flag value. Called by main after cli.Parse and before any code that calls Home() — see cmd/stepsecurity-dev-machine-guard/main.go.
Types ¶
This section is empty.