Skip to content

feat(json): record cliVersion, scannedAt and the effective options in the --json payload #1296

Closed

Description

@sonukapoor

The --json payload records nothing about how it was produced, so a JSON file on its own cannot be traced back to a version or an invocation.

What happened

An adopter shared a scan JSON on 2026-10-07 and asked about three diagnostics in it. Working out which release produced it took four separate runs against 1.29.0, 1.30.0, 1.37.0 and current main, and the flags were never recoverable from the file at all. The answer turned out to matter: two of the three diagnostics only appear with --check-overrides, which their CI workflow does not pass, so the file came from a different invocation than the one we were shown.

The gap

report.json already carries scannedAt and cliVersion. The --json payload carries neither. That is the same --json versus report.json drift #1176 set out to remove, and both now come from src/output/scan-json.ts, so the fix belongs in one place.

What to add

Three things, at the top level of the --json payload:

  • cliVersion - the running CLI version, read the same way report.json reads it
  • scannedAt - an ISO timestamp, same as report.json
  • the effective options for the run, not the raw command line (see below)

Record effective options, not process.argv

Effective options are more useful, because they capture defaults as well as what was typed, which is what you need to reproduce a run.

They are also safer, and this issue is the evidence: adopters share these files. --offline-db, --cache-dir and --osv-url can carry internal paths and internal registry or mirror hostnames, and raw argv would copy them verbatim into an artifact that gets uploaded to CI and emailed around. Emit the normalised boolean and enum options, and for any option whose value is a path or URL, record that it was set rather than what it was set to.

Success criterion

A --json run produces cliVersion, scannedAt and the effective options. Two runs differing only in --check-overrides produce payloads that differ in that field. No option value containing a filesystem path or a URL appears anywhere in the payload. Removing any of the three fields fails a test.

--json output is consumed by adopters' pipelines, so these are additive fields only; nothing existing changes shape.

Activity

  1. prx-my commented on Oct 7, 2026

    @prx-my
    Contributor

    @sonukapoor i have some pr opens and other stuff which is waiting for the review

  2. pintu544 commented on Oct 7, 2026

    @pintu544
    Contributor

    Hi, I'd like to work on this. My plan: add cliVersion, scannedAt, and effectiveOptions (booleans/enums normalized, path/URL options recorded as set-markers only) to the --json payload in the scan-json.ts builders, with tests covering the success criteria. Will open a PR shortly.

  3. sonukapoor commented on Oct 7, 2026

    @sonukapoor
    CollaboratorAuthor

    @prx-my Understood, and that is fair. Reviews here now go oldest-first by the date a PR was opened, so #1269 and #1271 from the 2nd sit near the front of the queue. They will go out in that order.

    Leaving this one open for whoever picks it up first.

  4. added 2 commits that reference this issue on Oct 11, 2026
    5fedb05
    ddff6c5
  5. added a commit that references this issue on Oct 15, 2026
    c5d2272
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions