config

package
v1.18.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

View Source
var (
	DeviceID            string // Optional device identity override; empty uses the machine serial.
	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
	EnableRuntimeScan   *bool // nil=auto (on)
	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.
	// IncludeNetworkVolumes defaults the OTHER way from IncludeTCCProtected:
	// nil or true = walk macOS network volumes (default); false = skip them.
	// Container runtimes (OrbStack, Docker Desktop, Colima) expose the guest
	// filesystem as a network volume, so walking them is what inventories
	// packages inside dev containers — and what fires a one-time
	// SystemPolicyNetworkVolumes prompt on machines with no PPPC
	// pre-approval. Fleets that cannot pre-approve trade that coverage away
	// by setting this to false. See docs/macos-tcc-permissions.md.
	// On Linux and Windows nil means skip remote mounts (a dead server can
	// hang the walk); only an explicit true walks them.
	IncludeNetworkVolumes *bool
	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.

	// 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 the package upload protocol selected by backend run-config.
	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).

View Source
var (
	AutoUpdate          *bool
	UpdateMirrorURL     string
	UpdateLagBehind     int
	UpdateCooldownHours int
)

Windows self-update settings (internal/selfupdate), read from the machine config the SYSTEM updater trusts. AutoUpdate nil means the default (on for MSI installs); `configure --auto-update=false` (the MSI AUTOUPDATE=0 property) turns it off. The other three mirror the loader's update-policy knobs and optional HTTPS packages mirror.

View Source
var ErrConfigInvalid = errors.New("config file unreadable or corrupt")

ErrConfigInvalid marks a config.json that exists but can't be read or parsed.

View Source
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 LoadError added in v1.18.0

func LoadError() error

LoadError returns why the last Load ignored an existing config file, if it did. Load runs before the logger exists, so main reports it.

func NormalizeAPIEndpoint added in v1.11.7

func NormalizeAPIEndpoint(s string) string

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

func PersistMaxExecutionDuration(value string) error

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). Refuses (ErrConfigInvalid) rather than overwrite a config file it can't parse.

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 SetFileOverride added in v1.17.0

func SetFileOverride(path string)

SetFileOverride pins the config file path. Called before Load(), from a pre-scan of argv — Load() runs before flag parsing, and its already-set-wins semantics make a second Load() a no-op.

func ShowConfigure

func ShowConfigure()

ShowConfigure prints the current configuration to stdout.

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 {
	DeviceID              string   `json:"device_id,omitempty"`
	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"`
	EnableRuntimeScan     *bool    `json:"enable_runtime_scan,omitempty"`
	IncludeTCCProtected   *bool    `json:"include_tcc_protected,omitempty"`
	IncludeNetworkVolumes *bool    `json:"include_network_volumes,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"`
	UseLegacyNodeScan     *bool    `json:"use_legacy_node_scan,omitempty"`
	UseLegacyPythonScan   *bool    `json:"use_legacy_python_scan,omitempty"`
	AutoUpdate            *bool    `json:"auto_update,omitempty"`
	UpdateMirrorURL       string   `json:"update_mirror_url,omitempty"`
	UpdateLagBehind       int      `json:"update_lag_behind,omitempty"`
	UpdateCooldownHours   int      `json:"update_cooldown_hours,omitempty"`
	// contains filtered or unexported fields
}

ConfigFile is the JSON structure persisted to ~/.stepsecurity/config.json.

func (ConfigFile) MarshalJSON added in v1.18.0

func (c ConfigFile) MarshalJSON() ([]byte, error)

MarshalJSON writes the known fields plus any unknown keys read earlier.

func (*ConfigFile) UnmarshalJSON added in v1.18.0

func (c *ConfigFile) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes into c field by field: keys absent from data leave c's values as they are (configure --from-file relies on this to merge), and unknown keys are kept for MarshalJSON.

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)
	AutoUpdate    *bool    // --auto-update=true|false (nil = 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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL