Skip to content

fix(scan): reject every --reach-* modifier when --reach is not enabled - #1493

Merged
Martin Torp (mtorp) merged 2 commits into
v1.xfrom
martin/warn-on-reach-without-reach
Aug 14, 2026
Merged

fix(scan): reject every --reach-* modifier when --reach is not enabled#1493
Martin Torp (mtorp) merged 2 commits into
v1.xfrom
martin/warn-on-reach-without-reach

Conversation

@mtorp

@mtorp Martin Torp (mtorp) commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Problem

Running socket scan create --reach-debug . completes successfully as a plain SBOM scan — no reachability analysis runs, and there is no warning that the flag did nothing. A user can easily believe they have a working reachability scan and ship that report as a reachability assessment.

socket scan create already has a guard ("Reachability analysis flags require --reach to be enabled"), but it relied on a hand-maintained list of flags that had drifted out of sync. Four boolean flags were missing and slipped through silently:

  • --reach-debug
  • --reach-detailed-analysis-log-file
  • --reach-disable-external-tool-checks
  • --reach-retain-facts-file

Fix

Derive the boolean-flag portion of the guard from the reachabilityFlags definition itself (comparing each boolean flag against its declared default), so newly added reach flags are covered automatically instead of relying on the list being kept up to date. The deprecated no-op --reach-disable-analysis-splitting remains exempt on purpose.

With this change, socket scan create --reach-debug . exits non-zero with:

✖ Reachability analysis flags require --reach to be enabled (add --reach flag to use --reach-* options)

Tests

  • New: --reach-debug without --reach fails.
  • New: --reach-retain-facts-file without --reach fails.
  • New: deprecated no-op --reach-disable-analysis-splitting without --reach still succeeds.
  • All 33 cmd-scan-create tests pass; pnpm run check passes.

The 'reachability flags require --reach' guard in 'socket scan create'
relied on a hand-maintained list of flags that had drifted out of sync:
--reach-debug, --reach-detailed-analysis-log-file,
--reach-disable-external-tool-checks, and --reach-retain-facts-file were
missing, so passing them without --reach silently produced a plain SBOM
scan that could be mistaken for a reachability scan.

Derive the boolean-flag check from the reachabilityFlags definition
instead, so newly added flags are covered automatically. The deprecated
no-op --reach-disable-analysis-splitting stays exempt.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice 🙂

Comment thread src/commands/scan/cmd-scan-create.mts Outdated
@mtorp
Martin Torp (mtorp) merged commit 178ece2 into v1.x Aug 14, 2026
10 checks passed
@mtorp
Martin Torp (mtorp) deleted the martin/warn-on-reach-without-reach branch August 14, 2026 11:24
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.

2 participants