socket 0.14.32 → 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 +126 -123
  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 +126 -123
  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 socket 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 === 'socket') {
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 = "socket";
45
- var version = "0.14.32";
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";
@@ -62,34 +60,19 @@ var bin = {
62
60
  };
63
61
  var exports$1 = {
64
62
  "./bin/cli.js": {
65
- "module-sync": {
66
- types: "./dist/module-sync/cli.d.ts",
67
- "default": "./dist/module-sync/cli.js"
68
- },
69
- require: {
70
- types: "./dist/require/cli.d.ts",
71
- "default": "./dist/require/cli.js"
72
- }
63
+ types: "./dist/module-sync/cli.d.ts",
64
+ "module-sync": "./dist/module-sync/cli.js",
65
+ require: "./dist/require/cli.js"
73
66
  },
74
67
  "./bin/npm-cli.js": {
75
- "module-sync": {
76
- types: "./dist/module-sync/npm-cli.d.ts",
77
- "default": "./dist/module-sync/npm-cli.js"
78
- },
79
- require: {
80
- types: "./dist/require/npm-cli.d.ts",
81
- "default": "./dist/require/npm-cli.js"
82
- }
68
+ types: "./dist/module-sync/npm-cli.d.ts",
69
+ "module-sync": "./dist/module-sync/npm-cli.js",
70
+ require: "./dist/require/npm-cli.js"
83
71
  },
84
72
  "./bin/npx-cli.js": {
85
- "module-sync": {
86
- types: "./dist/module-sync/npx-cli.d.ts",
87
- "default": "./dist/module-sync/npx-cli.js"
88
- },
89
- require: {
90
- types: "./dist/require/npx-cli.d.ts",
91
- "default": "./dist/require/npx-cli.js"
92
- }
73
+ types: "./dist/module-sync/npx-cli.d.ts",
74
+ "module-sync": "./dist/module-sync/npx-cli.js",
75
+ require: "./dist/require/npx-cli.js"
93
76
  },
94
77
  "./package.json": "./package.json",
95
78
  "./translations.json": "./translations.json"
@@ -108,23 +91,20 @@ var scripts = {
108
91
  "lint:fix": "npm run lint -- --fix && npm run lint:fix:fast",
109
92
  "lint:fix:fast": "prettier --cache --log-level warn --write .",
110
93
  prepare: "husky && custompatch",
111
- test: "run-s check build:* test:*",
112
- "test:c8": "c8 --reporter=none node --test 'test/socket-npm.test.cjs'",
94
+ test: "run-s check build:* test:* test:coverage:*",
113
95
  "test-ci": "run-s build:* test:*",
114
96
  "test:unit": "tap-run",
115
- "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"
97
+ "test:coverage:c8": "c8 --reporter=none node --test 'test/socket-npm.test.cjs'",
98
+ "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"
116
99
  };
117
100
  var dependencies = {
118
101
  "@apideck/better-ajv-errors": "^0.3.6",
119
102
  "@cyclonedx/cdxgen": "^11.0.5",
120
- "@inquirer/confirm": "^5.0.2",
121
- "@inquirer/password": "^4.0.3",
122
- "@inquirer/select": "^4.0.3",
123
103
  "@npmcli/promise-spawn": "^8.0.2",
124
104
  "@socketregistry/hyrious__bun.lockb": "1.0.5",
125
105
  "@socketregistry/yocto-spinner": "^1.0.1",
126
106
  "@socketsecurity/config": "^2.1.3",
127
- "@socketsecurity/registry": "^1.0.35",
107
+ "@socketsecurity/registry": "^1.0.51",
128
108
  "@socketsecurity/sdk": "^1.3.0",
129
109
  blessed: "^0.1.81",
130
110
  "blessed-contrib": "^4.11.0",
@@ -228,6 +208,8 @@ var overrides = {
228
208
  semver: "$semver",
229
209
  "set-function-length": "npm:@socketregistry/set-function-length@^1",
230
210
  "side-channel": "npm:@socketregistry/side-channel@^1",
211
+ "tiny-colors": "$yoctocolors-cjs",
212
+ typedarray: "npm:@socketregistry/typedarray@^1",
231
213
  yaml: "$yaml"
232
214
  };
233
215
  var resolutions = {
@@ -251,6 +233,8 @@ var resolutions = {
251
233
  semver: "^7.6.3",
252
234
  "set-function-length": "npm:@socketregistry/set-function-length@^1",
253
235
  "side-channel": "npm:@socketregistry/side-channel@^1",
236
+ "tiny-colors": "npm:yoctocolors-cjs@^2.1.2",
237
+ typedarray: "npm:@socketregistry/typedarray@^1",
254
238
  yaml: "^2.6.0"
255
239
  };
256
240
  var engines = {
@@ -321,7 +305,7 @@ function createNonStandardTTYServer() {
321
305
  output: hasOutput
322
306
  },
323
307
  ipc_version: remote_ipc_version
324
- } = JSON.parse(lineBuff.subarray(0, eolIndex).toString('utf-8'));
308
+ } = JSON.parse(lineBuff.subarray(0, eolIndex).toString('utf8'));
325
309
  lineBuff = null;
326
310
  captured = true;
327
311
  if (remote_ipc_version !== _package.version) {
@@ -479,12 +463,12 @@ function createTTYServer(isInteractive, npmlog) {
479
463
  return !isInteractive && TTY_IPC ? createNonStandardTTYServer() : createStandardTTYServer(isInteractive, npmlog);
480
464
  }
481
465
 
482
- var issueRules = {};
466
+ var alertRules = {};
483
467
 
484
- Object.defineProperty(issueRules, "__esModule", {
468
+ Object.defineProperty(alertRules, "__esModule", {
485
469
  value: true
486
470
  });
487
- issueRules.createAlertUXLookup = createAlertUXLookup;
471
+ alertRules.createAlertUXLookup = createAlertUXLookup;
488
472
  //#region UX Constants
489
473
 
490
474
  const IGNORE_UX = {
@@ -507,7 +491,7 @@ const ERROR_UX = {
507
491
  * all issue rules and finds the first defined value that does not defer otherwise
508
492
  * uses the defaultValue. Takes the value and converts into a UX workflow
509
493
  */
510
- function resolveIssueRuleUX(entriesOrderedIssueRules, defaultValue) {
494
+ function resolveAlertRuleUX(orderedRulesCollection, defaultValue) {
511
495
  if (defaultValue === true || defaultValue == null) {
512
496
  defaultValue = {
513
497
  action: 'error'
@@ -520,9 +504,9 @@ function resolveIssueRuleUX(entriesOrderedIssueRules, defaultValue) {
520
504
  let block = false;
521
505
  let display = false;
522
506
  let needDefault = true;
523
- iterate_entries: for (const issueRuleArr of entriesOrderedIssueRules) {
524
- for (const rule of issueRuleArr) {
525
- if (issueRuleValueDoesNotDefer(rule)) {
507
+ iterate_entries: for (const rules of orderedRulesCollection) {
508
+ for (const rule of rules) {
509
+ if (ruleValueDoesNotDefer(rule)) {
526
510
  needDefault = false;
527
511
  const narrowingFilter = uxForDefinedNonDeferValue(rule);
528
512
  block = block || narrowingFilter.block;
@@ -548,13 +532,13 @@ function resolveIssueRuleUX(entriesOrderedIssueRules, defaultValue) {
548
532
  /**
549
533
  * Negative form because it is narrowing the type
550
534
  */
551
- function issueRuleValueDoesNotDefer(issueRule) {
552
- if (issueRule === undefined) {
535
+ function ruleValueDoesNotDefer(rule) {
536
+ if (rule === undefined) {
553
537
  return false;
554
- } else if (issueRule !== null && typeof issueRule === 'object') {
538
+ } else if (rule !== null && typeof rule === 'object') {
555
539
  const {
556
540
  action
557
- } = issueRule;
541
+ } = rule;
558
542
  if (action === undefined || action === 'defer') {
559
543
  return false;
560
544
  }
@@ -565,13 +549,13 @@ function issueRuleValueDoesNotDefer(issueRule) {
565
549
  /**
566
550
  * Handles booleans for backwards compatibility
567
551
  */
568
- function uxForDefinedNonDeferValue(issueRuleValue) {
569
- if (typeof issueRuleValue === 'boolean') {
570
- return issueRuleValue ? ERROR_UX : IGNORE_UX;
552
+ function uxForDefinedNonDeferValue(ruleValue) {
553
+ if (typeof ruleValue === 'boolean') {
554
+ return ruleValue ? ERROR_UX : IGNORE_UX;
571
555
  }
572
556
  const {
573
557
  action
574
- } = issueRuleValue;
558
+ } = ruleValue;
575
559
  if (action === 'warn') {
576
560
  return WARN_UX;
577
561
  } else if (action === 'ignore') {
@@ -593,9 +577,9 @@ function createAlertUXLookup(settings) {
593
577
  if (ux) {
594
578
  return ux;
595
579
  }
596
- const entriesOrderedIssueRules = [];
580
+ const orderedRulesCollection = [];
597
581
  for (const settingsEntry of settings.entries) {
598
- const orderedIssueRules = [];
582
+ const orderedRules = [];
599
583
  let target = settingsEntry.start;
600
584
  while (target !== null) {
601
585
  const resolvedTarget = settingsEntry.settings[target];
@@ -604,11 +588,11 @@ function createAlertUXLookup(settings) {
604
588
  }
605
589
  const issueRuleValue = resolvedTarget.issueRules?.[type];
606
590
  if (typeof issueRuleValue !== 'undefined') {
607
- orderedIssueRules.push(issueRuleValue);
591
+ orderedRules.push(issueRuleValue);
608
592
  }
609
593
  target = resolvedTarget.deferTo ?? null;
610
594
  }
611
- entriesOrderedIssueRules.push(orderedIssueRules);
595
+ orderedRulesCollection.push(orderedRules);
612
596
  }
613
597
  const defaultValue = settings.defaults.issueRules[type];
614
598
  let resolvedDefaultValue = {
@@ -623,7 +607,7 @@ function createAlertUXLookup(settings) {
623
607
  action: defaultValue.action ?? 'error'
624
608
  };
625
609
  }
626
- ux = resolveIssueRuleUX(entriesOrderedIssueRules, resolvedDefaultValue);
610
+ ux = resolveAlertRuleUX(orderedRulesCollection, resolvedDefaultValue);
627
611
  cachedUX.set(type, ux);
628
612
  return ux;
629
613
  };
@@ -637,26 +621,37 @@ arborist.SafeArborist = void 0;
637
621
  arborist.installSafeArborist = installSafeArborist;
638
622
  var _nodeEvents = require$$1$4;
639
623
  var _nodeFs = require$$0;
640
- var _nodeHttps = require$$3$2;
624
+ var _nodeHttps = require$$3$3;
641
625
  var _nodePath = require$$1$1;
642
626
  var _nodeReadline = require$$3;
643
627
  var _promises = require$$6$2;
644
- var _confirm = require$$1$3;
645
- var _yoctoSpinner = require$$3$1;
628
+ var _prompts = require$$1$3;
629
+ var _yoctoSpinner = require$$3$2;
646
630
  var _isInteractive = _interopRequireDefault(vendor.isInteractive);
647
631
  var _npmPackageArg = require$$5$1;
648
- var _semver = require$$4;
632
+ var _semver = require$$3$1;
649
633
  var _config = require$$6$1;
650
634
  var _objects = require$$7;
635
+ var _packages = require$$8;
651
636
  var _ttyServer = ttyServer$1;
652
637
  var _constants$1 = constants.constants;
653
638
  var _colorOrMarkdown = sdk.colorOrMarkdown;
654
- var _issueRules = issueRules;
639
+ var _alertRules = alertRules;
655
640
  var _misc = sdk.misc;
656
641
  var _pathResolve = pathResolve.pathResolve;
657
642
  var _sdk = sdk.sdk;
658
643
  var _settings = sdk.settings;
659
- 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}.`;
644
+ const {
645
+ API_V0_URL,
646
+ ENV,
647
+ LOOP_SENTINEL,
648
+ NPM_REGISTRY_URL,
649
+ SOCKET_CLI_ISSUES_URL,
650
+ SOCKET_PUBLIC_API_KEY,
651
+ UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE,
652
+ rootPath
653
+ } = _constants$1;
654
+ 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}.`;
660
655
  const npmEntrypoint = (0, _nodeFs.realpathSync)(process.argv[1]);
661
656
  const npmRootPath = (0, _pathResolve.findRoot)(_nodePath.dirname(npmEntrypoint));
662
657
  function tryRequire(...ids) {
@@ -704,7 +699,7 @@ const pacote = tryRequire(_nodePath.join(npmNmPath, 'pacote'), 'pacote');
704
699
  const {
705
700
  tarball
706
701
  } = pacote;
707
- const translations = require(_nodePath.join(_constants$1.rootPath, 'translations.json'));
702
+ const translations = require(_nodePath.join(rootPath, 'translations.json'));
708
703
  const abortController = new AbortController();
709
704
  const {
710
705
  signal: abortSignal
@@ -717,7 +712,7 @@ const OverrideSet = require(arboristOverrideSetClassPatch);
717
712
  const kCtorArgs = Symbol('ctorArgs');
718
713
  const kRiskyReify = Symbol('riskyReify');
719
714
  const formatter = new _colorOrMarkdown.ColorOrMarkdown(false);
720
- const pubToken = (0, _sdk.getDefaultKey)() ?? _constants$1.SOCKET_PUBLIC_API_KEY;
715
+ const pubToken = (0, _sdk.getDefaultKey)() ?? SOCKET_PUBLIC_API_KEY;
721
716
  const ttyServer = (0, _ttyServer.createTTYServer)((0, _isInteractive.default)({
722
717
  stream: process.stdin
723
718
  }), log);
@@ -732,7 +727,7 @@ async function uxLookup(settings) {
732
727
  return _uxLookup(settings);
733
728
  }
734
729
  async function* batchScan(pkgIds) {
735
- const req = _nodeHttps.request(`${_constants$1.API_V0_URL}/purl?alerts=true`, {
730
+ const req = _nodeHttps.request(`${API_V0_URL}/purl?alerts=true`, {
736
731
  method: 'POST',
737
732
  headers: {
738
733
  Authorization: `Basic ${Buffer.from(`${pubToken}:`).toString('base64url')}`
@@ -848,7 +843,7 @@ async function getPackagesAlerts(safeArb, _registry, pkgs, output) {
848
843
  const {
849
844
  version
850
845
  } = artifact;
851
- const name = `${artifact.namespace ? `${artifact.namespace}/` : ''}${artifact.name}`;
846
+ const name = (0, _packages.resolvePackageName)(artifact);
852
847
  const id = `${name}@${artifact.version}`;
853
848
  let blocked = false;
854
849
  let displayWarning = false;
@@ -881,20 +876,16 @@ async function getPackagesAlerts(safeArb, _registry, pkgs, output) {
881
876
  });
882
877
  // Before we ask about problematic issues, check to see if they
883
878
  // already existed in the old version if they did, be quiet.
884
- const pkg = pkgs.find(p => p.pkgid === id && p.existing?.startsWith(`${name}@`));
885
- if (pkg?.existing) {
886
- // const oldArtifact: SocketArtifact =
887
- // // eslint-disable-next-line no-await-in-loop
888
- // (await batchScan([pkg.existing]).next()).value
889
- // console.log('oldArtifact', oldArtifact)
890
- // if (oldArtifact.type === 'success') {
891
- // issues = issues.filter(
892
- // ({ type }) =>
893
- // oldPkgData.value.issues.find(
894
- // oldIssue => oldIssue.type === type
895
- // ) === undefined
896
- // )
897
- // }
879
+ const existing = pkgs.find(p => p.existing?.startsWith(`${name}@`))?.existing;
880
+ if (existing) {
881
+ const oldArtifact =
882
+ // eslint-disable-next-line no-await-in-loop
883
+ (await batchScan([existing]).next()).value;
884
+ if (oldArtifact?.alerts?.length) {
885
+ alerts = alerts.filter(({
886
+ type
887
+ }) => !oldArtifact.alerts?.find(a => a.type === type));
888
+ }
898
889
  }
899
890
  }
900
891
  }
@@ -950,30 +941,38 @@ function walk(diff_, needInfoOn = []) {
950
941
  length: queueLength
951
942
  } = queue;
952
943
  while (pos < queueLength) {
953
- if (pos === _constants$1.LOOP_SENTINEL) {
944
+ if (pos === LOOP_SENTINEL) {
954
945
  throw new Error('Detected infinite loop while walking Arborist diff');
955
946
  }
956
947
  const diff = queue[pos++];
957
948
  if (!diff) {
958
949
  continue;
959
950
  }
960
- if (diff.action) {
961
- const sameVersion = diff.actual?.package.version === diff.ideal?.package.version;
951
+ const {
952
+ action
953
+ } = diff;
954
+ if (action) {
955
+ const oldNode = diff.actual;
956
+ const oldPkgid = oldNode?.pkgid;
957
+ const pkgNode = diff.ideal;
958
+ const pkgid = pkgNode?.pkgid;
959
+ let existing;
962
960
  let keep = false;
963
- let existing = null;
964
- if (diff.action === 'CHANGE') {
965
- if (!sameVersion) {
966
- existing = diff.actual.pkgid;
961
+ if (action === 'CHANGE') {
962
+ if (pkgNode?.package.version !== oldNode?.package.version) {
967
963
  keep = true;
964
+ if (oldNode?.package.name && oldNode.package.name === pkgNode?.package.name) {
965
+ existing = oldPkgid;
966
+ }
968
967
  }
969
968
  } else {
970
- keep = diff.action !== 'REMOVE';
969
+ keep = action !== 'REMOVE';
971
970
  }
972
- if (keep && diff.ideal?.pkgid && diff.ideal.resolved && (!diff.actual || diff.actual.resolved)) {
971
+ if (keep && pkgid && pkgNode.resolved && (!oldNode || oldNode.resolved)) {
973
972
  needInfoOn.push({
974
973
  existing,
975
- pkgid: diff.ideal.pkgid,
976
- repository_url: toRepoUrl(diff.ideal.resolved)
974
+ pkgid,
975
+ repository_url: toRepoUrl(pkgNode.resolved)
977
976
  });
978
977
  }
979
978
  }
@@ -1522,7 +1521,7 @@ class SafeOverrideSet extends OverrideSet {
1522
1521
  length: queueLength
1523
1522
  } = queue;
1524
1523
  while (pos < queueLength) {
1525
- if (pos === _constants$1.LOOP_SENTINEL) {
1524
+ if (pos === LOOP_SENTINEL) {
1526
1525
  throw new Error('Detected infinite loop while comparing override sets');
1527
1526
  }
1528
1527
  const {
@@ -1664,10 +1663,10 @@ class SafeArborist extends Arborist {
1664
1663
  options['save'] = old.save;
1665
1664
  options['saveBundle'] = old.saveBundle;
1666
1665
  // Nothing to check, mmm already installed or all private?
1667
- if (diff.findIndex(c => c.repository_url === _constants$1.NPM_REGISTRY_URL) === -1) {
1666
+ if (diff.findIndex(c => c.repository_url === NPM_REGISTRY_URL) === -1) {
1668
1667
  return await this[kRiskyReify](...args);
1669
1668
  }
1670
- let proceed = _constants$1.ENV[_constants$1.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE];
1669
+ let proceed = ENV[UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE];
1671
1670
  if (!proceed) {
1672
1671
  proceed = await ttyServer.captureTTY(async (input, output) => {
1673
1672
  if (input && output) {
@@ -1675,7 +1674,7 @@ class SafeArborist extends Arborist {
1675
1674
  if (!alerts.length) {
1676
1675
  return true;
1677
1676
  }
1678
- return await _confirm({
1677
+ return await (0, _prompts.confirm)({
1679
1678
  message: 'Accept risks of installing these packages?',
1680
1679
  default: false
1681
1680
  }, {
@@ -1784,14 +1783,18 @@ void (async () => {
1784
1783
  }
1785
1784
  });
1786
1785
  }
1787
- _uxLookup = (0, _issueRules.createAlertUXLookup)(settings);
1786
+ _uxLookup = (0, _alertRules.createAlertUXLookup)(settings);
1788
1787
  })();
1789
1788
 
1790
1789
  var _constants = constants.constants;
1791
1790
  var _arborist = arborist;
1792
1791
  var _link = link.link;
1792
+ const {
1793
+ shadowBinPath
1794
+ } = _constants;
1795
+
1793
1796
  // Shadow `npm` and `npx` to mitigate subshells.
1794
- (0, _link.installLinks)(_constants.shadowBinPath, 'npm');
1797
+ (0, _link.installLinks)(shadowBinPath, 'npm');
1795
1798
  (0, _arborist.installSafeArborist)();
1796
1799
 
1797
1800
  (function (exports) {