Repository navigation
feat(scan): add --reach-fallback-to-regular-scan flag - #1537
Merged
Martin Torp (mtorp) merged 2 commits intoSep 14, 2026
Merged
Conversation
When reachability analysis fails (e.g. backend gateway disconnect during compute-artifacts), �[34m?�[39m �[1mNo TARGET given. Do you want to use the current directory?�[22m �[2m(Use arrow keys)�[22m �[36m❯ Yes�[39m No �[36mTarget the current directory�[39m�[?25l�[29G �[?25h currently aborts the whole scan. The new opt-in flag continues with a regular SCA scan instead, so the rest of the scan still ships when reachability errors out.
…gnal The --reach-fallback-to-regular-scan path had three gaps. Coana writes its report over `.socket.facts.json` in place, so an analysis that fails part way leaves partial output where the scan's inputs were. The fallback uploaded that file as-is and left it on disk, where the next --reach run reads it as a pre-generated input. Snapshot the facts files before the analysis runs and restore them on fallback: captured files are rolled back to their pre-analysis bytes, and files the analysis created are removed. A producer-written facts file (socket manifest gradle --facts) is user-owned input and is restored rather than deleted. The JSON and Markdown output reported an unqualified success, so nothing downstream could tell a degraded scan from a full one. Carry the failure in a `reachabilityFallback` field alongside the scan result.
Martin Torp (mtorp)
marked this pull request as ready for review
September 14, 2026 11:25
Martin Torp (mtorp)
requested a review
from Benjamin Barslev Nielsen (barslev)
September 14, 2026 11:26
Benjamin Barslev Nielsen (barslev)
approved these changes
Sep 14, 2026
Martin Torp (mtorp)
deleted the
martin/flag-to-fall-back-to-regular-sca-when-re
branch
September 14, 2026 13:11
1 task
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.
Summary
Adds an opt-in
--reach-fallback-to-regular-scanflag tosocket scan create. When full application reachability analysis fails (e.g. a backend gateway disconnect during compute-artifacts), the CLI currently aborts the entire scan. With the flag set, a failed reachability run logs a warning and the scan continues as a regular SCA scan, so the rest of the pipeline still completes.Behavior
--reach-fallback-to-regular-scan(defaultfalse), part of the reachability flag family, so it requires--reach.scan_type: socketusing the plain manifest set, skipping tier1 finalize and the missing-reachability-ID warning.socket scan reach(standalone analysis has no scan to fall back to).Facts-file handling on fallback
Coana writes its report over
.socket.facts.jsonin place, so an analysis that fails part way leaves partial output where the scan's inputs were. Two consequences the fallback has to handle:--reach.0, and the next--reachrun reads a stale.socket.facts.jsonas a pre-generated input, silently overriding fresh analysis.snapshotSocketFacts(src/utils/coana.mts) copies every.socket.facts.jsonin the scan set — plus the analysis output path — aside before the analysis runs. On fallback,restore()rolls captured files back to their pre-analysis bytes and removes paths that did not exist beforehand. A producer-written facts file (socket manifest gradle --facts) is user-owned input, and for Gradle/Maven it is the manifest, so it is restored rather than deleted.Machine-readable signal
A fallback previously reported an unqualified success, so nothing downstream could tell a degraded scan from a full one.
scan createoutput now carries the failure alongside the scan result:{ "ok": true, "data": { "id": "…", "html_report_url": "…" }, "reachabilityFallback": { "cause": "upstream gateway disconnected", "message": "Failed to fetch artifacts from Socket API" } }The Markdown report gains a matching line.
--reportoutput is unchanged — it comes from the shared scan-report path thatsocket scan reportalso uses.Testing
reachabilityFallbackset) and the unchanged halt path.snapshotSocketFactsunit tests: restore, remove-if-created, and non-facts paths left alone.outputCreateNewScantests for the JSON and Markdown payloads with and without the marker.--reach, accepted with--reachin dry-run, help output updated.pnpm run checkand the scan/ci test suites pass.Note
Medium Risk
Changes reachability failure handling and scan upload inputs (facts rollback and scan type), which affects CI pipelines that rely on tier1 scans or assume reach failure is fatal.
Overview
Adds
--reach-fallback-to-regular-scantosocket scan create(requires--reach). When full application reachability analysis fails, the CLI can warn and continue with a normal SCA upload instead of exiting—scan_typebecomes regularsocket, tier1 finalize is skipped, and the missing-reachability-ID warning is suppressed on fallback.Before analysis,
snapshotSocketFactsbacks up.socket.facts.jsonpaths Coana may overwrite; on fallbackrestore()puts pre-analysis inputs back (or removes files the failed run created) so the degraded scan does not upload partial facts or leave stale artifacts.Successful create output can include a
reachabilityFallbackobject (message, optionalcause) in JSON and a note in Markdown, so automation can distinguish a downgraded scan from a full tier1 run. The flag is hidden/no-op onsocket scan reach. CI and GitHub-driven scan entry points default it to false; changelog and tests cover CLI validation, handler behavior, snapshot/restore, and output formatting.Reviewed by Cursor Bugbot for commit 27c53cd. Configure here.