@impart-security/impart-cli
v0.5.3
Published
Use Impart from the command line
Downloads
51
Keywords
Readme
impart-cli
Use Impart from the command line.
Linting
The Impart CLI includes an API Specification Linter that ensures your API specifications meet the high quality standards and also remain free from security vulnerabilities. This is achieved with static analysis of your API specification with different rulesets designed for quality and security. The Impart CLI can be configured entirely from the command line, making it easy to integrate into any CI/CD Pipeline.
The API Quality ruleset lints API specifications for conformance with Open API Specifications. The Impart CLI defaults to this ruleset.
The API Security ruleset lints API specifications for OWASP API Security 10 vulnerabilities and misconfigurations. The Impart CLI can be configured to enable this ruleset from the command line.
Usage
$ npm install -g @impart-security/impart-cli
$ impart COMMAND
running command...
$ impart (--version)
@impart-security/impart-cli/0.5.3 linux-x64 node-v22.12.0
$ impart --help [COMMAND]
USAGE
$ impart COMMAND
...
Usage in CI/CD workflows
impart-cli
can be called from within an NPM project or directly via pnpx
.
Example usage in a GitHub action using pnpx
:
jobs:
spec-update:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v3
- name: setup node
uses: actions/setup-node@v3
with:
node-version: "22"
- name: Update specification
run: npx @impart-security/impart-cli specs update --specPath {PATH_TO_SPEC_FILE} --force {YOUR_SPEC_ID}
env:
IMPART_ACCESS_TOKEN: ${{ secrets.SPEC_UPDATE_TOKEN }}
Commands
impart autocomplete [SHELL]
impart config
impart config init
impart specs
impart specs lint [SPECLOCATION]
impart specs update [SPECID]
impart autocomplete [SHELL]
Display autocomplete installation instructions.
USAGE
$ impart autocomplete [SHELL] [-r]
ARGUMENTS
SHELL (zsh|bash|powershell) Shell type
FLAGS
-r, --refresh-cache Refresh cache (ignores displaying instructions)
DESCRIPTION
Display autocomplete installation instructions.
EXAMPLES
$ impart autocomplete
$ impart autocomplete bash
$ impart autocomplete zsh
$ impart autocomplete powershell
$ impart autocomplete --refresh-cache
See code: @oclif/plugin-autocomplete
impart config
View configuration for impart-cli
USAGE
$ impart config
ALIASES
$ impart config show
impart config init
Initialize a new configuration for impart-cli
USAGE
$ impart config init
impart specs
Manage specifications for an organization
USAGE
$ impart specs
impart specs lint [SPECLOCATION]
Lint a specification
USAGE
$ impart specs lint [SPECLOCATION] [-r <value>] [--failSeverity error|warn|info|hint] [--displayOnlyFailures]
[--format json|stylish|junit|html|text|teamcity|pretty]
ARGUMENTS
SPECLOCATION
Path, URL or ID of the specification to update.
Examples:
impart specs lint ./openapi.yaml
impart specs lint https://example.com/openapi.yaml
impart specs lint 1234-5678-9012-3456
Note: An access token is required to lint a specification by ID in the Impart system:
https://console.impartsecurity.net/orgs/_/settings/tokens
FLAGS
-r, --rulesetPath=<value>
Path to a Spectral ruleset file.
Example:
impart specs lint --rulesetPath ./my-ruleset.yaml ./openapi.yaml
--displayOnlyFailures
Only output results equal to or greater than --failSeverity
Example:
impart specs lint --displayOnlyFailures ./openapi.yaml
--failSeverity=<option>
[default: error]
Results of this level or above will trigger a failure exit code.
Example:
impart specs lint --failSeverity warn ./openapi.yaml
<options: error|warn|info|hint>
--format=<option>
[default: pretty]
Format to use for outputting results.
Example:
impart specs lint --format json ./openapi.yaml
<options: json|stylish|junit|html|text|teamcity|pretty>
DESCRIPTION
Lint a specification
By default, linting uses a set of OWASP-focussed rules, provided by Spectral.
If you want to modify, disable or add new rules then you can provide your own ruleset file.
See https://meta.stoplight.io/docs/spectral for more information on how to use Spectral.
impart specs update [SPECID]
Update a specification for an organization
USAGE
$ impart specs update [SPECID] -p <value> [-n <value>] [-f]
ARGUMENTS
SPECID ID of the specification to update. If not provided, you will be prompted to select a specification from a
list.
Example:
impart specs update 1234-5678-9012-3456
FLAGS
-f, --force Force update of specification without confirmation (useful for scripting).
Example:
impart specs update --specPath ./openapi.yaml --force 1234-5678-9012-3456
-n, --name=<value> Specification name.
Example:
impart specs update --name "My API" 1234-5678-9012-3456
-p, --specPath=<value> (required)
Path to the specification file (YAML or JSON, Swagger2.0 or OpenAPI3.0).
Example:
impart specs update --specPath ./openapi.yaml 1234-5678-9012-3456