From d4dd1ed6e1a65b85d2025fdfa9d2aa4a07172b19 Mon Sep 17 00:00:00 2001 From: Jeppe Fredsgaard Blaabjerg Date: Fri, 27 Nov 2026 13:00:06 +0100 Subject: [PATCH 1/2] fix(scan): generate facts without downloads under --reach-disable-dependency-downloads A reachability scan with --reach-disable-dependency-downloads passed the option only to Coana's analysis, so the build tools resolving its facts first still downloaded. Facts generation now asks Coana for the same. Co-Authored-By: Claude Opus 5.5 --- src/commands/manifest/run-manifest-facts.mts | 6 ++++ .../manifest/run-manifest-facts.test.mts | 30 ++++++++++++++++++ src/commands/scan/handle-create-new-scan.mts | 2 ++ .../scan/handle-create-new-scan.test.mts | 31 +++++++++++++++++++ 4 files changed, 69 insertions(+) diff --git a/src/commands/manifest/run-manifest-facts.mts b/src/commands/manifest/run-manifest-facts.mts index ebe935661..5306984e3 100644 --- a/src/commands/manifest/run-manifest-facts.mts +++ b/src/commands/manifest/run-manifest-facts.mts @@ -88,6 +88,9 @@ type SocketFactsPurpose = 'upload' | 'fix' | 'reachability' export type SocketFactsContext = { // The Coana that reads `workDir` must be the one that wrote it. coanaVersion?: string | undefined + // Resolve from the build tools' own caches only, as the reachability run + // that reads the facts analyses only what is installed. + disableDependencyDownloads?: boolean | undefined orgSlug?: string | undefined workDir?: SocketFactsWorkDir | undefined } @@ -197,6 +200,9 @@ async function runGenerateSocketFacts( '--output-file', resultFile, ...flags, + ...(context.disableDependencyDownloads + ? ['--disable-dependency-downloads'] + : []), ], context.orgSlug, { diff --git a/src/commands/manifest/run-manifest-facts.test.mts b/src/commands/manifest/run-manifest-facts.test.mts index e712434ab..286683b49 100644 --- a/src/commands/manifest/run-manifest-facts.test.mts +++ b/src/commands/manifest/run-manifest-facts.test.mts @@ -504,6 +504,36 @@ describe('listBuildProjects', () => { }) }) + it.each([true, false])( + 'lists and generates with --disable-dependency-downloads only when its context disables downloads (%s)', + async disableDependencyDownloads => { + coanaAnswers({ projects: [], status: 'listed' }) + await listBuildProjects({ + ...listArgs, + context: { disableDependencyDownloads }, + cwd, + }) + coanaAnswers({ + factsPath: '/r/f', + projects: [], + status: 'generated', + targetPath: '/r/f', + }) + await runManifestFacts({ + ...baseArgs, + context: { disableDependencyDownloads }, + cwd, + staged: true, + }) + for (const { args } of calls) { + expect(args.includes('--disable-dependency-downloads')).toBe( + disableDependencyDownloads, + ) + } + expect(calls).toHaveLength(2) + }, + ) + it('lists with the Coana version and org of its context', async () => { coanaAnswers({ projects: [], status: 'listed' }) await listBuildProjects({ diff --git a/src/commands/scan/handle-create-new-scan.mts b/src/commands/scan/handle-create-new-scan.mts index 0961a4b9c..0d80f7838 100644 --- a/src/commands/scan/handle-create-new-scan.mts +++ b/src/commands/scan/handle-create-new-scan.mts @@ -178,6 +178,8 @@ async function createNewScan( await withTmpDir('socket-auto-manifest-', async manifestTmpDir => { const factsContext: SocketFactsContext = { coanaVersion: reach.reachVersion, + disableDependencyDownloads: + reach.runReachabilityAnalysis && reach.reachDisableDependencyDownloads, orgSlug, workDir: reach.runReachabilityAnalysis ? await createSocketFactsWorkDir( diff --git a/src/commands/scan/handle-create-new-scan.test.mts b/src/commands/scan/handle-create-new-scan.test.mts index 26daecf0b..cf2b02c19 100644 --- a/src/commands/scan/handle-create-new-scan.test.mts +++ b/src/commands/scan/handle-create-new-scan.test.mts @@ -538,6 +538,37 @@ describe('handleCreateNewScan excludePaths', () => { ) }) + it.each([ + { runReachabilityAnalysis: true, expected: true }, + { runReachabilityAnalysis: false, expected: false }, + ])( + 'generates facts without downloads when a reachability scan disables them (reachability: $runReachabilityAnalysis)', + async ({ expected, runReachabilityAnalysis }) => { + mockGenerateRecursiveManifests.mockResolvedValueOnce([ + { + dir: '/repo/service-a', + ecosystem: 'maven', + factsPath: '/repo/service-a/.socket.facts.json', + status: 'generated', + }, + ]) + const config = createConfig({ autoManifest: false, targets: ['/repo'] }) + config.reach.dynamicSbomInference = ['maven'] + config.reach.runReachabilityAnalysis = runReachabilityAnalysis + config.reach.reachDisableDependencyDownloads = true + + await handleCreateNewScan(config) + + expect(mockGenerateRecursiveManifests).toHaveBeenCalledWith( + expect.objectContaining({ + context: expect.objectContaining({ + disableDependencyDownloads: expected, + }), + }), + ) + }, + ) + it('aborts before scan creation when auto-manifest generation fails', async () => { mockGenerateAutoManifest.mockRejectedValueOnce( new Error('Bazel auto-manifest generation failed'), From ce3e9f2fd2ce8aaca306487a48c7fa28824021dc Mon Sep 17 00:00:00 2001 From: Jeppe Fredsgaard Blaabjerg Date: Fri, 27 Nov 2026 18:23:06 +0100 Subject: [PATCH 2/2] docs(changelog): note facts generation honouring --reach-disable-dependency-downloads Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index acf5f1aff..a85148083 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Changed - Updated the Coana CLI to v `15.15.7`. +### Fixed +- With `--reach-disable-dependency-downloads`, `--dynamic-sbom-inference` scans no longer let Gradle, Maven, sbt or .NET download dependencies while generating Socket facts. + ## [1.17.1](https://github.com/SocketDev/socket-cli/releases/tag/v1.17.1) - 2026-11-26 ### Changed