Skip to content

fix(scan): delete generated .socket.facts.json after reach submit#1424

Open
John-David Dalton (jdalton) wants to merge 1 commit into
mainfrom
jdalton/surf-641-update-socket-scan-to-delete-socketfactsjson-after
Open

fix(scan): delete generated .socket.facts.json after reach submit#1424
John-David Dalton (jdalton) wants to merge 1 commit into
mainfrom
jdalton/surf-641-update-socket-scan-to-delete-socketfactsjson-after

Conversation

@jdalton

@jdalton John-David Dalton (jdalton) commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

socket scan create --reach runs coana, which writes .socket.facts.json into the project, uploads it, and then left it sitting there. Martin: "you don't really want .socket.facts.json files lying around in your folder."

Change

Delete the facts file once the scan is submitted — but only when this run generated it.

Case Behavior
CLI generated the file this run deleted after successful submit
File pre-existed the run left untouched
--reach-use-only-pregenerated-sboms (user-managed artifacts) left untouched
Submission failed left in place (debuggability)

"Generated this run" is decided by snapshotting existsSync(.socket.facts.json) before the analysis runs (the create flow always writes coana's report to the default path in cwd), plus the explicit pregenerated-SBOMs flag.

Failure path

Kept, not deleted — a failed submit is exactly when you want the artifact around to inspect. The delete is already gated on fullScanCResult.ok.

Tests

Consolidated the facts-cleanup unit tests into handle-create-new-scan.test.mts and rewrote them to assert real on-disk state (tmp cwd + real safeDelete) instead of a mocked delete. Covers all four rows above.

Test Files  2 passed (2)
      Tests  18 passed (18)

Full scan unit dir: 72 files / 812 tests green. Lint + oxfmt clean on the three touched files.


Note

Low Risk
CLI-only post-upload file cleanup with narrow conditions; behavior is covered by integration-style unit tests and does not touch auth or server APIs.

Overview
Reach scan create no longer leaves .socket.facts.json in the project after a successful upload when this run produced it.

Deletion is gated on a new generatedFactsFile flag: snapshot existsSync before reachability runs, and skip cleanup when --reach-use-only-pregenerated-sboms is set or the file was already on disk. Failed submits still keep the file for debugging.

Unit tests for the four cleanup cases moved to handle-create-new-scan.test.mts and now assert real on-disk state via a temp cwd instead of mocking safeDelete.

Reviewed by Cursor Bugbot for commit e55eceb. Configure here.

`scan create --reach` left .socket.facts.json behind. Delete it once the
scan is submitted — but only when this run generated it. A file that
pre-existed the run, or one from --reach-use-only-pregenerated-sboms
(user-managed artifacts), is left untouched. On submission failure the
file is kept for debuggability.

Consolidate the facts-cleanup unit tests into handle-create-new-scan
and exercise real on-disk state (tmp cwd + real safeDelete) rather than
asserting on a mocked delete.
@jdalton
John-David Dalton (jdalton) force-pushed the jdalton/surf-641-update-socket-scan-to-delete-socketfactsjson-after branch from e55eceb to 3cf4ba4 Compare July 24, 2026 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant