Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f0f699a
Generate Socket facts with Coana
jfblaa Nov 17, 2026
479beb9
Write the generate-socket-facts request of its contract version
jfblaa Nov 20, 2026
7f066b1
Name the purpose Coana generates each root's facts for
jfblaa Nov 24, 2026
12e585b
Run auto-manifest's Maven where the scan starts
jfblaa Nov 25, 2026
53c2b04
Tell a failed solution listing from an unreadable solution
jfblaa Nov 25, 2026
dae0d20
Say when the scan excludes a module's old facts file
jfblaa Nov 25, 2026
3cb966e
Tighten comments on facts generation and the Coana launcher
jfblaa Nov 25, 2026
a0bdf83
Name test helpers for what they do instead of commenting them
jfblaa Nov 25, 2026
7efaeb8
Restore what the Coana launcher comments said about versions
jfblaa Nov 25, 2026
17c261f
Drop the Coana launcher comments that repeat the test name and the re…
jfblaa Nov 25, 2026
f2d6627
Drop the test header's bullet for the standalone build's embedded Coana
jfblaa Nov 25, 2026
63f04c9
Drop the standalone build's .NET facts smoke step
jfblaa Nov 25, 2026
75ee891
Require the first Coana with generate-socket-facts, not the pinned one
jfblaa Nov 26, 2026
71f2129
Import buildRootPath and realpathOrResolved from where they live
jfblaa Nov 26, 2026
7a746a1
Read Coana's result with readJson
jfblaa Nov 26, 2026
19abd04
Keep SocketFactsPurpose private and inline the request's hints
jfblaa Nov 26, 2026
4cb0b98
Count a loaded build's projects inside its exclusion base
jfblaa Nov 26, 2026
5eeb1ad
List a walked build's .NET members with the walk's own run options
jfblaa Nov 26, 2026
ca22989
Resolve each auto-manifest tool's settings once for both of its modes
jfblaa Nov 26, 2026
8d6cfff
Pass mavenOpts to Maven as written when walking builds
jfblaa Nov 26, 2026
8c0bc85
Place a build's facts when it is generated, unless the walk stages it
jfblaa Nov 26, 2026
9339970
Carry the facts' purpose in one work dir type for every consumer
jfblaa Nov 26, 2026
86d4b28
Hand every facts generation of a command the same flag hints
jfblaa Nov 26, 2026
a1fbe6b
Describe the walk tests' projects as Coana reports them
jfblaa Nov 26, 2026
20927cd
Order the work dir helpers and scan options, and say what the flag hi…
jfblaa Nov 26, 2026
9fa41ab
List a build with the run options it is generated with
jfblaa Nov 26, 2026
bdd7556
Install the test's Coana versions into the cache at once
jfblaa Nov 26, 2026
c9d4040
Say that a cache lookup takes an exact version
jfblaa Nov 26, 2026
5bafbea
Call it the Coana CLI in the changelog, as its version bumps do
jfblaa Nov 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -599,19 +599,12 @@
!/src/commands/manifest/convert-conda-to-requirements.mts
!/src/commands/manifest/convert-conda-to-requirements.test.mts
!/src/commands/manifest/convert-dotnet-to-facts.mts
!/src/commands/manifest/convert-gradle-to-facts.mts
!/src/commands/manifest/convert-maven-to-facts.mts
!/src/commands/manifest/convert-sbt-to-facts.mts
!/src/commands/manifest/convert_gradle_to_maven.mts
!/src/commands/manifest/convert_sbt_to_maven.mts
!/src/commands/manifest/detect-manifest-actions.mts
!/src/commands/manifest/detect-manifest-actions.test.mts
!/src/commands/manifest/discover-manifest-roots.mts
!/src/commands/manifest/discover-manifest-roots.test.mts
!/src/commands/manifest/enumerate-workspaces.mts
!/src/commands/manifest/enumerate-workspaces.test.mts
!/src/commands/manifest/expand-env-var-refs.mts
!/src/commands/manifest/expand-env-var-refs.test.mts
!/src/commands/manifest/generate-recursive-manifests.mts
!/src/commands/manifest/generate-recursive-manifests.test.mts
!/src/commands/manifest/generate_auto_manifest.mts
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

