System Configuration
Where the Safeguard CLI keeps its configuration, and the commands that change it
System Configuration
The CLI keeps three separate kinds of local state. Most machines only ever
need the first one, and /login creates it for you.
| What | Where | Changed with |
|---|---|---|
| Sign-in token | ~/.scanner/token.json | safeguard login, safeguard logout, /login |
| Deployment config (tenant, client, servers) | ~/.cli/config.json | safeguard init, safeguard config |
| Assistant and terminal settings | settings.json files, see below | editing the file |
Logs go to ~/.sg/logs/safeguard.log. Set LOG_DIR to write them somewhere
else.
Deployment config
A cloud user signed in with /login does not need this. It exists for
on-premise and managed deployments where the machine has to be pointed at a
specific tenant and auth server.
Initialize
Use the configuration file downloaded from your organization's settings page:
safeguard init --config-file ./safeguard-config.jsonOr pass the values directly. --tenant, --client-id and --auth-server are
required:
safeguard init \
--tenant <tenant-id> \
--client-id <client-id> \
--auth-server https://api.safeguard.sh/auth \
--api-server https://api.safeguard.shOther flags: --org-id, --org-name, --client-secret and --env
(dev, staging or prod, default prod).
View, change, reset
# Print the current deployment config
safeguard config show
# Change one value
safeguard config set api_server https://safeguard.example.internal
# Delete this machine's deployment and auth configuration
safeguard config resetconfig set accepts these keys and rejects anything else: tenant_id,
client_id, auth_server, api_server, org_name, environment.
config show exits non-zero when no configuration exists yet, so a script can
tell "not configured" apart from "configured".
Cloud or on-premise
safeguard mode # show the current mode and where it came from
safeguard mode cloud # switch to cloud
safeguard mode onprem # switch to on-premiseAssistant and terminal settings
The interactive terminal and the assistant (safeguard agent,
safeguard exec) read settings.json from up to three places. Higher in the
list wins:
- Command-line flags
<workspace>/.safeguard/settings.local.json, your own overrides, kept out of git<workspace>/.safeguard/settings.json, shared with the repository~/.safeguard/settings.json, your user settings- Built-in defaults
A repository's own settings apply only after you run safeguard trust in it,
and they can never set sign-in, provider or server URLs. Those stay in the
deployment config.
To turn off the background update check from settings:
{ "update": { "check": false } }Credential storage
The sign-in token is a file readable only by you (mode 0600) by default.
SAFEGUARD_CREDENTIAL_STORE selects where it is kept:
| Value | Store |
|---|---|
file (default) | ~/.scanner/token.json |
native | The operating system's credential store: macOS Keychain, the Linux Secret Service, or Windows DPAPI |
auto | The native store when one is available, otherwise the file |
Scanner tools
Scans run syft, grype and trivy. The interactive terminal downloads them the
first time it runs, into tools/<os> next to the binary. safeguard scan
looks for them in TOOLS_DIR first, then next to the binary, then on your
PATH. safeguard update refreshes their vulnerability databases, and
safeguard update --scanner grype --import <archive> loads a database you
downloaded by hand, for a machine with no internet access.
Environment variables
| Variable | Effect |
|---|---|
LOG_DIR | Where safeguard.log is written |
TOOLS_DIR | Where to look for the scanner binaries |
SAFEGUARD_CREDENTIAL_STORE | file, native or auto, see above |
SAFEGUARD_NO_UPDATE_CHECK=1 | Skip the background check for a new release |
SAFEGUARD_DISABLE_SELF_UPDATE=1 | Turn off binary updates entirely |
SAFEGUARD_NO_BROWSER | The interactive terminal does not open a browser for /login |
There is no API-key variable and no variable that points the CLI at a config
file. Sign in with /login or safeguard login instead.