@socketsecurity/cli 0.14.27 → 0.14.29

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.
Files changed (52) hide show
  1. package/bin/cli.js +9 -0
  2. package/bin/npm-cli.js +9 -0
  3. package/bin/npx-cli.js +9 -0
  4. package/bin/shadow/module-sync/npm +3 -0
  5. package/bin/shadow/module-sync/npx +3 -0
  6. package/bin/shadow/require/npm +3 -0
  7. package/bin/shadow/require/npx +3 -0
  8. package/dist/module-sync/cli.d.ts.map +1 -0
  9. package/dist/module-sync/cli.js +5256 -0
  10. package/dist/module-sync/constants.d.ts +15 -0
  11. package/dist/module-sync/constants.js +62 -0
  12. package/dist/module-sync/npm-cli.js +85 -0
  13. package/dist/{npm-injection.js → module-sync/npm-injection.js} +78 -92
  14. package/dist/module-sync/npx-cli.js +61 -0
  15. package/dist/{sdk.d.ts → module-sync/sdk.d.ts} +1 -5
  16. package/dist/module-sync/sdk.js +253 -0
  17. package/dist/require/cli.d.ts +3 -0
  18. package/dist/require/cli.d.ts.map +1 -0
  19. package/dist/{cli.js → require/cli.js} +72 -76
  20. package/dist/require/color-or-markdown.d.ts +23 -0
  21. package/dist/require/constants.d.ts +15 -0
  22. package/dist/require/constants.js +57 -0
  23. package/dist/require/errors.d.ts +7 -0
  24. package/dist/require/link.d.ts +2 -0
  25. package/dist/require/link.js +45 -0
  26. package/dist/require/npm-cli.d.ts +2 -0
  27. package/dist/{npm-cli.js → require/npm-cli.js} +12 -10
  28. package/dist/require/npm-injection.d.ts +1 -0
  29. package/dist/require/npm-injection.js +1830 -0
  30. package/dist/require/npx-cli.d.ts +2 -0
  31. package/dist/{npx-cli.js → require/npx-cli.js} +12 -12
  32. package/dist/require/path-resolve.d.ts +8 -0
  33. package/dist/require/path-resolve.js +183 -0
  34. package/dist/require/sdk.d.ts +9 -0
  35. package/dist/{sdk.js → require/sdk.js} +16 -36
  36. package/dist/require/settings.d.ts +9 -0
  37. package/dist/{vendor.js → require/vendor.js} +126 -13
  38. package/package.json +68 -36
  39. package/bin/npm +0 -2
  40. package/bin/npx +0 -2
  41. package/dist/cli.d.ts.map +0 -1
  42. /package/dist/{cli.d.ts → module-sync/cli.d.ts} +0 -0
  43. /package/dist/{color-or-markdown.d.ts → module-sync/color-or-markdown.d.ts} +0 -0
  44. /package/dist/{errors.d.ts → module-sync/errors.d.ts} +0 -0
  45. /package/dist/{link.d.ts → module-sync/link.d.ts} +0 -0
  46. /package/dist/{link.js → module-sync/link.js} +0 -0
  47. /package/dist/{npm-cli.d.ts → module-sync/npm-cli.d.ts} +0 -0
  48. /package/dist/{npm-injection.d.ts → module-sync/npm-injection.d.ts} +0 -0
  49. /package/dist/{npx-cli.d.ts → module-sync/npx-cli.d.ts} +0 -0
  50. /package/dist/{path-resolve.d.ts → module-sync/path-resolve.d.ts} +0 -0
  51. /package/dist/{path-resolve.js → module-sync/path-resolve.js} +0 -0
  52. /package/dist/{settings.d.ts → module-sync/settings.d.ts} +0 -0
