@impart-security/impart-cli
v0.4.4
Published
Use Impart from the command line
Downloads
88
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.4.4 linux-x64 node-v20.13.1
$ impart --help [COMMAND]
USAGE
$ impart COMMAND
...
Usage in CI/CD workflows
impart-cli
can be called from within an NPM project or directly via npx
.
Example usage in a GitHub action using npx
:
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: "20"
- name: Update specification
run: npx @impart-security/impart-cli specs update --specId {YOUR_SPEC_ID} --specPath {PATH_TO_SPEC_FILE} --force
env:
IMPART_ACCESS_TOKEN: ${{ secrets.SPEC_UPDATE_TOKEN }}
Commands
impart autocomplete [SHELL]
impart config
impart config init
impart specs
impart specs lint
impart specs update
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
Lint a specification file
USAGE
$ impart specs lint [-p <value> | -s <value>] [-r <value>] [--failSeverity error|warn|info|hint]
[--displayOnlyFailures] [--format json|stylish|junit|html|text|teamcity|pretty]
FLAGS
-p, --specPath=<value>
A path or URL to a specification file (YAML or JSON, Swagger2.0 or OpenAPI3.0).
Examples:
impart specs lint --specPath ./openapi.yaml
impart specs lint --specPath https://example.com/openapi.yaml
-r, --rulesetPath=<value>
Path to a Spectral ruleset file.
Example:
impart specs lint --specPath ./openapi.yaml --rulesetPath ./my-ruleset.yaml
-s, --specId=<value>
ID of the specification to lint. An access token is required to lint specifications in the Impart system:
https://console.impartsecurity.net/orgs/_/settings/tokens
Example:
impart specs lint --specId 1234-5678-9012-3456
--displayOnlyFailures
Only output results equal to or greater than --failSeverity
Example:
impart specs lint --specPath ./openapi.yaml --displayOnlyFailures
--failSeverity=<option>
[default: error]
Results of this level or above will trigger a failure exit code.
Example:
impart specs lint --specPath ./openapi.yaml --failSeverity warn
<options: error|warn|info|hint>
--format=<option>
[default: pretty]
Format to use for outputting results.
Example:
impart specs lint --specPath ./openapi.yaml --format json
<options: json|stylish|junit|html|text|teamcity|pretty>
DESCRIPTION
Lint a specification file
By default, linting is run against the OAS ruleset from 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
Update a specification for an organization
USAGE
$ impart specs update -p <value> [-s <value>] [-n <value>] [-f]
FLAGS
-f, --force Force update of specification without confirmation (useful for scripting).
Example:
impart specs update --specId 1234-5678-9012-3456 --specPath ./openapi.yaml --force
-n, --name=<value> Specification name.
Example:
impart specs update --specId 1234-5678-9012-3456 --name "My API"
-p, --specPath=<value> (required)
Path to the specification file (YAML or JSON, Swagger2.0 or OpenAPI3.0).
Example:
impart specs update --specId 1234-5678-9012-3456 --specPath ./openapi.yaml
-s, --specId=<value> ID of the specification to update. If not provided, you will be prompted to select a
specification from a list.
Example:
impart specs update --specId 1234-5678-9012-3456