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(reporters): always emit canonical argus-results.json regardless of config
Continues the work in this PR by addressing the *root* of the
missing-results pitfall: the canonical scan artifact, not just the
error message.
Before this commit, ``reporting.formats`` controlled whether
``argus-results.json`` got written. A config like
``formats: [terminal, sarif]`` would silently break ``argus view``,
the audit manifest's lossless dump, and ``argus report`` because
the JSON file simply wasn't there.
This commit shifts the contract:
- ``argus-results.json`` is always emitted by the source-scan flow.
It's the canonical artifact every other Argus surface depends on.
- ``reporting.formats`` now means "which *additional* human-readable
reports to emit alongside the canonical JSON," not "which
artifacts exist at all."
Implementation
- New ``argus.reporters.ensure_canonical_json(formats)`` helper —
idempotent, preserves user-configured ordering, appends ``json``
when absent. Lives next to ``REPORTER_REGISTRY`` and
``CANONICAL_FORMAT`` so the canonical artifact's identity is one
module-level constant away.
- ``argus/cli.py`` source-scan dispatch loop iterates the
helper-augmented format list. The diagnoser remains as a
defensive belt-and-suspenders for legacy result dirs produced
before this contract was in place.
- ``argus.example.yml`` comment block updated so users see the new
contract: "argus-results.json is always written; this list is for
additional reports." Available formats listed inline.
Scope notes
- Container and DAST flows have their own JSON helpers
(``_write_container_json`` / ``_write_dast_json``) that produce
domain-shaped summaries, not ``ScanSummary.to_dict()``. They're
consumed by their own viewers/handling, separate from
``argus view``. Adding "always emit argus-results.json" to those
flows would conflate two different artifacts; left for follow-up
if a clear use case arises.
Tests (+8)
- ``argus/tests/reporters/test_registry.py`` (7 cases): idempotent
on input that already lists json; preserves user order;
defensive-no-mutation; empty-formats edge case; constant-name
sanity. Decoupled from the cli.py dispatch loop so the helper's
invariants are testable without spinning up the engine.
- ``argus/tests/test_cli.py`` (1 case): integration regression for
the source-scan flow — captures the format names the dispatch
loop requests from ``get_reporter`` when configured with
``formats=[terminal]``, asserts ``json`` is in the captured list.
Validation
- Full SDK suite green: 1428 passed (+8 from this commit), 8
skipped.
- The diagnoser PR's failure-path tests still pass (the failure
mode is now extremely rare in practice but the messages remain
in case a user loads an older results dir or hits an unrelated
path issue).
0 commit comments