Skip to content
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

### 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.

### Changed
- Updated the Coana CLI to v `15.15.10`.

Expand Down
1 change: 1 addition & 0 deletions src/commands/ci/handle-ci.mts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export async function handleCi(autoManifest: boolean): Promise<void> {
reachEcosystems: [],
reachExcludePaths: [],
reachFallbackToRegularScan: false,
reachIncompleteAnalysisAsError: false,
reachRetainFactsFile: false,
reachSkipCache: false,
reachUseOnlyPregeneratedSboms: false,
Expand Down
3 changes: 3 additions & 0 deletions src/commands/scan/cmd-scan-create.mts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ async function run(
reachDisableDependencyDownloads,
reachDisableExternalToolChecks,
reachFallbackToRegularScan,
reachIncompleteAnalysisAsError,
reachRetainFactsFile,
reachSkipCache,
reachUseOnlyPregeneratedSboms,
Expand Down Expand Up @@ -373,6 +374,7 @@ async function run(
reachDisableDependencyDownloads: boolean
reachDisableExternalToolChecks: boolean
reachFallbackToRegularScan: boolean
reachIncompleteAnalysisAsError: boolean
reachRetainFactsFile: boolean
reachSkipCache: boolean
reachUseOnlyPregeneratedSboms: boolean
Expand Down Expand Up @@ -810,6 +812,7 @@ async function run(
reachEcosystems,
reachExcludePaths,
reachFallbackToRegularScan: Boolean(reachFallbackToRegularScan),
reachIncompleteAnalysisAsError: Boolean(reachIncompleteAnalysisAsError),
reachRetainFactsFile: Boolean(reachRetainFactsFile),
reachSkipCache: Boolean(reachSkipCache),
reachUseOnlyPregeneratedSboms: Boolean(reachUseOnlyPregeneratedSboms),
Expand Down
3 changes: 2 additions & 1 deletion src/commands/scan/cmd-scan-create.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ describe('socket scan create', async () => {
--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.
--reach-analysis-timeout Set the timeout for the reachability analysis as a whole number optionally followed by s, m or h (e.g. 90s, 10m, 1h). Defaults to 10m. Split analysis runs may cause the total scan time to exceed this timeout significantly.
--reach-concurrency Set the maximum number of concurrent reachability analysis runs. It is recommended to choose a concurrency level that ensures each analysis run has at least the --reach-analysis-memory-limit amount of memory available.
--reach-continue-on-analysis-errors Continue reachability analysis when errors occur (timeouts, OOM, parse errors, etc.), falling back to precomputed reachability results. By default, the CLI halts on analysis errors.
--reach-continue-on-analysis-errors Continue reachability analysis when errors occur (timeouts, OOM, parse errors, etc.), falling back to precomputed reachability results. By default, the CLI halts on analysis errors. With --reach-incomplete-analysis-as-error, an unreachable verdict from an analysis that stopped early is an error too.
--reach-continue-on-install-errors Continue reachability analysis when package installation fails, falling back to precomputed reachability results. By default, the CLI halts on installation errors.
--reach-continue-on-missing-lock-files Continue reachability analysis when a Gradle or SBT project is missing its lock file (or version catalog / pre-generated SBOM). By default, the CLI halts.
--reach-continue-on-no-source-files Continue reachability analysis when a workspace contains no source files for its ecosystem. By default, the CLI halts.
Expand All @@ -248,6 +248,7 @@ describe('socket scan create', async () => {
--reach-disable-external-tool-checks Disable external tool checks during reachability analysis.
--reach-ecosystems List of ecosystems to conduct reachability analysis on, as either a comma separated value or as multiple flags. Supported: cargo, composer, gem, golang, maven, npm, nuget, pypi. Defaults to all supported ecosystems.
--reach-fallback-to-regular-scan If reachability analysis fails, continue with a regular SCA scan (without reachability results) instead of halting. By default, the CLI halts on reachability errors.
--reach-incomplete-analysis-as-error An analysis that stops early (e.g. at --reach-analysis-timeout or --reach-analysis-memory-limit) can report a vulnerability unreachable because it found no path before it stopped. Report such a vulnerability as an analysis error instead. Analysis errors halt the scan unless --reach-continue-on-analysis-errors is set.
--reach-retain-facts-file Keep the \`.socket.facts.json\` reachability report that the analysis writes to the scan directory instead of deleting it after a successful scan. Delete it once inspected: later reachability scans ignore it, but a scan without --reach uploads it as an SBOM carrying stale reachability results.
--reach-skip-cache Skip caching-based optimizations. By default, the reachability analysis will use cached configurations from previous runs to speed up the analysis.
--reach-use-only-pregenerated-sboms When using this option, the scan is created based only on pre-generated CDX and SPDX files in your project.
Expand Down
3 changes: 3 additions & 0 deletions src/commands/scan/cmd-scan-reach.mts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ async function run(
reachDisableAnalytics,
reachDisableDependencyDownloads,
reachDisableExternalToolChecks,
reachIncompleteAnalysisAsError,
reachRetainFactsFile,
reachSkipCache,
reachUseOnlyPregeneratedSboms,
Expand All @@ -187,6 +188,7 @@ async function run(
reachDisableAnalytics: boolean
reachDisableDependencyDownloads: boolean
reachDisableExternalToolChecks: boolean
reachIncompleteAnalysisAsError: boolean
reachRetainFactsFile: boolean
reachSkipCache: boolean
reachUseOnlyPregeneratedSboms: boolean
Expand Down Expand Up @@ -315,6 +317,7 @@ async function run(
reachDisableExternalToolChecks: Boolean(reachDisableExternalToolChecks),
reachEcosystems,
reachExcludePaths,
reachIncompleteAnalysisAsError: Boolean(reachIncompleteAnalysisAsError),
reachRetainFactsFile: Boolean(reachRetainFactsFile),
reachSkipCache: Boolean(reachSkipCache),
reachUseOnlyPregeneratedSboms: Boolean(reachUseOnlyPregeneratedSboms),
Expand Down
3 changes: 2 additions & 1 deletion src/commands/scan/cmd-scan-reach.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('socket scan reach', async () => {
--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.
--reach-analysis-timeout Set the timeout for the reachability analysis as a whole number optionally followed by s, m or h (e.g. 90s, 10m, 1h). Defaults to 10m. Split analysis runs may cause the total scan time to exceed this timeout significantly.
--reach-concurrency Set the maximum number of concurrent reachability analysis runs. It is recommended to choose a concurrency level that ensures each analysis run has at least the --reach-analysis-memory-limit amount of memory available.
--reach-continue-on-analysis-errors Continue reachability analysis when errors occur (timeouts, OOM, parse errors, etc.), falling back to precomputed reachability results. By default, the CLI halts on analysis errors.
--reach-continue-on-analysis-errors Continue reachability analysis when errors occur (timeouts, OOM, parse errors, etc.), falling back to precomputed reachability results. By default, the CLI halts on analysis errors. With --reach-incomplete-analysis-as-error, an unreachable verdict from an analysis that stopped early is an error too.
--reach-continue-on-install-errors Continue reachability analysis when package installation fails, falling back to precomputed reachability results. By default, the CLI halts on installation errors.
--reach-continue-on-missing-lock-files Continue reachability analysis when a Gradle or SBT project is missing its lock file (or version catalog / pre-generated SBOM). By default, the CLI halts.
--reach-continue-on-no-source-files Continue reachability analysis when a workspace contains no source files for its ecosystem. By default, the CLI halts.
Expand All @@ -56,6 +56,7 @@ describe('socket scan reach', async () => {
--reach-disable-dependency-downloads Only analyze dependencies that are already installed (e.g. in the project's .venv, vendor directory or module cache). Missing dependencies count as installation failures.
--reach-disable-external-tool-checks Disable external tool checks during reachability analysis.
--reach-ecosystems List of ecosystems to conduct reachability analysis on, as either a comma separated value or as multiple flags. Supported: cargo, composer, gem, golang, maven, npm, nuget, pypi. Defaults to all supported ecosystems.
--reach-incomplete-analysis-as-error An analysis that stops early (e.g. at --reach-analysis-timeout or --reach-analysis-memory-limit) can report a vulnerability unreachable because it found no path before it stopped. Report such a vulnerability as an analysis error instead. Analysis errors halt the scan unless --reach-continue-on-analysis-errors is set.
--reach-retain-facts-file Keep the \`.socket.facts.json\` reachability report that the analysis writes to the scan directory instead of deleting it after a successful scan. Delete it once inspected: later reachability scans ignore it, but a scan without --reach uploads it as an SBOM carrying stale reachability results.
--reach-skip-cache Skip caching-based optimizations. By default, the reachability analysis will use cached configurations from previous runs to speed up the analysis.
--reach-use-only-pregenerated-sboms When using this option, the scan is created based only on pre-generated CDX and SPDX files in your project.
Expand Down
1 change: 1 addition & 0 deletions src/commands/scan/create-scan-from-github.mts
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ async function scanOneRepo(
reachEcosystems: [],
reachExcludePaths: [],
reachFallbackToRegularScan: false,
reachIncompleteAnalysisAsError: false,
reachRetainFactsFile: false,
reachSkipCache: false,
reachUseOnlyPregeneratedSboms: false,
Expand Down
4 changes: 4 additions & 0 deletions src/commands/scan/perform-reachability-analysis.mts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type ReachabilityOptions = {
reachDisableAnalytics: boolean
reachEcosystems: PURL_Type[]
reachExcludePaths: string[]
reachIncompleteAnalysisAsError: boolean
reachRetainFactsFile: boolean
reachSkipCache: boolean
reachUseOnlyPregeneratedSboms: boolean
Expand Down Expand Up @@ -243,6 +244,9 @@ export async function performReachabilityAnalysis(
...(reachabilityOptions.reachDisableExternalToolChecks
? ['--disable-external-tool-checks']
: []),
...(reachabilityOptions.reachIncompleteAnalysisAsError
? ['--incomplete-analysis-as-error']
: []),
// Older Coana versions split analyses unless this is passed.
'--disable-analysis-splitting',
'--run-without-docker',
Expand Down
12 changes: 12 additions & 0 deletions src/commands/scan/perform-reachability-analysis.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,18 @@ describe('performReachabilityAnalysis flag forwarding', () => {
const args = await coanaArgsFor(scanCwd, { reachAdvisories: [] })
expect(args).not.toContain('--ghsas')
})

it('passes --reach-incomplete-analysis-as-error to Coana as --incomplete-analysis-as-error', async () => {
const args = await coanaArgsFor(scanCwd, {
reachIncompleteAnalysisAsError: true,
})
expect(args).toContain('--incomplete-analysis-as-error')
})

it('omits --incomplete-analysis-as-error by default', async () => {
const args = await coanaArgsFor(scanCwd, {})
expect(args).not.toContain('--incomplete-analysis-as-error')
})
})

describe('performReachabilityAnalysis --use-only-socket-facts-artifacts gating', () => {
Expand Down
8 changes: 7 additions & 1 deletion src/commands/scan/reachability-flags.mts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const reachabilityFlags: MeowFlags = {
type: 'boolean',
default: false,
description:
'Continue reachability analysis when errors occur (timeouts, OOM, parse errors, etc.), falling back to precomputed reachability results. By default, the CLI halts on analysis errors.',
'Continue reachability analysis when errors occur (timeouts, OOM, parse errors, etc.), falling back to precomputed reachability results. By default, the CLI halts on analysis errors. With --reach-incomplete-analysis-as-error, an unreachable verdict from an analysis that stopped early is an error too.',
},
reachContinueOnInstallErrors: {
type: 'boolean',
Expand Down Expand Up @@ -160,6 +160,12 @@ export const reachabilityFlags: MeowFlags = {
description:
'If reachability analysis fails, continue with a regular SCA scan (without reachability results) instead of halting. By default, the CLI halts on reachability errors.',
},
reachIncompleteAnalysisAsError: {
type: 'boolean',
default: false,
description:
'An analysis that stops early (e.g. at --reach-analysis-timeout or --reach-analysis-memory-limit) can report a vulnerability unreachable because it found no path before it stopped. Report such a vulnerability as an analysis error instead. Analysis errors halt the scan unless --reach-continue-on-analysis-errors is set.',
},
reachLazyMode: {
type: 'boolean',
default: false,
Expand Down
1 change: 1 addition & 0 deletions test/reachability-options.mts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function makeReachabilityOptions(): ReachabilityOptions {
reachDisableExternalToolChecks: false,
reachEcosystems: [],
reachExcludePaths: [],
reachIncompleteAnalysisAsError: false,
reachRetainFactsFile: false,
reachSkipCache: false,
reachUseOnlyPregeneratedSboms: false,
Expand Down
Loading
Loading