Skip to content

fix: multi-folder --json writes a timestamped file like single-folder - #902

Open
Ayush7614 wants to merge 3 commits into
OWASP:mainfrom
Ayush7614:fix/multi-folder-json-file
Open

fix: multi-folder --json writes a timestamped file like single-folder#902
Ayush7614 wants to merge 3 commits into
OWASP:mainfrom
Ayush7614:fix/multi-folder-json-file

Conversation

@Ayush7614

@Ayush7614 Ayush7614 commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Multi-folder --json now writes cve-lite-scan-<ts>.json to the working directory and prints the saved path (same contract as single-folder writeOutputs).
  • Keeps the multi-folder payload shape (multiFolder, per-folder subfolder tags, optional OA/DM).
  • Updates docs that taught cve-lite . --json > file (nx-workspaces.md, workflow-integration.md) so redirects are no longer recommended.

Why

Help text says --json saves a timestamped file. Single-folder does that; multi-folder previously dumped JSON to stdout only. Unifying on the file-write contract also closes the docs/redirect footgun called out in #877.

Test plan

  • npm test -- tests/multi-folder-scan.test.ts
  • e2e multi-folder --json reads the written file
  • npm run build
  • Docs no longer show --json > … in NX or workflow-integration examples

Closes #877

@Ayush7614
Ayush7614 requested a review from sonukapoor as a code owner July 27, 2026 19:25

@sonukapoor sonukapoor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on @Ayush7614. The mechanism is right, and I like that you carried the maintenanceFindings / overrideFindings spreads over untouched rather than restructuring them. The tests are solid too: writing to a real temp cwd and reading the file back instead of asserting on the console.log call is exactly the right way to prove this, and catching that the file lands in process.cwd() (not the scanned project dir) in the e2e test was a good catch.

Two things before I can merge:

  1. Could you add Closes #877 to the PR body? Right now it is not referenced anywhere in the description, so merging will not auto-close the issue.
  2. I dogfooded a real redirect (cve-lite . --json > out.json) on a monorepo fixture and out.json just contains the text JSON saved to cve-lite-scan-....json, not the payload. That is expected given the design, but it is the exact pattern #877 calls out, and website/docs/workflow-integration.md (around lines 211 and 218) still shows cve-lite . --json > cve-lite-report.json. Since multi-folder used to print real JSON to stdout, that redirect actually worked before this change and is only broken now for multi-folder as a side effect. Could you update those two examples too, or note explicitly that they are being left for a follow-up? I do not want to close #877 while one of the two doc locations it names still teaches the broken pattern.

Everything else looks good, happy to merge once those are sorted.

Multi-folder --json dumped the payload to stdout while single-folder
(and the CLI help text) write a cve-lite-scan-*.json file. Align the
behavior and stop teaching stdout redirects in the NX workspace docs.
The e2e asserted JSON.parse(stdout); multi-folder --json now writes a
timestamped file like single-folder. Read the file and use the seeded
offline DB so the assertion is stable locally and in CI.
Align workflow-integration.md with the file-write contract so CI that
follows the docs does not capture "JSON saved to …" instead of findings.
@Ayush7614
Ayush7614 force-pushed the fix/multi-folder-json-file branch from 2968ea8 to 14cd97b Compare July 28, 2026 12:09
@Ayush7614

Copy link
Copy Markdown
Collaborator Author

@sonukapoor thanks for the review — addressed:

  1. Added Closes #877 to the PR body.
  2. Updated both --json > … examples in website/docs/workflow-integration.md so they no longer teach stdout redirects.

Also rebased this branch onto latest main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: docs teach --json > file but single-folder writes a timestamped file (redirect gets garbage)

2 participants