### Added
- Socket facts for a self-contained .NET build include its runtime packs.

### Changed
- Updated the Coana CLI to v `15.15.4`.
- The Coana CLI now generates Socket facts for Gradle, Maven, sbt and .NET builds, so generating them downloads the Coana CLI and needs network access and a Socket API token.
- `--reach-version` and `--fix-version` also select the Coana CLI that generates Socket facts, which must be 15.15.4 or newer.
- With `--dynamic-sbom-inference`, reachability analyzes each JVM project on the classpath its build resolved, and `socket fix` restores a build's files when an upgrade does not take.
- `--ignore-unresolved` no longer lets through a build whose resolution did not run, or a failure that names no project.
- `--dynamic-sbom-inference` passes `mavenOpts` to Maven as written, without warning about a `--file` in them: each POM is still built by its own file.

## [1.16.1](https://github.com/SocketDev/socket-cli/releases/tag/v1.16.1) - 2026-11-24

Expand Down
6 changes: 3 additions & 3 deletions src/commands/fix/coana-fix-dynamic-sbom-inference.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ describe('socket fix --dynamic-sbom-inference', () => {
)
const args = coanaCalls('compute-fixes-and-upgrade-purls')[0]!
expect(args).toContain('--maven-use-only-socket-facts')
expect(args).toContain('--compute-artifacts-sidecar')
expect(args[args.indexOf('--compute-artifacts-sidecar') + 1]).toBe(
expect(args).toContain('--socket-facts-sidecar')
expect(args[args.indexOf('--socket-facts-sidecar') + 1]).toBe(
generated.sidecarFile,
)
expect(generated.remove).toHaveBeenCalledTimes(1)
Expand All @@ -178,7 +178,7 @@ describe('socket fix --dynamic-sbom-inference', () => {

const args = coanaCalls('find-vulnerabilities')[0]
expect(args).toContain('--maven-use-only-socket-facts')
expect(args).not.toContain('--compute-artifacts-sidecar')
expect(args).not.toContain('--socket-facts-sidecar')
})

it('regenerates facts files that were already present, uploading each once', async () => {
Expand Down
8 changes: 4 additions & 4 deletions src/commands/fix/coana-fix.mts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ async function coanaFixWithFacts(
logger.info('Generating Socket facts for each build ...')
}
factsSlot.generated = await generateSocketFactsForFix({
context: { coanaVersion, orgSlug },
cwd,
excludePaths,
purlTypes: factsSlot.purlTypes,
Expand All @@ -414,13 +415,12 @@ async function coanaFixWithFacts(
}
}
const sidecarFile = factsSlot?.generated?.sidecarFile
// Discovery only needs which artifacts the facts files resolve. Applying
// fixes reads each project's tree; a Coana predating facts trees can only
// tell from the sidecar's classpaths which projects resolve an artifact.
// Discovery reads the artifacts resolved by the facts files.
// Applying a fix also reads the saved state for each build root.
const discoveryFlags = factsSlot?.generated?.artifactsFlags ?? []
const factsFlags = [
...discoveryFlags,
...(sidecarFile ? ['--compute-artifacts-sidecar', sidecarFile] : []),
...(sidecarFile ? ['--socket-facts-sidecar', sidecarFile] : []),
]
const uploadCResult = await handleApiCall(
sockSdk.uploadManifestFiles(orgSlug, scanFilepaths, {
Expand Down
40 changes: 24 additions & 16 deletions src/commands/fix/generated-socket-facts.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@ import { copyFile, mkdir, rm, writeFile } from 'node:fs/promises'
import path from 'node:path'

import { useOnlySocketFactsArtifactsFlags } from '../../utils/coana.mts'
import {
EXCLUDE_PATHS_HINTS,
createSocketFactsWorkDir,
socketFactsSidecar,
} from '../manifest/run-manifest-facts.mts'
import { runDynamicSbomInference } from '../scan/run-dynamic-sbom-inference.mts'

import type { PURL_Type } from '../../utils/ecosystem.mts'
import type { SocketFactsContext } from '../manifest/run-manifest-facts.mts'

export type GeneratedSocketFacts = {
// Coana's flags selecting what the facts files resolve.
artifactsFlags: string[]
// Facts files of dropped runs, which Coana must not read.
discardedPaths: string[]
paths: string[]
// The facts files' per-project classpaths, written outside the repository.
// Records each build root's saved state for `--socket-facts-sidecar`.
// The file lives outside the repository.
sidecarFile: string
remove: () => Promise<void>
restore: () => Promise<void>
Expand Down Expand Up @@ -40,12 +47,14 @@ async function restoreAll(backups: Backup[]): Promise<void> {
// Backed up so each fix attempt sees the pre-fix build after `git clean`, and
// facts files already present are left as they were found.
export async function generateSocketFactsForFix({
context,
cwd,
excludePaths,
findFactsPaths,
purlTypes,
tmpDir,
}: {
context: Omit<SocketFactsContext, 'workDir'>
cwd: string
excludePaths: string[]
findFactsPaths: () => Promise<string[]>
Expand All @@ -65,25 +74,25 @@ export async function generateSocketFactsForFix({
let discardedPaths: string[]
let paths: string[]
const sidecarFile = path.join(tmpDir, 'sidecar.json')
const workDir = await createSocketFactsWorkDir(
path.join(tmpDir, 'work'),
'fix',
)
try {
const {
discardedFactsPaths,
factsOnlyTypes,
factsPaths,
resolvedPathsSidecar,
} = await runDynamicSbomInference({
consumer: 'fix',
cwd,
excludePaths,
purlTypes,
sbtTmpDir: undefined,
})
const { discardedFactsPaths, factsOnlyTypes, factsPaths } =
await runDynamicSbomInference({
context: { ...context, workDir },
cwd,
excludePaths,
hints: EXCLUDE_PATHS_HINTS,
purlTypes,
})
artifactsFlags = useOnlySocketFactsArtifactsFlags(factsOnlyTypes)
discardedPaths = discardedFactsPaths
paths = factsPaths.map(p => path.resolve(cwd, p))
// Written even when empty, as for reach; applying fixes looks each facts
// file up in it, so an empty one is the same as none.
await writeFile(sidecarFile, JSON.stringify(resolvedPathsSidecar ?? {}))
await writeFile(sidecarFile, JSON.stringify(socketFactsSidecar(workDir)))
} catch (e) {
// A failed build root aborts inference after others wrote their facts.
await reset(await findFactsPaths())
Expand All @@ -99,8 +108,7 @@ export async function generateSocketFactsForFix({
discardedPaths,
paths,
sidecarFile,
// A discarded file a run left as written is removed too.
remove: () => reset([...paths, ...discardedPaths]),
remove: () => reset(paths),
restore: () => restoreAll(backups),
}
}
50 changes: 23 additions & 27 deletions src/commands/fix/generated-socket-facts.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('generateSocketFactsForFix', () => {

async function generate() {
return await generateSocketFactsForFix({
context: { coanaVersion: '1.2.3', orgSlug: 'acme' },
cwd,
excludePaths: [],
findFactsPaths: async () => [existing, fresh].filter(p => existsSync(p)),
Expand Down Expand Up @@ -67,51 +68,46 @@ describe('generateSocketFactsForFix', () => {
expect(existsSync(fresh)).toBe(false)
})

it('removes a discarded facts file a dropped run left behind', async () => {
const discarded = path.join(cwd, 'sub', 'pom.xml.socket.facts.json')
mockRunDynamicSbomInference.mockImplementation(async () => {
await fs.writeFile(discarded, 'dropped')
return {
discardedFactsPaths: [discarded, existing],
factsOnlyTypes: ['maven'],
factsPaths: [],
}
})

const generated = await generate()
await generated.remove()

expect(existsSync(discarded)).toBe(false)
expect(await fs.readFile(existing, 'utf8')).toBe('original')
})

it('writes the sidecar outside the repository', async () => {
mockRunDynamicSbomInference.mockImplementation(async () => {
it('keeps what Coana kept of each build root outside the repository', async () => {
const entry = { factsFile: fresh, stateDir: path.join(tmpDir, 'work', 'x') }
let workDirExisted = false
mockRunDynamicSbomInference.mockImplementation(async ({ context }) => {
workDirExisted = existsSync(context.workDir.dir)
await fs.writeFile(fresh, 'generated')
context.workDir.entries.set(entry.factsFile, entry)
return {
discardedFactsPaths: [],
factsOnlyTypes: ['maven', 'nuget'],
factsPaths: [fresh],
resolvedPathsSidecar: { [fresh]: { components: [], projects: [] } },
}
})

const { artifactsFlags, sidecarFile } = await generate()

expect(workDirExisted).toBe(true)
expect(mockRunDynamicSbomInference).toHaveBeenCalledWith(
expect.objectContaining({ consumer: 'fix', purlTypes: ['maven'] }),
expect.objectContaining({
context: {
coanaVersion: '1.2.3',
orgSlug: 'acme',
workDir: {
dir: path.join(tmpDir, 'work'),
entries: new Map([[entry.factsFile, entry]]),
purpose: 'fix',
},
},
purlTypes: ['maven'],
}),
)
expect(artifactsFlags).toEqual([
'--use-only-socket-facts-artifacts',
'maven,nuget',
])
expect(path.dirname(sidecarFile)).toBe(tmpDir)
expect(JSON.parse(await fs.readFile(sidecarFile, 'utf8'))).toEqual({
[fresh]: { components: [], projects: [] },
})
expect(JSON.parse(await fs.readFile(sidecarFile, 'utf8'))).toEqual([entry])
})

it('writes an empty sidecar when no build root resolved any paths', async () => {
it('writes an empty sidecar when no build root generated facts', async () => {
mockRunDynamicSbomInference.mockResolvedValue({
discardedFactsPaths: [],
factsOnlyTypes: ['maven'],
Expand All @@ -121,7 +117,7 @@ describe('generateSocketFactsForFix', () => {
const { artifactsFlags, sidecarFile } = await generate()

expect(artifactsFlags).toEqual(['--maven-use-only-socket-facts'])
expect(JSON.parse(await fs.readFile(sidecarFile, 'utf8'))).toEqual({})
expect(JSON.parse(await fs.readFile(sidecarFile, 'utf8'))).toEqual([])
})

it('restores an existing facts file that generation does not rewrite', async () => {
Expand Down
8 changes: 6 additions & 2 deletions src/commands/manifest/build-root-config.mts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { existsSync } from 'node:fs'
import path from 'node:path'

import { buildRootPath, isBuildFile } from './discover-manifest-roots.mts'
import { BUILD_FILES, BUILD_TOOLS } from './scripts/build-tool.mts'
import { isBuildFile } from './discover-manifest-roots.mts'
import {
BUILD_FILES,
BUILD_TOOLS,
buildRootPath,
} from './scripts/build-tool.mts'
import { SOCKET_JSON } from '../../constants.mts'
import { InputError } from '../../utils/errors.mts'
import { getOrInsert } from '../../utils/get-or-insert.mts'
Expand Down
20 changes: 9 additions & 11 deletions src/commands/manifest/cmd-manifest-auto.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import path from 'node:path'
import { detectManifestActions } from './detect-manifest-actions.mts'
import { generateAutoManifest } from './generate_auto_manifest.mts'
import { excludePathsFlag } from './manifest-flags.mts'
import { EXCLUDE_PATHS_HINTS } from './run-manifest-facts.mts'
import constants from '../../constants.mts'
import { commonFlags } from '../../flags.mts'
import { cmdFlagValueToArray } from '../../utils/cmd.mts'
import { debugDir } from '../../utils/debug.mts'
import { withTmpDir } from '../../utils/fs.mts'
import { getOutputKind } from '../../utils/get-output-kind.mts'
import { logger } from '../../utils/logger.mts'
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
Expand Down Expand Up @@ -124,16 +124,14 @@ async function run(
const excludePaths = cmdFlagValueToArray(cli.flags['excludePaths'])
assertValidExcludePaths(excludePaths)

await withTmpDir('socket-manifest-auto-', tmpDir =>
generateAutoManifest({
detected,
cwd,
excludePaths,
outputKind,
tmpDir,
verbose,
}),
)
await generateAutoManifest({
detected,
cwd,
excludePaths,
hints: EXCLUDE_PATHS_HINTS,
outputKind,
verbose,
})

logger.success(
`Finished. Should have attempted to generate manifest files for ${detected.count} targets.`,
Expand Down
7 changes: 4 additions & 3 deletions src/commands/manifest/cmd-manifest-gradle.mts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from 'node:path'

import { convertGradleToFacts } from './convert-gradle-to-facts.mts'
import { convertGradleToMaven } from './convert_gradle_to_maven.mts'
import { excludePathsFlag } from './manifest-flags.mts'
import { parseBuildToolOpts } from './parse-build-tool-opts.mts'
import { runManifestFacts } from './run-manifest-facts.mts'
import { resolveBuildToolBin } from './scripts/build-tool.mts'
import constants, { REQUIREMENTS_TXT, SOCKET_JSON } from '../../constants.mts'
import { commonFlags } from '../../flags.mts'
Expand Down Expand Up @@ -296,12 +296,13 @@ async function run(
assertValidExcludePaths(excludePaths)

if (facts) {
await convertGradleToFacts({
await runManifestFacts({
bin: String(bin),
buildOpts: parsedGradleOpts,
cwd,
ecosystem: 'gradle',
excludeConfigs: String(excludeConfigs || ''),
excludePaths,
gradleOpts: parsedGradleOpts,
ignoreUnresolved: Boolean(ignoreUnresolved),
includeConfigs: String(includeConfigs || ''),
javaHome,
Expand Down
7 changes: 4 additions & 3 deletions src/commands/manifest/cmd-manifest-kotlin.mts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from 'node:path'

import { convertGradleToFacts } from './convert-gradle-to-facts.mts'
import { convertGradleToMaven } from './convert_gradle_to_maven.mts'
import { excludePathsFlag } from './manifest-flags.mts'
import { parseBuildToolOpts } from './parse-build-tool-opts.mts'
import { runManifestFacts } from './run-manifest-facts.mts'
import { resolveBuildToolBin } from './scripts/build-tool.mts'
import constants, { REQUIREMENTS_TXT, SOCKET_JSON } from '../../constants.mts'
import { commonFlags } from '../../flags.mts'
Expand Down Expand Up @@ -299,12 +299,13 @@ async function run(
assertValidExcludePaths(excludePaths)

if (facts) {
await convertGradleToFacts({
await runManifestFacts({
bin: String(bin),
buildOpts: parsedGradleOpts,
cwd,
ecosystem: 'gradle',
excludeConfigs: String(excludeConfigs || ''),
excludePaths,
gradleOpts: parsedGradleOpts,
ignoreUnresolved: Boolean(ignoreUnresolved),
includeConfigs: String(includeConfigs || ''),
javaHome,
Expand Down
7 changes: 4 additions & 3 deletions src/commands/manifest/cmd-manifest-maven.mts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'node:path'

import { convertMavenToFacts } from './convert-maven-to-facts.mts'
import { excludePathsFlag } from './manifest-flags.mts'
import { parseBuildToolOpts } from './parse-build-tool-opts.mts'
import { runManifestFacts } from './run-manifest-facts.mts'
import { resolveBuildToolBin } from './scripts/build-tool.mts'
import constants, { SOCKET_JSON } from '../../constants.mts'
import { commonFlags } from '../../flags.mts'
Expand Down Expand Up @@ -233,15 +233,16 @@ async function run(
const excludePaths = cmdFlagValueToArray(cli.flags['excludePaths'])
assertValidExcludePaths(excludePaths)

await convertMavenToFacts({
await runManifestFacts({
bin: String(bin),
buildOpts: parsedMavenOpts,
cwd,
ecosystem: 'maven',
excludeConfigs: String(excludeConfigs || ''),
excludePaths,
ignoreUnresolved: Boolean(ignoreUnresolved),
includeConfigs: String(includeConfigs || ''),
javaHome,
mavenOpts: parsedMavenOpts,
verbose: Boolean(verbose),
})
}
Loading
Loading