Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

### Added
- Catch reachability analyses that stop early: with `--reach-incomplete-analysis-as-error`, `socket scan create --reach` and `socket scan reach` report a vulnerability whose analysis hit the timeout or memory limit before finding a reachable path as an analysis error instead of unreachable.
- Scan many repositories with `--dynamic-sbom-inference` without a `socket.json` in each: `--dynamic-sbom-inference-ignore-unresolved` tolerates unresolved dependencies in every build. A build that cannot be loaded, for example over a missing imported Maven BOM, still fails.

### Changed
- Updated the Coana CLI to v `15.15.10`.
- `--dynamic-sbom-inference` can be passed to every repository: one without a .NET, Gradle, Maven or sbt build is scanned as without the flag instead of failing, and `socket manifest dynamic-sbom-inference` reports that no build root was found and exits successfully.
- `socket scan create` and `socket scan reach` now reject `--ignore-unresolved`, `--exclude-configs`, `--include-configs` and `--verbose` instead of ignoring them, as each could swallow the scan target.

## [1.18.2](https://github.com/SocketDev/socket-cli/releases/tag/v1.18.2) - 2026-12-02

Expand Down
11 changes: 11 additions & 0 deletions docs/dynamic-sbom-inference-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ Only reachability scans read the `reachability` fields, each cascading on its
own, and only for the build tools they run. An invalid value or a field the
build tool does not take fails the scan.

## On the command line

- `socket scan create`, `socket scan reach` and `socket fix` take only
`ignoreUnresolved` as a flag, `--dynamic-sbom-inference-ignore-unresolved`
with `--dynamic-sbom-inference`; set the other fields in `socket.json`.
- `socket manifest dynamic-sbom-inference` takes `--ignore-unresolved`, and
`--verbose` turns on every build's output.
- The ignore-unresolved flag applies to every build and wins over every
`socket.json`, a build's own `builds` entry included. The `--no-` form sets
it to `false`.

## Skipping builds

