@socketsecurity/cli-with-sentry 1.0.71 → 1.0.73
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/bin/npm-cli.js +1 -1
- package/bin/npx-cli.js +1 -1
- package/dist/cli.js +97 -57
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +36 -8
- package/dist/constants.js.map +1 -1
- package/dist/instrument-with-sentry.js +3 -2
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/shadow-npm-bin.js +18 -24
- package/dist/shadow-npm-bin.js.map +1 -1
- package/dist/shadow-npm-inject.js +3 -2
- package/dist/shadow-npm-inject.js.map +1 -1
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/npm-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/pnpm-fix.d.mts.map +1 -1
- package/dist/types/constants.d.mts +3 -0
- package/dist/types/constants.d.mts.map +1 -1
- package/dist/types/shadow/npm/bin.d.mts.map +1 -1
- package/dist/types/utils/pnpm.d.mts.map +1 -1
- package/dist/utils.js +9 -4
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +4 -3
- package/external/@coana-tech/cli/cli.mjs +1 -1
- package/external/@socketsecurity/registry/external/libnpmpack.js +20520 -4658
- package/external/@socketsecurity/registry/external/make-fetch-happen.js +7702 -4384
- package/external/@socketsecurity/registry/external/pacote.js +20310 -4448
- package/external/@socketsecurity/registry/lib/constants/npm-real-exec-path.js +2 -2
- package/external/@socketsecurity/registry/lib/spawn.js +25 -2
- package/package.json +8 -8
- package/shadow-bin/npm +1 -1
- package/shadow-bin/npx +1 -1
package/bin/npm-cli.js
CHANGED
|
@@ -6,5 +6,5 @@ const path = require('node:path')
|
|
|
6
6
|
const rootPath = path.join(__dirname, '..')
|
|
7
7
|
Module.enableCompileCache?.(path.join(rootPath, '.cache'))
|
|
8
8
|
|
|
9
|
-
const shadowBin = require(path.join(rootPath, 'dist/shadow-bin.js'))
|
|
9
|
+
const shadowBin = require(path.join(rootPath, 'dist/shadow-npm-bin.js'))
|
|
10
10
|
shadowBin('npm')
|
package/bin/npx-cli.js
CHANGED
|
@@ -6,5 +6,5 @@ const path = require('node:path')
|
|
|
6
6
|
const rootPath = path.join(__dirname, '..')
|
|
7
7
|
Module.enableCompileCache?.(path.join(rootPath, '.cache'))
|
|
8
8
|
|
|
9
|
-
const shadowBin = require(path.join(rootPath, 'dist/shadow-bin.js'))
|
|
9
|
+
const shadowBin = require(path.join(rootPath, 'dist/shadow-npm-bin.js'))
|
|
10
10
|
shadowBin('npx')
|
package/dist/cli.js
CHANGED
|
@@ -30,6 +30,7 @@ var require$$1 = require('node:util');
|
|
|
30
30
|
var os = require('node:os');
|
|
31
31
|
var promises = require('node:stream/promises');
|
|
32
32
|
|
|
33
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
33
34
|
async function fetchOrgAnalyticsData(time, options) {
|
|
34
35
|
const {
|
|
35
36
|
sdkOptions
|
|
@@ -66,7 +67,7 @@ async function fetchRepoAnalyticsData(repo, time, options) {
|
|
|
66
67
|
|
|
67
68
|
// Note: Widgets does not seem to actually work as code :'(
|
|
68
69
|
|
|
69
|
-
const require$5 = require$$5.createRequire(
|
|
70
|
+
const require$5 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
|
|
70
71
|
const METRICS = ['total_critical_alerts', 'total_high_alerts', 'total_medium_alerts', 'total_low_alerts', 'total_critical_added', 'total_medium_added', 'total_low_added', 'total_high_added', 'total_critical_prevented', 'total_high_prevented', 'total_medium_prevented', 'total_low_prevented'];
|
|
71
72
|
|
|
72
73
|
// Note: This maps `new Date(date).getMonth()` to English three letters
|
|
@@ -498,7 +499,7 @@ async function fetchAuditLog(config, options) {
|
|
|
498
499
|
});
|
|
499
500
|
}
|
|
500
501
|
|
|
501
|
-
const require$4 = require$$5.createRequire(
|
|
502
|
+
const require$4 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
|
|
502
503
|
const {
|
|
503
504
|
REDACTED
|
|
504
505
|
} = constants;
|
|
@@ -4327,6 +4328,7 @@ async function npmFix(pkgEnvDetails, fixConfig) {
|
|
|
4327
4328
|
return await agentFix(pkgEnvDetails, actualTree, alertsMap, install$1, {
|
|
4328
4329
|
async beforeInstall(editablePkgJson) {
|
|
4329
4330
|
revertData = {
|
|
4331
|
+
// Track existing dependencies in the root package.json to revert to later.
|
|
4330
4332
|
...(editablePkgJson.content.dependencies && {
|
|
4331
4333
|
dependencies: {
|
|
4332
4334
|
...editablePkgJson.content.dependencies
|
|
@@ -4345,24 +4347,34 @@ async function npmFix(pkgEnvDetails, fixConfig) {
|
|
|
4345
4347
|
};
|
|
4346
4348
|
},
|
|
4347
4349
|
async afterUpdate(editablePkgJson, packument, oldVersion, newVersion) {
|
|
4348
|
-
|
|
4349
|
-
if (
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4350
|
+
// Exit early if not the root workspace.
|
|
4351
|
+
if (editablePkgJson.filename !== pkgEnvDetails.editablePkgJson.filename) {
|
|
4352
|
+
return;
|
|
4353
|
+
}
|
|
4354
|
+
// Update package-lock.json using @npmcli/arborist.
|
|
4355
|
+
const arb = new shadowNpmInject.Arborist({
|
|
4356
|
+
path: pkgEnvDetails.pkgPath,
|
|
4357
|
+
...flatConfig,
|
|
4358
|
+
...shadowNpmInject.SAFE_WITH_SAVE_ARBORIST_REIFY_OPTIONS_OVERRIDES
|
|
4359
|
+
});
|
|
4360
|
+
// Build the ideal tree of nodes that are used to generated the saved
|
|
4361
|
+
// package-lock.json
|
|
4362
|
+
const idealTree = await arb.buildIdealTree();
|
|
4363
|
+
const node = shadowNpmInject.findPackageNode(idealTree, packument.name, oldVersion);
|
|
4364
|
+
if (node) {
|
|
4365
|
+
// Update the ideal tree node.
|
|
4366
|
+
shadowNpmInject.updateNode(node, newVersion, packument.versions[newVersion]);
|
|
4367
|
+
// Save package-lock.json lockfile.
|
|
4368
|
+
await arb.reify();
|
|
4361
4369
|
}
|
|
4362
4370
|
},
|
|
4363
4371
|
async revertInstall(editablePkgJson) {
|
|
4364
4372
|
if (revertData) {
|
|
4373
|
+
// Revert package.json.
|
|
4365
4374
|
editablePkgJson.update(revertData);
|
|
4375
|
+
await editablePkgJson.save({
|
|
4376
|
+
ignoreWhitespace: true
|
|
4377
|
+
});
|
|
4366
4378
|
}
|
|
4367
4379
|
}
|
|
4368
4380
|
}, fixConfig);
|
|
@@ -4459,8 +4471,12 @@ async function pnpmFix(pkgEnvDetails, fixConfig) {
|
|
|
4459
4471
|
cwd,
|
|
4460
4472
|
spinner
|
|
4461
4473
|
});
|
|
4462
|
-
|
|
4463
|
-
|
|
4474
|
+
if (maybeActualTree) {
|
|
4475
|
+
lockSrc = (await utils.readLockfile(pkgEnvDetails.lockPath)) ?? '';
|
|
4476
|
+
} else {
|
|
4477
|
+
lockSrc = '';
|
|
4478
|
+
}
|
|
4479
|
+
if (lockSrc) {
|
|
4464
4480
|
actualTree = maybeActualTree;
|
|
4465
4481
|
lockfile = utils.parsePnpmLockfile(lockSrc);
|
|
4466
4482
|
} else {
|
|
@@ -4498,25 +4514,29 @@ async function pnpmFix(pkgEnvDetails, fixConfig) {
|
|
|
4498
4514
|
let revertOverridesSrc = '';
|
|
4499
4515
|
return await agentFix(pkgEnvDetails, actualTree, alertsMap, install, {
|
|
4500
4516
|
async beforeInstall(editablePkgJson, packument, oldVersion, newVersion, vulnerableVersionRange, options) {
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4517
|
+
lockSrc = (await utils.readLockfile(pkgEnvDetails.lockPath)) ?? '';
|
|
4518
|
+
|
|
4519
|
+
// Update overrides for the root workspace.
|
|
4520
|
+
if (editablePkgJson.filename === pkgEnvDetails.editablePkgJson.filename) {
|
|
4521
|
+
const {
|
|
4522
|
+
overrides: oldOverrides
|
|
4523
|
+
} = getOverridesDataPnpm(pkgEnvDetails, editablePkgJson.content);
|
|
4524
|
+
const oldPnpmSection = editablePkgJson.content[PNPM$6];
|
|
4525
|
+
const overrideKey = `${packument.name}@${vulnerableVersionRange}`;
|
|
4526
|
+
revertOverridesSrc = utils.extractOverridesFromPnpmLockSrc(lockSrc);
|
|
4527
|
+
// Track existing overrides in the root package.json to revert to later.
|
|
4512
4528
|
revertOverrides = {
|
|
4513
4529
|
[PNPM$6]: oldPnpmSection ? {
|
|
4514
4530
|
...oldPnpmSection,
|
|
4515
4531
|
[OVERRIDES$1]: require$$7.hasKeys(oldOverrides) ? {
|
|
4516
4532
|
...oldOverrides,
|
|
4517
4533
|
[overrideKey]: undefined
|
|
4518
|
-
} :
|
|
4519
|
-
|
|
4534
|
+
} :
|
|
4535
|
+
// Properties with undefined values are deleted when saved as JSON.
|
|
4536
|
+
undefined
|
|
4537
|
+
} :
|
|
4538
|
+
// Properties with undefined values are deleted when saved as JSON.
|
|
4539
|
+
undefined
|
|
4520
4540
|
};
|
|
4521
4541
|
// Update overrides in the root package.json so that when `pnpm install`
|
|
4522
4542
|
// generates pnpm-lock.yaml it updates transitive dependencies too.
|
|
@@ -4529,9 +4549,15 @@ async function pnpmFix(pkgEnvDetails, fixConfig) {
|
|
|
4529
4549
|
}
|
|
4530
4550
|
}
|
|
4531
4551
|
});
|
|
4552
|
+
} else {
|
|
4553
|
+
revertOverrides = undefined;
|
|
4554
|
+
revertOverridesSrc = '';
|
|
4532
4555
|
}
|
|
4533
4556
|
revertData = {
|
|
4557
|
+
// If "pnpm" or "pnpm.overrides" fields are undefined they will be
|
|
4558
|
+
// deleted when saved.
|
|
4534
4559
|
...revertOverrides,
|
|
4560
|
+
// Track existing dependencies in the root package.json to revert to later.
|
|
4535
4561
|
...(editablePkgJson.content.dependencies && {
|
|
4536
4562
|
dependencies: {
|
|
4537
4563
|
...editablePkgJson.content.dependencies
|
|
@@ -4554,20 +4580,32 @@ async function pnpmFix(pkgEnvDetails, fixConfig) {
|
|
|
4554
4580
|
// Revert overrides metadata in package.json now that pnpm-lock.yaml
|
|
4555
4581
|
// has been updated.
|
|
4556
4582
|
editablePkgJson.update(revertOverrides);
|
|
4583
|
+
await editablePkgJson.save({
|
|
4584
|
+
ignoreWhitespace: true
|
|
4585
|
+
});
|
|
4557
4586
|
}
|
|
4558
|
-
await
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4587
|
+
lockSrc = (await utils.readLockfile(pkgEnvDetails.lockPath)) ?? '';
|
|
4588
|
+
// Remove "overrides" block from pnpm-lock.yaml lockfile when processing
|
|
4589
|
+
// the root workspace.
|
|
4590
|
+
if (editablePkgJson.filename === pkgEnvDetails.editablePkgJson.filename) {
|
|
4591
|
+
const updatedOverridesContent = utils.extractOverridesFromPnpmLockSrc(lockSrc);
|
|
4592
|
+
if (updatedOverridesContent) {
|
|
4593
|
+
// Remove "overrides" block from pnpm-lock.yaml lockfile.
|
|
4594
|
+
lockSrc = lockSrc.replace(updatedOverridesContent, revertOverridesSrc);
|
|
4595
|
+
// Save pnpm-lock.yaml lockfile.
|
|
4596
|
+
await fs$1.promises.writeFile(pkgEnvDetails.lockPath, lockSrc, 'utf8');
|
|
4597
|
+
}
|
|
4566
4598
|
}
|
|
4567
4599
|
},
|
|
4568
4600
|
async revertInstall(editablePkgJson) {
|
|
4569
4601
|
if (revertData) {
|
|
4602
|
+
// Revert package.json.
|
|
4570
4603
|
editablePkgJson.update(revertData);
|
|
4604
|
+
await editablePkgJson.save({
|
|
4605
|
+
ignoreWhitespace: true
|
|
4606
|
+
});
|
|
4607
|
+
// Revert pnpm-lock.yaml lockfile to be on the safe side.
|
|
4608
|
+
await fs$1.promises.writeFile(pkgEnvDetails.lockPath, lockSrc, 'utf8');
|
|
4571
4609
|
}
|
|
4572
4610
|
}
|
|
4573
4611
|
}, fixConfig);
|
|
@@ -4618,6 +4656,9 @@ async function handleFix({
|
|
|
4618
4656
|
}, outputKind);
|
|
4619
4657
|
return;
|
|
4620
4658
|
}
|
|
4659
|
+
debug.debugDir('inspect', {
|
|
4660
|
+
pkgEnvDetails
|
|
4661
|
+
});
|
|
4621
4662
|
|
|
4622
4663
|
// Lazily access constants.
|
|
4623
4664
|
const {
|
|
@@ -4929,7 +4970,7 @@ async function setupTabCompletion(targetName) {
|
|
|
4929
4970
|
};
|
|
4930
4971
|
}
|
|
4931
4972
|
function getTabCompletionScriptRaw() {
|
|
4932
|
-
const sourceDir = path.dirname(require$$0.fileURLToPath(
|
|
4973
|
+
const sourceDir = path.dirname(require$$0.fileURLToPath((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href))));
|
|
4933
4974
|
const sourcePath = path.join(sourceDir, 'socket-completion.bash');
|
|
4934
4975
|
if (!fs$1.existsSync(sourcePath)) {
|
|
4935
4976
|
return {
|
|
@@ -6966,7 +7007,7 @@ async function run$v(argv, importMeta, {
|
|
|
6966
7007
|
});
|
|
6967
7008
|
}
|
|
6968
7009
|
|
|
6969
|
-
const require$3 = require$$5.createRequire(
|
|
7010
|
+
const require$3 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
|
|
6970
7011
|
const {
|
|
6971
7012
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$u
|
|
6972
7013
|
} = constants;
|
|
@@ -7019,7 +7060,7 @@ async function run$u(argv, importMeta, {
|
|
|
7019
7060
|
await shadowBin('npm', argv);
|
|
7020
7061
|
}
|
|
7021
7062
|
|
|
7022
|
-
const require$2 = require$$5.createRequire(
|
|
7063
|
+
const require$2 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
|
|
7023
7064
|
const {
|
|
7024
7065
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$t
|
|
7025
7066
|
} = constants;
|
|
@@ -7479,7 +7520,7 @@ function updatePkgJsonField(editablePkgJson, field, value) {
|
|
|
7479
7520
|
}
|
|
7480
7521
|
});
|
|
7481
7522
|
} else {
|
|
7482
|
-
// Properties with undefined values are
|
|
7523
|
+
// Properties with undefined values are deleted when saved as JSON.
|
|
7483
7524
|
editablePkgJson.update(require$$7.hasKeys(oldValue) ? {
|
|
7484
7525
|
[field]: {
|
|
7485
7526
|
...(isPnpmObj ? oldValue : {}),
|
|
@@ -7490,7 +7531,7 @@ function updatePkgJsonField(editablePkgJson, field, value) {
|
|
|
7490
7531
|
});
|
|
7491
7532
|
}
|
|
7492
7533
|
} else if (field === OVERRIDES || field === RESOLUTIONS) {
|
|
7493
|
-
// Properties with undefined values are
|
|
7534
|
+
// Properties with undefined values are deleted when saved as JSON.
|
|
7494
7535
|
editablePkgJson.update({
|
|
7495
7536
|
[field]: require$$7.hasKeys(value) ? value : undefined
|
|
7496
7537
|
});
|
|
@@ -13616,7 +13657,7 @@ async function fetchThreatFeed({
|
|
|
13616
13657
|
return await utils.queryApiSafeJson(`orgs/${orgSlug}/threat-feed?${queryParams}`, 'the Threat Feed data');
|
|
13617
13658
|
}
|
|
13618
13659
|
|
|
13619
|
-
const require$1 = require$$5.createRequire(
|
|
13660
|
+
const require$1 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
|
|
13620
13661
|
async function outputThreatFeed(result, outputKind) {
|
|
13621
13662
|
if (!result.ok) {
|
|
13622
13663
|
process.exitCode = result.code ?? 1;
|
|
@@ -14398,17 +14439,15 @@ async function run(argv, importMeta, {
|
|
|
14398
14439
|
}
|
|
14399
14440
|
}
|
|
14400
14441
|
|
|
14401
|
-
const __filename$1 = require$$0.fileURLToPath(
|
|
14402
|
-
const {
|
|
14403
|
-
SOCKET_CLI_BIN_NAME
|
|
14404
|
-
} = constants;
|
|
14442
|
+
const __filename$1 = require$$0.fileURLToPath((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
|
|
14405
14443
|
void (async () => {
|
|
14406
14444
|
const registryUrl = vendor.registryUrl();
|
|
14407
14445
|
await vendor.updater({
|
|
14408
14446
|
authInfo: vendor.registryAuthTokenExports(registryUrl, {
|
|
14409
14447
|
recursive: true
|
|
14410
14448
|
}),
|
|
14411
|
-
|
|
14449
|
+
// Lazily access constants.SOCKET_CLI_BIN_NAME.
|
|
14450
|
+
name: constants.SOCKET_CLI_BIN_NAME,
|
|
14412
14451
|
registryUrl,
|
|
14413
14452
|
ttl: 86_400_000 /* 24 hours in milliseconds */,
|
|
14414
14453
|
|
|
@@ -14417,6 +14456,8 @@ void (async () => {
|
|
|
14417
14456
|
});
|
|
14418
14457
|
try {
|
|
14419
14458
|
await utils.meowWithSubcommands({
|
|
14459
|
+
analytics: cmdAnalytics,
|
|
14460
|
+
'audit-log': cmdAuditLog,
|
|
14420
14461
|
ci: cmdCI,
|
|
14421
14462
|
config: cmdConfig,
|
|
14422
14463
|
fix: cmdFix,
|
|
@@ -14430,16 +14471,14 @@ void (async () => {
|
|
|
14430
14471
|
optimize: cmdOptimize,
|
|
14431
14472
|
organization: cmdOrganization,
|
|
14432
14473
|
package: cmdPackage,
|
|
14474
|
+
manifest: cmdManifest,
|
|
14475
|
+
scan: cmdScan,
|
|
14433
14476
|
'raw-npm': cmdRawNpm,
|
|
14434
14477
|
'raw-npx': cmdRawNpx,
|
|
14435
|
-
wrapper: cmdWrapper,
|
|
14436
|
-
scan: cmdScan,
|
|
14437
|
-
'audit-log': cmdAuditLog,
|
|
14438
14478
|
repos: cmdRepository,
|
|
14439
|
-
analytics: cmdAnalytics,
|
|
14440
14479
|
'threat-feed': cmdThreatFeed,
|
|
14441
|
-
|
|
14442
|
-
|
|
14480
|
+
uninstall: cmdUninstall,
|
|
14481
|
+
wrapper: cmdWrapper
|
|
14443
14482
|
}, {
|
|
14444
14483
|
aliases: {
|
|
14445
14484
|
audit: {
|
|
@@ -14534,7 +14573,8 @@ void (async () => {
|
|
|
14534
14573
|
}
|
|
14535
14574
|
},
|
|
14536
14575
|
argv: process.argv.slice(2),
|
|
14537
|
-
|
|
14576
|
+
// Lazily access constants.SOCKET_CLI_BIN_NAME.
|
|
14577
|
+
name: constants.SOCKET_CLI_BIN_NAME,
|
|
14538
14578
|
importMeta: {
|
|
14539
14579
|
url: `${require$$0.pathToFileURL(__filename$1)}`
|
|
14540
14580
|
}
|
|
@@ -14594,5 +14634,5 @@ void (async () => {
|
|
|
14594
14634
|
await utils.captureException(e);
|
|
14595
14635
|
}
|
|
14596
14636
|
})();
|
|
14597
|
-
//# debugId=
|
|
14637
|
+
//# debugId=ba4215ca-3cc8-45b8-8900-a36e38e6cc4a
|
|
14598
14638
|
//# sourceMappingURL=cli.js.map
|