@socketsecurity/cli 1.1.33 → 1.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/cli.js +110 -4
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +3 -3
- package/dist/constants.js.map +1 -1
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/ci/handle-ci.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-create.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-reach.d.mts.map +1 -1
- package/dist/types/commands/scan/handle-create-new-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/handle-scan-reach.d.mts.map +1 -1
- package/dist/types/commands/scan/perform-reachability-analysis.d.mts +2 -0
- package/dist/types/commands/scan/perform-reachability-analysis.d.mts.map +1 -1
- package/dist/types/commands/scan/reachability-flags.d.mts.map +1 -1
- package/dist/types/commands/scan/validate-reachability-target.d.mts +15 -0
- package/dist/types/commands/scan/validate-reachability-target.d.mts.map +1 -0
- package/dist/types/utils/glob.d.mts +1 -1
- package/dist/types/utils/glob.d.mts.map +1 -1
- package/dist/utils.js +15 -4
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
6
|
|
|
7
|
+
|
|
8
|
+
## [1.1.34](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.33) - 2025-11-21
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- The target path is now properly considered when conducting reachability analysis: `socket scan reach <target>` and `socket scan create --reach <target>`.
|
|
12
|
+
- Fixed a bug where manifest files `<target>` were not included in a scan when the target was pointing to a directory.
|
|
13
|
+
|
|
7
14
|
## [1.1.33](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.33) - 2025-11-20
|
|
8
15
|
|
|
9
16
|
### Changed
|
package/dist/cli.js
CHANGED
|
@@ -1563,12 +1563,19 @@ async function performReachabilityAnalysis(options) {
|
|
|
1563
1563
|
reachabilityOptions,
|
|
1564
1564
|
repoName,
|
|
1565
1565
|
spinner,
|
|
1566
|
+
target,
|
|
1566
1567
|
uploadManifests = true
|
|
1567
1568
|
} = {
|
|
1568
1569
|
__proto__: null,
|
|
1569
1570
|
...options
|
|
1570
1571
|
};
|
|
1571
1572
|
|
|
1573
|
+
// Determine the analysis target - make it relative to cwd if absolute.
|
|
1574
|
+
let analysisTarget = target;
|
|
1575
|
+
if (path.isAbsolute(analysisTarget)) {
|
|
1576
|
+
analysisTarget = path.relative(cwd, analysisTarget) || '.';
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1572
1579
|
// Check if user has enterprise plan for reachability analysis.
|
|
1573
1580
|
const orgsCResult = await utils.fetchOrganization();
|
|
1574
1581
|
if (!orgsCResult.ok) {
|
|
@@ -1631,7 +1638,7 @@ async function performReachabilityAnalysis(options) {
|
|
|
1631
1638
|
spinner?.infoAndStop('Running reachability analysis with Coana...');
|
|
1632
1639
|
|
|
1633
1640
|
// Build Coana arguments.
|
|
1634
|
-
const coanaArgs = ['run',
|
|
1641
|
+
const coanaArgs = ['run', analysisTarget, '--output-dir', cwd, '--socket-mode', constants.default.DOT_SOCKET_DOT_FACTS_JSON, '--disable-report-submission', ...(reachabilityOptions.reachAnalysisTimeout ? ['--analysis-timeout', `${reachabilityOptions.reachAnalysisTimeout}`] : []), ...(reachabilityOptions.reachAnalysisMemoryLimit ? ['--memory-limit', `${reachabilityOptions.reachAnalysisMemoryLimit}`] : []), ...(reachabilityOptions.reachConcurrency ? ['--concurrency', `${reachabilityOptions.reachConcurrency}`] : []), ...(reachabilityOptions.reachDebug ? ['--debug'] : []), ...(reachabilityOptions.reachDisableAnalytics ? ['--disable-analytics-sharing'] : []), ...(reachabilityOptions.reachDisableAnalysisSplitting ? ['--disable-analysis-splitting'] : []), ...(tarHash ? ['--run-without-docker', '--manifests-tar-hash', tarHash] : []),
|
|
1635
1642
|
// Empty reachEcosystems implies scanning all ecosystems.
|
|
1636
1643
|
...(reachabilityOptions.reachEcosystems.length ? ['--purl-types', ...reachabilityOptions.reachEcosystems] : []), ...(reachabilityOptions.reachExcludePaths.length ? ['--exclude-dirs', ...reachabilityOptions.reachExcludePaths] : []), ...(reachabilityOptions.reachSkipCache ? ['--skip-cache-usage'] : [])];
|
|
1637
1644
|
|
|
@@ -2260,7 +2267,8 @@ async function handleCreateNewScan({
|
|
|
2260
2267
|
packagePaths,
|
|
2261
2268
|
reachabilityOptions: reach,
|
|
2262
2269
|
repoName,
|
|
2263
|
-
spinner
|
|
2270
|
+
spinner,
|
|
2271
|
+
target: targets[0]
|
|
2264
2272
|
});
|
|
2265
2273
|
spinner.stop();
|
|
2266
2274
|
if (!reachResult.ok) {
|
|
@@ -2372,6 +2380,7 @@ async function handleCi(autoManifest) {
|
|
|
2372
2380
|
reachAnalysisTimeout: 0,
|
|
2373
2381
|
reachAnalysisMemoryLimit: 0,
|
|
2374
2382
|
reachConcurrency: 1,
|
|
2383
|
+
reachDebug: false,
|
|
2375
2384
|
reachDisableAnalytics: false,
|
|
2376
2385
|
reachDisableAnalysisSplitting: false,
|
|
2377
2386
|
reachEcosystems: [],
|
|
@@ -11062,6 +11071,11 @@ const reachabilityFlags = {
|
|
|
11062
11071
|
default: 1,
|
|
11063
11072
|
description: '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. NPM reachability analysis does not support concurrent execution, so the concurrency level is ignored for NPM.'
|
|
11064
11073
|
},
|
|
11074
|
+
reachDebug: {
|
|
11075
|
+
type: 'boolean',
|
|
11076
|
+
default: false,
|
|
11077
|
+
description: 'Enable debug mode for reachability analysis. Provides verbose logging from the reachability CLI.'
|
|
11078
|
+
},
|
|
11065
11079
|
reachDisableAnalytics: {
|
|
11066
11080
|
type: 'boolean',
|
|
11067
11081
|
default: false,
|
|
@@ -11107,6 +11121,41 @@ async function suggestTarget() {
|
|
|
11107
11121
|
return proceed ? ['.'] : [];
|
|
11108
11122
|
}
|
|
11109
11123
|
|
|
11124
|
+
/**
|
|
11125
|
+
* Validates that a target directory meets the requirements for reachability analysis.
|
|
11126
|
+
*
|
|
11127
|
+
* @param targets - Array of target paths to validate.
|
|
11128
|
+
* @param cwd - Current working directory.
|
|
11129
|
+
* @returns Validation result object with boolean flags.
|
|
11130
|
+
*/
|
|
11131
|
+
async function validateReachabilityTarget(targets, cwd) {
|
|
11132
|
+
const result = {
|
|
11133
|
+
isDirectory: false,
|
|
11134
|
+
isInsideCwd: false,
|
|
11135
|
+
isValid: targets.length === 1,
|
|
11136
|
+
targetExists: false
|
|
11137
|
+
};
|
|
11138
|
+
if (!result.isValid || !targets[0]) {
|
|
11139
|
+
return result;
|
|
11140
|
+
}
|
|
11141
|
+
|
|
11142
|
+
// Resolve cwd to absolute path to handle relative cwd values.
|
|
11143
|
+
const absoluteCwd = path.resolve(cwd);
|
|
11144
|
+
|
|
11145
|
+
// Resolve target path to absolute for validation.
|
|
11146
|
+
const targetPath = path.isAbsolute(targets[0]) ? targets[0] : path.resolve(absoluteCwd, targets[0]);
|
|
11147
|
+
|
|
11148
|
+
// Check if target is inside cwd.
|
|
11149
|
+
const relativePath = path.relative(absoluteCwd, targetPath);
|
|
11150
|
+
result.isInsideCwd = !relativePath.startsWith('..') && !path.isAbsolute(relativePath);
|
|
11151
|
+
result.targetExists = fs$1.existsSync(targetPath);
|
|
11152
|
+
if (result.targetExists) {
|
|
11153
|
+
const targetStat = await fs$1.promises.stat(targetPath);
|
|
11154
|
+
result.isDirectory = targetStat.isDirectory();
|
|
11155
|
+
}
|
|
11156
|
+
return result;
|
|
11157
|
+
}
|
|
11158
|
+
|
|
11110
11159
|
const CMD_NAME$a = 'create';
|
|
11111
11160
|
const description$c = 'Create a new Socket scan and report';
|
|
11112
11161
|
const hidden$a = false;
|
|
@@ -11291,6 +11340,7 @@ async function run$d(argv, importMeta, {
|
|
|
11291
11340
|
reachAnalysisMemoryLimit,
|
|
11292
11341
|
reachAnalysisTimeout,
|
|
11293
11342
|
reachConcurrency,
|
|
11343
|
+
reachDebug,
|
|
11294
11344
|
reachDisableAnalysisSplitting,
|
|
11295
11345
|
reachDisableAnalytics,
|
|
11296
11346
|
reachSkipCache,
|
|
@@ -11422,6 +11472,14 @@ async function run$d(argv, importMeta, {
|
|
|
11422
11472
|
const isUsingNonDefaultConcurrency = reachConcurrency !== reachabilityFlags['reachConcurrency']?.default;
|
|
11423
11473
|
const isUsingNonDefaultAnalytics = reachDisableAnalytics !== reachabilityFlags['reachDisableAnalytics']?.default;
|
|
11424
11474
|
const isUsingAnyReachabilityFlags = isUsingNonDefaultMemoryLimit || isUsingNonDefaultTimeout || isUsingNonDefaultConcurrency || isUsingNonDefaultAnalytics || hasReachEcosystems || hasReachExcludePaths || reachSkipCache || reachDisableAnalysisSplitting;
|
|
11475
|
+
|
|
11476
|
+
// Validate target constraints when --reach is enabled.
|
|
11477
|
+
const reachTargetValidation = reach ? await validateReachabilityTarget(targets, cwd) : {
|
|
11478
|
+
isDirectory: false,
|
|
11479
|
+
isInsideCwd: false,
|
|
11480
|
+
isValid: true,
|
|
11481
|
+
targetExists: false
|
|
11482
|
+
};
|
|
11425
11483
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
11426
11484
|
nook: true,
|
|
11427
11485
|
test: !!orgSlug,
|
|
@@ -11456,6 +11514,26 @@ async function run$d(argv, importMeta, {
|
|
|
11456
11514
|
test: reach || !isUsingAnyReachabilityFlags,
|
|
11457
11515
|
message: 'Reachability analysis flags require --reach to be enabled',
|
|
11458
11516
|
fail: 'add --reach flag to use --reach-* options'
|
|
11517
|
+
}, {
|
|
11518
|
+
nook: true,
|
|
11519
|
+
test: !reach || reachTargetValidation.isValid,
|
|
11520
|
+
message: 'Reachability analysis requires exactly one target directory when --reach is enabled',
|
|
11521
|
+
fail: 'provide exactly one directory path'
|
|
11522
|
+
}, {
|
|
11523
|
+
nook: true,
|
|
11524
|
+
test: !reach || reachTargetValidation.isDirectory,
|
|
11525
|
+
message: 'Reachability analysis target must be a directory when --reach is enabled',
|
|
11526
|
+
fail: 'provide a directory path, not a file'
|
|
11527
|
+
}, {
|
|
11528
|
+
nook: true,
|
|
11529
|
+
test: !reach || reachTargetValidation.targetExists,
|
|
11530
|
+
message: 'Target directory must exist when --reach is enabled',
|
|
11531
|
+
fail: 'provide an existing directory path'
|
|
11532
|
+
}, {
|
|
11533
|
+
nook: true,
|
|
11534
|
+
test: !reach || reachTargetValidation.isInsideCwd,
|
|
11535
|
+
message: 'Target directory must be inside the current working directory when --reach is enabled',
|
|
11536
|
+
fail: 'provide a path inside the working directory'
|
|
11459
11537
|
});
|
|
11460
11538
|
if (!wasValidInput) {
|
|
11461
11539
|
return;
|
|
@@ -11483,6 +11561,7 @@ async function run$d(argv, importMeta, {
|
|
|
11483
11561
|
reachAnalysisTimeout: Number(reachAnalysisTimeout),
|
|
11484
11562
|
reachAnalysisMemoryLimit: Number(reachAnalysisMemoryLimit),
|
|
11485
11563
|
reachConcurrency: Number(reachConcurrency),
|
|
11564
|
+
reachDebug: Boolean(reachDebug),
|
|
11486
11565
|
reachDisableAnalysisSplitting: Boolean(reachDisableAnalysisSplitting),
|
|
11487
11566
|
reachEcosystems,
|
|
11488
11567
|
reachExcludePaths,
|
|
@@ -12130,6 +12209,7 @@ async function scanOneRepo(repoSlug, {
|
|
|
12130
12209
|
reachAnalysisTimeout: 0,
|
|
12131
12210
|
reachAnalysisMemoryLimit: 0,
|
|
12132
12211
|
reachConcurrency: 1,
|
|
12212
|
+
reachDebug: false,
|
|
12133
12213
|
reachDisableAnalysisSplitting: false,
|
|
12134
12214
|
reachEcosystems: [],
|
|
12135
12215
|
reachExcludePaths: [],
|
|
@@ -13319,6 +13399,7 @@ async function handleScanReach({
|
|
|
13319
13399
|
packagePaths,
|
|
13320
13400
|
reachabilityOptions,
|
|
13321
13401
|
spinner,
|
|
13402
|
+
target: targets[0],
|
|
13322
13403
|
uploadManifests: true
|
|
13323
13404
|
});
|
|
13324
13405
|
spinner.stop();
|
|
@@ -13402,6 +13483,7 @@ async function run$7(argv, importMeta, {
|
|
|
13402
13483
|
reachAnalysisMemoryLimit,
|
|
13403
13484
|
reachAnalysisTimeout,
|
|
13404
13485
|
reachConcurrency,
|
|
13486
|
+
reachDebug,
|
|
13405
13487
|
reachDisableAnalysisSplitting,
|
|
13406
13488
|
reachDisableAnalytics,
|
|
13407
13489
|
reachSkipCache
|
|
@@ -13425,7 +13507,7 @@ async function run$7(argv, importMeta, {
|
|
|
13425
13507
|
const cwd = cwdOverride && cwdOverride !== '.' && cwdOverride !== processCwd ? path.resolve(processCwd, cwdOverride) : processCwd;
|
|
13426
13508
|
|
|
13427
13509
|
// Accept zero or more paths. Default to cwd() if none given.
|
|
13428
|
-
let targets = cli.input
|
|
13510
|
+
let targets = cli.input.length ? cli.input : [cwd];
|
|
13429
13511
|
|
|
13430
13512
|
// Use suggestTarget if no targets specified and in interactive mode
|
|
13431
13513
|
if (!targets.length && !dryRun && interactive) {
|
|
@@ -13436,6 +13518,9 @@ async function run$7(argv, importMeta, {
|
|
|
13436
13518
|
} = await utils.determineOrgSlug(orgFlag, interactive, dryRun);
|
|
13437
13519
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
13438
13520
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
13521
|
+
|
|
13522
|
+
// Validate target constraints for reachability analysis.
|
|
13523
|
+
const targetValidation = await validateReachabilityTarget(targets, cwd);
|
|
13439
13524
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
13440
13525
|
nook: true,
|
|
13441
13526
|
test: !!orgSlug,
|
|
@@ -13451,6 +13536,26 @@ async function run$7(argv, importMeta, {
|
|
|
13451
13536
|
test: !json || !markdown,
|
|
13452
13537
|
message: 'The json and markdown flags cannot be both set, pick one',
|
|
13453
13538
|
fail: 'omit one'
|
|
13539
|
+
}, {
|
|
13540
|
+
nook: true,
|
|
13541
|
+
test: targetValidation.isValid,
|
|
13542
|
+
message: 'Reachability analysis requires exactly one target directory',
|
|
13543
|
+
fail: 'provide exactly one directory path'
|
|
13544
|
+
}, {
|
|
13545
|
+
nook: true,
|
|
13546
|
+
test: targetValidation.isDirectory,
|
|
13547
|
+
message: 'Reachability analysis target must be a directory',
|
|
13548
|
+
fail: 'provide a directory path, not a file'
|
|
13549
|
+
}, {
|
|
13550
|
+
nook: true,
|
|
13551
|
+
test: targetValidation.targetExists,
|
|
13552
|
+
message: 'Target directory must exist',
|
|
13553
|
+
fail: 'provide an existing directory path'
|
|
13554
|
+
}, {
|
|
13555
|
+
nook: true,
|
|
13556
|
+
test: targetValidation.isInsideCwd,
|
|
13557
|
+
message: 'Target directory must be inside the current working directory',
|
|
13558
|
+
fail: 'provide a path inside the working directory'
|
|
13454
13559
|
});
|
|
13455
13560
|
if (!wasValidInput) {
|
|
13456
13561
|
return;
|
|
@@ -13469,6 +13574,7 @@ async function run$7(argv, importMeta, {
|
|
|
13469
13574
|
reachAnalysisTimeout: Number(reachAnalysisTimeout),
|
|
13470
13575
|
reachAnalysisMemoryLimit: Number(reachAnalysisMemoryLimit),
|
|
13471
13576
|
reachConcurrency: Number(reachConcurrency),
|
|
13577
|
+
reachDebug: Boolean(reachDebug),
|
|
13472
13578
|
reachDisableAnalytics: Boolean(reachDisableAnalytics),
|
|
13473
13579
|
reachDisableAnalysisSplitting: Boolean(reachDisableAnalysisSplitting),
|
|
13474
13580
|
reachEcosystems,
|
|
@@ -15311,5 +15417,5 @@ void (async () => {
|
|
|
15311
15417
|
await utils.captureException(e);
|
|
15312
15418
|
}
|
|
15313
15419
|
})();
|
|
15314
|
-
//# debugId=
|
|
15420
|
+
//# debugId=eed4ae6e-70d5-40a8-9ca4-86ec9e6e0d6c
|
|
15315
15421
|
//# sourceMappingURL=cli.js.map
|