Safeguard Docs
Credentials VaultProviders

Environment variables and files

Read a scan credential from an environment variable or a local file on the machine that runs the scan, for CI jobs and for secrets another agent writes to disk.

Environment variables and files

Two references read a value from the machine that runs the scan, with no PAM call:

ReferenceReads
env://NAMEThe environment variable NAME of the CLI or runner process. Not set is NOT_FOUND.
file:///absolute/pathThe file's content, with one trailing newline dropped. On Windows: file:///C:/safeguard/token.txt. A missing file is NOT_FOUND, an unreadable one FORBIDDEN.

Use them when something else already puts the secret on the machine: a CI system's masked variable, a Vault agent or CyberArk Credential Provider that writes a file, a Kubernetes secret mounted as a file.

# CI: the token comes from the CI system's secret store
safeguard scan --repo https://gitlab.example.internal/payments/api.git --git-token env://CI_GIT_TOKEN

# A file a local agent keeps current
safeguard scan --repo https://gitlab.example.internal/payments/api.git --git-token file:///run/secrets/git-token

Where they are allowed

  • On the CLI and the runner they are allowed unless the provider file sets allow_env: false or allow_file: false.
  • Safeguard's cloud scanner never reads them, because a scan must not read the scanner's own environment or files.
  • A vault entry cannot point at an env:// or file:// reference (a PAM entry holds a pam:// or vault:// reference). Use them directly in a CLI flag or scan option.

Hygiene

  • Keep such files readable only by the runner's account (chmod 600).
  • Values read this way are redacted from output and recorded in the audit trail like any other read (provider env or file, never the value).

On this page