@socketsecurity/cli 0.14.33 → 0.14.35

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 +34 -4
  2. package/bin/npm-cli.js +3 -4
  3. package/bin/npx-cli.js +3 -4
  4. package/dist/constants.js +59 -0
  5. package/dist/module-sync/cli.d.ts +0 -1
  6. package/dist/module-sync/cli.js +637 -1423
  7. package/dist/module-sync/constants.d.ts +24 -21
  8. package/dist/module-sync/constants.d.ts.map +1 -0
  9. package/dist/module-sync/constants.js +2 -79
  10. package/dist/module-sync/npm-injection.js +116 -436
  11. package/dist/module-sync/path-resolve.js +24 -45
  12. package/dist/module-sync/sdk.js +69 -118
  13. package/dist/module-sync/shadow-bin.d.ts +2 -0
  14. package/dist/module-sync/shadow-bin.js +109 -0
  15. package/dist/require/cli.js +633 -1418
  16. package/dist/require/constants.d.ts.map +1 -0
  17. package/dist/require/constants.js +2 -79
  18. package/dist/require/npm-injection.js +116 -435
  19. package/dist/require/path-resolve.js +24 -45
  20. package/dist/require/sdk.js +67 -115
  21. package/dist/require/shadow-bin.js +109 -0
  22. package/dist/require/vendor.js +8300 -8798
  23. package/package.json +39 -54
  24. package/shadow-bin/npm +4 -0
  25. package/shadow-bin/npx +4 -0
  26. package/bin/shadow/module-sync/npm +0 -3
  27. package/bin/shadow/module-sync/npx +0 -3
  28. package/bin/shadow/require/npm +0 -3
  29. package/bin/shadow/require/npx +0 -3
  30. package/dist/module-sync/cli.d.ts.map +0 -1
  31. package/dist/module-sync/link.d.ts +0 -2
  32. package/dist/module-sync/link.js +0 -57
  33. package/dist/module-sync/npm-cli.d.ts +0 -2
  34. package/dist/module-sync/npm-cli.js +0 -97
  35. package/dist/module-sync/npx-cli.d.ts +0 -2
  36. package/dist/module-sync/npx-cli.js +0 -73
  37. package/dist/module-sync/vendor.js +0 -82
  38. package/dist/require/cli.d.ts +0 -3
  39. package/dist/require/cli.d.ts.map +0 -1
  40. package/dist/require/color-or-markdown.d.ts +0 -23
  41. package/dist/require/constants.d.ts +0 -21
  42. package/dist/require/errors.d.ts +0 -7
  43. package/dist/require/link.d.ts +0 -2
  44. package/dist/require/link.js +0 -57
  45. package/dist/require/npm-cli.d.ts +0 -2
  46. package/dist/require/npm-cli.js +0 -97
  47. package/dist/require/npm-injection.d.ts +0 -1
  48. package/dist/require/npx-cli.d.ts +0 -2
  49. package/dist/require/npx-cli.js +0 -73
  50. package/dist/require/path-resolve.d.ts +0 -8
  51. package/dist/require/sdk.d.ts +0 -8
  52. package/dist/require/settings.d.ts +0 -9
@@ -1,308 +1,47 @@
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 && k !== '__esModule') 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'));
35
-
36
- var npmInjection$2 = {};
37
-
38
- var npmInjection$1 = {};
12
+ var events = require('node:events');
13
+ var fs = require('node:fs');
14
+ var https = require('node:https');
15
+ var path = require('node:path');
16
+ var readline = require('node:readline');
17
+ var promises = require('node:timers/promises');
18
+ var prompts = require('@socketsecurity/registry/lib/prompts');
19
+ var yoctoSpinner = require('@socketregistry/yocto-spinner');
20
+ var vendor = require('./vendor.js');
21
+ var npa = _socketInterop(require('npm-package-arg'));
22
+ var semver = _socketInterop(require('semver'));
23
+ var config = require('@socketsecurity/config');
24
+ var objects = require('@socketsecurity/registry/lib/objects');
25
+ var packages = require('@socketsecurity/registry/lib/packages');
26
+ var net = require('node:net');
27
+ var os = require('node:os');
28
+ var node_stream = require('node:stream');
29
+ var sdk = require('./sdk.js');
30
+ var constants = require('./constants.js');
31
+ var pathResolve = require('./path-resolve.js');
39
32
 
