Safeguard Docs
Safeguard CLI

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.

WhatWhereChanged with
Sign-in token~/.scanner/token.jsonsafeguard login, safeguard logout, /login
Deployment config (tenant, client, servers)~/.cli/config.jsonsafeguard init, safeguard config
Assistant and terminal settingssettings.json files, see belowediting 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.json

Or 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.sh

Other 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 reset

config 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-premise

Assistant 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:

  1. Command-line flags
  2. <workspace>/.safeguard/settings.local.json, your own overrides, kept out of git
  3. <workspace>/.safeguard/settings.json, shared with the repository
  4. ~/.safeguard/settings.json, your user settings
  5. 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:

ValueStore
file (default)~/.scanner/token.json
nativeThe operating system's credential store: macOS Keychain, the Linux Secret Service, or Windows DPAPI
autoThe 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

VariableEffect
LOG_DIRWhere safeguard.log is written
TOOLS_DIRWhere to look for the scanner binaries
SAFEGUARD_CREDENTIAL_STOREfile, native or auto, see above
SAFEGUARD_NO_UPDATE_CHECK=1Skip the background check for a new release
SAFEGUARD_DISABLE_SELF_UPDATE=1Turn off binary updates entirely
SAFEGUARD_NO_BROWSERThe 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.

Next Steps

On this page