Skip to content

Commit d7a3dc9

Browse files
authored
Reachability analysis improvements (#709)
* use shared performReachabilityAnalysis for socket scan create --reach * add API Token Requirements to socket scan reach help description * use reachabilityReport instead of scanPaths for ReachabilityAnalysisResult * remove --reach-continue-on-failing-projects since it's now the default behaviour * upgrade coana CLI to version 14.11.10 * use the new Coana CLI flag --purl-types instead of computing --reach-ecosystems to legacy Coana-compatible advisory ecosystems
1 parent 70fe2a7 commit d7a3dc9

13 files changed

+28
-350
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"@babel/preset-typescript": "7.27.1",
8585
"@babel/runtime": "7.28.3",
8686
"@biomejs/biome": "2.2.0",
87-
"@coana-tech/cli": "14.11.8",
87+
"@coana-tech/cli": "14.11.10",
8888
"@cyclonedx/cdxgen": "11.5.0",
8989
"@dotenvx/dotenvx": "1.48.4",
9090
"@eslint/compat": "1.3.2",

src/commands/ci/handle-ci.mts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export async function handleCi(autoManifest: boolean): Promise<void> {
3939
pullRequest: 0,
4040
reach: {
4141
runReachabilityAnalysis: false,
42-
reachContinueOnFailingProjects: false,
4342
reachDisableAnalytics: false,
4443
reachAnalysisTimeout: 0,
4544
reachAnalysisMemoryLimit: 0,

src/commands/scan/cmd-scan-create.mts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ async function run(
218218
reach,
219219
reachAnalysisMemoryLimit,
220220
reachAnalysisTimeout,
221-
reachContinueOnFailingProjects,
222221
reachDisableAnalytics,
223222
readOnly,
224223
setAsAlertsPage: pendingHeadFlag,
@@ -241,7 +240,6 @@ async function run(
241240
reach: boolean
242241
reachAnalysisTimeout: number
243242
reachAnalysisMemoryLimit: number
244-
reachContinueOnFailingProjects: boolean
245243
reachDisableAnalytics: boolean
246244
}
247245

@@ -467,13 +465,6 @@ async function run(
467465
message: 'The --reachEcosystems flag requires --reach to be set',
468466
fail: 'missing --reach flag',
469467
},
470-
{
471-
nook: true,
472-
test: reach || !reachContinueOnFailingProjects,
473-
message:
474-
'The --reachContinueOnFailingProjects flag requires --reach to be set',
475-
fail: 'missing --reach flag',
476-
},
477468
{
478469
nook: true,
479470
test: reach || !reachExcludePaths.length,
@@ -505,7 +496,6 @@ async function run(
505496
pullRequest: Number(pullRequest),
506497
reach: {
507498
runReachabilityAnalysis: Boolean(reach),
508-
reachContinueOnFailingProjects: Boolean(reachContinueOnFailingProjects),
509499
reachDisableAnalytics: Boolean(reachDisableAnalytics),
510500
reachAnalysisTimeout: Number(reachAnalysisTimeout),
511501
reachAnalysisMemoryLimit: Number(reachAnalysisMemoryLimit),

src/commands/scan/cmd-scan-create.test.mts

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ describe('socket scan create', async () => {
4545
Reachability Options (when --reach is used)
4646
--reach-analysis-memory-limit The maximum memory in MB to use for the reachability analysis. The default is 8192MB.
4747
--reach-analysis-timeout Set timeout for the reachability analysis. Split analysis runs may cause the total scan time to exceed this timeout significantly.
48-
--reach-continue-on-failing-projects Continue reachability analysis even when some projects/workspaces fail. Default is to crash the CLI at the first failing project/workspace.
4948
--reach-disable-analytics Disable reachability analytics sharing with Socket. Also disables caching-based optimizations.
5049
--reach-ecosystems List of ecosystems to conduct reachability analysis on, as either a comma separated value or as multiple flags. Defaults to all ecosystems.
5150
--reach-exclude-paths List of paths to exclude from reachability analysis, as either a comma separated value or as multiple flags.
@@ -285,37 +284,6 @@ describe('socket scan create', async () => {
285284
},
286285
)
287286

288-
cmdit(
289-
[
290-
'scan',
291-
'create',
292-
'--org',
293-
'fakeOrg',
294-
'target',
295-
'--dry-run',
296-
'--repo',
297-
'xyz',
298-
'--branch',
299-
'abc',
300-
'--reach-continue-on-failing-projects',
301-
'--config',
302-
'{"apiToken":"fakeToken"}',
303-
],
304-
'should fail when --reach-continue-on-failing-projects is used without --reach',
305-
async cmd => {
306-
const { code, stderr, stdout } = await invokeNpm(binCliPath, cmd)
307-
const output = stdout + stderr
308-
expect(output).toContain(
309-
'The --reachContinueOnFailingProjects flag requires --reach to be set',
310-
)
311-
expect(output).toContain('missing --reach flag')
312-
expect(
313-
code,
314-
'should exit with non-zero code when validation fails',
315-
).not.toBe(0)
316-
},
317-
)
318-
319287
cmdit(
320288
[
321289
'scan',
@@ -394,39 +362,6 @@ describe('socket scan create', async () => {
394362
'--branch',
395363
'abc',
396364
'--reach',
397-
'--reach-continue-on-failing-projects',
398-
'--reach-disable-analytics',
399-
'--reach-analysis-memory-limit',
400-
'4096',
401-
'--reach-analysis-timeout',
402-
'3600',
403-
'--reach-ecosystems',
404-
'npm',
405-
'--config',
406-
'{"apiToken":"fakeToken"}',
407-
],
408-
'should succeed when all reachability options including reachContinueOnFailingProjects are used with --reach',
409-
async cmd => {
410-
const { code, stdout } = await invokeNpm(binCliPath, cmd)
411-
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
412-
expect(code, 'should exit with code 0 when all flags are valid').toBe(0)
413-
},
414-
)
415-
416-
cmdit(
417-
[
418-
'scan',
419-
'create',
420-
'--org',
421-
'fakeOrg',
422-
'target',
423-
'--dry-run',
424-
'--repo',
425-
'xyz',
426-
'--branch',
427-
'abc',
428-
'--reach',
429-
'--reach-continue-on-failing-projects',
430365
'--reach-disable-analytics',
431366
'--reach-analysis-memory-limit',
432367
'4096',

src/commands/scan/cmd-scan-reach.mts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ const config: CliCommandConfig = {
5050
Usage
5151
$ ${command} [options] [CWD=.]
5252
53+
API Token Requirements
54+
- Quota: 1 unit
55+
- Permissions: full-scans:create
56+
5357
Options
5458
${getFlagListOutput(generalFlags)}
5559
@@ -96,7 +100,6 @@ async function run(
96100
org: orgFlag,
97101
reachAnalysisMemoryLimit,
98102
reachAnalysisTimeout,
99-
reachContinueOnFailingProjects,
100103
reachDisableAnalytics,
101104
} = cli.flags as {
102105
cwd: string
@@ -106,7 +109,6 @@ async function run(
106109
org: string
107110
reachAnalysisTimeout: number
108111
reachAnalysisMemoryLimit: number
109-
reachContinueOnFailingProjects: boolean
110112
reachDisableAnalytics: boolean
111113
}
112114

@@ -183,7 +185,6 @@ async function run(
183185
targets,
184186
interactive,
185187
reachabilityOptions: {
186-
reachContinueOnFailingProjects: Boolean(reachContinueOnFailingProjects),
187188
reachDisableAnalytics: Boolean(reachDisableAnalytics),
188189
reachAnalysisTimeout: Number(reachAnalysisTimeout),
189190
reachAnalysisMemoryLimit: Number(reachAnalysisMemoryLimit),

src/commands/scan/cmd-scan-reach.test.mts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ describe('socket scan reach', async () => {
1818
Usage
1919
$ socket scan reach [options] [CWD=.]
2020
21+
API Token Requirements
22+
- Quota: 1 unit
23+
- Permissions: full-scans:create
24+
2125
Options
2226
--cwd working directory, defaults to process.cwd()
2327
--json Output result as json
@@ -27,7 +31,6 @@ describe('socket scan reach', async () => {
2731
Reachability Options
2832
--reach-analysis-memory-limit The maximum memory in MB to use for the reachability analysis. The default is 8192MB.
2933
--reach-analysis-timeout Set timeout for the reachability analysis. Split analysis runs may cause the total scan time to exceed this timeout significantly.
30-
--reach-continue-on-failing-projects Continue reachability analysis even when some projects/workspaces fail. Default is to crash the CLI at the first failing project/workspace.
3134
--reach-disable-analytics Disable reachability analytics sharing with Socket. Also disables caching-based optimizations.
3235
--reach-ecosystems List of ecosystems to conduct reachability analysis on, as either a comma separated value or as multiple flags. Defaults to all ecosystems.
3336
--reach-exclude-paths List of paths to exclude from reachability analysis, as either a comma separated value or as multiple flags.
@@ -206,25 +209,6 @@ describe('socket scan reach', async () => {
206209
},
207210
)
208211

209-
cmdit(
210-
[
211-
'scan',
212-
'reach',
213-
'--dry-run',
214-
'--reach-continue-on-failing-projects',
215-
'--org',
216-
'fakeOrg',
217-
'--config',
218-
'{"apiToken":"fakeToken"}',
219-
],
220-
'should accept --reach-continue-on-failing-projects flag',
221-
async cmd => {
222-
const { code, stdout } = await invokeNpm(binCliPath, cmd)
223-
expect(stdout).toMatchInlineSnapshot(`"[DryRun]: Bailing now"`)
224-
expect(code, 'should exit with code 0').toBe(0)
225-
},
226-
)
227-
228212
cmdit(
229213
[
230214
'scan',
@@ -279,7 +263,6 @@ describe('socket scan reach', async () => {
279263
'3600',
280264
'--reach-ecosystems',
281265
'npm,pypi',
282-
'--reach-continue-on-failing-projects',
283266
'--reach-exclude-paths',
284267
'node_modules,dist',
285268
'--org',

src/commands/scan/create-scan-from-github.mts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ async function scanOneRepo(
241241
pullRequest: 0,
242242
reach: {
243243
runReachabilityAnalysis: false,
244-
reachContinueOnFailingProjects: false,
245244
reachDisableAnalytics: false,
246245
reachAnalysisTimeout: 0,
247246
reachAnalysisMemoryLimit: 0,

0 commit comments

Comments
 (0)