@@ -0,0 +1,15 @@
1
+ declare const API_V0_URL = "https://api.socket.dev/v0";
2
+ declare const ENV: Readonly<{
3
+ UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: boolean;
4
+ }>;
5
+ declare const SUPPORTS_SYNC_ESM: boolean;
6
+ declare const rootPath: string;
7
+ declare const rootDistPath: string;
8
+ declare const rootBinPath: string;
9
+ declare const rootPkgJsonPath: string;
10
+ declare const nmBinPath: string;
11
+ declare const cdxgenBinPath: string;
12
+ declare const distPath: string;
13
+ declare const shadowBinPath: string;
14
+ declare const synpBinPath: string;
15
+ export { API_V0_URL, ENV, SUPPORTS_SYNC_ESM, rootPath, rootDistPath, rootBinPath, rootPkgJsonPath, nmBinPath, cdxgenBinPath, distPath, shadowBinPath, synpBinPath };
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ var require$$0 = require('node:fs');
4
+ var require$$1 = require('node:path');
5
+ var require$$2 = require('@socketsecurity/registry/lib/env');
6
+ var require$$3 = require('@socketsecurity/registry/lib/constants');
7
+ var require$$4 = require('semver');
8
+
9
+ function getDefaultExportFromCjs (x) {
10
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
11
+ }
12
+
13
+ var constants = {};
14
+
15
+ Object.defineProperty(constants, "__esModule", {
16
+ value: true
17
+ });
18
+ constants.synpBinPath = constants.shadowBinPath = constants.rootPkgJsonPath = constants.rootPath = constants.rootDistPath = constants.rootBinPath = constants.nmBinPath = constants.distPath = constants.cdxgenBinPath = constants.SUPPORTS_SYNC_ESM = constants.ENV = constants.API_V0_URL = void 0;
19
+ var _nodeFs = require$$0;
20
+ var _nodePath = require$$1;
21
+ var _env = require$$2;
22
+ var _constants = require$$3;
23
+ var _semver = require$$4;
24
+ const {
25
+ PACKAGE_JSON
26
+ } = _constants;
27
+ constants.API_V0_URL = 'https://api.socket.dev/v0';
28
+ constants.ENV = Object.freeze({
29
+ // Flag set by the optimize command to bypass the packagesHaveRiskyIssues check.
30
+ UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: (0, _env.envAsBoolean)(process.env['UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE'])
31
+ });
32
+ const SUPPORTS_SYNC_ESM = constants.SUPPORTS_SYNC_ESM = _semver.satisfies(process.versions.node, '>=22.12');
33
+ const rootPath = constants.rootPath = (() => {
34
+ let oldPath;
35
+ let currPath = (0, _nodeFs.realpathSync)(__dirname);
36
+ while (currPath !== oldPath) {
37
+ const pkgJsonPath = _nodePath.join(currPath, PACKAGE_JSON);
38
+ if ((0, _nodeFs.existsSync)(pkgJsonPath)) {
39
+ try {
40
+ // @socketsecurity/cli is replaced by .config/rollup.base.config.mjs
41
+ // with either 'socket' or '@socketsecurity/cli'.
42
+ if (require(pkgJsonPath)?.name === '@socketsecurity/cli') {
43
+ return currPath;
44
+ }
45
+ } catch {}
46
+ }
47
+ oldPath = currPath;
48
+ currPath = _nodePath.dirname(currPath);
49
+ }
50
+ throw new TypeError('rootPath cannot be resolved.');
51
+ })();
52
+ const rootDistPath = constants.rootDistPath = _nodePath.join(rootPath, 'dist');
53
+ constants.rootBinPath = _nodePath.join(rootPath, 'bin');
54
+ constants.rootPkgJsonPath = _nodePath.join(rootPath, PACKAGE_JSON);
55
+ const nmBinPath = constants.nmBinPath = _nodePath.join(rootPath, 'node_modules/.bin');
56
+ constants.cdxgenBinPath = _nodePath.join(nmBinPath, 'cdxgen');
57
+ constants.distPath = _nodePath.join(rootDistPath, SUPPORTS_SYNC_ESM ? 'module-sync' : 'require');
58
+ constants.shadowBinPath = _nodePath.join(rootPath, 'shadow', SUPPORTS_SYNC_ESM ? 'module-sync' : 'require');
59
+ constants.synpBinPath = _nodePath.join(nmBinPath, 'synp');
60
+
61
+ exports.constants = constants;
62
+ exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ var constants = require('./constants.js');
5
+ var require$$0$1 = require('@babel/runtime/helpers/interopRequireWildcard');
6
+ var require$$0 = require('node:fs');
7
+ var require$$1 = require('node:path');
8
+ var require$$1$1 = require('@npmcli/promise-spawn');
9
+ var link = require('./link.js');
10
+ var pathResolve = require('./path-resolve.js');
11
+
12
+ var npmCli$2 = {};
13
+
14
+ var npmCli$1 = {};
15
+
16
+ var _nodeFs = require$$0;
17
+ var _nodePath = require$$1;
18
+ var _promiseSpawn = require$$1$1;
19
+ var _constants = constants.constants;
20
+ var _link = link.link;
21
+ var _pathResolve = pathResolve.pathResolve;
22
+ const npmPath = (0, _link.installLinks)(_constants.shadowBinPath, 'npm');
23
+ const injectionPath = _nodePath.join(_constants.distPath, 'npm-injection.js');
24
+
25
+ // Adding the `--quiet` and `--no-progress` flags when the `proc-log` module
26
+ // is found to fix a UX issue when running the command with recent versions of
27
+ // npm (input swallowed by the standard npm spinner)
28
+ const npmArgs = process.argv.slice(2);
29
+ if (npmArgs.includes('install') && !npmArgs.includes('--no-progress') && !npmArgs.includes('--quiet')) {
30
+ const npmEntrypoint = (0, _nodeFs.realpathSync)(npmPath);
31
+ const npmRootPath = (0, _pathResolve.findRoot)(_nodePath.dirname(npmEntrypoint));
32
+ if (npmRootPath === undefined) {
33
+ process.exit(127);
34
+ }
35
+ const npmDepPath = _nodePath.join(npmRootPath, 'node_modules');
36
+ let procLog;
37
+ try {
38
+ procLog = require(_nodePath.join(npmDepPath, 'proc-log/lib/index.js')).log;
39
+ } catch {}
40
+ if (procLog) {
41
+ npmArgs.push('--no-progress', '--quiet');
42
+ }
43
+ }
44
+ process.exitCode = 1;
45
+ const spawnPromise = _promiseSpawn(process.execPath, ['--disable-warning', 'ExperimentalWarning', '--require', injectionPath, npmPath, ...npmArgs], {
46
+ stdio: 'inherit'
47
+ });
48
+ spawnPromise.process.on('exit', (code, signal) => {
49
+ if (signal) {
50
+ process.kill(process.pid, signal);
51
+ } else if (code !== null) {
52
+ process.exit(code);
53
+ }
54
+ });
55
+
56
+ (function (exports) {
57
+
58
+ var _interopRequireWildcard = require$$0$1.default;
59
+ Object.defineProperty(exports, "__esModule", {
60
+ value: true
61
+ });
62
+ var _exportNames = {};
63
+ Object.defineProperty(exports, "default", {
64
+ enumerable: true,
65
+ get: function () {
66
+ return _npmCli.default;
67
+ }
68
+ });
69
+ var _npmCli = _interopRequireWildcard(npmCli$1, true);
70
+ Object.keys(_npmCli).forEach(function (key) {
71
+ if (key === "default" || key === "__esModule") return;
72
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
73
+ if (key in exports && exports[key] === _npmCli[key]) return;
74
+ Object.defineProperty(exports, key, {
75
+ enumerable: true,
76
+ get: function () {
77
+ return _npmCli[key];
78
+ }
79
+ });
80
+ });
81
+ } (npmCli$2));
82
+
83
+ var npmCli = /*@__PURE__*/constants.getDefaultExportFromCjs(npmCli$2);
84
+
85
+ module.exports = npmCli;
@@ -1,28 +1,31 @@
1
1
  'use strict';
2
2
 
3
- var vendor = require('./vendor.js');
3
+ var constants = require('./constants.js');
4
+ var require$$0$2 = require('@babel/runtime/helpers/interopRequireWildcard');
5
+ var require$$0$1 = require('@babel/runtime/helpers/interopRequireDefault');
6
+ var require$$1$2 = require('node:events');
4
7
  var require$$0 = require('node:fs');
5
- var require$$1$1 = require('node:path');
6
- var require$$1$3 = require('node:events');
7
8
  var require$$3$3 = require('node:https');
9
+ var require$$1 = require('node:path');
8
10
  var require$$3 = require('node:readline');
9
11
  var require$$5 = require('node:stream');
10
12
  var require$$7$1 = require('node:timers/promises');
13
+ var require$$3$1 = require('is-interactive');
11
14
  var require$$5$1 = require('npm-package-arg');
12
15
  var require$$3$2 = require('@socketregistry/yocto-spinner');
13
- var require$$3$1 = require('semver');
16
+ var require$$4 = require('semver');
14
17
  var require$$6$1 = require('@socketsecurity/config');
15
18
  var require$$7 = require('@socketsecurity/registry/lib/objects');
16
- var require$$1$2 = require('node:net');
17
- var require$$1 = require('node:os');
18
- var require$$6 = require('../package.json');
19
+ var require$$1$1 = require('node:net');
20
+ var require$$2 = require('node:os');
21
+ var require$$6 = require('../../package.json');
19
22
  var sdk = require('./sdk.js');
20
23
  var pathResolve = require('./path-resolve.js');
21
24
  var link = require('./link.js');
22
25
 
23
- var npmInjection$1 = {};
26
+ var npmInjection$2 = {};
24
27
 
25
- var npmInjection = {};
28
+ var npmInjection$1 = {};
26
29
 
27
30
  var arborist = {};
28
31
 
@@ -32,10 +35,10 @@ Object.defineProperty(ttyServer$1, "__esModule", {
32
35
  value: true
33
36
  });
34
37
  ttyServer$1.createTTYServer = createTTYServer;
35
- var _nodeFs$2 = require$$0;
36
- var _nodeNet = require$$1$2;
37
- var _nodeOs = require$$1;
38
- var _nodePath$2 = require$$1$1;
38
+ var _nodeFs$1 = require$$0;
39
+ var _nodeNet = require$$1$1;
40
+ var _nodeOs = require$$2;
41
+ var _nodePath$1 = require$$1;
39
42
  var _nodeReadline$1 = require$$3;
40
43
  var _nodeStream$1 = require$$5;
41
44
  var _package = require$$6;
@@ -43,7 +46,7 @@ var _misc$1 = sdk.misc;
43
46
  const NEWLINE_CHAR_CODE = 10; /*'\n'*/
44
47
 
45
48
  const TTY_IPC = process.env['SOCKET_SECURITY_TTY_IPC'];
46
- const sock = _nodePath$2.join(_nodeOs.tmpdir(), `socket-security-tty-${process.pid}.sock`);
49
+ const sock = _nodePath$1.join(_nodeOs.tmpdir(), `socket-security-tty-${process.pid}.sock`);
47
50
  process.env['SOCKET_SECURITY_TTY_IPC'] = sock;
