You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(container): emit canonical argus-results.json + persist raw scanner output
Two related fixes for the container-scan flow, addressing user
reports that:
1. ``argus view`` doesn't display container vulnerabilities — the
container-scan flow only wrote a domain-shaped
``container-scan.json`` (per-image counts, ``container_count``,
etc.) which the viewers don't know how to render. The viewers
consume the canonical ``argus-results.json`` shape produced by
source scans.
2. The ``argus-results/`` dir doesn't preserve the raw per-scanner
output files (``trivy-results.json``, ``grype-results.json``,
``syft-sbom.json``) — they live in a tempdir that gets wiped at
the end of ``scan_image``. Users who want forensics, audit
trails, or manual triage have nowhere to look.
Both rooted in the same architectural drift: the container flow
diverged from the source-scan output contract. This PR re-aligns it.
Canonical ScanSummary for container scans
- ``_cmd_container_scan`` now builds a canonical ``ScanSummary``
alongside the existing ``ContainerScanSummary``: each container
target maps to ``ScanResult(scanner=f"container/<name>",
findings=combined, metadata={image_ref, build_success,
scanner_errors, scan_error})``.
- The JSON reporter writes that to ``argus-results.json``
unconditionally (matches the source-scan canonical-artifact
contract from PR #111).
- The SARIF reporter now consumes the same canonical summary
instead of building a one-off conversion locally.
- The domain-shaped ``container-scan.json`` (with ``container_count``,
per-image stats) is preserved for backward compat with downstream
tooling that consumes it; it just lives alongside the canonical
artifact rather than instead of it.
- ``argus view`` opens container scan results without any new code
on the viewer side — it just sees ``ScanResult`` rows named
``container/<image>`` and renders them like any other scanner.
Raw scanner output persistence
- ``scan_image`` gains a ``raw_output_dir: Path | None`` parameter.
When set, copies ``trivy-results.json``, ``grype-results.json``,
and ``syft-sbom.json`` into that directory before the tempdir is
cleaned up. Best-effort — copy errors log a warning but don't
fail the scan.
- ``ContainerEngine`` reads ``_raw_output_root`` from its config
dict (the dispatcher sets this) and threads a per-target subdir
to ``scan_image`` as ``<root>/<target.name>/``.
- ``_cmd_container_scan`` defaults to ON: raw outputs land at
``<output_dir>/raw/<image>/``. Opt out via
``--no-keep-raw`` flag or ``containers.keep_raw: false`` in
argus.yml. CLI flag wins on conflict (explicit > implicit).
- 0-byte files are explicitly skipped (they're failure signals
upstream; persisting them would make a known-bad output look
authoritative on disk).
Documentation
- ``argus.example.yml`` documents ``containers.keep_raw: true`` in
the commented schema block, alongside the existing ``images``,
``discover``, and ``scanners`` keys.
Tests (+5)
- ``TestScanImageRawOutputPersistence`` (4 cases): all artifacts
copied when dir supplied, no copy when ``raw_output_dir=None``,
partial coverage (only trivy ran) doesn't block the others, 0-byte
files are explicitly skipped.
- ``TestContainerCanonicalScanSummary`` (1 case): each
ContainerScanResult maps to a canonical ScanResult(scanner=
"container/<name>") with combined findings; metadata lifts onto
the ScanResult; round-trips through ``ScanSummary.to_dict()``
unchanged so the viewer gets the same shape it expects.
Validation
- Full SDK suite: 1464 passed (+5 net), 8 skipped.
* feat(scan): persist raw per-scanner output for source scans
Extend the raw-output preservation already in place for container
scans to cover source scans. ArgusEngine.run() now accepts
raw_output_dir and copies each scanner's results.json / *.sarif /
stdout.txt under <output_dir>/raw/<scanner>/ alongside the
canonical argus-results.json — the same posture as the container
flow, so forensics and manual triage have the same surface area
regardless of which scan path produced the findings.
The CLI gains a unified --no-keep-raw flag (moved out of the
container-only group) and reporting.keep_raw replaces the
container-scoped containers.keep_raw key. CLI flag wins on
conflict; default remains keep-raw=true.
---------
Co-authored-by: eFAILution <eFAILution@users.noreply.github.com>
0 commit comments