kx scan
Resolves the unique container images of a workload and scans each for vulnerabilities, printing a severity summary table.
With no index, sweeps every workload in the current namespace, or in the namespace given by -n, or in every namespace with -A; -m narrows the sweep to the workloads whose name matches.
Requires the CLI for the selected engine. Docker Scout is the default: https://docs.docker.com/scout/ Trivy is available via --engine trivy: https://trivy.dev/ Grype is available via --engine grype: https://github.com/anchore/grype Run ‘kx engine’ to see or change the default.
A --sort orders the summary by its columns, IMAGE, CRIT, HIGH, MED, LOW and UNSPEC, with a leading - for largest first: --sort -crit,-high puts the most critical images first. The order carries into --json and the --html page, and an image that failed to scan sorts last.
A --limit keeps the first N images of the summary, after --sort orders it: kx scan -A --sort -crit,-high --limit 5 is the five most critical. Every image is still scanned, and --fail-on still reads them all.
Unrecognized flags are passed through to the scanner.
Usage
kx scan [OPTIONS] [index] [scanner flags]Arguments
| Argument | Description |
|---|---|
[index] | Row number from the current listing, @name for a mark, or kind/name such as deploy/api |
Options
| Option | Description |
|---|---|
-A, --all-namespaces | Sweep every namespace |
--context string | Kubeconfig context of a kind/name target; defaults to the current one. An index carries its own |
--engine string | Vulnerability scanner to use; run ‘kx engine’ to see available engines and the configured default |
--fail-on string | Exit 2 when any image carries a vulnerability at this severity or worse (critical, high, medium, low) |
--full | Stream the scanner’s full output instead of the summary table |
--html | Render the report as HTML and serve it in a browser |
--json | Print the severity counts and every finding as JSON instead of a table |
--limit int | Keep the first N images of the summary, after --sort |
-m, --match string | Match by name (substring, case-insensitive) |
-n, --namespace string | Namespace to sweep; defaults to the current namespace |
--no-open | Serve the HTML report without opening a browser |
--out string | Write the HTML report to this file instead of serving it in a browser |
--port int | Port to serve the HTML report on; 0 picks a free one |
--sort string | Sort the summary by its columns: ‘-crit,-high’ puts the most critical images first |
Global options
| Option | Description |
|---|---|
--no-color | Disable styled output |
-h, --help | Show this message and exit |
Examples
kx scan
kx scan 1
kx scan deploy/api -n prod
kx scan -n prod
kx scan -m api
kx scan --sort -crit,-high
kx scan -A --sort -crit,-high --limit 5
kx scan 1 --full
kx scan --html
kx scan -A --json
kx scan -A --fail-on high --out report.html