40
- var arborist = {};
41
-
42
- var ttyServer$1 = {};
43
-
44
- var name = "@socketsecurity/cli";
45
- var version = "0.14.33";
46
- var description = "CLI tool for Socket.dev";
47
- var homepage = "http://github.com/SocketDev/socket-cli";
48
- var license = "MIT";
49
- var repository = {
50
- type: "git",
51
- url: "git+https://github.com/SocketDev/socket-cli.git"
52
- };
53
- var author = {
54
- name: "Socket Inc",
55
- email: "eng@socket.dev",
56
- url: "https://socket.dev"
57
- };
58
- var bin = {
59
- cli: "./bin/cli.js",
60
- socket: "./bin/cli.js",
61
- "socket-npm": "./bin/npm-cli.js",
62
- "socket-npx": "./bin/npx-cli.js"
63
- };
64
- var exports$1 = {
65
- "./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
- }
74
- },
75
- "./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
- }
84
- },
85
- "./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
- }
94
- },
95
- "./package.json": "./package.json",
96
- "./translations.json": "./translations.json"
97
- };
98
- var scripts = {
99
- build: "run-s build:*",
100
- "build:dist": "rollup -c .config/rollup.dist.config.mjs",
101
- "build:test": "rollup -c .config/rollup.test.config.mjs",
102
- check: "run-p -c --aggregate-output check:*",
103
- "check:lint": "eslint --report-unused-disable-directives .",
104
- "check:tsc": "tsc",
105
- "check:type-coverage": "type-coverage --detail --strict --at-least 95 --ignore-files 'test/*'",
106
- "knip:dependencies": "knip --dependencies",
107
- "knip:exports": "knip --include exports,duplicates",
108
- lint: "oxlint -c=./.oxlintrc.json --ignore-path=./.prettierignore --tsconfig=./tsconfig.json .",
109
- "lint:fix": "npm run lint -- --fix && npm run lint:fix:fast",
110
- "lint:fix:fast": "prettier --cache --log-level warn --write .",
111
- prepare: "husky && custompatch",
112
- test: "run-s check build:* test:*",
113
- "test:c8": "c8 --reporter=none node --test 'test/socket-npm.test.cjs'",
114
- "test-ci": "run-s build:* test:*",
115
- "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"
117
- };
118
- var dependencies = {
119
- "@apideck/better-ajv-errors": "^0.3.6",
120
- "@cyclonedx/cdxgen": "^11.0.5",
121
- "@inquirer/confirm": "^5.0.2",
122
- "@inquirer/password": "^4.0.3",
123
- "@inquirer/select": "^4.0.3",
124
- "@npmcli/promise-spawn": "^8.0.2",
125
- "@socketregistry/hyrious__bun.lockb": "1.0.5",
126
- "@socketregistry/yocto-spinner": "^1.0.1",
127
- "@socketsecurity/config": "^2.1.3",
128
- "@socketsecurity/registry": "^1.0.35",
129
- "@socketsecurity/sdk": "^1.3.0",
130
- blessed: "^0.1.81",
131
- "blessed-contrib": "^4.11.0",
132
- browserslist: "4.24.2",
133
- "chalk-table": "^1.0.2",
134
- "has-flag": "^4.0.0",
135
- hpagent: "^1.2.0",
136
- ignore: "^6.0.2",
137
- micromatch: "^4.0.8",
138
- "npm-package-arg": "^12.0.0",
139
- "pony-cause": "^2.1.11",
140
- semver: "^7.6.3",
141
- synp: "^1.9.14",
142
- tinyglobby: "^0.2.10",
143
- which: "^5.0.0",
144
- yaml: "^2.6.1",
145
- "yargs-parser": "^21.1.1",
146
- "yoctocolors-cjs": "^2.1.2"
147
- };
148
- var devDependencies = {
149
- "@babel/core": "^7.26.0",
150
- "@babel/plugin-proposal-export-default-from": "^7.25.9",
151
- "@babel/plugin-syntax-dynamic-import": "^7.8.3",
152
- "@babel/plugin-transform-export-namespace-from": "^7.25.9",
153
- "@babel/plugin-transform-modules-commonjs": "^7.26.3",
154
- "@babel/plugin-transform-runtime": "^7.25.9",
155
- "@babel/preset-env": "^7.26.0",
156
- "@babel/preset-typescript": "^7.26.0",
157
- "@babel/runtime": "^7.26.0",
158
- "@eslint/compat": "^1.2.4",
159
- "@eslint/js": "^9.16.0",
160
- "@rollup/plugin-commonjs": "^28.0.1",
161
- "@rollup/plugin-json": "^6.1.0",
162
- "@rollup/plugin-node-resolve": "^15.3.0",
163
- "@rollup/plugin-replace": "^6.0.1",
164
- "@rollup/pluginutils": "^5.1.3",
165
- "@tapjs/run": "^4.0.1",
166
- "@types/blessed": "^0.1.25",
167
- "@types/micromatch": "^4.0.9",
168
- "@types/mocha": "^10.0.10",
169
- "@types/mock-fs": "^4.13.4",
170
- "@types/node": "^22.10.1",
171
- "@types/npmcli__arborist": "^5.6.11",
172
- "@types/npmcli__promise-spawn": "^6.0.3",
173
- "@types/proc-log": "^3.0.4",
174
- "@types/semver": "^7.5.8",
175
- "@types/update-notifier": "^6.0.8",
176
- "@types/which": "^3.0.4",
177
- "@types/yargs-parser": "^21.0.3",
178
- "@typescript-eslint/eslint-plugin": "^8.17.0",
179
- "@typescript-eslint/parser": "^8.17.0",
180
- c8: "^10.1.2",
181
- custompatch: "^1.0.28",
182
- eslint: "^9.16.0",
183
- "eslint-import-resolver-oxc": "^0.6.0",
184
- "eslint-plugin-depend": "^0.12.0",
185
- "eslint-plugin-import-x": "^4.5.0",
186
- "eslint-plugin-n": "^17.14.0",
187
- "eslint-plugin-sort-destructure-keys": "^2.0.0",
188
- "eslint-plugin-unicorn": "^56.0.1",
189
- husky: "^9.1.7",
190
- "is-interactive": "^2.0.0",
191
- "is-unicode-supported": "^2.1.0",
192
- knip: "^5.39.2",
193
- "magic-string": "^0.30.14",
194
- meow: "^13.2.0",
195
- "mock-fs": "^5.4.1",
196
- nock: "^13.5.6",
197
- "npm-run-all2": "^7.0.1",
198
- open: "^10.1.0",
199
- oxlint: "0.14.1",
200
- prettier: "3.4.2",
201
- "read-package-up": "^11.0.0",
202
- rollup: "4.28.1",
203
- "rollup-plugin-ts": "^3.4.5",
204
- "terminal-link": "^3.0.0",
205
- "tiny-updater": "^3.5.2",
206
- "type-coverage": "^2.29.7",
207
- typescript: "5.4.5",
208
- "typescript-eslint": "^8.17.0",
209
- "unplugin-purge-polyfills": "^0.0.7"
210
- };
211
- var overrides = {
212
- "aggregate-error": "npm:@socketregistry/aggregate-error@^1",
213
- "es-define-property": "npm:@socketregistry/es-define-property@^1",
214
- "function-bind": "npm:@socketregistry/function-bind@^1",
215
- globalthis: "npm:@socketregistry/globalthis@^1",
216
- gopd: "npm:@socketregistry/gopd@^1",
217
- "has-property-descriptors": "npm:@socketregistry/has-property-descriptors@^1",
218
- "has-proto": "npm:@socketregistry/has-proto@^1",
219
- "has-symbols": "npm:@socketregistry/has-symbols@^1",
220
- hasown: "npm:@socketregistry/hasown@^1",
221
- "indent-string": "npm:@socketregistry/indent-string@^1",
222
- "is-core-module": "npm:@socketregistry/is-core-module@^1",
223
- isarray: "npm:@socketregistry/isarray@^1",
224
- "npm-package-arg": "$npm-package-arg",
225
- "packageurl-js": "npm:@socketregistry/packageurl-js@^1",
226
- "path-parse": "npm:@socketregistry/path-parse@^1",
227
- "safe-buffer": "npm:@socketregistry/safe-buffer@^1",
228
- "safer-buffer": "npm:@socketregistry/safer-buffer@^1",
229
- semver: "$semver",
230
- "set-function-length": "npm:@socketregistry/set-function-length@^1",
231
- "side-channel": "npm:@socketregistry/side-channel@^1",
232
- yaml: "$yaml"
233
- };
234
- var resolutions = {
235
- "aggregate-error": "npm:@socketregistry/aggregate-error@^1",
236
- "es-define-property": "npm:@socketregistry/es-define-property@^1",
237
- "function-bind": "npm:@socketregistry/function-bind@^1",
238
- globalthis: "npm:@socketregistry/globalthis@^1",
239
- gopd: "npm:@socketregistry/gopd@^1",
240
- "has-property-descriptors": "npm:@socketregistry/has-property-descriptors@^1",
241
- "has-proto": "npm:@socketregistry/has-proto@^1",
242
- "has-symbols": "npm:@socketregistry/has-symbols@^1",
243
- hasown: "npm:@socketregistry/hasown@^1",
244
- "indent-string": "npm:@socketregistry/indent-string@^1",
245
- "is-core-module": "npm:@socketregistry/is-core-module@^1",
246
- isarray: "npm:@socketregistry/isarray@^1",
247
- "npm-package-arg": "^12.0.0",
248
- "packageurl-js": "npm:@socketregistry/packageurl-js@^1",
249
- "path-parse": "npm:@socketregistry/path-parse@^1",
250
- "safe-buffer": "npm:@socketregistry/safe-buffer@^1",
251
- "safer-buffer": "npm:@socketregistry/safer-buffer@^1",
252
- semver: "^7.6.3",
253
- "set-function-length": "npm:@socketregistry/set-function-length@^1",
254
- "side-channel": "npm:@socketregistry/side-channel@^1",
255
- yaml: "^2.6.0"
256
- };
257
- var engines = {
258
- node: "^18.20.4 || ^20.9.0 || >=22.0.0"
259
- };
260
- var files = [
261
- "bin/**",
262
- "dist/**",
263
- "translations.json"
264
- ];
265
- var require$$6 = {
266
- name: name,
267
- version: version,
268
- description: description,
269
- homepage: homepage,
270
- license: license,
271
- repository: repository,
272
- author: author,
273
- bin: bin,
274
- exports: exports$1,
275
- scripts: scripts,
276
- dependencies: dependencies,
277
- devDependencies: devDependencies,
278
- overrides: overrides,
279
- resolutions: resolutions,
280
- engines: engines,
281
- files: files
282
- };
33
+ var version = "0.14.35";
283
34
 