| To skip | Set | Effect |
Expand Down
1 change: 1 addition & 0 deletions src/commands/fix/cmd-fix.integration.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ describe('socket fix', async () => {
--disable-external-tool-checks Disable external tool checks during fix analysis.
--dynamic-sbom-inference For Gradle, sbt, Maven and .NET: generate a Socket facts SBOM (produced directly by each package manager) per independent build root, instead of one synthetic root. Fixes are then attributed to the projects/modules that actually resolve each vulnerable dependency. The generated files are removed afterwards.
--dynamic-sbom-inference-ecosystems With --dynamic-sbom-inference: generate Socket facts only for these ecosystems, as either a comma separated value or as multiple flags; the others keep their manifest files as they are. Supported: maven (Gradle, Maven, and sbt) and nuget (.NET). Defaults to all of them.
--dynamic-sbom-inference-ignore-unresolved With --dynamic-sbom-inference: warn on unresolved dependencies instead of failing the build (unresolved deps are not emitted to the facts files); overrides each build's socket.json setting. A build that cannot be loaded, for example over a missing imported Maven BOM, still fails.
--ecosystems Limit fix analysis to specific ecosystems. Accepts space- or comma-separated values and is case-insensitive. Defaults to all ecosystems.
--exclude-paths Skip matching paths from the scan entirely: manifests under these paths are not uploaded, and fixes are not applied to workspaces under them. Patterns are anchored micromatch globs matched relative to the target directory (CWD); \`data/postgres/pgdata\` matches that exact path, \`**/pgdata\` matches at any depth. Use this to skip directories the current user cannot read so they do not abort manifest collection. Negation patterns (\`!path\`) are not supported. Accepts a comma-separated value or multiple flags.
--fix-version Override the version of @coana-tech/cli used for fix analysis. Default: <coana-version>.
Expand Down
4 changes: 2 additions & 2 deletions src/commands/fix/cmd-fix.mts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { getDefaultOrgSlug } from '../ci/fetch-default-org-slug.mts'
import { assertValidExcludePaths } from '../scan/exclude-paths.mts'
import {
DYNAMIC_SBOM_INFERENCE_DESCRIPTION,
dynamicSbomInferenceEcosystemsFlags,
dynamicSbomInferenceFlags,
parseDynamicSbomInferenceFlags,
} from '../scan/reachability-flags.mts'

Expand Down Expand Up @@ -191,7 +191,7 @@ Available styles:
default: false,
description: `${DYNAMIC_SBOM_INFERENCE_DESCRIPTION} Fixes are then attributed to the projects/modules that actually resolve each vulnerable dependency. The generated files are removed afterwards.`,
},
...dynamicSbomInferenceEcosystemsFlags,
...dynamicSbomInferenceFlags,
ecosystems: {
type: 'string',
default: [],
Expand Down
17 changes: 16 additions & 1 deletion src/commands/fix/coana-fix-dynamic-sbom-inference.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { promises as fs } from 'node:fs'
import { beforeEach, describe, expect, it, vi } from 'vitest'

import { coanaFix } from './coana-fix.mts'
import { makeDynamicSbomInference } from '../../../test/reachability-options.mts'
import { logger } from '../../utils/logger.mts'

import type { FixConfig } from './types.mts'
Expand Down Expand Up @@ -101,7 +102,7 @@ describe('socket fix --dynamic-sbom-inference', () => {
debug: false,
disableExternalToolChecks: false,
disableMajorUpdates: false,
dynamicSbomInference: ['maven'],
dynamicSbomInference: makeDynamicSbomInference({ purlTypes: ['maven'] }),
ecosystems: [],
exclude: [],
excludePaths: [],
Expand Down Expand Up @@ -163,6 +164,20 @@ describe('socket fix --dynamic-sbom-inference', () => {
expect(generated.remove).toHaveBeenCalledTimes(1)
})

it('passes --dynamic-sbom-inference-ignore-unresolved on to facts generation', async () => {
await coanaFix({
...baseConfig,
dynamicSbomInference: makeDynamicSbomInference({
ignoreUnresolved: true,
purlTypes: ['maven'],
}),
})

expect(mockGenerateSocketFactsForFix).toHaveBeenCalledWith(
expect.objectContaining({ ignoreUnresolved: true, purlTypes: ['maven'] }),
)
})

it('runs Coana as without the flag when no build root was found', async () => {
mockGenerateSocketFactsForFix.mockResolvedValue(undefined)

Expand Down
12 changes: 6 additions & 6 deletions src/commands/fix/coana-fix.mts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ import { withoutDiscardedFacts } from '../scan/run-dynamic-sbom-inference.mts'
import type { GeneratedSocketFacts } from './generated-socket-facts.mts'
import type { FixConfig } from './types.mts'
import type { CResult } from '../../types.mts'
import type { FactsOnlyTypes } from '../../utils/coana.mts'
import type { PURL_Type } from '../../utils/ecosystem.mts'
import type { Spinner } from '../../utils/spinner.mts'
import type { DynamicSbomInference } from '../scan/reachability-flags.mts'

type DiscoverGhsaIdsOptions = {
coanaVersion?: string | undefined
Expand Down Expand Up @@ -283,18 +283,18 @@ function formatNotAppliedFixes(notApplied: NotAppliedFix[]): string {
}

type GeneratedSocketFactsSlot = {
dynamicSbomInference: DynamicSbomInference
generated?: GeneratedSocketFacts | undefined
purlTypes: FactsOnlyTypes
tmpDir: string
}

export async function coanaFix(fixConfig: FixConfig): Promise<CoanaFixResult> {
const purlTypes = fixConfig.dynamicSbomInference
if (!purlTypes) {
const { dynamicSbomInference } = fixConfig
if (!dynamicSbomInference) {
return await coanaFixWithFacts(fixConfig, undefined)
}
return await withTmpDir('socket-fix-facts-', async tmpDir => {
const slot: GeneratedSocketFactsSlot = { purlTypes, tmpDir }
const slot: GeneratedSocketFactsSlot = { dynamicSbomInference, tmpDir }
try {
return await coanaFixWithFacts(fixConfig, slot)
} finally {
Expand Down Expand Up @@ -403,7 +403,7 @@ async function coanaFixWithFacts(
existingPaths: scanFilepaths.filter(isSocketFactsFile),
findFactsPaths: async () =>
(await findScanFilepaths()).filter(isSocketFactsFile),
purlTypes: factsSlot.purlTypes,
...factsSlot.dynamicSbomInference,
tmpDir: factsSlot.tmpDir,
})
factsSlot.generated = generated
Expand Down
7 changes: 4 additions & 3 deletions src/commands/fix/generated-socket-facts.mts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
import { runDynamicSbomInference } from '../scan/run-dynamic-sbom-inference.mts'

import type { FactsOnlyTypes } from '../../utils/coana.mts'
import type { PURL_Type } from '../../utils/ecosystem.mts'
import type { SocketFactsContext } from '../manifest/run-manifest-facts.mts'
import type { DynamicSbomInference } from '../scan/reachability-flags.mts'

export type GeneratedSocketFacts = {
// Facts files of dropped runs, which Coana must not read.
Expand Down Expand Up @@ -53,15 +53,15 @@ export async function generateSocketFactsForFix({
excludePaths,
existingPaths,
findFactsPaths,
ignoreUnresolved,
purlTypes,
tmpDir,
}: {
}: DynamicSbomInference & {
context: Omit<SocketFactsContext, 'workDir'>
cwd: string
excludePaths: string[]
existingPaths: string[]
findFactsPaths: () => Promise<string[]>
purlTypes: readonly PURL_Type[]
tmpDir: string
}): Promise<GeneratedSocketFacts | undefined> {
const originals = await backUp(existingPaths, path.join(tmpDir, 'existing'))
Expand All @@ -86,6 +86,7 @@ export async function generateSocketFactsForFix({
cwd,
excludePaths,
hints: EXCLUDE_PATHS_HINTS,
ignoreUnresolved,
purlTypes,
})
if (!inferred) {
Expand Down
5 changes: 3 additions & 2 deletions src/commands/fix/generated-socket-facts.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import path from 'node:path'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'

import { generateSocketFactsForFix } from './generated-socket-facts.mts'
import { makeDynamicSbomInference } from '../../../test/reachability-options.mts'

const mockRunDynamicSbomInference = vi.hoisted(() => vi.fn())

Expand Down Expand Up @@ -43,7 +44,7 @@ describe('generateSocketFactsForFix', () => {
excludePaths: [],
existingPaths: await factsPaths(),
findFactsPaths: factsPaths,
purlTypes: ['maven'],
...makeDynamicSbomInference({ purlTypes: ['maven'] }),
tmpDir,
})
}
Expand Down Expand Up @@ -101,7 +102,7 @@ describe('generateSocketFactsForFix', () => {
purpose: 'fix',
},
},
purlTypes: ['maven'],
...makeDynamicSbomInference({ purlTypes: ['maven'] }),
}),
)
expect(factsOnlyTypes).toEqual(['maven', 'nuget'])
Expand Down
6 changes: 3 additions & 3 deletions src/commands/fix/types.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { FactsOnlyTypes } from '../../utils/coana.mts'
import type { PURL_Type } from '../../utils/ecosystem.mts'
import type { RangeStyle } from '../../utils/semver.mts'
import type { Spinner } from '../../utils/spinner.mts'
import type { DynamicSbomInference } from '../scan/reachability-flags.mts'

export type FixConfig = {
all: boolean
Expand All @@ -13,8 +13,8 @@ export type FixConfig = {
debug: boolean
disableExternalToolChecks: boolean
disableMajorUpdates: boolean
// The ecosystems to generate Socket facts for; undefined when off.
dynamicSbomInference: FactsOnlyTypes | undefined
// Undefined when off.
dynamicSbomInference: DynamicSbomInference | undefined
ecosystems: PURL_Type[]
exclude: string[]
excludePaths: string[]
Expand Down
31 changes: 19 additions & 12 deletions src/commands/manifest/generate-recursive-manifests.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -977,18 +977,25 @@ describe('generateRecursiveManifests', () => {
)
})

it.each([true, false])(
'lets an explicit ignoreUnresolved (%s) override every build root socket.json',
async ignoreUnresolved => {
mockCascade(dir =>
dir === dualMarkerDir
? {
defaults: {
manifest: { maven: { ignoreUnresolved: !ignoreUnresolved } },
},
}
: {},
)
it.for(
[true, false].flatMap(ignoreUnresolved => [
{
ignoreUnresolved,
manifest: { maven: { ignoreUnresolved: !ignoreUnresolved } },
name: 'tool defaults',
},
{
ignoreUnresolved,
manifest: {
builds: { 'pom.xml': { ignoreUnresolved: !ignoreUnresolved } },
},
name: "a build's own entry",
},
]),
)(
'lets an explicit ignoreUnresolved ($ignoreUnresolved) override socket.json $name',
async ({ ignoreUnresolved, manifest }) => {
mockOwnSettings({ [dualMarkerDir]: { defaults: { manifest } } })
mockFacts(async ({ cwd }) => ({
factsPath: path.join(cwd, '.socket.facts.json'),
projects: [],
Expand Down
8 changes: 4 additions & 4 deletions src/commands/scan/cmd-scan-create.mts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { outputCreateNewScan } from './output-create-new-scan.mts'
import { resolveReachAdvisories } from './reach-advisories.mts'
import {
DYNAMIC_SBOM_INFERENCE_DESCRIPTION,
dynamicSbomInferenceEcosystemsFlags,
dynamicSbomInferenceFlags,
excludePathsFlag,
parseDynamicSbomInferenceFlags,
reachabilityFlags,
Expand All @@ -20,10 +20,10 @@ import {
isOmittedReachValue,
reachMemoryLimitToMb,
} from './reachability-units.mts'
import { rejectManifestOnlyFlags } from './reject-manifest-only-flags.mts'
import { suggestOrgSlug } from './suggest-org-slug.mts'
import { suggestTarget } from './suggest_target.mts'
import { validateReachabilityTarget } from './validate-reachability-target.mts'
import { warnSocketJsonOnlyFlags } from './warn-socket-json-only-flags.mts'
import constants, { REQUIREMENTS_TXT, SOCKET_JSON } from '../../constants.mts'
import { commonFlags, outputFlags } from '../../flags.mts'
import { checkCommandInput } from '../../utils/check-input.mts'
Expand Down Expand Up @@ -134,7 +134,7 @@ const generalFlags: MeowFlags = {
default: false,
description: `${DYNAMIC_SBOM_INFERENCE_DESCRIPTION} Combine with --reach to split the reachability analysis per project/module.`,
},
...dynamicSbomInferenceEcosystemsFlags,
...dynamicSbomInferenceFlags,
interactive: {
type: 'boolean',
default: true,
Expand Down Expand Up @@ -388,7 +388,7 @@ async function run(

const dynamicSbomInference = parseDynamicSbomInferenceFlags(cli.flags)

warnSocketJsonOnlyFlags(cli.flags, `${parentName} ${CMD_NAME}`)
rejectManifestOnlyFlags(cli.flags, `${parentName} ${CMD_NAME}`)

const dryRun = !!cli.flags['dryRun']
const uvMembers = !!cli.flags['uvMembers']
Expand Down
1 change: 1 addition & 0 deletions src/commands/scan/cmd-scan-create.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ describe('socket scan create', async () => {
--default-branch Set the default branch of the repository to the branch of this full-scan. Should only need to be done once, for example for the "main" or "master" branch.
--dynamic-sbom-inference For Gradle, sbt, Maven and .NET: generate a Socket facts SBOM (produced directly by each package manager) per independent build root, instead of one synthetic root. Combine with --reach to split the reachability analysis per project/module.
--dynamic-sbom-inference-ecosystems With --dynamic-sbom-inference: generate Socket facts only for these ecosystems, as either a comma separated value or as multiple flags; the others keep their manifest files as they are. Supported: maven (Gradle, Maven, and sbt) and nuget (.NET). Defaults to all of them.
--dynamic-sbom-inference-ignore-unresolved With --dynamic-sbom-inference: warn on unresolved dependencies instead of failing the build (unresolved deps are not emitted to the facts files); overrides each build's socket.json setting. A build that cannot be loaded, for example over a missing imported Maven BOM, still fails.
--exclude-paths List of glob patterns to exclude from the scan, including SCA/SBOM manifest discovery and (when --reach is enabled) full application reachability analysis. Patterns are anchored micromatch globs matched relative to the Socket scan root, which is the command working directory (\`--cwd\` if set), not the reachability target: \`tests\` matches only \`<cwd>/tests\`; use \`**/tests\` to match at any depth. Negation patterns (\`!path\`) are not supported. Accepts a comma-separated value or multiple flags. An excluded JVM build module or .NET project is not analysed as a project of its own, but where a project that is not excluded depends on it, its code is analysed as part of that project. A build module or project outside the scan root cannot be excluded.
--interactive Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions,
defaulting them to cancel/no.
Expand Down
8 changes: 4 additions & 4 deletions src/commands/scan/cmd-scan-reach.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { handleScanReach } from './handle-scan-reach.mts'
import { resolveReachAdvisories } from './reach-advisories.mts'
import {
DYNAMIC_SBOM_INFERENCE_DESCRIPTION,
dynamicSbomInferenceEcosystemsFlags,
dynamicSbomInferenceFlags,
excludePathsFlag,
parseDynamicSbomInferenceFlags,
reachabilityFlags,
} from './reachability-flags.mts'
import { rejectManifestOnlyFlags } from './reject-manifest-only-flags.mts'
import { suggestTarget } from './suggest_target.mts'
import { validateReachabilityTarget } from './validate-reachability-target.mts'
import { warnSocketJsonOnlyFlags } from './warn-socket-json-only-flags.mts'
import constants from '../../constants.mts'
import { commonFlags, outputFlags } from '../../flags.mts'
import { checkCommandInput } from '../../utils/check-input.mts'
Expand Down Expand Up @@ -50,7 +50,7 @@ const reachabilityFlagsForReach: MeowFlags = {
default: false,
description: `${DYNAMIC_SBOM_INFERENCE_DESCRIPTION} The reachability analysis is split per project/module accordingly.`,
},
...dynamicSbomInferenceEcosystemsFlags,
...dynamicSbomInferenceFlags,
// Fallback targets scan creation, which this command never performs.
reachFallbackToRegularScan: {
type: 'boolean',
Expand Down Expand Up @@ -143,7 +143,7 @@ async function run(
parentName,
})

warnSocketJsonOnlyFlags(cli.flags, `${parentName} ${CMD_NAME}`)
rejectManifestOnlyFlags(cli.flags, `${parentName} ${CMD_NAME}`)

const {
cwd: cwdOverride,
Expand Down
1 change: 1 addition & 0 deletions src/commands/scan/cmd-scan-reach.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('socket scan reach', async () => {
Reachability Options
--dynamic-sbom-inference For Gradle, sbt, Maven and .NET: generate a Socket facts SBOM (produced directly by each package manager) per independent build root, instead of one synthetic root. The reachability analysis is split per project/module accordingly.
--dynamic-sbom-inference-ecosystems With --dynamic-sbom-inference: generate Socket facts only for these ecosystems, as either a comma separated value or as multiple flags; the others keep their manifest files as they are. Supported: maven (Gradle, Maven, and sbt) and nuget (.NET). Defaults to all of them.
--dynamic-sbom-inference-ignore-unresolved With --dynamic-sbom-inference: warn on unresolved dependencies instead of failing the build (unresolved deps are not emitted to the facts files); overrides each build's socket.json setting. A build that cannot be loaded, for example over a missing imported Maven BOM, still fails.
--exclude-paths List of glob patterns to exclude from the scan, including SCA/SBOM manifest discovery and (when --reach is enabled) full application reachability analysis. Patterns are anchored micromatch globs matched relative to the Socket scan root, which is the command working directory (\`--cwd\` if set), not the reachability target: \`tests\` matches only \`<cwd>/tests\`; use \`**/tests\` to match at any depth. Negation patterns (\`!path\`) are not supported. Accepts a comma-separated value or multiple flags. An excluded JVM build module or .NET project is not analysed as a project of its own, but where a project that is not excluded depends on it, its code is analysed as part of that project. A build module or project outside the scan root cannot be excluded.
--reach-advisories List of advisories to run reachability analysis for, as GHSA or CVE IDs, either as a comma separated value or as multiple flags. CVE IDs are converted to GHSA IDs through the GitHub API. Vulnerabilities from other advisories get unknown reachability. Defaults to all advisories.
--reach-analysis-memory-limit The maximum memory for the reachability analysis as a whole number optionally followed by MB or GB (e.g. 512MB, 8GB). The default is 8GB.
Expand Down
Loading
Loading