fix(scan): delete generated .socket.facts.json after reach submit#1424
Open
John-David Dalton (jdalton) wants to merge 1 commit into
Open
Conversation
`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.
John-David Dalton (jdalton)
force-pushed
the
jdalton/surf-641-update-socket-scan-to-delete-socketfactsjson-after
branch
from
July 24, 2026 21:50
e55eceb to
3cf4ba4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
socket scan create --reachruns coana, which writes.socket.facts.jsoninto 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.
--reach-use-only-pregenerated-sboms(user-managed artifacts)"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.mtsand rewrote them to assert real on-disk state (tmp cwd + realsafeDelete) instead of a mocked delete. Covers all four rows above.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.jsonin the project after a successful upload when this run produced it.Deletion is gated on a new
generatedFactsFileflag: snapshotexistsSyncbefore reachability runs, and skip cleanup when--reach-use-only-pregenerated-sbomsis 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.mtsand now assert real on-disk state via a temp cwd instead of mockingsafeDelete.Reviewed by Cursor Bugbot for commit e55eceb. Configure here.