Skip to content

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

ArgumentDescription
[index]Row number from the current listing, @name for a mark, or kind/name such as deploy/api

Options

OptionDescription
-A, --all-namespacesSweep every namespace
--context stringKubeconfig context of a kind/name target; defaults to the current one. An index carries its own
--engine stringVulnerability scanner to use; run ‘kx engine’ to see available engines and the configured default
--fail-on stringExit 2 when any image carries a vulnerability at this severity or worse (critical, high, medium, low)
--fullStream the scanner’s full output instead of the summary table
--htmlRender the report as HTML and serve it in a browser
--jsonPrint the severity counts and every finding as JSON instead of a table
--limit intKeep the first N images of the summary, after --sort
-m, --match stringMatch by name (substring, case-insensitive)
-n, --namespace stringNamespace to sweep; defaults to the current namespace
--no-openServe the HTML report without opening a browser
--out stringWrite the HTML report to this file instead of serving it in a browser
--port intPort to serve the HTML report on; 0 picks a free one
--sort stringSort the summary by its columns: ‘-crit,-high’ puts the most critical images first

Global options

OptionDescription
--no-colorDisable styled output
-h, --helpShow 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