Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigFilePath() string
- func IsEnterpriseMode() bool
- func LegacyDir() string
- func Load()
- func NormalizeAPIEndpoint(s string) string
- func PersistMaxExecutionDuration(value string) error
- func RunConfigure() error
- func RunConfigureNonInteractive(opts NonInteractiveOptions) error
- func ShowConfigure()
- func WriteConfigFilePath() string
- type ConfigFile
- type NonInteractiveOptions
Constants ¶
const LegacyDirName = ".stepsecurity"
LegacyDirName is the basename of the per-user agent directory under $HOME. config.json always lives here so the agent can bootstrap; other files (logs, hook errors, the binary) may be relocated via the resolved install dir — see internal/paths.
Variables ¶
var ( CustomerID = "{{CUSTOMER_ID}}" APIEndpoint = "{{API_ENDPOINT}}" APIKey = "{{API_KEY}}" //#nosec G101 -- build-time placeholder substituted by the backend installer; the literal is not a real credential. ScanFrequencyHours = "{{SCAN_FREQUENCY_HOURS}}" SearchDirs []string EnableNPMScan *bool // nil=auto EnableBrewScan *bool // nil=auto EnablePythonScan *bool // nil=auto IncludeTCCProtected *bool // nil or false = skip macOS TCC-protected dirs (default); true = walk them. The scan as a whole runs in both cases; only reads inside the TCC-protected subtrees themselves (Documents, Mail, etc.) need the agent to have Full Disk Access (PPPC or manual grant) — without that, those walks return EACCES per entry while the rest of the scan completes normally. See docs/macos-tcc-permissions.md. ColorMode string // "" means auto OutputFormat string // "" means default (pretty) HTMLOutputFile string // "" means not set LogLevel string // "" means default (info); one of error/warn/info/debug InstallDir string // "" means default (~/.stepsecurity); non-empty makes the agent put all its files (logs, hook errors, future state) under this directory. Bootstrap config.json itself stays at the legacy location. Per-run opt-out is the CLI flag --install-dir=. Resolution: --install-dir flag > STEPSECURITY_HOME env > this field > default — see internal/paths. // UseLegacyPackageScan, when true, disables the scan-state delta-upload // optimization for npm and Python project scans — every run re-uploads // the full snapshot as in pre-1.13 agents. // // Defaults to true: the delta protocol is gated OFF until the agent-api // side ships. Set use_legacy_package_scan=false in config.json (or // STEPSEC_ENABLE_SCAN_STATE=1) to opt back in. STEPSEC_DISABLE_SCAN_STATE=1 // always forces legacy. UseLegacyPackageScan = true // UseLegacyNodeScan, when true, reverts Node.js package discovery to the // command-based path (`npm ls` / `yarn list` / `pnpm ls` / `bun pm ls`, // shipped as raw output for the backend to parse). Defaults to false: Node // packages are read from on-disk lockfiles (and node_modules as a fallback) // with no package-manager subprocess. Set use_legacy_node_scan=true in // config.json (or --legacy-node-scan) to opt back into the command path. // // Independent of UseLegacyPackageScan above (which gates the delta-upload // optimization, not the disk-vs-command source). UseLegacyNodeScan = false // UseLegacyPythonScan, when true, reverts Python package discovery to the // command-based path (`pip list` per venv and `pip3`/`conda`/`uv list` // for globals). Defaults to false: Python packages are read from on-disk // install metadata (*.dist-info/METADATA, *.egg-info/PKG-INFO) with no // package-manager subprocess. Set use_legacy_python_scan=true in // config.json (or --legacy-python-scan) to opt back into the pip path. UseLegacyPythonScan = false )
Default placeholders (replaced by backend for enterprise installation scripts).
var MaxExecutionDuration string
MaxExecutionDuration is the whole-process execution-watchdog limit (STEPSEC_MAX_EXECUTION_DURATION). Persisted into config.json at install time so scheduler-fired runs (launchd/systemd/schtasks) — which invoke the binary directly and never inherit the loader-exported env var — resolve the same value the loader configured. "" means fall back to the binary's built-in default (4h). Declared in its own var block (not the placeholder group above) because it carries no build-time {{...}} placeholder. See telemetry.ExecutionDeadline.
Functions ¶
func ConfigFilePath ¶
func ConfigFilePath() string
ConfigFilePath returns the path to the config file (read-preferred).
func IsEnterpriseMode ¶
func IsEnterpriseMode() bool
IsEnterpriseMode returns true if valid enterprise credentials are configured.
func LegacyDir ¶ added in v1.11.3
func LegacyDir() string
LegacyDir returns the per-user agent directory (~/.stepsecurity), used as the reference point for the install-dir migration warning in main: if the operator has moved the install dir but this directory still holds diagnostic files, the agent surfaces a heads-up. Returns "" when $HOME can't be resolved.
Distinct from ConfigFilePath / WriteConfigFilePath above: those follow the machine-vs-user resolution that lets MSI-deployed installs share config with a scheduled task running as a logged-in user. LegacyDir is always per-user, regardless of elevation.
func Load ¶
func Load()
Load reads the config file and applies values to the package-level variables. Values already set (not placeholders) are not overridden — build-time values take precedence.
func NormalizeAPIEndpoint ¶ added in v1.11.7
NormalizeAPIEndpoint strips trailing slashes and surrounding whitespace from an API endpoint URL. Every callsite in the agent composes URLs as fmt.Sprintf("%s/v1/...", APIEndpoint, ...) — a trailing slash on the configured value would compose to "//v1/..." and some gateways respond with 403/500 instead of normalizing. Normalising once at the config boundary keeps every consumer simple.
func PersistMaxExecutionDuration ¶ added in v1.11.7
PersistMaxExecutionDuration records the STEPSEC_MAX_EXECUTION_DURATION value the loader exported into config.json at install time. Scheduler-fired runs (launchd/systemd/schtasks) invoke the binary directly and never inherit the loader's exported env var, so without this they fall back to the built-in 4h default regardless of the loader's MAX_EXECUTION_DURATION_HOURS. Persisting it lets telemetry.ExecutionDeadline pick it up on every scheduled run. Read-modify-write so the loader-written customer_id/api_key/etc. survive. No-op when value is empty (a direct binary install with no loader-configured value keeps the built-in default).
func RunConfigure ¶
func RunConfigure() error
RunConfigure interactively prompts for config values and saves to the config file.
func RunConfigureNonInteractive ¶ added in v1.11.3
func RunConfigureNonInteractive(opts NonInteractiveOptions) error
RunConfigureNonInteractive applies the supplied options to the existing on-disk config and saves. Designed for MSI custom actions, CI, and any orchestrator that can't drive stdin prompts. Always writes to writeConfigDir() — so an MSI running as SYSTEM lands config under C:\ProgramData\StepSecurity where the scheduled task (running as the logged-in user) can read it.
func WriteConfigFilePath ¶ added in v1.11.3
func WriteConfigFilePath() string
WriteConfigFilePath returns the path config would be written to under the current process's privilege level. Surfaced so `configure show` / install messages can name the exact file the next save will touch.
Types ¶
type ConfigFile ¶
type ConfigFile struct {
CustomerID string `json:"customer_id,omitempty"`
APIEndpoint string `json:"api_endpoint,omitempty"`
APIKey string `json:"api_key,omitempty"`
ScanFrequencyHours string `json:"scan_frequency_hours,omitempty"`
SearchDirs []string `json:"search_dirs,omitempty"`
EnableNPMScan *bool `json:"enable_npm_scan,omitempty"`
EnableBrewScan *bool `json:"enable_brew_scan,omitempty"`
EnablePythonScan *bool `json:"enable_python_scan,omitempty"`
IncludeTCCProtected *bool `json:"include_tcc_protected,omitempty"`
ColorMode string `json:"color_mode,omitempty"`
OutputFormat string `json:"output_format,omitempty"`
HTMLOutputFile string `json:"html_output_file,omitempty"`
LogLevel string `json:"log_level,omitempty"`
InstallDir string `json:"install_dir,omitempty"`
MaxExecutionDuration string `json:"max_execution_duration,omitempty"`
UseLegacyPackageScan *bool `json:"use_legacy_package_scan,omitempty"`
UseLegacyNodeScan *bool `json:"use_legacy_node_scan,omitempty"`
UseLegacyPythonScan *bool `json:"use_legacy_python_scan,omitempty"`
}
ConfigFile is the JSON structure persisted to ~/.stepsecurity/config.json.
type NonInteractiveOptions ¶ added in v1.11.3
type NonInteractiveOptions struct {
FromFile string // path to a complete ConfigFile JSON; wins over inline values
CustomerID string // --customer-id
APIEndpoint string // --api-endpoint
APIKey string // --api-key (or DMG_API_KEY env)
ScanFrequency string // --scan-frequency (hours, as string)
SearchDirs []string // --search-dirs (re-used from scan flag; empty = unchanged)
}
NonInteractiveOptions captures every input the non-interactive configure path accepts. Populated by main.go from cli.Config plus the DMG_API_KEY env var fallback. Empty fields preserve the existing on-disk value (merge semantics — same as the interactive prompt's "press Enter to keep").
func (NonInteractiveOptions) HasAny ¶ added in v1.11.3
func (o NonInteractiveOptions) HasAny() bool
HasAny reports whether the caller supplied any inline value. Used by main.go to decide whether `configure` was invoked non-interactively even without the explicit --non-interactive flag (e.g. an MSI that only passes --from-file).