@socketsecurity/cli 0.14.33 → 0.14.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.
Files changed (38) hide show
  1. package/bin/cli.js +2 -4
  2. package/bin/npm-cli.js +2 -4
  3. package/bin/npx-cli.js +2 -4
  4. package/dist/constants.js +68 -0
  5. package/dist/module-sync/cli.d.ts +0 -1
  6. package/dist/module-sync/cli.js +184 -164
  7. package/dist/module-sync/constants.d.ts +91 -18
  8. package/dist/module-sync/constants.js +2 -79
  9. package/dist/module-sync/link.js +9 -12
  10. package/dist/module-sync/npm-cli.js +23 -19
  11. package/dist/module-sync/npm-injection.js +98 -99
  12. package/dist/module-sync/npx-cli.js +21 -17
  13. package/dist/module-sync/path-resolve.js +11 -14
  14. package/dist/module-sync/sdk.js +30 -29
  15. package/dist/module-sync/vendor.js +0 -12
  16. package/dist/require/cli.js +168 -148
  17. package/dist/require/constants.js +2 -79
  18. package/dist/require/link.js +9 -12
  19. package/dist/require/npm-cli.js +23 -19
  20. package/dist/require/npm-injection.js +98 -99
  21. package/dist/require/npx-cli.js +21 -17
  22. package/dist/require/path-resolve.js +11 -14
  23. package/dist/require/sdk.js +26 -25
  24. package/dist/require/vendor.js +30 -115
  25. package/package.json +18 -32
  26. package/dist/module-sync/cli.d.ts.map +0 -1
  27. package/dist/require/cli.d.ts +0 -3
  28. package/dist/require/cli.d.ts.map +0 -1
  29. package/dist/require/color-or-markdown.d.ts +0 -23
  30. package/dist/require/constants.d.ts +0 -21
  31. package/dist/require/errors.d.ts +0 -7
  32. package/dist/require/link.d.ts +0 -2
  33. package/dist/require/npm-cli.d.ts +0 -2
  34. package/dist/require/npm-injection.d.ts +0 -1
  35. package/dist/require/npx-cli.d.ts +0 -2
  36. package/dist/require/path-resolve.d.ts +0 -8
  37. package/dist/require/sdk.d.ts +0 -8
  38. package/dist/require/settings.d.ts +0 -9
@@ -1,80 +1,3 @@
1
- 'use strict';
1
+ 'use strict'
2
2
 
3
- function _interop(e) {
4
- let d
5
- if (e) {
6
- let c = 0
7
- for (const k in e) {
8
- d = c++ === 0 && k === 'default' ? e[k] : void 0
9
- if (!d) break
10
- }
11
- }
12
- return d ?? e
13
- }
14
-
15
- var require$$0 = _interop(require('node:fs'));
16
- var require$$1 = _interop(require('node:path'));
17
- var require$$2 = _interop(require('@socketsecurity/registry/lib/env'));
18
- var require$$3 = _interop(require('@socketsecurity/registry/lib/constants'));
19
- var require$$4 = _interop(require('semver'));
20
-
21
- var constants = {};
22
-
23
- Object.defineProperty(constants, "__esModule", {
24
- value: true
25
- });
26
- constants.synpBinPath = constants.shadowBinPath = constants.rootPkgJsonPath = constants.rootPath = constants.rootDistPath = constants.rootBinPath = constants.nmBinPath = constants.distPath = constants.cdxgenBinPath = constants.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE = constants.SUPPORTS_SYNC_ESM = constants.SOCKET_PUBLIC_API_KEY = constants.SOCKET_CLI_ISSUES_URL = constants.NPM_REGISTRY_URL = constants.LOOP_SENTINEL = constants.ENV = constants.DIST_TYPE = constants.API_V0_URL = void 0;
27
- var _nodeFs = require$$0;
28
- var _nodePath = require$$1;
29
- var _env = require$$2;
30
- var _constants = require$$3;
31
- var _semver = require$$4;
32
- const {
33
- PACKAGE_JSON
34
- } = _constants;
35
- const SUPPORTS_SYNC_ESM = constants.SUPPORTS_SYNC_ESM = _semver.satisfies(process.versions.node, '>=22.12');
36
- constants.API_V0_URL = 'https://api.socket.dev/v0';
37
- const DIST_TYPE = constants.DIST_TYPE = SUPPORTS_SYNC_ESM ? 'module-sync' : 'require';
38
- constants.LOOP_SENTINEL = 1_000_000;
39
- constants.NPM_REGISTRY_URL = 'https://registry.npmjs.org';
40
- constants.SOCKET_PUBLIC_API_KEY = 'sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api';
41
- const SOCKET_CLI_ISSUES_URL = constants.SOCKET_CLI_ISSUES_URL = 'https://github.com/SocketDev/socket-cli/issues';
42
- const UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE = constants.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE = 'UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE';
43
- constants.ENV = Object.freeze({
44
- // Flag set by the optimize command to bypass the packagesHaveRiskyIssues check.
45
- [UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE]: (0, _env.envAsBoolean)(process.env[UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE])
46
- });
47
-
48
- // Dynamically detect the rootPath so constants.ts can be used in tests.
49
- const rootPath = constants.rootPath = (() => {
50
- let oldPath;
51
- let currPath = (0, _nodeFs.realpathSync)(__dirname);
52
- // Dirname stops when at the filepath root, e.g. '/' for posix and 'C:\\' for win32,
53
- // so `currPath` equal `oldPath`.
54
- while (currPath !== oldPath) {
55
- const pkgJsonPath = _nodePath.join(currPath, PACKAGE_JSON);
56
- if ((0, _nodeFs.existsSync)(pkgJsonPath)) {
57
- try {
58
- // Content matching @socketsecurity/cli is replaced by
59
- // the @rollup/plugin-replace plugin used in .config/rollup.base.config.mjs
60
- // with either 'socket' or '@socketsecurity/cli'.
61
- if (require(pkgJsonPath)?.name === '@socketsecurity/cli') {
62
- return currPath;
63
- }
64
- } catch {}
65
- }
66
- oldPath = currPath;
67
- currPath = _nodePath.dirname(currPath);
68
- }
69
- throw new TypeError(`Socket CLI initialization error: rootPath cannot be resolved.\n\nPlease report to ${SOCKET_CLI_ISSUES_URL}.`);
70
- })();
71
- const rootDistPath = constants.rootDistPath = _nodePath.join(rootPath, 'dist');
72
- constants.rootBinPath = _nodePath.join(rootPath, 'bin');
73
- constants.rootPkgJsonPath = _nodePath.join(rootPath, PACKAGE_JSON);
74
- const nmBinPath = constants.nmBinPath = _nodePath.join(rootPath, 'node_modules/.bin');
75
- constants.cdxgenBinPath = _nodePath.join(nmBinPath, 'cdxgen');
76
- constants.distPath = _nodePath.join(rootDistPath, DIST_TYPE);
77
- constants.shadowBinPath = _nodePath.join(rootPath, 'shadow', DIST_TYPE);
78
- constants.synpBinPath = _nodePath.join(nmBinPath, 'synp');
79
-
80
- exports.constants = constants;
3
+ module.exports = require('../constants.js')
@@ -1,20 +1,17 @@
1
1
  'use strict';
2
2
 
3
- function _interop(e) {
4
- let d
5
- if (e) {
6
- let c = 0
7
- for (const k in e) {
8
- d = c++ === 0 && k === 'default' ? e[k] : void 0
9
- if (!d) break
10
- }
3
+ function _socketInterop(e) {
4
+ let c = 0
5
+ for (const k in e ?? {}) {
6
+ c = c === 0 && k === 'default' ? 1 : 0
7
+ if (!c) break
11
8
  }
12
- return d ?? e
9
+ return c ? e.default : e
13
10
  }
14
11
 
15
- var require$$0 = _interop(require('node:fs'));
16
- var require$$1 = _interop(require('node:path'));
17
- var require$$4 = _interop(require('which'));
12
+ var require$$0 = require('node:fs');
13
+ var require$$1 = require('node:path');
14
+ var require$$4 = _socketInterop(require('which'));
18
15
 
19
16
  var link = {};
20
17
 
@@ -1,25 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- function _interop(e) {
5
- let d
6
- if (e) {
7
- let c = 0
8
- for (const k in e) {
9
- d = c++ === 0 && k === 'default' ? e[k] : void 0
10
- if (!d) break
11
- }
4
+ function _socketInterop(e) {
5
+ let c = 0
6
+ for (const k in e ?? {}) {
7
+ c = c === 0 && k === 'default' ? 1 : 0
8
+ if (!c) break
12
9
  }
13
- return d ?? e
10
+ return c ? e.default : e
14
11
  }
15
12
 
16
- var vendor = _interop(require('./vendor.js'));
17
- var require$$0 = _interop(require('node:fs'));
18
- var require$$1 = _interop(require('node:path'));
19
- var require$$1$1 = _interop(require('@npmcli/promise-spawn'));
20
- var constants = _interop(require('./constants.js'));
21
- var link = _interop(require('./link.js'));
22
- var pathResolve = _interop(require('./path-resolve.js'));
13
+ var vendor = require('./vendor.js');
14
+ var require$$0 = require('node:fs');
15
+ var require$$1 = require('node:path');
16
+ var require$$1$1 = _socketInterop(require('@npmcli/promise-spawn'));
17
+ var constants = require('./constants.js');
18
+ var link = require('./link.js');
19
+ var pathResolve = require('./path-resolve.js');
23
20
 
24
21
  var npmCli$2 = {};
25
22
 
@@ -31,8 +28,13 @@ var _promiseSpawn = require$$1$1;
31
28
  var _constants = constants.constants;
32
29
  var _link = link.link;
33
30
  var _pathResolve = pathResolve.pathResolve;
34
- const npmPath = (0, _link.installLinks)(_constants.shadowBinPath, 'npm');
35
- const injectionPath = _nodePath.join(_constants.distPath, 'npm-injection.js');
31
+ const {
32
+ distPath,
33
+ execPath,
34
+ shadowBinPath
35
+ } = _constants;
36
+ const npmPath = (0, _link.installLinks)(shadowBinPath, 'npm');
37
+ const injectionPath = _nodePath.join(distPath, 'npm-injection.js');
36
38
 
37
39
  // Adding the `--quiet` and `--no-progress` flags when the `proc-log` module
38
40
  // is found to fix a UX issue when running the command with recent versions of
@@ -54,7 +56,9 @@ if (npmArgs.includes('install') && !npmArgs.includes('--no-progress') && !npmArg
54
56
  }
55
57
  }
56
58
  process.exitCode = 1;
57
- const spawnPromise = _promiseSpawn(process.execPath, ['--disable-warning', 'ExperimentalWarning', '--require', injectionPath, npmPath, ...npmArgs], {
59
+ const spawnPromise = _promiseSpawn(execPath, [
60
+ // Lazily access constants.nodeNoWarningsFlags.
61
+ ..._constants.nodeNoWarningsFlags, '--require', injectionPath, npmPath, ...npmArgs], {
58
62
  stdio: 'inherit'
59
63
  });
60
64
  spawnPromise.process.on('exit', (code, signal) => {
@@ -1,37 +1,35 @@
1
1
  'use strict';
2
2
 
3
- function _interop(e) {
4
- let d
5
- if (e) {
6
- let c = 0
7
- for (const k in e) {
8
- d = c++ === 0 && k === 'default' ? e[k] : void 0
9
- if (!d) break
10
- }
3
+ function _socketInterop(e) {
4
+ let c = 0
5
+ for (const k in e ?? {}) {
6
+ c = c === 0 && k === 'default' ? 1 : 0
7
+ if (!c) break
11
8
  }
12
- return d ?? e
9
+ return c ? e.default : e
13
10
  }
14
11
 
15
- var vendor = _interop(require('./vendor.js'));
16
- var constants = _interop(require('./constants.js'));
17
- var require$$1$4 = _interop(require('node:events'));
18
- var require$$0 = _interop(require('node:fs'));
19
- var require$$3$2 = _interop(require('node:https'));
20
- var require$$1$1 = _interop(require('node:path'));
21
- var require$$3 = _interop(require('node:readline'));
22
- var require$$6$2 = _interop(require('node:timers/promises'));
23
- var require$$1$3 = _interop(require('@inquirer/confirm'));
24
- var require$$3$1 = _interop(require('@socketregistry/yocto-spinner'));
25
- var require$$5$1 = _interop(require('npm-package-arg'));
26
- var require$$4 = _interop(require('semver'));
27
- var require$$6$1 = _interop(require('@socketsecurity/config'));
28
- var require$$7 = _interop(require('@socketsecurity/registry/lib/objects'));
29
- var require$$1$2 = _interop(require('node:net'));
30
- var require$$1 = _interop(require('node:os'));
31
- var require$$5 = _interop(require('node:stream'));
32
- var sdk = _interop(require('./sdk.js'));
33
- var pathResolve = _interop(require('./path-resolve.js'));
34
- var link = _interop(require('./link.js'));
12
+ var vendor = require('./vendor.js');
13
+ var constants = require('./constants.js');
14
+ var require$$1$4 = require('node:events');
15
+ var require$$0 = require('node:fs');
16
+ var require$$3$3 = require('node:https');
17
+ var require$$1$1 = require('node:path');
18
+ var require$$3 = require('node:readline');
19
+ var require$$6$2 = require('node:timers/promises');
20
+ var require$$1$3 = require('@socketsecurity/registry/lib/prompts');
21
+ var require$$3$2 = require('@socketregistry/yocto-spinner');
22
+ var require$$5$1 = _socketInterop(require('npm-package-arg'));
23
+ var require$$3$1 = _socketInterop(require('semver'));
24
+ var require$$6$1 = require('@socketsecurity/config');
25
+ var require$$7 = require('@socketsecurity/registry/lib/objects');
26
+ var require$$8 = require('@socketsecurity/registry/lib/packages');
27
+ var require$$1$2 = require('node:net');
28
+ var require$$1 = require('node:os');
29
+ var require$$5 = require('node:stream');
30
+ var sdk = require('./sdk.js');
31
+ var pathResolve = require('./path-resolve.js');
32
+ var link = require('./link.js');
35
33
 
36
34
  var npmInjection$2 = {};
37
35
 
@@ -42,7 +40,7 @@ var arborist = {};
42
40
  var ttyServer$1 = {};
43
41
 
44
42
  var name = "@socketsecurity/cli";
45
- var version = "0.14.33";
43
+ var version = "0.14.34";
46
44
  var description = "CLI tool for Socket.dev";
47
45
  var homepage = "http://github.com/SocketDev/socket-cli";
48
46
  var license = "MIT";
@@ -63,34 +61,19 @@ var bin = {
63
61
  };
64
62
  var exports$1 = {
65
63
  "./bin/cli.js": {
66
- "module-sync": {
67
- types: "./dist/module-sync/cli.d.ts",
68
- "default": "./dist/module-sync/cli.js"
69
- },
70
- require: {
71
- types: "./dist/require/cli.d.ts",
72
- "default": "./dist/require/cli.js"
73
- }
64
+ types: "./dist/module-sync/cli.d.ts",
65
+ "module-sync": "./dist/module-sync/cli.js",
66
+ require: "./dist/require/cli.js"
74
67
  },
75
68
  "./bin/npm-cli.js": {
76
- "module-sync": {
77
- types: "./dist/module-sync/npm-cli.d.ts",
78
- "default": "./dist/module-sync/npm-cli.js"
79
- },
80
- require: {
81
- types: "./dist/require/npm-cli.d.ts",
82
- "default": "./dist/require/npm-cli.js"
83
- }
69
+ types: "./dist/module-sync/npm-cli.d.ts",
70
+ "module-sync": "./dist/module-sync/npm-cli.js",
71
+ require: "./dist/require/npm-cli.js"
84
72
  },
85
73
  "./bin/npx-cli.js": {
86
- "module-sync": {
87
- types: "./dist/module-sync/npx-cli.d.ts",
88
- "default": "./dist/module-sync/npx-cli.js"
89
- },
90
- require: {
91
- types: "./dist/require/npx-cli.d.ts",
92
- "default": "./dist/require/npx-cli.js"
93
- }
74
+ types: "./dist/module-sync/npx-cli.d.ts",
75
+ "module-sync": "./dist/module-sync/npx-cli.js",
76
+ require: "./dist/require/npx-cli.js"
94
77
  },
95
78
  "./package.json": "./package.json",
96
79
  "./translations.json": "./translations.json"
@@ -109,23 +92,20 @@ var scripts = {
109
92
  "lint:fix": "npm run lint -- --fix && npm run lint:fix:fast",
110
93
  "lint:fix:fast": "prettier --cache --log-level warn --write .",
111
94
  prepare: "husky && custompatch",
112
- test: "run-s check build:* test:*",
113
- "test:c8": "c8 --reporter=none node --test 'test/socket-npm.test.cjs'",
95
+ test: "run-s check build:* test:* test:coverage:*",
114
96
  "test-ci": "run-s build:* test:*",
115
97
  "test:unit": "tap-run",
116
- "test:coverage": "cp -r .tap/coverage/*.json coverage/tmp && c8 --reporter=lcov --reporter=text --include 'dist/{module-sync,require}/*.js' --exclude 'dist/require/vendor.js' report"
98
+ "test:coverage:c8": "c8 --reporter=none node --test 'test/socket-npm.test.cjs'",
99
+ "test:coverage:merge": "cp -r .tap/coverage/*.json coverage/tmp && c8 --reporter=lcov --reporter=text --include 'dist/{module-sync,require}/*.js' --exclude 'dist/require/vendor.js' report"
117
100
  };
118
101
  var dependencies = {
119
102
  "@apideck/better-ajv-errors": "^0.3.6",
120
103
  "@cyclonedx/cdxgen": "^11.0.5",
121
- "@inquirer/confirm": "^5.0.2",
122
- "@inquirer/password": "^4.0.3",
123
- "@inquirer/select": "^4.0.3",
124
104
  "@npmcli/promise-spawn": "^8.0.2",
125
105
  "@socketregistry/hyrious__bun.lockb": "1.0.5",
126
106
  "@socketregistry/yocto-spinner": "^1.0.1",
127
107
  "@socketsecurity/config": "^2.1.3",
128
- "@socketsecurity/registry": "^1.0.35",
108
+ "@socketsecurity/registry": "^1.0.51",
129
109
  "@socketsecurity/sdk": "^1.3.0",
130
110
  blessed: "^0.1.81",
131
111
  "blessed-contrib": "^4.11.0",
@@ -229,6 +209,8 @@ var overrides = {
229
209
  semver: "$semver",
230
210
  "set-function-length": "npm:@socketregistry/set-function-length@^1",
231
211
  "side-channel": "npm:@socketregistry/side-channel@^1",
212
+ "tiny-colors": "$yoctocolors-cjs",
213
+ typedarray: "npm:@socketregistry/typedarray@^1",
232
214
  yaml: "$yaml"
233
215
  };
234
216
  var resolutions = {
@@ -252,6 +234,8 @@ var resolutions = {
252
234
  semver: "^7.6.3",
253
235
  "set-function-length": "npm:@socketregistry/set-function-length@^1",
254
236
  "side-channel": "npm:@socketregistry/side-channel@^1",
237
+ "tiny-colors": "npm:yoctocolors-cjs@^2.1.2",
238
+ typedarray: "npm:@socketregistry/typedarray@^1",
255
239
  yaml: "^2.6.0"
256
240
  };
257
241
  var engines = {
@@ -322,7 +306,7 @@ function createNonStandardTTYServer() {
322
306
  output: hasOutput
323
307
  },
324
308
  ipc_version: remote_ipc_version
325
- } = JSON.parse(lineBuff.subarray(0, eolIndex).toString('utf-8'));
309
+ } = JSON.parse(lineBuff.subarray(0, eolIndex).toString('utf8'));
326
310
  lineBuff = null;
327
311
  captured = true;
328
312
  if (remote_ipc_version !== _package.version) {
@@ -480,12 +464,12 @@ function createTTYServer(isInteractive, npmlog) {
480
464
  return !isInteractive && TTY_IPC ? createNonStandardTTYServer() : createStandardTTYServer(isInteractive, npmlog);
481
465
  }
482
466
 
483
- var issueRules = {};
467
+ var alertRules = {};
484
468
 
485
- Object.defineProperty(issueRules, "__esModule", {
469
+ Object.defineProperty(alertRules, "__esModule", {
486
470
  value: true
487
471
  });
488
- issueRules.createAlertUXLookup = createAlertUXLookup;
472
+ alertRules.createAlertUXLookup = createAlertUXLookup;
489
473
  //#region UX Constants
490
474
 
491
475
  const IGNORE_UX = {
@@ -508,7 +492,7 @@ const ERROR_UX = {
508
492
  * all issue rules and finds the first defined value that does not defer otherwise
509
493
  * uses the defaultValue. Takes the value and converts into a UX workflow
510
494
  */
511
- function resolveIssueRuleUX(entriesOrderedIssueRules, defaultValue) {
495
+ function resolveAlertRuleUX(orderedRulesCollection, defaultValue) {
512
496
  if (defaultValue === true || defaultValue == null) {
513
497
  defaultValue = {
514
498
  action: 'error'
@@ -521,9 +505,9 @@ function resolveIssueRuleUX(entriesOrderedIssueRules, defaultValue) {
521
505
  let block = false;
522
506
  let display = false;
523
507
  let needDefault = true;
524
- iterate_entries: for (const issueRuleArr of entriesOrderedIssueRules) {
525
- for (const rule of issueRuleArr) {
526
- if (issueRuleValueDoesNotDefer(rule)) {
508
+ iterate_entries: for (const rules of orderedRulesCollection) {
509
+ for (const rule of rules) {
510
+ if (ruleValueDoesNotDefer(rule)) {
527
511
  needDefault = false;
528
512
  const narrowingFilter = uxForDefinedNonDeferValue(rule);
529
513
  block = block || narrowingFilter.block;
@@ -549,13 +533,13 @@ function resolveIssueRuleUX(entriesOrderedIssueRules, defaultValue) {
549
533
  /**
550
534
  * Negative form because it is narrowing the type
551
535
  */
552
- function issueRuleValueDoesNotDefer(issueRule) {
553
- if (issueRule === undefined) {
536
+ function ruleValueDoesNotDefer(rule) {
537
+ if (rule === undefined) {
554
538
  return false;
555
- } else if (issueRule !== null && typeof issueRule === 'object') {
539
+ } else if (rule !== null && typeof rule === 'object') {
556
540
  const {
557
541
  action
558
- } = issueRule;
542
+ } = rule;
559
543
  if (action === undefined || action === 'defer') {
560
544
  return false;
561
545
  }
@@ -566,13 +550,13 @@ function issueRuleValueDoesNotDefer(issueRule) {
566
550
  /**
567
551
  * Handles booleans for backwards compatibility
568
552
  */
569
- function uxForDefinedNonDeferValue(issueRuleValue) {
570
- if (typeof issueRuleValue === 'boolean') {
571
- return issueRuleValue ? ERROR_UX : IGNORE_UX;
553
+ function uxForDefinedNonDeferValue(ruleValue) {
554
+ if (typeof ruleValue === 'boolean') {
555
+ return ruleValue ? ERROR_UX : IGNORE_UX;
572
556
  }
573
557
  const {
574
558
  action
575
- } = issueRuleValue;
559
+ } = ruleValue;
576
560
  if (action === 'warn') {
577
561
  return WARN_UX;
578
562
  } else if (action === 'ignore') {
@@ -594,9 +578,9 @@ function createAlertUXLookup(settings) {
594
578
  if (ux) {
595
579
  return ux;
596
580
  }
597
- const entriesOrderedIssueRules = [];
581
+ const orderedRulesCollection = [];
598
582
  for (const settingsEntry of settings.entries) {
599
- const orderedIssueRules = [];
583
+ const orderedRules = [];
600
584
  let target = settingsEntry.start;
601
585
  while (target !== null) {
602
586
  const resolvedTarget = settingsEntry.settings[target];
@@ -605,11 +589,11 @@ function createAlertUXLookup(settings) {
605
589
  }
606
590
  const issueRuleValue = resolvedTarget.issueRules?.[type];
607
591
  if (typeof issueRuleValue !== 'undefined') {
608
- orderedIssueRules.push(issueRuleValue);
592
+ orderedRules.push(issueRuleValue);
609
593
  }
610
594
  target = resolvedTarget.deferTo ?? null;
611
595
  }
612
- entriesOrderedIssueRules.push(orderedIssueRules);
596
+ orderedRulesCollection.push(orderedRules);
613
597
  }
614
598
  const defaultValue = settings.defaults.issueRules[type];
615
599
  let resolvedDefaultValue = {
@@ -624,7 +608,7 @@ function createAlertUXLookup(settings) {
624
608
  action: defaultValue.action ?? 'error'
625
609
  };
626
610
  }
627
- ux = resolveIssueRuleUX(entriesOrderedIssueRules, resolvedDefaultValue);
611
+ ux = resolveAlertRuleUX(orderedRulesCollection, resolvedDefaultValue);
628
612
  cachedUX.set(type, ux);
629
613
  return ux;
630
614
  };
@@ -638,26 +622,37 @@ arborist.SafeArborist = void 0;
638
622
  arborist.installSafeArborist = installSafeArborist;
639
623
  var _nodeEvents = require$$1$4;
640
624
  var _nodeFs = require$$0;
641
- var _nodeHttps = require$$3$2;
625
+ var _nodeHttps = require$$3$3;
642
626
  var _nodePath = require$$1$1;
643
627
  var _nodeReadline = require$$3;
644
628
  var _promises = require$$6$2;
645
- var _confirm = require$$1$3;
646
- var _yoctoSpinner = require$$3$1;
629
+ var _prompts = require$$1$3;
630
+ var _yoctoSpinner = require$$3$2;
647
631
  var _isInteractive = _interopRequireDefault(vendor.isInteractive);
648
632
  var _npmPackageArg = require$$5$1;
649
- var _semver = require$$4;
633
+ var _semver = require$$3$1;
650
634
  var _config = require$$6$1;
651
635
  var _objects = require$$7;
636
+ var _packages = require$$8;
652
637
  var _ttyServer = ttyServer$1;
653
638
  var _constants$1 = constants.constants;
654
639
  var _colorOrMarkdown = sdk.colorOrMarkdown;
655
- var _issueRules = issueRules;
640
+ var _alertRules = alertRules;
656
641
  var _misc = sdk.misc;
657
642
  var _pathResolve = pathResolve.pathResolve;
658
643
  var _sdk = sdk.sdk;
659
644
  var _settings = sdk.settings;
660
- const POTENTIAL_BUG_ERROR_MESSAGE = `This is may be a bug with socket-npm related to changes to the npm CLI.\nPlease report to ${_constants$1.SOCKET_CLI_ISSUES_URL}.`;
645
+ const {
646
+ API_V0_URL,
647
+ ENV,
648
+ LOOP_SENTINEL,
649
+ NPM_REGISTRY_URL,
650
+ SOCKET_CLI_ISSUES_URL,
651
+ SOCKET_PUBLIC_API_KEY,
652
+ UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE,
653
+ rootPath
654
+ } = _constants$1;
655
+ const POTENTIAL_BUG_ERROR_MESSAGE = `This is may be a bug with socket-npm related to changes to the npm CLI.\nPlease report to ${SOCKET_CLI_ISSUES_URL}.`;
661
656
  const npmEntrypoint = (0, _nodeFs.realpathSync)(process.argv[1]);
662
657
  const npmRootPath = (0, _pathResolve.findRoot)(_nodePath.dirname(npmEntrypoint));
663
658
  function tryRequire(...ids) {
@@ -705,7 +700,7 @@ const pacote = tryRequire(_nodePath.join(npmNmPath, 'pacote'), 'pacote');
705
700
  const {
706
701
  tarball
707
702
  } = pacote;
708
- const translations = require(_nodePath.join(_constants$1.rootPath, 'translations.json'));
703
+ const translations = require(_nodePath.join(rootPath, 'translations.json'));
709
704
  const abortController = new AbortController();
710
705
  const {
711
706
  signal: abortSignal
@@ -718,7 +713,7 @@ const OverrideSet = require(arboristOverrideSetClassPatch);
718
713
  const kCtorArgs = Symbol('ctorArgs');
719
714
  const kRiskyReify = Symbol('riskyReify');
720
715
  const formatter = new _colorOrMarkdown.ColorOrMarkdown(false);
721
- const pubToken = (0, _sdk.getDefaultKey)() ?? _constants$1.SOCKET_PUBLIC_API_KEY;
716
+ const pubToken = (0, _sdk.getDefaultKey)() ?? SOCKET_PUBLIC_API_KEY;
722
717
  const ttyServer = (0, _ttyServer.createTTYServer)((0, _isInteractive.default)({
723
718
  stream: process.stdin
724
719
  }), log);
@@ -733,7 +728,7 @@ async function uxLookup(settings) {
733
728
  return _uxLookup(settings);
734
729
  }
735
730
  async function* batchScan(pkgIds) {
736
- const req = _nodeHttps.request(`${_constants$1.API_V0_URL}/purl?alerts=true`, {
731
+ const req = _nodeHttps.request(`${API_V0_URL}/purl?alerts=true`, {
737
732
  method: 'POST',
738
733
  headers: {
739
734
  Authorization: `Basic ${Buffer.from(`${pubToken}:`).toString('base64url')}`
@@ -849,7 +844,7 @@ async function getPackagesAlerts(safeArb, _registry, pkgs, output) {
849
844
  const {
850
845
  version
851
846
  } = artifact;
852
- const name = `${artifact.namespace ? `${artifact.namespace}/` : ''}${artifact.name}`;
847
+ const name = (0, _packages.resolvePackageName)(artifact);
853
848
  const id = `${name}@${artifact.version}`;
854
849
  let blocked = false;
855
850
  let displayWarning = false;
@@ -947,7 +942,7 @@ function walk(diff_, needInfoOn = []) {
947
942
  length: queueLength
948
943
  } = queue;
949
944
  while (pos < queueLength) {
950
- if (pos === _constants$1.LOOP_SENTINEL) {
945
+ if (pos === LOOP_SENTINEL) {
951
946
  throw new Error('Detected infinite loop while walking Arborist diff');
952
947
  }
953
948
  const diff = queue[pos++];
@@ -1527,7 +1522,7 @@ class SafeOverrideSet extends OverrideSet {
1527
1522
  length: queueLength
1528
1523
  } = queue;
1529
1524
  while (pos < queueLength) {
1530
- if (pos === _constants$1.LOOP_SENTINEL) {
1525
+ if (pos === LOOP_SENTINEL) {
1531
1526
  throw new Error('Detected infinite loop while comparing override sets');
1532
1527
  }
1533
1528
  const {
@@ -1669,10 +1664,10 @@ class SafeArborist extends Arborist {
1669
1664
  options['save'] = old.save;
1670
1665
  options['saveBundle'] = old.saveBundle;
1671
1666
  // Nothing to check, mmm already installed or all private?
1672
- if (diff.findIndex(c => c.repository_url === _constants$1.NPM_REGISTRY_URL) === -1) {
1667
+ if (diff.findIndex(c => c.repository_url === NPM_REGISTRY_URL) === -1) {
1673
1668
  return await this[kRiskyReify](...args);
1674
1669
  }
1675
- let proceed = _constants$1.ENV[_constants$1.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE];
1670
+ let proceed = ENV[UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE];
1676
1671
  if (!proceed) {
1677
1672
  proceed = await ttyServer.captureTTY(async (input, output) => {
1678
1673
  if (input && output) {
@@ -1680,7 +1675,7 @@ class SafeArborist extends Arborist {
1680
1675
  if (!alerts.length) {
1681
1676
  return true;
1682
1677
  }
1683
- return await _confirm({
1678
+ return await (0, _prompts.confirm)({
1684
1679
  message: 'Accept risks of installing these packages?',
1685
1680
  default: false
1686
1681
  }, {
@@ -1789,14 +1784,18 @@ void (async () => {
1789
1784
  }
1790
1785
  });
1791
1786
  }
1792
- _uxLookup = (0, _issueRules.createAlertUXLookup)(settings);
1787
+ _uxLookup = (0, _alertRules.createAlertUXLookup)(settings);
1793
1788
  })();
1794
1789
 
1795
1790
  var _constants = constants.constants;
1796
1791
  var _arborist = arborist;
1797
1792
  var _link = link.link;
1793
+ const {
1794
+ shadowBinPath
1795
+ } = _constants;
1796
+
1798
1797
  // Shadow `npm` and `npx` to mitigate subshells.
1799
- (0, _link.installLinks)(_constants.shadowBinPath, 'npm');
1798
+ (0, _link.installLinks)(shadowBinPath, 'npm');
1800
1799
  (0, _arborist.installSafeArborist)();
1801
1800
 
1802
1801
  (function (exports) {
@@ -1,23 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- function _interop(e) {
5
- let d
6
- if (e) {
7
- let c = 0
8
- for (const k in e) {
9
- d = c++ === 0 && k === 'default' ? e[k] : void 0
10
- if (!d) break
11
- }
4
+ function _socketInterop(e) {
5
+ let c = 0
6
+ for (const k in e ?? {}) {
7
+ c = c === 0 && k === 'default' ? 1 : 0
8
+ if (!c) break
12
9
  }
13
- return d ?? e
10
+ return c ? e.default : e
14
11
  }
15
12
 
16
- var vendor = _interop(require('./vendor.js'));
17
- var require$$1 = _interop(require('node:path'));
18
- var require$$1$1 = _interop(require('@npmcli/promise-spawn'));
19
- var constants = _interop(require('./constants.js'));
20
- var link = _interop(require('./link.js'));
13
+ var vendor = require('./vendor.js');
14
+ var require$$1 = require('node:path');
15
+ var require$$1$1 = _socketInterop(require('@npmcli/promise-spawn'));
16
+ var constants = require('./constants.js');
17
+ var link = require('./link.js');
21
18
 
22
19
  var npxCli$2 = {};
23
20
 
@@ -27,10 +24,17 @@ var _nodePath = require$$1;
27
24
  var _promiseSpawn = require$$1$1;
28
25
  var _constants = constants.constants;
29
26
  var _link = link.link;
30
- const npxPath = (0, _link.installLinks)(_constants.shadowBinPath, 'npx');
31
- const injectionPath = _nodePath.join(_constants.distPath, 'npm-injection.js');
27
+ const {
28
+ distPath,
29
+ execPath,
30
+ shadowBinPath
31
+ } = _constants;
32
+ const npxPath = (0, _link.installLinks)(shadowBinPath, 'npx');
33
+ const injectionPath = _nodePath.join(distPath, 'npm-injection.js');
32
34
  process.exitCode = 1;
33
- const spawnPromise = _promiseSpawn(process.execPath, ['--disable-warning', 'ExperimentalWarning', '--require', injectionPath, npxPath, ...process.argv.slice(2)], {
35
+ const spawnPromise = _promiseSpawn(execPath, [
36
+ // Lazily access constants.nodeNoWarningsFlags.
37
+ ..._constants.nodeNoWarningsFlags, '--require', injectionPath, npxPath, ...process.argv.slice(2)], {
34
38
  stdio: 'inherit'
35
39
  });
36
40
  spawnPromise.process.on('exit', (code, signal) => {