InSpec CLI
Use the InSpec CLI to run tests and audits against targets using local, SSH, WinRM, or Docker connections.
archive
Archive a profile to tar.gz (default) or zip
Syntax
This subcommand has the following syntax:
inspec archive PATH
Options
This subcommand has additional options:
-
--airgap,--no-airgapFallback to using local archives if fetching fails. -
--ignore-errors,--no-ignore-errorsIgnore profile warnings. -
-o,--output=OUTPUTSave the archive to a path -
--overwrite,--no-overwriteOverwrite existing archive. -
--profiles-path=PROFILES_PATHFolder which contains referenced profiles. -
--tar,--no-tarGenerates a tar.gz archive. -
--vendor-cache=VENDOR_CACHEUse the given path for caching dependencies. (default: ~/.inspec/cache) -
--zip,--no-zipGenerates a zip archive.
check
Verify all tests at the specified path
Syntax
This subcommand has the following syntax:
inspec check PATH
Options
This subcommand has additional options:
--format=FORMAT--profiles-path=PROFILES_PATHFolder which contains referenced profiles.--vendor-cache=VENDOR_CACHEUse the given path for caching dependencies. (default: ~/.inspec/cache)
detect
Detect the target os
Syntax
This subcommand has the following syntax:
inspec detect
Options
This subcommand has additional options:
-b,--backend=BACKENDChoose a backend: local, ssh, winrm, docker.--bastion-host=BASTION_HOSTSpecifies the bastion host if applicable--bastion-port=BASTION_PORTSpecifies the bastion port if applicable--bastion-user=BASTION_USERSpecifies the bastion user if applicable--config=CONFIGRead configuration from JSON file (-reads from stdin).--enable-password=ENABLE_PASSWORDPassword for enable mode on Cisco IOS devices.--format=FORMAT--host=HOSTSpecify a remote host which is tested.--insecure,--no-insecureDisable SSL verification on select targets-i,--key-files=one two threeLogin key or certificate file for a remote scan.--password=PASSWORDLogin password for a remote scan, if required.--path=PATHLogin path to use when connecting to the target (WinRM).-p,--port=NSpecify the login port for a remote scan.--proxy-command=PROXY_COMMANDSpecifies the command to use to connect to the server--self-signed,--no-self-signedAllow remote scans with self-signed certificates (WinRM).--shell,--no-shellRun scans in a subshell. Only activates on Unix.--shell-command=SHELL_COMMANDSpecify a particular shell to use.--shell-options=SHELL_OPTIONSAdditional shell options.--ssl,--no-sslUse SSL for transport layer encryption (WinRM).--sudo,--no-sudoRun scans with sudo. Only activates on Unix and non-root user.--sudo-command=SUDO_COMMANDAlternate command for sudo.--sudo-options=SUDO_OPTIONSAdditional sudo options for a remote scan.--sudo-password=SUDO_PASSWORDSpecify a sudo password, if it is required.-t,--target=TARGETSimple targeting option using URIs, e.g. ssh://user:pass@host:port--target-id=TARGET_IDProvide a ID which will be included on reports--user=USERThe login user for a remote scan.--winrm-basic-auth-only,--no-winrm-basic-auth-onlyWhether to use basic authentication, defaults to false (WinRM).--winrm-disable-sspi,--no-winrm-disable-sspiWhether to use disable sspi authentication, defaults to false (WinRM).--winrm-transport=WINRM_TRANSPORTSpecify which transport to use, defaults to negotiate (WinRM).
env
Output shell-appropriate completion configuration
Syntax
This subcommand has the following syntax:
inspec env
exec
Run all test files at the specified locations.
loads the given profile(s) and fetches their dependencies if needed. then connects to the target and executes any controls contained in the profiles. one or more reporters are used to generate output.
exit codes:
0 normal exit, all tests passed
1 usage or general error
2 error in plugin system
3 fatal deprecation encountered
100 normal exit, at least one test failed
101 normal exit, at least one test skipped but none failed
172 chef license not accepted
below are some examples of using exec with different test locations:
automate:
inspec compliance login
inspec exec compliance://username/linux-baseline
supermarket:
inspec exec supermarket://username/linux-baseline
local profile (executes all tests in controls/):
inspec exec /path/to/profile
local single test (doesn’t allow inputs or custom resources)
inspec exec /path/to/a_test.rb
git via ssh
inspec exec [email protected]:dev-sec/linux-baseline.git
git via https (.git suffix is required):
inspec exec https://github.com/dev-sec/linux-baseline.git
private git via https (.git suffix is required):
inspec exec https://[email protected]/dev-sec/linux-baseline.git
private git via https and cached credentials (.git suffix is required):
git config credential.helper cache
git ls-remote https://github.com/dev-sec/linux-baseline.git
inspec exec https://github.com/dev-sec/linux-baseline.git
web hosted fileshare (also supports .zip):
inspec exec https://webserver/linux-baseline.tar.gz
web hosted fileshare with basic authentication (supports .zip):
inspec exec https://username:password@webserver/linux-baseline.tar.gz
Syntax
This subcommand has the following syntax:
inspec exec LOCATIONS
Options
This subcommand has additional options:
-
--attrs=one two threeLegacy name for –input-file - deprecated. -
-b,--backend=BACKENDChoose a backend: local, ssh, winrm, docker. -
--backend-cache,--no-backend-cacheAllow caching for backend command output. (default: true) -
--bastion-host=BASTION_HOSTSpecifies the bastion host if applicable -
--bastion-port=BASTION_PORTSpecifies the bastion port if applicable -
--bastion-user=BASTION_USERSpecifies the bastion user if applicable -
--config=CONFIGRead configuration from JSON file (-reads from stdin). -
--controls=one two threeA list of control names to run, or a list of /regexes/ to match against control names. Ignore all other tests. -
--create-lockfile,--no-create-lockfileWrite out a lockfile based on this execution (unless one already exists) -
--distinct-exit,--no-distinct-exitExit with code 101 if any tests fail, and 100 if any are skipped (default). If disabled, exit 0 on skips and 1 for failures. -
--enable-password=ENABLE_PASSWORDPassword for enable mode on Cisco IOS devices. -
--host=HOSTSpecify a remote host which is tested. -
--input=name1=value1 name2=value2Specify one or more inputs directly on the command line, as –input NAME=VALUE. Accepts single-quoted YAML and JSON structures. -
--input-file=one two threeLoad one or more input files, a YAML file with values for the profile to use -
--insecure,--no-insecureDisable SSL verification on select targets -
-i,--key-files=one two threeLogin key or certificate file for a remote scan. -
--password=PASSWORDLogin password for a remote scan, if required. -
--path=PATHLogin path to use when connecting to the target (WinRM). -
-p,--port=NSpecify the login port for a remote scan. -
--profiles-path=PROFILES_PATHFolder which contains referenced profiles. -
--proxy-command=PROXY_COMMANDSpecifies the command to use to connect to the server -
--reporter=one two:/output/file/pathEnable one or more output reporters: cli, documentation, html, progress, json, json-min, json-rspec, junit, yaml -
--reporter-backtrace-inclusion,--no-reporter-backtrace-inclusionInclude a code backtrace in report data (default: true) -
--reporter-message-truncation=REPORTER_MESSAGE_TRUNCATIONNumber of characters to truncate failure messages in report data to (default: no truncation) -
--self-signed,--no-self-signedAllow remote scans with self-signed certificates (WinRM). -
--shell,--no-shellRun scans in a subshell. Only activates on Unix. -
--shell-command=SHELL_COMMANDSpecify a particular shell to use. -
--shell-options=SHELL_OPTIONSAdditional shell options. -
--show-progress,--no-show-progressShow progress while executing tests. -
--silence-deprecations=all|GROUP GROUP...Suppress deprecation warnings. See install_dir/etc/deprecations.json for list of GROUPs or use ‘all’. -
--ssl,--no-sslUse SSL for transport layer encryption (WinRM). -
--sudo,--no-sudoRun scans with sudo. Only activates on Unix and non-root user. -
--sudo-command=SUDO_COMMANDAlternate command for sudo. -
--sudo-options=SUDO_OPTIONSAdditional sudo options for a remote scan. -
--sudo-password=SUDO_PASSWORDSpecify a sudo password, if it is required. -
-t,--target=TARGETSimple targeting option using URIs, e.g. ssh://user:pass@host:port -
--target-id=TARGET_IDProvide a ID which will be included on reports -
--user=USERThe login user for a remote scan. -
--vendor-cache=VENDOR_CACHEUse the given path for caching dependencies. (default: ~/.inspec/cache) -
--waiver-file=one two threeLoad one or more waiver files. -
--winrm-basic-auth-only,--no-winrm-basic-auth-onlyWhether to use basic authentication, defaults to false (WinRM). -
--winrm-disable-sspi,--no-winrm-disable-sspiWhether to use disable sspi authentication, defaults to false (WinRM). -
--winrm-transport=WINRM_TRANSPORTSpecify which transport to use, defaults to negotiate (WinRM).
help
Describe available commands or one specific command
Syntax
This subcommand has the following syntax:
inspec help [COMMAND]
json
Read all tests in path and generate a json summary
Syntax
This subcommand has the following syntax:
inspec json PATH
Options
This subcommand has additional options:
-
--controls=one two threeA list of controls to include. Ignore all other tests. -
-o,--output=OUTPUTSave the created profile to a path -
--profiles-path=PROFILES_PATHFolder which contains referenced profiles. -
--vendor-cache=VENDOR_CACHEUse the given path for caching dependencies. (default: ~/.inspec/cache)
nothing
Does nothing
Syntax
This subcommand has the following syntax:
inspec nothing
schema
Print the json schema
Syntax
This subcommand has the following syntax:
inspec schema NAME
shell
Open an interactive debugging shell
Syntax
This subcommand has the following syntax:
inspec shell
Options
This subcommand has additional options:
-
-b,--backend=BACKENDChoose a backend: local, ssh, winrm, docker. -
--bastion-host=BASTION_HOSTSpecifies the bastion host if applicable -
--bastion-port=BASTION_PORTSpecifies the bastion port if applicable -
--bastion-user=BASTION_USERSpecifies the bastion user if applicable -
-c,--command=COMMANDA single command string to run instead of launching the shell -
--config=CONFIGRead configuration from JSON file (-reads from stdin). -
--depends=one two threeA space-delimited list of local folders containing profiles whose libraries and resources will be loaded into the new shell -
--distinct-exit,--no-distinct-exitExit with code 100 if any tests fail, and 101 if any are skipped but none failed (default). If disabled, exit 0 on skips and 1 for failures. -
--enable-password=ENABLE_PASSWORDPassword for enable mode on Cisco IOS devices. -
--host=HOSTSpecify a remote host which is tested. -
--insecure,--no-insecureDisable SSL verification on select targets -
--inspect,--no-inspectUse verbose/debugging output for resources. -
-i,--key-files=one two threeLogin key or certificate file for a remote scan. -
--password=PASSWORDLogin password for a remote scan, if required. -
--path=PATHLogin path to use when connecting to the target (WinRM). -
-p,--port=NSpecify the login port for a remote scan. -
--proxy-command=PROXY_COMMANDSpecifies the command to use to connect to the server -
--reporter=one two:/output/file/pathEnable one or more output reporters: cli, documentation, html, progress, json, json-min, json-rspec, junit -
--self-signed,--no-self-signedAllow remote scans with self-signed certificates (WinRM). -
--shell,--no-shellRun scans in a subshell. Only activates on Unix. -
--shell-command=SHELL_COMMANDSpecify a particular shell to use. -
--shell-options=SHELL_OPTIONSAdditional shell options. -
--ssl,--no-sslUse SSL for transport layer encryption (WinRM). -
--sudo,--no-sudoRun scans with sudo. Only activates on Unix and non-root user. -
--sudo-command=SUDO_COMMANDAlternate command for sudo. -
--sudo-options=SUDO_OPTIONSAdditional sudo options for a remote scan. -
--sudo-password=SUDO_PASSWORDSpecify a sudo password, if it is required. -
-t,--target=TARGETSimple targeting option using URIs, e.g. ssh://user:pass@host:port -
--target-id=TARGET_IDProvide a ID which will be included on reports -
--user=USERThe login user for a remote scan. -
--winrm-basic-auth-only,--no-winrm-basic-auth-onlyWhether to use basic authentication, defaults to false (WinRM). -
--winrm-disable-sspi,--no-winrm-disable-sspiWhether to use disable sspi authentication, defaults to false (WinRM). -
--winrm-transport=WINRM_TRANSPORTSpecify which transport to use, defaults to negotiate (WinRM).
supermarket
Supermarket commands
Syntax
This subcommand has the following syntax:
inspec supermarket SUBCOMMAND ...
vendor
Download all dependencies and generate a lockfile in a vendor directory
Syntax
This subcommand has the following syntax:
inspec vendor PATH
Options
This subcommand has additional options:
-
--overwrite,--no-overwriteOverwrite existing vendored dependencies and lockfile.
version
Prints the version of this tool
Syntax
This subcommand has the following syntax:
inspec version
Options
This subcommand has additional options:
--format=FORMAT
© Chef Software, Inc.
Licensed under the Creative Commons Attribution 3.0 Unported License.
The Chef™ Mark and Chef Logo are either registered trademarks/service marks or trademarks/servicemarks of Chef, in the United States and other countries and are used with Chef Inc's permission.
We are not affiliated with, endorsed or sponsored by Chef Inc.
https://docs.chef.io/inspec/cli/