48
51
  function createNonStandardTTYServer() {
49
52
  return {
@@ -216,7 +219,7 @@ function createStandardTTYServer(isInteractive, npmlog) {
216
219
  }
217
220
  function tryUnlinkSync(filepath) {
218
221
  try {
219
- (0, _nodeFs$2.unlinkSync)(filepath);
222
+ (0, _nodeFs$1.unlinkSync)(filepath);
220
223
  } catch (e) {
221
224
  if ((0, _misc$1.isErrnoException)(e) && e.code !== 'ENOENT') {
222
225
  throw e;
@@ -375,27 +378,27 @@ function createIssueUXLookup(settings) {
375
378
  };
376
379
  }
377
380
 
378
- var _interopRequireDefault = vendor.interopRequireDefault.default;
381
+ var _interopRequireDefault = require$$0$1.default;
379
382
  Object.defineProperty(arborist, "__esModule", {
380
383
  value: true
381
384
  });
382
385
  arborist.SafeArborist = void 0;
383
386
  arborist.installSafeArborist = installSafeArborist;
384
- var _nodeEvents = require$$1$3;
385
- var _nodeFs$1 = require$$0;
387
+ var _nodeEvents = require$$1$2;
388
+ var _nodeFs = require$$0;
386
389
  var _nodeHttps = require$$3$3;
387
- var _nodePath$1 = require$$1$1;
390
+ var _nodePath = require$$1;
388
391
  var _nodeReadline = require$$3;
389
392
  var _nodeStream = require$$5;
390
393
  var _promises = require$$7$1;
391
- var _isInteractive = _interopRequireDefault(vendor.isInteractive);
394
+ var _isInteractive = _interopRequireDefault(require$$3$1);
392
395
  var _npmPackageArg = require$$5$1;
393
396
  var _yoctoSpinner = require$$3$2;
394
- var _semver = require$$3$1;
397
+ var _semver = require$$4;
395
398
  var _config = require$$6$1;
396
399
  var _objects = require$$7;
397
400
  var _ttyServer = ttyServer$1;
398
- var _constants = sdk.constants;
401
+ var _constants$1 = constants.constants;
399
402
  var _colorOrMarkdown = sdk.colorOrMarkdown;
400
403
  var _issueRules = issueRules;
401
404
  var _misc = sdk.misc;
@@ -403,10 +406,8 @@ var _pathResolve = pathResolve.pathResolve;
403
406
  var _sdk = sdk.sdk;
404
407
  var _settings = sdk.settings;
405
408
  const POTENTIALLY_BUG_ERROR_SNIPPET = 'this is potentially a bug with socket-npm caused by changes to the npm cli';
406
- const distPath$1 = __dirname;
407
- const rootPath$1 = _nodePath$1.resolve(distPath$1, '..');
408
- const npmEntrypoint = (0, _nodeFs$1.realpathSync)(process.argv[1]);
409
- const npmRootPath = (0, _pathResolve.findRoot)(_nodePath$1.dirname(npmEntrypoint));
409
+ const npmEntrypoint = (0, _nodeFs.realpathSync)(process.argv[1]);
410
+ const npmRootPath = (0, _pathResolve.findRoot)(_nodePath.dirname(npmEntrypoint));
410
411
  function tryRequire(...ids) {
411
412
  for (const data of ids) {
412
413
  let id;
@@ -436,26 +437,26 @@ if (npmRootPath === undefined) {
436
437
  }
437
438
  const LOOP_SENTINEL = 1_000_000;
438
439
  const NPM_REGISTRY_URL = 'https://registry.npmjs.org';
439
- const npmNmPath = _nodePath$1.join(npmRootPath, 'node_modules');
440
- const arboristPkgPath = _nodePath$1.join(npmNmPath, '@npmcli/arborist');
441
- const arboristClassPath = _nodePath$1.join(arboristPkgPath, 'lib/arborist/index.js');
442
- const arboristDepValidPath = _nodePath$1.join(arboristPkgPath, 'lib/dep-valid.js');
443
- const arboristEdgeClassPath = _nodePath$1.join(arboristPkgPath, 'lib/edge.js');
444
- const arboristNodeClassPath = _nodePath$1.join(arboristPkgPath, 'lib/node.js');
445
- const arboristOverrideSetClassPatch = _nodePath$1.join(arboristPkgPath, 'lib/override-set.js');
446
- const log = tryRequire([_nodePath$1.join(npmNmPath, 'proc-log/lib/index.js'),
440
+ const npmNmPath = _nodePath.join(npmRootPath, 'node_modules');
441
+ const arboristPkgPath = _nodePath.join(npmNmPath, '@npmcli/arborist');
442
+ const arboristClassPath = _nodePath.join(arboristPkgPath, 'lib/arborist/index.js');
443
+ const arboristDepValidPath = _nodePath.join(arboristPkgPath, 'lib/dep-valid.js');
444
+ const arboristEdgeClassPath = _nodePath.join(arboristPkgPath, 'lib/edge.js');
445
+ const arboristNodeClassPath = _nodePath.join(arboristPkgPath, 'lib/node.js');
446
+ const arboristOverrideSetClassPatch = _nodePath.join(arboristPkgPath, 'lib/override-set.js');
447
+ const log = tryRequire([_nodePath.join(npmNmPath, 'proc-log/lib/index.js'),
447
448
  // The proc-log DefinitelyTyped definition is incorrect. The type definition
448
449
  // is really that of its export log.
449
- mod => mod.log], _nodePath$1.join(npmNmPath, 'npmlog/lib/log.js'));
450
+ mod => mod.log], _nodePath.join(npmNmPath, 'npmlog/lib/log.js'));
450
451
  if (log === undefined) {
451
452
  console.error(`Unable to integrate with npm cli logging infrastructure, ${POTENTIALLY_BUG_ERROR_SNIPPET}.`);
452
453
  process.exit(127);
453
454
  }
454
- const pacote = tryRequire(_nodePath$1.join(npmNmPath, 'pacote'), 'pacote');
455
+ const pacote = tryRequire(_nodePath.join(npmNmPath, 'pacote'), 'pacote');
455
456
  const {
456
457
  tarball
457
458
  } = pacote;
458
- const translations = require(_nodePath$1.join(rootPath$1, 'translations.json'));
459
+ const translations = require(_nodePath.join(_constants$1.rootPath, 'translations.json'));
459
460
  const abortController = new AbortController();
460
461
  const {
461
462
  signal: abortSignal
@@ -484,11 +485,11 @@ async function uxLookup(settings) {
484
485
  }
485
486
  async function* batchScan(pkgIds) {
486
487
  const query = {
487
- packages: pkgIds.map(pkgid => {
488
+ packages: pkgIds.map(id => {
488
489
  const {
489
490
  name,
490
491
  version
491
- } = pkgidParts(pkgid);
492
+ } = pkgidParts(id);
492
493
  return {
493
494
  eco: 'npm',
494
495
  pkg: name,
@@ -498,7 +499,7 @@ async function* batchScan(pkgIds) {
498
499
  })
499
500
  };
500
501
  // TODO: Migrate to SDK.
501
- const pkgDataReq = _nodeHttps.request(`${_constants.API_V0_URL}/scan/batch`, {
502
+ const pkgDataReq = _nodeHttps.request(`${_constants$1.API_V0_URL}/scan/batch`, {
502
503
  method: 'POST',
503
504
  headers: {
504
505
  Authorization: `Basic ${Buffer.from(`${pubToken}:`).toString('base64url')}`
@@ -530,10 +531,10 @@ function findSocketYmlSync() {
530
531
  let prevDir = null;
531
532
  let dir = process.cwd();
532
533
  while (dir !== prevDir) {
533
- let ymlPath = _nodePath$1.join(dir, 'socket.yml');
534
+ let ymlPath = _nodePath.join(dir, 'socket.yml');
534
535
  let yml = maybeReadfileSync(ymlPath);
535
536
  if (yml === undefined) {
536
- ymlPath = _nodePath$1.join(dir, 'socket.yaml');
537
+ ymlPath = _nodePath.join(dir, 'socket.yaml');
537
538
  yml = maybeReadfileSync(ymlPath);
538
539
  }
539
540
  if (typeof yml === 'string') {
@@ -547,7 +548,7 @@ function findSocketYmlSync() {
547
548
  }
548
549
  }
549
550
  prevDir = dir;
550
- dir = _nodePath$1.join(dir, '..');
551
+ dir = _nodePath.join(dir, '..');
551
552
  }
552
553
  return null;
553
554
  }
@@ -575,28 +576,33 @@ function findSpecificOverrideSet(first, second) {
575
576
  }
576
577
  function maybeReadfileSync(filepath) {
577
578
  try {
578
- return (0, _nodeFs$1.readFileSync)(filepath, 'utf8');
579
+ return (0, _nodeFs.readFileSync)(filepath, 'utf8');
579
580
  } catch {}
580
581
  return undefined;
581
582
  }
582
583
  async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
584
+ const spinner = _yoctoSpinner({
585
+ stream: output
586
+ });
583
587
  let result = false;
584
- let remaining = pkgs.length;
588
+ let {
589
+ length: remaining
590
+ } = pkgs;
585
591
  if (!remaining) {
586
- _yoctoSpinner().success('No changes detected');
592
+ spinner.success('No changes detected');
587
593
  return result;
588
594
  }
589
595
  const getText = () => `Looking up data for ${remaining} packages`;
590
- const spinner = _yoctoSpinner({
591
- stream: output
592
- }).start(getText());
596
+ spinner.start(getText());
593
597
  try {
594
- for await (const pkgData of batchScan(pkgs.map(pkg => pkg.pkgid))) {
595
- let failures = [];
596
- let displayWarning = false;
597
- const name = pkgData.pkg;
598
- const version = pkgData.ver;
598
+ for await (const pkgData of batchScan(pkgs.map(p => p.pkgid))) {
599
+ const {
600
+ pkg: name,
601
+ ver: version
602
+ } = pkgData;
599
603
  const id = `${name}@${version}`;
604
+ let displayWarning = false;
605
+ let failures = [];
600
606
  if (pkgData.type === 'missing') {
601
607
  result = true;
602
608
  failures.push({
@@ -622,7 +628,7 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
622
628
  });
623
629
  // Before we ask about problematic issues, check to see if they
624
630
  // already existed in the old version if they did, be quiet.
625
- const pkg = pkgs.find(pkg => pkg.pkgid === id && pkg.existing?.startsWith(`${name}@`));
631
+ const pkg = pkgs.find(p => p.pkgid === id && p.existing?.startsWith(`${name}@`));
626
632
  if (pkg?.existing) {
627
633
  // eslint-disable-next-line no-await-in-loop
628
634
  for await (const oldPkgData of batchScan([pkg.existing])) {
@@ -641,7 +647,7 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
641
647
  }
642
648
  }
643
649
  if (!blocked) {
644
- const pkg = pkgs.find(pkg => pkg.pkgid === id);
650
+ const pkg = pkgs.find(p => p.pkgid === id);
645
651
  if (pkg) {
646
652
  await tarball.stream(id, stream => {
647
653
  stream.resume();
@@ -653,8 +659,7 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
653
659
  }
654
660
  }
655
661
  if (displayWarning) {
656
- spinner.stop();
657
- output?.write(`(socket) ${formatter.hyperlink(id, `https://socket.dev/npm/package/${name}/overview/${version}`)} contains risks:\n`);
662
+ spinner.stop(`(socket) ${formatter.hyperlink(id, `https://socket.dev/npm/package/${name}/overview/${version}`)} contains risks:`);
658
663
  failures.sort((a, b) => a.raw.type < b.raw.type ? -1 : 1);
659
664
  const lines = new Set();
660
665
  for (const failure of failures) {
@@ -675,9 +680,7 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
675
680
  }
676
681
  return result;
677
682
  } finally {
678
- if (spinner.isSpinning) {
679
- spinner.stop();
680
- }
683
+ spinner.stop();
681
684
  }
682
685
  }
683
686
  function pkgidParts(pkgid) {
@@ -689,18 +692,8 @@ function pkgidParts(pkgid) {
689
692
  version
690
693
  };
691
694
  }
692
- function toPURL(pkgid, resolved) {
693
- const repo = resolved.replace(/#[\s\S]*$/u, '').replace(/\?[\s\S]*$/u, '').replace(/\/[^/]*\/-\/[\s\S]*$/u, '');
694
- const {
695
- name,
696
- version
697
- } = pkgidParts(pkgid);
698
- return {
699
- type: 'npm',
700
- namespace_and_name: name,
701
- version,
702
- repository_url: repo
703
- };
695
+ function toRepoUrl(resolved) {
696
+ return resolved.replace(/#[\s\S]*$/, '').replace(/\?[\s\S]*$/, '').replace(/\/[^/]*\/-\/[\s\S]*$/, '');
704
697
  }
705
698
  function walk(diff_, needInfoOn = []) {
706
699
  const queue = [diff_];
@@ -731,12 +724,8 @@ function walk(diff_, needInfoOn = []) {
731
724
  if (keep && diff.ideal?.pkgid && diff.ideal.resolved && (!diff.actual || diff.actual.resolved)) {
732
725
  needInfoOn.push({
733
726
  existing,
734
- action: diff.action,
735
- location: diff.ideal.location,
736
727
  pkgid: diff.ideal.pkgid,
737
- newPackage: toPURL(diff.ideal.pkgid, diff.ideal.resolved),
738
- oldPackage: diff.actual && diff.actual.resolved ? toPURL(diff.actual.pkgid, diff.actual.resolved) : null,
739
- resolved: diff.ideal.resolved
728
+ repository_url: toRepoUrl(diff.ideal.resolved)
740
729
  });
741
730
  }
742
731
  }
@@ -1427,10 +1416,10 @@ class SafeArborist extends Arborist {
1427
1416
  options['save'] = old.save;
1428
1417
  options['saveBundle'] = old.saveBundle;
1429
1418
  // Nothing to check, mmm already installed or all private?
1430
- if (diff.findIndex(c => c.newPackage.repository_url === NPM_REGISTRY_URL) === -1) {
1419
+ if (diff.findIndex(c => c.repository_url === NPM_REGISTRY_URL) === -1) {
1431
1420
  return await this[kRiskyReify](...args);
1432
1421
  }
1433
- let proceed = _constants.ENV.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE;
1422
+ let proceed = _constants$1.ENV.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE;
1434
1423
  if (!proceed) {
1435
1424
  proceed = await ttyServer.captureTTY(async (input, output) => {
1436
1425
  if (input && output) {
@@ -1567,21 +1556,16 @@ void (async () => {
1567
1556
  _uxLookup = (0, _issueRules.createIssueUXLookup)(settings);
1568
1557
  })();
1569
1558
 
1570
- var _nodeFs = require$$0;
1571
- var _nodePath = require$$1$1;
1559
+ var _constants = constants.constants;
1572
1560
  var _arborist = arborist;
1573
1561
  var _link = link.link;
1574
- const distPath = __dirname;
1575
- const rootPath = _nodePath.resolve(distPath, '..');
1576
- const binPath = _nodePath.join(rootPath, 'bin');
1577
-
1578
- // shadow `npm` and `npx` to mitigate subshells
1579
- (0, _link.installLinks)((0, _nodeFs.realpathSync)(binPath), 'npm');
1562
+ // Shadow `npm` and `npx` to mitigate subshells.
1563
+ (0, _link.installLinks)(_constants.shadowBinPath, 'npm');
1580
1564
  (0, _arborist.installSafeArborist)();
1581
1565
 
1582
1566
  (function (exports) {
1583
1567
 
1584
- var _interopRequireWildcard = vendor.interopRequireWildcard.default;
1568
+ var _interopRequireWildcard = require$$0$2.default;
1585
1569
  Object.defineProperty(exports, "__esModule", {
1586
1570
  value: true
1587
1571
  });
@@ -1592,7 +1576,7 @@ const binPath = _nodePath.join(rootPath, 'bin');
1592
1576
  return _npmInjection.default;
1593
1577
  }
1594
1578
  });
1595
- var _npmInjection = _interopRequireWildcard(npmInjection, true);
1579
+ var _npmInjection = _interopRequireWildcard(npmInjection$1, true);
1596
1580
  Object.keys(_npmInjection).forEach(function (key) {
1597
1581
  if (key === "default" || key === "__esModule") return;
1598
1582
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -1604,6 +1588,8 @@ const binPath = _nodePath.join(rootPath, 'bin');
1604
1588
  }
1605
1589
  });
1606
1590
  });
1607
- } (npmInjection$1));
1591
+ } (npmInjection$2));
1592
+
1593
+ var npmInjection = /*@__PURE__*/constants.getDefaultExportFromCjs(npmInjection$2);
1608
1594
 
1609
- module.exports = npmInjection$1;
1595
+ module.exports = npmInjection;
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ var constants = require('./constants.js');
5
+ var require$$0 = require('@babel/runtime/helpers/interopRequireWildcard');
6
+ var require$$1 = require('node:path');
7
+ var require$$1$1 = require('@npmcli/promise-spawn');
8
+ var link = require('./link.js');
9
+
10
+ var npxCli$2 = {};
11
+
12
+ var npxCli$1 = {};
13
+
14
+ var _nodePath = require$$1;
15
+ var _promiseSpawn = require$$1$1;
16
+ var _constants = constants.constants;
17
+ var _link = link.link;
18
+ const npxPath = (0, _link.installLinks)(_constants.shadowBinPath, 'npx');
19
+ const injectionPath = _nodePath.join(_constants.distPath, 'npm-injection.js');
20
+ process.exitCode = 1;
21
+ const spawnPromise = _promiseSpawn(process.execPath, ['--disable-warning', 'ExperimentalWarning', '--require', injectionPath, npxPath, ...process.argv.slice(2)], {
22
+ stdio: 'inherit'
23
+ });
24
+ spawnPromise.process.on('exit', (code, signal) => {
25
+ if (signal) {
26
+ process.kill(process.pid, signal);
27
+ } else if (code !== null) {
28
+ process.exit(code);
29
+ }
30
+ });
31
+
32
+ (function (exports) {
33
+
34
+ var _interopRequireWildcard = require$$0.default;
35
+ Object.defineProperty(exports, "__esModule", {
36
+ value: true
37
+ });
38
+ var _exportNames = {};
39
+ Object.defineProperty(exports, "default", {
40
+ enumerable: true,
41
+ get: function () {
42
+ return _npxCli.default;
43
+ }
44
+ });
45
+ var _npxCli = _interopRequireWildcard(npxCli$1, true);
46
+ Object.keys(_npxCli).forEach(function (key) {
47
+ if (key === "default" || key === "__esModule") return;
48
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
49
+ if (key in exports && exports[key] === _npxCli[key]) return;
50
+ Object.defineProperty(exports, key, {
51
+ enumerable: true,
52
+ get: function () {
53
+ return _npxCli[key];
54
+ }
55
+ });
56
+ });
57
+ } (npxCli$2));
58
+
59
+ var npxCli = /*@__PURE__*/constants.getDefaultExportFromCjs(npxCli$2);
60
+
61
+ module.exports = npxCli;
@@ -3,11 +3,7 @@ import { SocketSdk } from '@socketsecurity/sdk';
3
3
  declare function createDebugLogger(printDebugLogs?: boolean): typeof console.error;
4
4
  declare function isErrnoException(value: unknown): value is NodeJS.ErrnoException;
5
5
  declare function stringJoinWithSeparateFinalSeparator(list: (string | undefined)[], separator?: string): string;
6
- declare const API_V0_URL = "https://api.socket.dev/v0";
7
- declare const ENV: Readonly<{
8
- UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: boolean;
9
- }>;
10
6
  declare const FREE_API_KEY = "sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api";
11
7
  declare function getDefaultKey(): string | undefined;
12
8
  declare function setupSdk(apiKey?: string | undefined, apiBaseUrl?: string | undefined, proxy?: string | undefined): Promise<SocketSdk>;
13
- export { createDebugLogger, isErrnoException, stringJoinWithSeparateFinalSeparator, API_V0_URL, ENV, FREE_API_KEY, getDefaultKey, setupSdk };
9
+ export { createDebugLogger, isErrnoException, stringJoinWithSeparateFinalSeparator, FREE_API_KEY, getDefaultKey, setupSdk };