Description
Validates that the container image does not contain sensitive data (passwords, tokens, keys). Scans both environment variables and files across all image layers for common secret patterns.Command Syntax
Flags
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--secrets-policy | -s | string | - | Secrets policy file (JSON or YAML) (optional) |
--skip-env-vars | - | bool | false | Skip environment variable checks (optional) |
--skip-files | - | bool | false | Skip file system checks (optional) |
--output | -o | string | text | Output format: text or json |
--log-level | - | string | info | Log level (trace, debug, info, warn, error, fatal, panic) |
How It Works
Environment Variable Scanning
Scans all environment variables for sensitive patterns using case-insensitive keyword matching. Default patterns include:passwordpasswdsecrettokenkeycredentialauthapi
PUBLIC_KEYSSH_PUBLIC_KEY
File System Scanning
Scans all image layers for files matching sensitive patterns. Default patterns include: SSH Keys:id_rsa- SSH private keyid_dsa- SSH private keyid_ecdsa- SSH private keyid_ed25519- SSH private key*.ppk- PuTTY private key
.aws/credentials- AWS credentials.kube/config- Kubernetes config
*.key- private key file
/etc/shadow- shadow password file.pgpass- PostgreSQL password file.my.cnf- MySQL credentials.netrc- authentication credentials
.npmrc- NPM credentials.git-credentials- Git credentialssecrets.json- secrets filesecrets.yaml- secrets filesecrets.yml- secrets filewallet.dat- cryptocurrency wallet
Usage Examples
Basic Usage (No Policy File)
Runs with sensible defaults:With Custom Policy File
Skip Environment Variable Checks
Skip File System Checks
Policy from stdin
OCI Archive
Example Output
Text Format (Success)
Text Format (Failure)
JSON Format
Policy File Format
YAML Example
JSON Example
Policy Configuration Options
| Field | Type | Default | Description |
|---|---|---|---|
check-env-vars | bool | true | Enable environment variable scanning |
check-files | bool | true | Enable file system scanning |
excluded-paths | array | [] | Glob patterns for paths to exclude from file scanning |
excluded-env-vars | array | ["PUBLIC_KEY", "SSH_PUBLIC_KEY"] | Environment variable names to exclude |
custom-env-patterns | array | [] | Additional keywords for environment variable scanning |
custom-file-patterns | array | [] | Additional file patterns to detect |
Exit Codes
| Exit Code | Meaning | Example | |-----------|---------|---------|----------| | 0 | No secrets detected | Image is clean | | 1 | Secrets detected | Image contains sensitive data | | 2 | Execution error | Invalid policy file, image not found |Related Configuration Files
config/secrets-policy.yaml- Sample secrets policy in YAML formatconfig/secrets-policy.json- Sample secrets policy in JSON format
Notes
- The check scans all image layers, not just the final filesystem. Secrets in earlier layers remain in the image history.
- Works out-of-the-box with sensible defaults when no policy file is provided.
- Environment variable detection uses case-insensitive pattern matching.
- Exclusion patterns support glob syntax (e.g.,
/usr/share/**). - CLI flags (
--skip-env-vars,--skip-files) override policy file settings.