284
- Object.defineProperty(ttyServer$1, "__esModule", {
285
- value: true
286
- });
287
- ttyServer$1.createTTYServer = createTTYServer;
288
- var _nodeFs$1 = require$$0;
289
- var _nodeNet = require$$1$2;
290
- var _nodeOs = require$$1;
291
- var _nodePath$1 = require$$1$1;
292
- var _nodeReadline$1 = require$$3;
293
- var _nodeStream = require$$5;
294
- var _package = require$$6;
295
- var _misc$1 = sdk.misc;
296
35
  const NEWLINE_CHAR_CODE = 10; /*'\n'*/
297
36
 
298
37
  const TTY_IPC = process.env['SOCKET_SECURITY_TTY_IPC'];
299
- const sock = _nodePath$1.join(_nodeOs.tmpdir(), `socket-security-tty-${process.pid}.sock`);
38
+ const sock = path.join(os.tmpdir(), `socket-security-tty-${process.pid}.sock`);
300
39
  process.env['SOCKET_SECURITY_TTY_IPC'] = sock;
301
40
  function createNonStandardTTYServer() {
302
41
  return {
303
42
  async captureTTY(mutexFn) {
304
43
  return await new Promise((resolve, reject) => {
305
- const conn = _nodeNet.createConnection({
44
+ const conn = net.createConnection({
306
45
  path: TTY_IPC
307
46
  }).on('error', reject);
308
47
  let captured = false;
@@ -322,26 +61,26 @@ function createNonStandardTTYServer() {
322
61
  output: hasOutput
323
62
  },
324
63
  ipc_version: remote_ipc_version
325
- } = JSON.parse(lineBuff.subarray(0, eolIndex).toString('utf-8'));
64
+ } = JSON.parse(lineBuff.subarray(0, eolIndex).toString('utf8'));
326
65
  lineBuff = null;
327
66
  captured = true;
328
- if (remote_ipc_version !== _package.version) {
67
+ if (remote_ipc_version !== version) {
329
68
  throw new Error('Mismatched STDIO tunnel IPC version, ensure you only have 1 version of socket CLI being called.');
330
69
  }
331
- const input = hasInput ? new _nodeStream.PassThrough() : null;
70
+ const input = hasInput ? new node_stream.PassThrough() : null;
332
71
  input?.pause();
333
72
  if (input) conn.pipe(input);
334
- const output = hasOutput ? new _nodeStream.PassThrough() : null;
73
+ const output = hasOutput ? new node_stream.PassThrough() : null;
335
74
  if (output) {
336
75
  output.pipe(conn)
337
76
  // Make ora happy
338
77
  ;
339
78
  output.isTTY = true;
340
79
  output.cursorTo = function cursorTo(x, y, callback) {
341
- _nodeReadline$1.cursorTo(this, x, y, callback);
80
+ readline.cursorTo(this, x, y, callback);
342
81
  };
343
82
  output.clearLine = function clearLine(dir, callback) {
344
- _nodeReadline$1.clearLine(this, dir, callback);
83
+ readline.clearLine(this, dir, callback);
345
84
  };
346
85
  }
347
86
  mutexFn(hasInput ? input : undefined, hasOutput ? output : undefined).then(resolve, reject).finally(() => {
@@ -364,7 +103,7 @@ function createIPCServer(captureState, npmlog) {
364
103
  const input = process.stdin;
365
104
  const output = process.stderr;
366
105
  return new Promise((resolve, reject) => {
367
- const server = _nodeNet
106
+ const server = net
368
107
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
369
108
  .createServer(async conn => {
370
109
  if (captureState.captured) {
@@ -384,7 +123,7 @@ function createIPCServer(captureState, npmlog) {
384
123
  npmlog.disableProgress();
385
124
  }
386
125
  conn.write(`${JSON.stringify({
387
- ipc_version: _package.version,
126
+ ipc_version: version,
388
127
  capabilities: {
389
128
  input: Boolean(input),
390
129
  output: true
@@ -469,9 +208,9 @@ function createStandardTTYServer(isInteractive, npmlog) {
469
208
  }
470
209
  function tryUnlinkSync(filepath) {
471
210
  try {
472
- (0, _nodeFs$1.unlinkSync)(filepath);
211
+ fs.unlinkSync(filepath);
473
212
  } catch (e) {
474
- if ((0, _misc$1.isErrnoException)(e) && e.code !== 'ENOENT') {
213
+ if (sdk.isErrnoException(e) && e.code !== 'ENOENT') {
475
214
  throw e;
476
215
  }
477
216
  }
@@ -480,12 +219,6 @@ function createTTYServer(isInteractive, npmlog) {
480
219
  return !isInteractive && TTY_IPC ? createNonStandardTTYServer() : createStandardTTYServer(isInteractive, npmlog);
481
220
  }
482
221
 
483
- var issueRules = {};
484
-
485
- Object.defineProperty(issueRules, "__esModule", {
486
- value: true
487
- });
488
- issueRules.createAlertUXLookup = createAlertUXLookup;
489
222
  //#region UX Constants
490
223
 
491
224
  const IGNORE_UX = {
@@ -508,7 +241,7 @@ const ERROR_UX = {
508
241
  * all issue rules and finds the first defined value that does not defer otherwise
509
242
  * uses the defaultValue. Takes the value and converts into a UX workflow
510
243
  */
511
- function resolveIssueRuleUX(entriesOrderedIssueRules, defaultValue) {
244
+ function resolveAlertRuleUX(orderedRulesCollection, defaultValue) {
512
245
  if (defaultValue === true || defaultValue == null) {
513
246
  defaultValue = {
514
247
  action: 'error'
@@ -521,9 +254,9 @@ function resolveIssueRuleUX(entriesOrderedIssueRules, defaultValue) {
521
254
  let block = false;
522
255
  let display = false;
523
256
  let needDefault = true;
524
- iterate_entries: for (const issueRuleArr of entriesOrderedIssueRules) {
525
- for (const rule of issueRuleArr) {
526
- if (issueRuleValueDoesNotDefer(rule)) {
257
+ iterate_entries: for (const rules of orderedRulesCollection) {
258
+ for (const rule of rules) {
259
+ if (ruleValueDoesNotDefer(rule)) {
527
260
  needDefault = false;
528
261
  const narrowingFilter = uxForDefinedNonDeferValue(rule);
529
262
  block = block || narrowingFilter.block;
@@ -549,13 +282,13 @@ function resolveIssueRuleUX(entriesOrderedIssueRules, defaultValue) {
549
282
  /**
550
283
  * Negative form because it is narrowing the type
551
284
  */
552
- function issueRuleValueDoesNotDefer(issueRule) {
553
- if (issueRule === undefined) {
285
+ function ruleValueDoesNotDefer(rule) {
286
+ if (rule === undefined) {
554
287
  return false;
555
- } else if (issueRule !== null && typeof issueRule === 'object') {
288
+ } else if (rule !== null && typeof rule === 'object') {
556
289
  const {
557
290
  action
558
- } = issueRule;
291
+ } = rule;
559
292
  if (action === undefined || action === 'defer') {
560
293
  return false;
561
294
  }
@@ -566,13 +299,13 @@ function issueRuleValueDoesNotDefer(issueRule) {
566
299
  /**
567
300
  * Handles booleans for backwards compatibility
568
301
  */
569
- function uxForDefinedNonDeferValue(issueRuleValue) {
570
- if (typeof issueRuleValue === 'boolean') {
571
- return issueRuleValue ? ERROR_UX : IGNORE_UX;
302
+ function uxForDefinedNonDeferValue(ruleValue) {
303
+ if (typeof ruleValue === 'boolean') {
304
+ return ruleValue ? ERROR_UX : IGNORE_UX;
572
305
  }
573
306
  const {
574
307
  action
575
- } = issueRuleValue;
308
+ } = ruleValue;
576
309
  if (action === 'warn') {
577
310
  return WARN_UX;
578
311
  } else if (action === 'ignore') {
@@ -594,9 +327,9 @@ function createAlertUXLookup(settings) {
594
327
  if (ux) {
595
328
  return ux;
596
329
  }
597
- const entriesOrderedIssueRules = [];
330
+ const orderedRulesCollection = [];
598
331
  for (const settingsEntry of settings.entries) {
599
- const orderedIssueRules = [];
332
+ const orderedRules = [];
600
333
  let target = settingsEntry.start;
601
334
  while (target !== null) {
602
335
  const resolvedTarget = settingsEntry.settings[target];
@@ -605,11 +338,11 @@ function createAlertUXLookup(settings) {
605
338
  }
606
339
  const issueRuleValue = resolvedTarget.issueRules?.[type];
607
340
  if (typeof issueRuleValue !== 'undefined') {
608
- orderedIssueRules.push(issueRuleValue);
341
+ orderedRules.push(issueRuleValue);
609
342
  }
610
343
  target = resolvedTarget.deferTo ?? null;
611
344
  }
612
- entriesOrderedIssueRules.push(orderedIssueRules);
345
+ orderedRulesCollection.push(orderedRules);
613
346
  }
614
347
  const defaultValue = settings.defaults.issueRules[type];
615
348
  let resolvedDefaultValue = {
@@ -624,42 +357,27 @@ function createAlertUXLookup(settings) {
624
357
  action: defaultValue.action ?? 'error'
625
358
  };
626
359
  }
627
- ux = resolveIssueRuleUX(entriesOrderedIssueRules, resolvedDefaultValue);
360
+ ux = resolveAlertRuleUX(orderedRulesCollection, resolvedDefaultValue);
628
361
  cachedUX.set(type, ux);
629
362
  return ux;
630
363
  };
631
364
  }
365
+ //#endregion
632
366
 
633
- var _interopRequireDefault = vendor.interopRequireDefault.default;
634
- Object.defineProperty(arborist, "__esModule", {
635
- value: true
636
- });
637
- arborist.SafeArborist = void 0;
638
- arborist.installSafeArborist = installSafeArborist;
639
- var _nodeEvents = require$$1$4;
640
- var _nodeFs = require$$0;
641
- var _nodeHttps = require$$3$2;
642
- var _nodePath = require$$1$1;
643
- var _nodeReadline = require$$3;
644
- var _promises = require$$6$2;
645
- var _confirm = require$$1$3;
646
- var _yoctoSpinner = require$$3$1;
647
- var _isInteractive = _interopRequireDefault(vendor.isInteractive);
648
- var _npmPackageArg = require$$5$1;
649
- var _semver = require$$4;
650
- var _config = require$$6$1;
651
- var _objects = require$$7;
652
- var _ttyServer = ttyServer$1;
653
- var _constants$1 = constants.constants;
654
- var _colorOrMarkdown = sdk.colorOrMarkdown;
655
- var _issueRules = issueRules;
656
- var _misc = sdk.misc;
657
- var _pathResolve = pathResolve.pathResolve;
658
- var _sdk = sdk.sdk;
659
- 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}.`;
661
- const npmEntrypoint = (0, _nodeFs.realpathSync)(process.argv[1]);
662
- const npmRootPath = (0, _pathResolve.findRoot)(_nodePath.dirname(npmEntrypoint));
367
+ const {
368
+ API_V0_URL,
369
+ ENV,
370
+ LOOP_SENTINEL,
371
+ NPM_REGISTRY_URL,
372
+ SOCKET_CLI_ISSUES_URL,
373
+ SOCKET_PUBLIC_API_KEY,
374
+ UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE,
375
+ abortSignal,
376
+ rootPath
377
+ } = constants;
378
+ 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}.`;
379
+ const npmEntrypoint = fs.realpathSync(process.argv[1]);
380
+ const npmRootPath = pathResolve.findRoot(path.dirname(npmEntrypoint));
663
381
  function tryRequire(...ids) {
664
382
  for (const data of ids) {
665
383
  let id;
@@ -684,32 +402,32 @@ function tryRequire(...ids) {
684
402
  }
685
403
  if (npmRootPath === undefined) {
686
404
  console.error(`Unable to find npm CLI install directory.\nSearched parent directories of ${npmEntrypoint}.\n\n${POTENTIAL_BUG_ERROR_MESSAGE}`);
405
+ // The exit code 127 indicates that the command or binary being executed
406
+ // could not be found.
687
407
  process.exit(127);
688
408
  }
689
- const npmNmPath = _nodePath.join(npmRootPath, 'node_modules');
690
- const arboristPkgPath = _nodePath.join(npmNmPath, '@npmcli/arborist');
691
- const arboristClassPath = _nodePath.join(arboristPkgPath, 'lib/arborist/index.js');
692
- const arboristDepValidPath = _nodePath.join(arboristPkgPath, 'lib/dep-valid.js');
693
- const arboristEdgeClassPath = _nodePath.join(arboristPkgPath, 'lib/edge.js');
694
- const arboristNodeClassPath = _nodePath.join(arboristPkgPath, 'lib/node.js');
695
- const arboristOverrideSetClassPatch = _nodePath.join(arboristPkgPath, 'lib/override-set.js');
696
- const log = tryRequire([_nodePath.join(npmNmPath, 'proc-log/lib/index.js'),
409
+ const npmNmPath = path.join(npmRootPath, 'node_modules');
410
+ const arboristPkgPath = path.join(npmNmPath, '@npmcli/arborist');
411
+ const arboristClassPath = path.join(arboristPkgPath, 'lib/arborist/index.js');
412
+ const arboristDepValidPath = path.join(arboristPkgPath, 'lib/dep-valid.js');
413
+ const arboristEdgeClassPath = path.join(arboristPkgPath, 'lib/edge.js');
414
+ const arboristNodeClassPath = path.join(arboristPkgPath, 'lib/node.js');
415
+ const arboristOverrideSetClassPatch = path.join(arboristPkgPath, 'lib/override-set.js');
416
+ const log = tryRequire([path.join(npmNmPath, 'proc-log/lib/index.js'),
697
417
  // The proc-log DefinitelyTyped definition is incorrect. The type definition
698
418
  // is really that of its export log.
699
- mod => mod.log], _nodePath.join(npmNmPath, 'npmlog/lib/log.js'));
419
+ mod => mod.log], path.join(npmNmPath, 'npmlog/lib/log.js'));
700
420
  if (log === undefined) {
701
421
  console.error(`Unable to integrate with npm CLI logging infrastructure.\n\n${POTENTIAL_BUG_ERROR_MESSAGE}.`);
422
+ // The exit code 127 indicates that the command or binary being executed
423
+ // could not be found.
702
424
  process.exit(127);
703
425
  }
704
- const pacote = tryRequire(_nodePath.join(npmNmPath, 'pacote'), 'pacote');
426
+ const pacote = tryRequire(path.join(npmNmPath, 'pacote'), 'pacote');
705
427
  const {
706
428
  tarball
707
429
  } = pacote;
708
- const translations = require(_nodePath.join(_constants$1.rootPath, 'translations.json'));
709
- const abortController = new AbortController();
710
- const {
711
- signal: abortSignal
712
- } = abortController;
430
+ const translations = require(path.join(rootPath, 'translations.json'));
713
431
  const Arborist = require(arboristClassPath);
714
432
  const depValid = require(arboristDepValidPath);
715
433
  const Edge = require(arboristEdgeClassPath);
@@ -717,23 +435,23 @@ const Node = require(arboristNodeClassPath);
717
435
  const OverrideSet = require(arboristOverrideSetClassPatch);
718
436
  const kCtorArgs = Symbol('ctorArgs');
719
437
  const kRiskyReify = Symbol('riskyReify');
720
- const formatter = new _colorOrMarkdown.ColorOrMarkdown(false);
721
- const pubToken = (0, _sdk.getDefaultKey)() ?? _constants$1.SOCKET_PUBLIC_API_KEY;
722
- const ttyServer = (0, _ttyServer.createTTYServer)((0, _isInteractive.default)({
438
+ const formatter = new sdk.ColorOrMarkdown(false);
439
+ const pubToken = sdk.getDefaultKey() ?? SOCKET_PUBLIC_API_KEY;
440
+ const ttyServer = createTTYServer(vendor.isInteractive({
723
441
  stream: process.stdin
724
442
  }), log);
725
443
  let _uxLookup;
726
444
  async function uxLookup(settings) {
727
445
  while (_uxLookup === undefined) {
728
446
  // eslint-disable-next-line no-await-in-loop
729
- await (0, _promises.setTimeout)(1, {
447
+ await promises.setTimeout(1, {
730
448
  signal: abortSignal
731
449
  });
732
450
  }
733
451
  return _uxLookup(settings);
734
452
  }
735
453
  async function* batchScan(pkgIds) {
736
- const req = _nodeHttps.request(`${_constants$1.API_V0_URL}/purl?alerts=true`, {
454
+ const req = https.request(`${API_V0_URL}/purl?alerts=true`, {
737
455
  method: 'POST',
738
456
  headers: {
739
457
  Authorization: `Basic ${Buffer.from(`${pubToken}:`).toString('base64url')}`
@@ -746,12 +464,12 @@ async function* batchScan(pkgIds) {
746
464
  }));
747
465
  const {
748
466
  0: res
749
- } = await _nodeEvents.once(req, 'response');
467
+ } = await events.once(req, 'response');
750
468
  const ok = res.statusCode >= 200 && res.statusCode <= 299;
751
469
  if (!ok) {
752
470
  throw new Error(`Socket API Error: ${res.statusCode}`);
753
471
  }
754
- const rli = _nodeReadline.createInterface(res);
472
+ const rli = readline.createInterface(res);
755
473
  for await (const line of rli) {
756
474
  yield JSON.parse(line);
757
475
  }
@@ -769,24 +487,24 @@ function findSocketYmlSync() {
769
487
  let prevDir = null;
770
488
  let dir = process.cwd();
771
489
  while (dir !== prevDir) {
772
- let ymlPath = _nodePath.join(dir, 'socket.yml');
490
+ let ymlPath = path.join(dir, 'socket.yml');
773
491
  let yml = maybeReadfileSync(ymlPath);
774
492
  if (yml === undefined) {
775
- ymlPath = _nodePath.join(dir, 'socket.yaml');
493
+ ymlPath = path.join(dir, 'socket.yaml');
776
494
  yml = maybeReadfileSync(ymlPath);
777
495
  }
778
496
  if (typeof yml === 'string') {
779
497
  try {
780
498
  return {
781
499
  path: ymlPath,
782
- parsed: _config.parseSocketConfig(yml)
500
+ parsed: config.parseSocketConfig(yml)
783
501
  };
784
502
  } catch {
785
503
  throw new Error(`Found file but was unable to parse ${ymlPath}`);
786
504
  }
787
505
  }
788
506
  prevDir = dir;
789
- dir = _nodePath.join(dir, '..');
507
+ dir = path.join(dir, '..');
790
508
  }
791
509
  return null;
792
510
  }
@@ -823,12 +541,12 @@ function isAlertFixable(alert) {
823
541
  }
824
542
  function maybeReadfileSync(filepath) {
825
543
  try {
826
- return (0, _nodeFs.readFileSync)(filepath, 'utf8');
544
+ return fs.readFileSync(filepath, 'utf8');
827
545
  } catch {}
828
546
  return undefined;
829
547
  }
830
548
  async function getPackagesAlerts(safeArb, _registry, pkgs, output) {
831
- const spinner = _yoctoSpinner({
549
+ const spinner = yoctoSpinner({
832
550
  stream: output
833
551
  });
834
552
  let {
@@ -849,7 +567,7 @@ async function getPackagesAlerts(safeArb, _registry, pkgs, output) {
849
567
  const {
850
568
  version
851
569
  } = artifact;
852
- const name = `${artifact.namespace ? `${artifact.namespace}/` : ''}${artifact.name}`;
570
+ const name = packages.resolvePackageName(artifact);
853
571
  const id = `${name}@${artifact.version}`;
854
572
  let blocked = false;
855
573
  let displayWarning = false;
@@ -947,7 +665,7 @@ function walk(diff_, needInfoOn = []) {
947
665
  length: queueLength
948
666
  } = queue;
949
667
  while (pos < queueLength) {
950
- if (pos === _constants$1.LOOP_SENTINEL) {
668
+ if (pos === LOOP_SENTINEL) {
951
669
  throw new Error('Detected infinite loop while walking Arborist diff');
952
670
  }
953
671
  const diff = queue[pos++];
@@ -1286,12 +1004,12 @@ class SafeNode extends Node {
1286
1004
  // is based on https://github.com/npm/cli/pull/7025.
1287
1005
  //
1288
1006
  // If we prefer dedupe, or if the version is equal, take the other.
1289
- if (preferDedupe || _semver.eq(other.version, this.version)) {
1007
+ if (preferDedupe || semver.eq(other.version, this.version)) {
1290
1008
  return true;
1291
1009
  }
1292
1010
  // If our current version isn't the result of an override, then prefer to
1293
1011
  // take the greater version.
1294
- if (!this.overridden && _semver.gt(other.version, this.version)) {
1012
+ if (!this.overridden && semver.gt(other.version, this.version)) {
1295
1013
  return true;
1296
1014
  }
1297
1015
  return false;
@@ -1527,7 +1245,7 @@ class SafeOverrideSet extends OverrideSet {
1527
1245
  length: queueLength
1528
1246
  } = queue;
1529
1247
  while (pos < queueLength) {
1530
- if (pos === _constants$1.LOOP_SENTINEL) {
1248
+ if (pos === LOOP_SENTINEL) {
1531
1249
  throw new Error('Detected infinite loop while comparing override sets');
1532
1250
  }
1533
1251
  const {
@@ -1572,18 +1290,18 @@ class SafeOverrideSet extends OverrideSet {
1572
1290
  //
1573
1291
  // We need to use the rawSpec here, because the spec has the overrides
1574
1292
  // applied to it already.
1575
- let spec = _npmPackageArg(`${edge.name}@${edge.rawSpec}`);
1293
+ let spec = npa(`${edge.name}@${edge.rawSpec}`);
1576
1294
  if (spec.type === 'alias') {
1577
1295
  spec = spec.subSpec;
1578
1296
  }
1579
1297
  if (spec.type === 'git') {
1580
- if (spec.gitRange && rule.keySpec && _semver.intersects(spec.gitRange, rule.keySpec)) {
1298
+ if (spec.gitRange && rule.keySpec && semver.intersects(spec.gitRange, rule.keySpec)) {
1581
1299
  return rule;
1582
1300
  }
1583
1301
  continue;
1584
1302
  }
1585
1303
  if (spec.type === 'range' || spec.type === 'version') {
1586
- if (rule.keySpec && _semver.intersects(spec.fetchSpec, rule.keySpec)) {
1304
+ if (rule.keySpec && semver.intersects(spec.fetchSpec, rule.keySpec)) {
1587
1305
  return rule;
1588
1306
  }
1589
1307
  continue;
@@ -1669,10 +1387,10 @@ class SafeArborist extends Arborist {
1669
1387
  options['save'] = old.save;
1670
1388
  options['saveBundle'] = old.saveBundle;
1671
1389
  // Nothing to check, mmm already installed or all private?
1672
- if (diff.findIndex(c => c.repository_url === _constants$1.NPM_REGISTRY_URL) === -1) {
1390
+ if (diff.findIndex(c => c.repository_url === NPM_REGISTRY_URL) === -1) {
1673
1391
  return await this[kRiskyReify](...args);
1674
1392
  }
1675
- let proceed = _constants$1.ENV[_constants$1.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE];
1393
+ let proceed = ENV[UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE];
1676
1394
  if (!proceed) {
1677
1395
  proceed = await ttyServer.captureTTY(async (input, output) => {
1678
1396
  if (input && output) {
@@ -1680,7 +1398,7 @@ class SafeArborist extends Arborist {
1680
1398
  if (!alerts.length) {
1681
1399
  return true;
1682
1400
  }
1683
- return await _confirm({
1401
+ return await prompts.confirm({
1684
1402
  message: 'Accept risks of installing these packages?',
1685
1403
  default: false
1686
1404
  }, {
@@ -1701,7 +1419,6 @@ class SafeArborist extends Arborist {
1701
1419
  }
1702
1420
  }
1703
1421
  }
1704
- arborist.SafeArborist = SafeArborist;
1705
1422
  function installSafeArborist() {
1706
1423
  const cache = require.cache;
1707
1424
  cache[arboristClassPath] = {
@@ -1720,7 +1437,7 @@ function installSafeArborist() {
1720
1437
  void (async () => {
1721
1438
  const remoteSettings = await (async () => {
1722
1439
  try {
1723
- const socketSdk = await (0, _sdk.setupSdk)(pubToken);
1440
+ const socketSdk = await sdk.setupSdk(pubToken);
1724
1441
  const orgResult = await socketSdk.getOrganizations();
1725
1442
  if (!orgResult.success) {
1726
1443
  throw new Error(`Failed to fetch Socket organization info: ${orgResult.error.message}`);
@@ -1742,11 +1459,11 @@ void (async () => {
1742
1459
  settings: result.data
1743
1460
  };
1744
1461
  } catch (e) {
1745
- if ((0, _objects.isObject)(e) && 'cause' in e) {
1462
+ if (objects.isObject(e) && 'cause' in e) {
1746
1463
  const {
1747
1464
  cause
1748
1465
  } = e;
1749
- if ((0, _misc.isErrnoException)(cause)) {
1466
+ if (sdk.isErrnoException(cause)) {
1750
1467
  if (cause.code === 'ENOTFOUND' || cause.code === 'ECONNREFUSED') {
1751
1468
  throw new Error('Unable to connect to socket.dev, ensure internet connectivity before retrying', {
1752
1469
  cause: e
@@ -1761,7 +1478,7 @@ void (async () => {
1761
1478
  orgs,
1762
1479
  settings
1763
1480
  } = remoteSettings;
1764
- const enforcedOrgs = (0, _settings.getSetting)('enforcedOrgs') ?? [];
1481
+ const enforcedOrgs = sdk.getSetting('enforcedOrgs') ?? [];
1765
1482
 
1766
1483
  // Remove any organizations not being enforced.
1767
1484
  for (const {
@@ -1789,43 +1506,7 @@ void (async () => {
1789
1506
  }
1790
1507
  });
1791
1508
  }
1792
- _uxLookup = (0, _issueRules.createAlertUXLookup)(settings);
1509
+ _uxLookup = createAlertUXLookup(settings);
1793
1510
  })();
1794
1511
 
1795
- var _constants = constants.constants;
1796
- var _arborist = arborist;
1797
- var _link = link.link;
1798
- // Shadow `npm` and `npx` to mitigate subshells.
1799
- (0, _link.installLinks)(_constants.shadowBinPath, 'npm');
1800
- (0, _arborist.installSafeArborist)();
1801
-
1802
- (function (exports) {
1803
-
1804
- var _interopRequireWildcard = vendor.interopRequireWildcard.default;
1805
- Object.defineProperty(exports, "__esModule", {
1806
- value: true
1807
- });
1808
- var _exportNames = {};
1809
- Object.defineProperty(exports, "default", {
1810
- enumerable: true,
1811
- get: function () {
1812
- return _npmInjection.default;
1813
- }
1814
- });
1815
- var _npmInjection = _interopRequireWildcard(npmInjection$1, true);
1816
- Object.keys(_npmInjection).forEach(function (key) {
1817
- if (key === "default" || key === "__esModule") return;
1818
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
1819
- if (key in exports && exports[key] === _npmInjection[key]) return;
1820
- Object.defineProperty(exports, key, {
1821
- enumerable: true,
1822
- get: function () {
1823
- return _npmInjection[key];
1824
- }
1825
- });
1826
- });
1827
- } (npmInjection$2));
1828
-
1829
- var npmInjection = /*@__PURE__*/vendor.getDefaultExportFromCjs(npmInjection$2);
1830
-
1831
- module.exports = npmInjection;
1512
+ installSafeArborist();