CLI

Spectral is a CLI (Command Line Interface) driven toolchain.

If you have to remember just one thing

For testing and playing around interactively:

$ $HOME/.spectral/spectral run

And in your CI:

$ $HOME/.spectral/spectral scan
๐Ÿฆธโ€โ™€๏ธ
Command line driven?
Our thesis is that people can get value the fastest, by wielding Spectral as a tool. We try hard to make that true for Windows users as well with PowerShell.
Hello Spectral ๐Ÿ‘‹
Hello Spectral ๐Ÿ‘‹

Commands

CommandDescription
runRun a scan interactively, for exploring or auditing
scanRun a scan from your CI/pipeline
initInitialize configuration in your repo. This is how you customize ignores, detectors, and more. Once your run the init command a hidden .spectral folder will be created & you can customize your configuration
fingerprintEncode a one-way fingerprint from a secret, for ignoring content.
githubAudit a github organization, user, or repo
gitlabAudit a gitlab organization, group, user, or repo
historyRun a Spectral git history scan
custom-rulesManage custom rules

Env variables

CommandDescription
SPECTRAL_DSN=<DSN>Your private Spectral DSN, which connects to your account
SPECTRAL_SHOW_MATCH=1Show secrets in scan output (off by default)

Common flags

CommandDescription
-t, --tokenSupply a token for Github, Gitlab, or others for auditing
-h, --hostSupply a git host (where relevant, e.g.: Gitlab)
-d, --destWhere to put git repos in case of auditing
-k, --kindWhat to audit? e.g.: group, user, org
--include-tags base,auditInclude additional ML-based detectors for full security coverage (more tags details: `spectral info --tags`)
--include-tags base,iacInclude IaC (Infrastructure As Code) security coverage (more tags details: `spectral info --tags`)
--unstagedScan with pre-commit and pre-receive hooks and send data to spectralops
-f, --fail-on-errorFail with non-zero exit code just on error severity matches
scanRun a scan from your CI/pipeline
initInitialize configuration in your repo. This is how you customize ignores, detectors, and more.
fingerprintEncode a one-way fingerprint from a secret, for ignoring content.
githubAudit a github organization, user, or repo
gitlabAudit a gitlab organization, group, user, or repo
gitlab -k all-groupsScan all GitLab groups

Help! ๐Ÿ”ฎ

When in doubt, you can always use the --help option for the main binary, or using a sub command, for example $HOME/.spectral/spectral run --help:

spectral --help
Spectral Scan 1.8.37
Spectral Cyber Technologies Inc.
USAGE:
spectral [FLAGS] [SUBCOMMAND]
FLAGS:
-h, --help Prints help information
--nobanners No help/free text banners. Make it easier to parse output
-V, --version Prints version information
SUBCOMMANDS:
config Your local SPECTRAL_DSN config
custom-rules Manage custom rules
discover Discover configuration at a remote provider
fingerprint Fingerprint sensitive information for ignores
github Run a Spectral scan on a github organization, user, or team. Alias: 'git'.
gitlab Run a Spectral scan on a Gitlab organization, user, or team
help Prints this message or the help of the given subcommand(s)
history Run a Spectral git history scan
info Spectral information
init Initialize Spectral configuration for a current project. (Must be in the project root)
local Run a Spectral audit on local assets
login Log into your Spectral account
logout Log out from your Spectral account
register Register for your own Spectral account
run Run a Spectral scan interactively
scan Run a Spectral scan in your CI pipeline
version