make --dynamic-sbom-inference a standalone flag - #1500
Open
Jeppe Fredsgaard Blaabjerg (jfblaa) wants to merge 1 commit into
Open
Conversation
The flag lived in reachabilityFlags, so when the --reach guard switched from a hand-maintained list to a derivation over every boolean in that object, `scan create . --dynamic-sbom-inference` started failing with "Reachability analysis flags require --reach to be enabled". It is not a --reach-* modifier; move it to generalFlags so the guard no longer sees it and the help text stops filing it under Reachability Options. It also implied --auto-manifest to get its per-build-root facts generated, and the handler suppressed only the JVM entries of the detection result before calling generateAutoManifest. Conda and Bazel survived that, so asking for JVM dynamic SBOM inference generated their manifests too. Run the recursive JVM generation on its own instead, and reach generateAutoManifest only when --auto-manifest was genuinely requested, which also makes the two flags additive rather than one silently forcing the other. Drops the side effect where the forced auto-manifest overrode an explicit `autoManifest: false` in socket.json.
Jeppe Fredsgaard Blaabjerg (jfblaa)
requested a review
from Martin Torp (mtorp)
August 18, 2026 07:10
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.
Fixes two user-visible problems with
--dynamic-sbom-inference, both stemming from where the flag was filed rather than from what it does. See REA-712.Problem 1 — rejected without
--reachsocket scan create . --dynamic-sbom-inferencefailed with:The flag lived in
reachabilityFlags. #1493 replaced that guard's hand-maintained list with a derivation over every boolean in that object, exempting onlyreachDisableAnalysisSplitting— so this flag got swept up incidentally. It is not a--reach-*modifier, #1493's description never names it, and no test asserted the new behaviour.Rather than add a second exemption, this moves the flag into
generalFlags. That fixes the guard, stops it printing under "Reachability Options (when --reach is used)", and keeps the next change to the derived guard from re-breaking it.reachabilityFlagsnow contains onlyreach*flags, which is what the derivation assumes.Problem 2 — implying
--auto-manifestgenerated Conda and Bazel manifestsThe flag forced
autoManifest = trueto get its per-build-root facts generated, andhandleCreateNewScanthen suppressed only the JVM entries of the detection result before callinggenerateAutoManifest.detected.condaanddetected.bazelsurvived, so a repository containing a Conda environment or a Bazel workspace had those manifests generated as a side effect of asking for JVM dynamic SBOM inference.Clearing those two booleans as well would have broken the legitimate
--auto-manifest --dynamic-sbom-inferencecombination, where they should be generated. The forcing is the real defect: it destroys the information about whether the user asked for auto-manifest at all. So the oneif (autoManifest)block is split into two independent halves underif (autoManifest || reach.dynamicSbomInference):reach.dynamicSbomInferencedetectManifestActions+generateAutoManifest, gated onautoManifestThe existing JVM zeroing stays inside the second half, so the combined case still doesn't resolve cwd's own build root twice and race on the same
.socket.facts.json. The sidecar merge,scanTargetsunion, andexcludePathsanchoring are unchanged — they already handled either path contributing or not.Net effect:
--dynamic-sbom-inferencegenerates Gradle, sbt, and Maven and nothing else; the two flags are additive instead of one silently forcing the other.Other changes
!dynamicSbomInferenceto the "Detected N manifest targets…" hint, which was previously suppressed only as a side effect of the forcedautoManifest.reachabilityFlagsForReachwrapper incmd-scan-reach.mts. It existed only to re-hide the flag and readreachabilityFlags['dynamicSbomInference']!.description, which would now throw on undefined.socket scan reachstill hardcodesdynamicSbomInference: falseand is otherwise untouched — it stays an internal debugging command.Also drops the side effect where the forced auto-manifest overrode an explicit
autoManifest: falseinsocket.json.Tests
There were none for this flag outside the
--helpsnapshot, which is why the regression shipped. Added:--dynamic-sbom-inferencewithout--reachincmd-scan-create.test.mts— asserts exit 0 and that the guard message is absent.handle-create-new-scan.test.mtscase assertinggenerateAutoManifestis never called when the flag is used alone. That is the actual Conda/Bazel invariant, and there is no buildable Conda or Bazel fixture to assert it end-to-end.Retitled the existing combined-flags test to say so explicitly, and switched the four standalone-path tests from
autoManifest: truetofalsenow that the CLI no longer forces the pairing. Help snapshot regenerated: the flag moved from Reachability Options into Options.pnpm run checkpasses. Full unit suite green (1728 passed, 2 skipped).Docs impact
Once this ships, the baseline-scan step in the Gradle reachability guide in SocketDev/docs can collapse from two commands to a single
socket scan create . --dynamic-sbom-inference.Related: #1484 (introduced the flag), #1493 (introduced the regression), #1486 (fail-closed when no JVM build root is found).
Note
Medium Risk
Changes scan-create manifest orchestration and flag validation; behavior shifts for users who relied on implicit
--auto-manifestwith--dynamic-sbom-inference, but scope is limited to CLI scan/manifest paths with added regression tests.Overview
--dynamic-sbom-inferenceis a generalsocket scan createoption again, not a reach-only flag. It no longer trips the “Reachability analysis flags require--reach” guard or appears under reachability help.Manifest generation is split by intent: recursive Gradle/sbt/Maven facts run when this flag is set;
generateAutoManifest(Conda, Bazel, etc.) runs only when--auto-manifestis set. The old behavior that forcedautoManifest = trueand could pull in non-JVM ecosystems is removed. With both flags, JVM roots are still generated recursively first and duplicate cwd JVM work in auto-manifest is skipped.socket scan reachdrops the wrapper that hid the flag; it still hardcodesdynamicSbomInference: false.Tests and CHANGELOG document standalone use and the Conda/Bazel side-effect fix.
Reviewed by Cursor Bugbot for commit 9165955. Configure here.