@socketsecurity/cli 0.14.28 → 0.14.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +7 -0
- package/bin/npm-cli.js +7 -0
- package/bin/npx-cli.js +7 -0
- package/bin/shadow/module-sync/npm +3 -0
- package/bin/shadow/module-sync/npx +3 -0
- package/bin/shadow/require/npm +3 -0
- package/bin/shadow/require/npx +3 -0
- package/dist/module-sync/cli.d.ts.map +1 -0
- package/dist/module-sync/cli.js +5258 -0
- package/dist/module-sync/constants.d.ts +20 -0
- package/dist/module-sync/constants.js +72 -0
- package/dist/module-sync/npm-cli.js +85 -0
- package/dist/module-sync/npm-injection.js +1609 -0
- package/dist/module-sync/npx-cli.js +61 -0
- package/dist/{sdk.d.ts → module-sync/sdk.d.ts} +1 -5
- package/dist/module-sync/sdk.js +253 -0
- package/dist/require/cli.d.ts +3 -0
- package/dist/require/cli.d.ts.map +1 -0
- package/dist/{cli.js → require/cli.js} +80 -82
- package/dist/require/color-or-markdown.d.ts +23 -0
- package/dist/require/constants.d.ts +20 -0
- package/dist/require/constants.js +67 -0
- package/dist/require/errors.d.ts +7 -0
- package/dist/require/link.d.ts +2 -0
- package/dist/require/link.js +45 -0
- package/dist/require/npm-cli.d.ts +2 -0
- package/dist/{npm-cli.js → require/npm-cli.js} +12 -10
- package/dist/require/npm-injection.d.ts +1 -0
- package/dist/{npm-injection.js → require/npm-injection.js} +169 -135
- package/dist/require/npx-cli.d.ts +2 -0
- package/dist/{npx-cli.js → require/npx-cli.js} +12 -12
- package/dist/require/path-resolve.d.ts +8 -0
- package/dist/require/path-resolve.js +183 -0
- package/dist/require/sdk.d.ts +9 -0
- package/dist/{sdk.js → require/sdk.js} +16 -36
- package/dist/require/settings.d.ts +9 -0
- package/dist/{vendor.js → require/vendor.js} +6 -1
- package/package.json +54 -19
- package/translations.json +190 -287
- package/bin/npm +0 -2
- package/bin/npx +0 -2
- package/dist/cli.d.ts.map +0 -1
- /package/dist/{cli.d.ts → module-sync/cli.d.ts} +0 -0
- /package/dist/{color-or-markdown.d.ts → module-sync/color-or-markdown.d.ts} +0 -0
- /package/dist/{errors.d.ts → module-sync/errors.d.ts} +0 -0
- /package/dist/{link.d.ts → module-sync/link.d.ts} +0 -0
- /package/dist/{link.js → module-sync/link.js} +0 -0
- /package/dist/{npm-cli.d.ts → module-sync/npm-cli.d.ts} +0 -0
- /package/dist/{npm-injection.d.ts → module-sync/npm-injection.d.ts} +0 -0
- /package/dist/{npx-cli.d.ts → module-sync/npx-cli.d.ts} +0 -0
- /package/dist/{path-resolve.d.ts → module-sync/path-resolve.d.ts} +0 -0
- /package/dist/{path-resolve.js → module-sync/path-resolve.js} +0 -0
- /package/dist/{settings.d.ts → module-sync/settings.d.ts} +0 -0
|
@@ -5,22 +5,22 @@ var vendor = require('./vendor.js');
|
|
|
5
5
|
var require$$0 = require('node:fs');
|
|
6
6
|
var require$$1 = require('node:path');
|
|
7
7
|
var require$$1$1 = require('@npmcli/promise-spawn');
|
|
8
|
+
var constants = require('./constants.js');
|
|
8
9
|
var link = require('./link.js');
|
|
9
10
|
var pathResolve = require('./path-resolve.js');
|
|
10
11
|
|
|
11
|
-
var npmCli$
|
|
12
|
+
var npmCli$2 = {};
|
|
12
13
|
|
|
13
|
-
var npmCli = {};
|
|
14
|
+
var npmCli$1 = {};
|
|
14
15
|
|
|
15
16
|
var _nodeFs = require$$0;
|
|
16
17
|
var _nodePath = require$$1;
|
|
17
18
|
var _promiseSpawn = require$$1$1;
|
|
19
|
+
var _constants = constants.constants;
|
|
18
20
|
var _link = link.link;
|
|
19
21
|
var _pathResolve = pathResolve.pathResolve;
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const npmPath = (0, _link.installLinks)(_nodePath.join(realDirname, 'bin'), 'npm');
|
|
23
|
-
const injectionPath = _nodePath.join(realDirname, 'npm-injection.js');
|
|
22
|
+
const npmPath = (0, _link.installLinks)(_constants.shadowBinPath, 'npm');
|
|
23
|
+
const injectionPath = _nodePath.join(_constants.distPath, 'npm-injection.js');
|
|
24
24
|
|
|
25
25
|
// Adding the `--quiet` and `--no-progress` flags when the `proc-log` module
|
|
26
26
|
// is found to fix a UX issue when running the command with recent versions of
|
|
@@ -42,7 +42,7 @@ if (npmArgs.includes('install') && !npmArgs.includes('--no-progress') && !npmArg
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
process.exitCode = 1;
|
|
45
|
-
const spawnPromise = _promiseSpawn(process.execPath, ['--require', injectionPath, npmPath, ...npmArgs], {
|
|
45
|
+
const spawnPromise = _promiseSpawn(process.execPath, ['--disable-warning', 'ExperimentalWarning', '--require', injectionPath, npmPath, ...npmArgs], {
|
|
46
46
|
stdio: 'inherit'
|
|
47
47
|
});
|
|
48
48
|
spawnPromise.process.on('exit', (code, signal) => {
|
|
@@ -66,7 +66,7 @@ spawnPromise.process.on('exit', (code, signal) => {
|
|
|
66
66
|
return _npmCli.default;
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
|
-
var _npmCli = _interopRequireWildcard(npmCli, true);
|
|
69
|
+
var _npmCli = _interopRequireWildcard(npmCli$1, true);
|
|
70
70
|
Object.keys(_npmCli).forEach(function (key) {
|
|
71
71
|
if (key === "default" || key === "__esModule") return;
|
|
72
72
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -78,6 +78,8 @@ spawnPromise.process.on('exit', (code, signal) => {
|
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
});
|
|
81
|
-
} (npmCli$
|
|
81
|
+
} (npmCli$2));
|
|
82
|
+
|
|
83
|
+
var npmCli = /*@__PURE__*/vendor.getDefaultExportFromCjs(npmCli$2);
|
|
82
84
|
|
|
83
|
-
module.exports = npmCli
|
|
85
|
+
module.exports = npmCli;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var vendor = require('./vendor.js');
|
|
4
|
+
var constants = require('./constants.js');
|
|
5
|
+
var require$$1$3 = require('node:events');
|
|
4
6
|
var require$$0 = require('node:fs');
|
|
7
|
+
var require$$3$2 = require('node:https');
|
|
5
8
|
var require$$1$1 = require('node:path');
|
|
6
|
-
var require$$1$3 = require('node:events');
|
|
7
|
-
var require$$3$3 = require('node:https');
|
|
8
9
|
var require$$3 = require('node:readline');
|
|
9
10
|
var require$$5 = require('node:stream');
|
|
10
11
|
var require$$7$1 = require('node:timers/promises');
|
|
11
12
|
var require$$5$1 = require('npm-package-arg');
|
|
12
|
-
var require$$3$
|
|
13
|
-
var require$$
|
|
13
|
+
var require$$3$1 = require('@socketregistry/yocto-spinner');
|
|
14
|
+
var require$$4 = require('semver');
|
|
14
15
|
var require$$6$1 = require('@socketsecurity/config');
|
|
15
16
|
var require$$7 = require('@socketsecurity/registry/lib/objects');
|
|
16
17
|
var require$$1$2 = require('node:net');
|
|
@@ -19,16 +20,16 @@ var sdk = require('./sdk.js');
|
|
|
19
20
|
var pathResolve = require('./path-resolve.js');
|
|
20
21
|
var link = require('./link.js');
|
|
21
22
|
|
|
22
|
-
var npmInjection$
|
|
23
|
+
var npmInjection$2 = {};
|
|
23
24
|
|
|
24
|
-
var npmInjection = {};
|
|
25
|
+
var npmInjection$1 = {};
|
|
25
26
|
|
|
26
27
|
var arborist = {};
|
|
27
28
|
|
|
28
29
|
var ttyServer$1 = {};
|
|
29
30
|
|
|
30
31
|
var name = "@socketsecurity/cli";
|
|
31
|
-
var version = "0.14.
|
|
32
|
+
var version = "0.14.30";
|
|
32
33
|
var description = "CLI tool for Socket.dev";
|
|
33
34
|
var homepage = "http://github.com/SocketDev/socket-cli";
|
|
34
35
|
var license = "MIT";
|
|
@@ -42,10 +43,44 @@ var author = {
|
|
|
42
43
|
url: "https://socket.dev"
|
|
43
44
|
};
|
|
44
45
|
var bin = {
|
|
45
|
-
cli: "
|
|
46
|
-
socket: "
|
|
47
|
-
"socket-npm": "
|
|
48
|
-
"socket-npx": "
|
|
46
|
+
cli: "./bin/cli.js",
|
|
47
|
+
socket: "./bin/cli.js",
|
|
48
|
+
"socket-npm": "./bin/npm-cli.js",
|
|
49
|
+
"socket-npx": "./bin/npx-cli.js"
|
|
50
|
+
};
|
|
51
|
+
var exports$1 = {
|
|
52
|
+
"./bin/cli.js": {
|
|
53
|
+
"module-sync": {
|
|
54
|
+
types: "./dist/module-sync/cli.d.ts",
|
|
55
|
+
"default": "./dist/module-sync/cli.js"
|
|
56
|
+
},
|
|
57
|
+
require: {
|
|
58
|
+
types: "./dist/require/cli.d.ts",
|
|
59
|
+
"default": "./dist/require/cli.js"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"./bin/npm-cli.js": {
|
|
63
|
+
"module-sync": {
|
|
64
|
+
types: "./dist/module-sync/npm-cli.d.ts",
|
|
65
|
+
"default": "./dist/module-sync/npm-cli.js"
|
|
66
|
+
},
|
|
67
|
+
require: {
|
|
68
|
+
types: "./dist/require/npm-cli.d.ts",
|
|
69
|
+
"default": "./dist/require/npm-cli.js"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"./bin/npx-cli.js": {
|
|
73
|
+
"module-sync": {
|
|
74
|
+
types: "./dist/module-sync/npx-cli.d.ts",
|
|
75
|
+
"default": "./dist/module-sync/npx-cli.js"
|
|
76
|
+
},
|
|
77
|
+
require: {
|
|
78
|
+
types: "./dist/require/npx-cli.d.ts",
|
|
79
|
+
"default": "./dist/require/npx-cli.js"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"./package.json": "./package.json",
|
|
83
|
+
"./translations.json": "./translations.json"
|
|
49
84
|
};
|
|
50
85
|
var scripts = {
|
|
51
86
|
build: "run-s build:*",
|
|
@@ -60,22 +95,22 @@ var scripts = {
|
|
|
60
95
|
lint: "oxlint -c=./.oxlintrc.json --ignore-path=./.prettierignore --tsconfig=./tsconfig.json .",
|
|
61
96
|
"lint:fix": "npm run lint -- --fix && npm run lint:fix:fast",
|
|
62
97
|
"lint:fix:fast": "prettier --cache --log-level warn --write .",
|
|
63
|
-
prepare: "husky",
|
|
98
|
+
prepare: "husky && custompatch",
|
|
64
99
|
test: "run-s check build:* test:*",
|
|
65
100
|
"test:c8": "c8 --reporter=none node --test 'test/socket-npm.test.cjs'",
|
|
66
101
|
"test-ci": "run-s build:* test:*",
|
|
67
|
-
"test:unit": "tap",
|
|
68
|
-
"test:coverage": "cp -r .tap/coverage/*.json coverage/tmp && c8 --reporter=lcov --reporter=text --include 'dist/*.js' --exclude 'dist/vendor.js' report"
|
|
102
|
+
"test:unit": "tap-run",
|
|
103
|
+
"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"
|
|
69
104
|
};
|
|
70
105
|
var dependencies = {
|
|
71
106
|
"@apideck/better-ajv-errors": "^0.3.6",
|
|
72
|
-
"@cyclonedx/cdxgen": "^11.0.
|
|
107
|
+
"@cyclonedx/cdxgen": "^11.0.5",
|
|
73
108
|
"@inquirer/prompts": "^7.1.0",
|
|
74
109
|
"@npmcli/promise-spawn": "^8.0.2",
|
|
75
110
|
"@socketregistry/hyrious__bun.lockb": "1.0.5",
|
|
76
111
|
"@socketregistry/yocto-spinner": "^1.0.1",
|
|
77
112
|
"@socketsecurity/config": "^2.1.3",
|
|
78
|
-
"@socketsecurity/registry": "^1.0.
|
|
113
|
+
"@socketsecurity/registry": "^1.0.33",
|
|
79
114
|
"@socketsecurity/sdk": "^1.3.0",
|
|
80
115
|
blessed: "^0.1.81",
|
|
81
116
|
"blessed-contrib": "^4.11.0",
|
|
@@ -100,18 +135,19 @@ var devDependencies = {
|
|
|
100
135
|
"@babel/plugin-proposal-export-default-from": "^7.25.9",
|
|
101
136
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
102
137
|
"@babel/plugin-transform-export-namespace-from": "^7.25.9",
|
|
103
|
-
"@babel/plugin-transform-modules-commonjs": "^7.
|
|
138
|
+
"@babel/plugin-transform-modules-commonjs": "^7.26.3",
|
|
104
139
|
"@babel/plugin-transform-runtime": "^7.25.9",
|
|
105
140
|
"@babel/preset-env": "^7.26.0",
|
|
106
141
|
"@babel/preset-typescript": "^7.26.0",
|
|
107
142
|
"@babel/runtime": "^7.26.0",
|
|
108
|
-
"@eslint/compat": "^1.2.
|
|
143
|
+
"@eslint/compat": "^1.2.4",
|
|
109
144
|
"@eslint/js": "^9.16.0",
|
|
110
145
|
"@rollup/plugin-commonjs": "^28.0.1",
|
|
111
146
|
"@rollup/plugin-json": "^6.1.0",
|
|
112
147
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
113
148
|
"@rollup/plugin-replace": "^6.0.1",
|
|
114
149
|
"@rollup/pluginutils": "^5.1.3",
|
|
150
|
+
"@tapjs/run": "^4.0.1",
|
|
115
151
|
"@types/blessed": "^0.1.25",
|
|
116
152
|
"@types/micromatch": "^4.0.9",
|
|
117
153
|
"@types/mocha": "^10.0.10",
|
|
@@ -127,29 +163,29 @@ var devDependencies = {
|
|
|
127
163
|
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
|
128
164
|
"@typescript-eslint/parser": "^8.17.0",
|
|
129
165
|
c8: "^10.1.2",
|
|
166
|
+
custompatch: "^1.0.28",
|
|
130
167
|
eslint: "^9.16.0",
|
|
131
|
-
"eslint-import-resolver-oxc": "^0.
|
|
168
|
+
"eslint-import-resolver-oxc": "^0.6.0",
|
|
132
169
|
"eslint-plugin-depend": "^0.12.0",
|
|
133
|
-
"eslint-plugin-import-x": "^4.
|
|
170
|
+
"eslint-plugin-import-x": "^4.5.0",
|
|
134
171
|
"eslint-plugin-n": "^17.14.0",
|
|
135
172
|
"eslint-plugin-sort-destructure-keys": "^2.0.0",
|
|
136
173
|
"eslint-plugin-unicorn": "^56.0.1",
|
|
137
174
|
husky: "^9.1.7",
|
|
138
175
|
"is-interactive": "^2.0.0",
|
|
139
176
|
"is-unicode-supported": "^2.1.0",
|
|
140
|
-
knip: "^5.39.
|
|
177
|
+
knip: "^5.39.2",
|
|
141
178
|
"magic-string": "^0.30.14",
|
|
142
179
|
meow: "^13.2.0",
|
|
143
180
|
"mock-fs": "^5.4.1",
|
|
144
181
|
nock: "^13.5.6",
|
|
145
182
|
"npm-run-all2": "^7.0.1",
|
|
146
183
|
open: "^10.1.0",
|
|
147
|
-
oxlint: "0.14.
|
|
148
|
-
prettier: "3.4.
|
|
184
|
+
oxlint: "0.14.1",
|
|
185
|
+
prettier: "3.4.2",
|
|
149
186
|
"read-package-up": "^11.0.0",
|
|
150
|
-
rollup: "4.28.
|
|
187
|
+
rollup: "4.28.1",
|
|
151
188
|
"rollup-plugin-ts": "^3.4.5",
|
|
152
|
-
tap: "^21.0.1",
|
|
153
189
|
"terminal-link": "^3.0.0",
|
|
154
190
|
"tiny-updater": "^3.5.2",
|
|
155
191
|
"type-coverage": "^2.29.7",
|
|
@@ -220,6 +256,7 @@ var require$$6 = {
|
|
|
220
256
|
repository: repository,
|
|
221
257
|
author: author,
|
|
222
258
|
bin: bin,
|
|
259
|
+
exports: exports$1,
|
|
223
260
|
scripts: scripts,
|
|
224
261
|
dependencies: dependencies,
|
|
225
262
|
devDependencies: devDependencies,
|
|
@@ -233,10 +270,10 @@ Object.defineProperty(ttyServer$1, "__esModule", {
|
|
|
233
270
|
value: true
|
|
234
271
|
});
|
|
235
272
|
ttyServer$1.createTTYServer = createTTYServer;
|
|
236
|
-
var _nodeFs$
|
|
273
|
+
var _nodeFs$1 = require$$0;
|
|
237
274
|
var _nodeNet = require$$1$2;
|
|
238
275
|
var _nodeOs = require$$1;
|
|
239
|
-
var _nodePath$
|
|
276
|
+
var _nodePath$1 = require$$1$1;
|
|
240
277
|
var _nodeReadline$1 = require$$3;
|
|
241
278
|
var _nodeStream$1 = require$$5;
|
|
242
279
|
var _package = require$$6;
|
|
@@ -244,7 +281,7 @@ var _misc$1 = sdk.misc;
|
|
|
244
281
|
const NEWLINE_CHAR_CODE = 10; /*'\n'*/
|
|
245
282
|
|
|
246
283
|
const TTY_IPC = process.env['SOCKET_SECURITY_TTY_IPC'];
|
|
247
|
-
const sock = _nodePath$
|
|
284
|
+
const sock = _nodePath$1.join(_nodeOs.tmpdir(), `socket-security-tty-${process.pid}.sock`);
|
|
248
285
|
process.env['SOCKET_SECURITY_TTY_IPC'] = sock;
|
|
249
286
|
function createNonStandardTTYServer() {
|
|
250
287
|
return {
|
|
@@ -417,7 +454,7 @@ function createStandardTTYServer(isInteractive, npmlog) {
|
|
|
417
454
|
}
|
|
418
455
|
function tryUnlinkSync(filepath) {
|
|
419
456
|
try {
|
|
420
|
-
(0, _nodeFs$
|
|
457
|
+
(0, _nodeFs$1.unlinkSync)(filepath);
|
|
421
458
|
} catch (e) {
|
|
422
459
|
if ((0, _misc$1.isErrnoException)(e) && e.code !== 'ENOENT') {
|
|
423
460
|
throw e;
|
|
@@ -583,31 +620,29 @@ Object.defineProperty(arborist, "__esModule", {
|
|
|
583
620
|
arborist.SafeArborist = void 0;
|
|
584
621
|
arborist.installSafeArborist = installSafeArborist;
|
|
585
622
|
var _nodeEvents = require$$1$3;
|
|
586
|
-
var _nodeFs
|
|
587
|
-
var _nodeHttps = require$$3$
|
|
588
|
-
var _nodePath
|
|
623
|
+
var _nodeFs = require$$0;
|
|
624
|
+
var _nodeHttps = require$$3$2;
|
|
625
|
+
var _nodePath = require$$1$1;
|
|
589
626
|
var _nodeReadline = require$$3;
|
|
590
627
|
var _nodeStream = require$$5;
|
|
591
628
|
var _promises = require$$7$1;
|
|
592
629
|
var _isInteractive = _interopRequireDefault(vendor.isInteractive);
|
|
593
630
|
var _npmPackageArg = require$$5$1;
|
|
594
|
-
var _yoctoSpinner = require$$3$
|
|
595
|
-
var _semver = require$$
|
|
631
|
+
var _yoctoSpinner = require$$3$1;
|
|
632
|
+
var _semver = require$$4;
|
|
596
633
|
var _config = require$$6$1;
|
|
597
634
|
var _objects = require$$7;
|
|
598
635
|
var _ttyServer = ttyServer$1;
|
|
599
|
-
var _constants =
|
|
636
|
+
var _constants$1 = constants.constants;
|
|
600
637
|
var _colorOrMarkdown = sdk.colorOrMarkdown;
|
|
601
638
|
var _issueRules = issueRules;
|
|
602
639
|
var _misc = sdk.misc;
|
|
603
640
|
var _pathResolve = pathResolve.pathResolve;
|
|
604
641
|
var _sdk = sdk.sdk;
|
|
605
642
|
var _settings = sdk.settings;
|
|
606
|
-
const
|
|
607
|
-
const
|
|
608
|
-
const
|
|
609
|
-
const npmEntrypoint = (0, _nodeFs$1.realpathSync)(process.argv[1]);
|
|
610
|
-
const npmRootPath = (0, _pathResolve.findRoot)(_nodePath$1.dirname(npmEntrypoint));
|
|
643
|
+
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 npmEntrypoint = (0, _nodeFs.realpathSync)(process.argv[1]);
|
|
645
|
+
const npmRootPath = (0, _pathResolve.findRoot)(_nodePath.dirname(npmEntrypoint));
|
|
611
646
|
function tryRequire(...ids) {
|
|
612
647
|
for (const data of ids) {
|
|
613
648
|
let id;
|
|
@@ -631,32 +666,29 @@ function tryRequire(...ids) {
|
|
|
631
666
|
return undefined;
|
|
632
667
|
}
|
|
633
668
|
if (npmRootPath === undefined) {
|
|
634
|
-
console.error(`Unable to find npm
|
|
635
|
-
console.error(`Searched parent directories of ${npmEntrypoint}`);
|
|
669
|
+
console.error(`Unable to find npm CLI install directory.\nSearched parent directories of ${npmEntrypoint}.\n\n${POTENTIAL_BUG_ERROR_MESSAGE}`);
|
|
636
670
|
process.exit(127);
|
|
637
671
|
}
|
|
638
|
-
const
|
|
639
|
-
const
|
|
640
|
-
const
|
|
641
|
-
const
|
|
642
|
-
const
|
|
643
|
-
const
|
|
644
|
-
const
|
|
645
|
-
const
|
|
646
|
-
const arboristOverrideSetClassPatch = _nodePath$1.join(arboristPkgPath, 'lib/override-set.js');
|
|
647
|
-
const log = tryRequire([_nodePath$1.join(npmNmPath, 'proc-log/lib/index.js'),
|
|
672
|
+
const npmNmPath = _nodePath.join(npmRootPath, 'node_modules');
|
|
673
|
+
const arboristPkgPath = _nodePath.join(npmNmPath, '@npmcli/arborist');
|
|
674
|
+
const arboristClassPath = _nodePath.join(arboristPkgPath, 'lib/arborist/index.js');
|
|
675
|
+
const arboristDepValidPath = _nodePath.join(arboristPkgPath, 'lib/dep-valid.js');
|
|
676
|
+
const arboristEdgeClassPath = _nodePath.join(arboristPkgPath, 'lib/edge.js');
|
|
677
|
+
const arboristNodeClassPath = _nodePath.join(arboristPkgPath, 'lib/node.js');
|
|
678
|
+
const arboristOverrideSetClassPatch = _nodePath.join(arboristPkgPath, 'lib/override-set.js');
|
|
679
|
+
const log = tryRequire([_nodePath.join(npmNmPath, 'proc-log/lib/index.js'),
|
|
648
680
|
// The proc-log DefinitelyTyped definition is incorrect. The type definition
|
|
649
681
|
// is really that of its export log.
|
|
650
|
-
mod => mod.log], _nodePath
|
|
682
|
+
mod => mod.log], _nodePath.join(npmNmPath, 'npmlog/lib/log.js'));
|
|
651
683
|
if (log === undefined) {
|
|
652
|
-
console.error(`Unable to integrate with npm
|
|
684
|
+
console.error(`Unable to integrate with npm CLI logging infrastructure.\n\n${POTENTIAL_BUG_ERROR_MESSAGE}.`);
|
|
653
685
|
process.exit(127);
|
|
654
686
|
}
|
|
655
|
-
const pacote = tryRequire(_nodePath
|
|
687
|
+
const pacote = tryRequire(_nodePath.join(npmNmPath, 'pacote'), 'pacote');
|
|
656
688
|
const {
|
|
657
689
|
tarball
|
|
658
690
|
} = pacote;
|
|
659
|
-
const translations = require(_nodePath
|
|
691
|
+
const translations = require(_nodePath.join(_constants$1.rootPath, 'translations.json'));
|
|
660
692
|
const abortController = new AbortController();
|
|
661
693
|
const {
|
|
662
694
|
signal: abortSignal
|
|
@@ -685,11 +717,11 @@ async function uxLookup(settings) {
|
|
|
685
717
|
}
|
|
686
718
|
async function* batchScan(pkgIds) {
|
|
687
719
|
const query = {
|
|
688
|
-
packages: pkgIds.map(
|
|
720
|
+
packages: pkgIds.map(id => {
|
|
689
721
|
const {
|
|
690
722
|
name,
|
|
691
723
|
version
|
|
692
|
-
} = pkgidParts(
|
|
724
|
+
} = pkgidParts(id);
|
|
693
725
|
return {
|
|
694
726
|
eco: 'npm',
|
|
695
727
|
pkg: name,
|
|
@@ -699,7 +731,7 @@ async function* batchScan(pkgIds) {
|
|
|
699
731
|
})
|
|
700
732
|
};
|
|
701
733
|
// TODO: Migrate to SDK.
|
|
702
|
-
const pkgDataReq = _nodeHttps.request(`${_constants.API_V0_URL}/scan/batch`, {
|
|
734
|
+
const pkgDataReq = _nodeHttps.request(`${_constants$1.API_V0_URL}/scan/batch`, {
|
|
703
735
|
method: 'POST',
|
|
704
736
|
headers: {
|
|
705
737
|
Authorization: `Basic ${Buffer.from(`${pubToken}:`).toString('base64url')}`
|
|
@@ -731,10 +763,10 @@ function findSocketYmlSync() {
|
|
|
731
763
|
let prevDir = null;
|
|
732
764
|
let dir = process.cwd();
|
|
733
765
|
while (dir !== prevDir) {
|
|
734
|
-
let ymlPath = _nodePath
|
|
766
|
+
let ymlPath = _nodePath.join(dir, 'socket.yml');
|
|
735
767
|
let yml = maybeReadfileSync(ymlPath);
|
|
736
768
|
if (yml === undefined) {
|
|
737
|
-
ymlPath = _nodePath
|
|
769
|
+
ymlPath = _nodePath.join(dir, 'socket.yaml');
|
|
738
770
|
yml = maybeReadfileSync(ymlPath);
|
|
739
771
|
}
|
|
740
772
|
if (typeof yml === 'string') {
|
|
@@ -748,7 +780,7 @@ function findSocketYmlSync() {
|
|
|
748
780
|
}
|
|
749
781
|
}
|
|
750
782
|
prevDir = dir;
|
|
751
|
-
dir = _nodePath
|
|
783
|
+
dir = _nodePath.join(dir, '..');
|
|
752
784
|
}
|
|
753
785
|
return null;
|
|
754
786
|
}
|
|
@@ -776,36 +808,46 @@ function findSpecificOverrideSet(first, second) {
|
|
|
776
808
|
}
|
|
777
809
|
function maybeReadfileSync(filepath) {
|
|
778
810
|
try {
|
|
779
|
-
return (0, _nodeFs
|
|
811
|
+
return (0, _nodeFs.readFileSync)(filepath, 'utf8');
|
|
780
812
|
} catch {}
|
|
781
813
|
return undefined;
|
|
782
814
|
}
|
|
783
815
|
async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
|
|
816
|
+
const spinner = _yoctoSpinner({
|
|
817
|
+
stream: output
|
|
818
|
+
});
|
|
784
819
|
let result = false;
|
|
785
|
-
let
|
|
820
|
+
let {
|
|
821
|
+
length: remaining
|
|
822
|
+
} = pkgs;
|
|
786
823
|
if (!remaining) {
|
|
787
|
-
|
|
824
|
+
spinner.success('No changes detected');
|
|
788
825
|
return result;
|
|
789
826
|
}
|
|
790
827
|
const getText = () => `Looking up data for ${remaining} packages`;
|
|
791
|
-
|
|
792
|
-
stream: output
|
|
793
|
-
}).start(getText());
|
|
828
|
+
spinner.start(getText());
|
|
794
829
|
try {
|
|
795
|
-
for await (const pkgData of batchScan(pkgs.map(
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
830
|
+
for await (const pkgData of batchScan(pkgs.map(p => p.pkgid))) {
|
|
831
|
+
const {
|
|
832
|
+
pkg: name,
|
|
833
|
+
ver: version
|
|
834
|
+
} = pkgData;
|
|
800
835
|
const id = `${name}@${version}`;
|
|
836
|
+
let displayWarning = false;
|
|
837
|
+
let failures = [];
|
|
801
838
|
if (pkgData.type === 'missing') {
|
|
802
839
|
result = true;
|
|
803
840
|
failures.push({
|
|
804
|
-
type: 'missingDependency'
|
|
841
|
+
type: 'missingDependency',
|
|
842
|
+
block: false,
|
|
843
|
+
raw: undefined
|
|
805
844
|
});
|
|
806
845
|
} else {
|
|
807
846
|
let blocked = false;
|
|
808
847
|
for (const failure of pkgData.value.issues) {
|
|
848
|
+
const {
|
|
849
|
+
type
|
|
850
|
+
} = failure;
|
|
809
851
|
// eslint-disable-next-line no-await-in-loop
|
|
810
852
|
const ux = await uxLookup({
|
|
811
853
|
package: {
|
|
@@ -813,36 +855,37 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
|
|
|
813
855
|
version
|
|
814
856
|
},
|
|
815
857
|
issue: {
|
|
816
|
-
type
|
|
858
|
+
type
|
|
817
859
|
}
|
|
818
860
|
});
|
|
819
|
-
if (ux.
|
|
861
|
+
if (ux.block) {
|
|
862
|
+
result = true;
|
|
863
|
+
blocked = true;
|
|
864
|
+
}
|
|
865
|
+
if (ux.display) {
|
|
866
|
+
displayWarning = true;
|
|
867
|
+
}
|
|
868
|
+
if (ux.block || ux.display) {
|
|
820
869
|
failures.push({
|
|
821
|
-
|
|
822
|
-
block: ux.block
|
|
870
|
+
type,
|
|
871
|
+
block: ux.block,
|
|
872
|
+
raw: failure
|
|
823
873
|
});
|
|
824
874
|
// Before we ask about problematic issues, check to see if they
|
|
825
875
|
// already existed in the old version if they did, be quiet.
|
|
826
|
-
const pkg = pkgs.find(
|
|
876
|
+
const pkg = pkgs.find(p => p.pkgid === id && p.existing?.startsWith(`${name}@`));
|
|
827
877
|
if (pkg?.existing) {
|
|
878
|
+
const oldPkgData =
|
|
828
879
|
// eslint-disable-next-line no-await-in-loop
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
}
|
|
880
|
+
(await batchScan([pkg.existing]).next()).value;
|
|
881
|
+
if (oldPkgData.type === 'success') {
|
|
882
|
+
failures = failures.filter(issue => oldPkgData.value.issues.find(oldIssue => oldIssue.type === issue.type) === undefined);
|
|
833
883
|
}
|
|
834
884
|
}
|
|
835
885
|
}
|
|
836
|
-
if (ux.block) {
|
|
837
|
-
result = true;
|
|
838
|
-
blocked = true;
|
|
839
|
-
}
|
|
840
|
-
if (ux.display) {
|
|
841
|
-
displayWarning = true;
|
|
842
|
-
}
|
|
843
886
|
}
|
|
844
887
|
if (!blocked) {
|
|
845
|
-
const pkg = pkgs.find(
|
|
888
|
+
const pkg = pkgs.find(p => p.pkgid === id);
|
|
846
889
|
if (pkg) {
|
|
847
890
|
await tarball.stream(id, stream => {
|
|
848
891
|
stream.resume();
|
|
@@ -854,17 +897,27 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
|
|
|
854
897
|
}
|
|
855
898
|
}
|
|
856
899
|
if (displayWarning) {
|
|
857
|
-
spinner.stop();
|
|
858
|
-
|
|
859
|
-
|
|
900
|
+
spinner.stop(`(socket) ${formatter.hyperlink(id, `https://socket.dev/npm/package/${name}/overview/${version}`)} contains risks:`);
|
|
901
|
+
// Filter issues for blessed packages.
|
|
902
|
+
if (name === 'socket' || name.startsWith('@socketregistry/') || name.startsWith('@socketsecurity/')) {
|
|
903
|
+
failures = failures.filter(({
|
|
904
|
+
type
|
|
905
|
+
}) => type !== 'unpopularPackage' && type !== 'unstableOwnership');
|
|
906
|
+
}
|
|
907
|
+
failures.sort((a, b) => a.type < b.type ? -1 : 1);
|
|
860
908
|
const lines = new Set();
|
|
861
909
|
for (const failure of failures) {
|
|
862
|
-
const
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
910
|
+
const {
|
|
911
|
+
type
|
|
912
|
+
} = failure;
|
|
913
|
+
// Based data from { pageProps: { alertTypes } } of:
|
|
914
|
+
// https://socket.dev/_next/data/94666139314b6437ee4491a0864e72b264547585/en-US.json
|
|
915
|
+
const info = translations.issues[type];
|
|
916
|
+
const title = info?.title ?? type;
|
|
917
|
+
const maybeBlocking = failure.block ? '' : ' (non-blocking)';
|
|
918
|
+
const maybeDesc = info?.description ? ` - ${info.description}` : '';
|
|
919
|
+
// TODO: emoji seems to mis-align terminals sometimes
|
|
920
|
+
lines.add(` ${title}${maybeBlocking}${maybeDesc}\n`);
|
|
868
921
|
}
|
|
869
922
|
for (const line of lines) {
|
|
870
923
|
output?.write(line);
|
|
@@ -876,9 +929,7 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
|
|
|
876
929
|
}
|
|
877
930
|
return result;
|
|
878
931
|
} finally {
|
|
879
|
-
|
|
880
|
-
spinner.stop();
|
|
881
|
-
}
|
|
932
|
+
spinner.stop();
|
|
882
933
|
}
|
|
883
934
|
}
|
|
884
935
|
function pkgidParts(pkgid) {
|
|
@@ -890,18 +941,8 @@ function pkgidParts(pkgid) {
|
|
|
890
941
|
version
|
|
891
942
|
};
|
|
892
943
|
}
|
|
893
|
-
function
|
|
894
|
-
|
|
895
|
-
const {
|
|
896
|
-
name,
|
|
897
|
-
version
|
|
898
|
-
} = pkgidParts(pkgid);
|
|
899
|
-
return {
|
|
900
|
-
type: 'npm',
|
|
901
|
-
namespace_and_name: name,
|
|
902
|
-
version,
|
|
903
|
-
repository_url: repo
|
|
904
|
-
};
|
|
944
|
+
function toRepoUrl(resolved) {
|
|
945
|
+
return resolved.replace(/#[\s\S]*$/, '').replace(/\?[\s\S]*$/, '').replace(/\/[^/]*\/-\/[\s\S]*$/, '');
|
|
905
946
|
}
|
|
906
947
|
function walk(diff_, needInfoOn = []) {
|
|
907
948
|
const queue = [diff_];
|
|
@@ -910,7 +951,7 @@ function walk(diff_, needInfoOn = []) {
|
|
|
910
951
|
length: queueLength
|
|
911
952
|
} = queue;
|
|
912
953
|
while (pos < queueLength) {
|
|
913
|
-
if (pos === LOOP_SENTINEL) {
|
|
954
|
+
if (pos === _constants$1.LOOP_SENTINEL) {
|
|
914
955
|
throw new Error('Detected infinite loop while walking Arborist diff');
|
|
915
956
|
}
|
|
916
957
|
const diff = queue[pos++];
|
|
@@ -932,12 +973,8 @@ function walk(diff_, needInfoOn = []) {
|
|
|
932
973
|
if (keep && diff.ideal?.pkgid && diff.ideal.resolved && (!diff.actual || diff.actual.resolved)) {
|
|
933
974
|
needInfoOn.push({
|
|
934
975
|
existing,
|
|
935
|
-
action: diff.action,
|
|
936
|
-
location: diff.ideal.location,
|
|
937
976
|
pkgid: diff.ideal.pkgid,
|
|
938
|
-
|
|
939
|
-
oldPackage: diff.actual && diff.actual.resolved ? toPURL(diff.actual.pkgid, diff.actual.resolved) : null,
|
|
940
|
-
resolved: diff.ideal.resolved
|
|
977
|
+
repository_url: toRepoUrl(diff.ideal.resolved)
|
|
941
978
|
});
|
|
942
979
|
}
|
|
943
980
|
}
|
|
@@ -1486,7 +1523,7 @@ class SafeOverrideSet extends OverrideSet {
|
|
|
1486
1523
|
length: queueLength
|
|
1487
1524
|
} = queue;
|
|
1488
1525
|
while (pos < queueLength) {
|
|
1489
|
-
if (pos === LOOP_SENTINEL) {
|
|
1526
|
+
if (pos === _constants$1.LOOP_SENTINEL) {
|
|
1490
1527
|
throw new Error('Detected infinite loop while comparing override sets');
|
|
1491
1528
|
}
|
|
1492
1529
|
const {
|
|
@@ -1628,10 +1665,10 @@ class SafeArborist extends Arborist {
|
|
|
1628
1665
|
options['save'] = old.save;
|
|
1629
1666
|
options['saveBundle'] = old.saveBundle;
|
|
1630
1667
|
// Nothing to check, mmm already installed or all private?
|
|
1631
|
-
if (diff.findIndex(c => c.
|
|
1668
|
+
if (diff.findIndex(c => c.repository_url === _constants$1.NPM_REGISTRY_URL) === -1) {
|
|
1632
1669
|
return await this[kRiskyReify](...args);
|
|
1633
1670
|
}
|
|
1634
|
-
let proceed = _constants.ENV.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE;
|
|
1671
|
+
let proceed = _constants$1.ENV[_constants$1.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE];
|
|
1635
1672
|
if (!proceed) {
|
|
1636
1673
|
proceed = await ttyServer.captureTTY(async (input, output) => {
|
|
1637
1674
|
if (input && output) {
|
|
@@ -1768,16 +1805,11 @@ void (async () => {
|
|
|
1768
1805
|
_uxLookup = (0, _issueRules.createIssueUXLookup)(settings);
|
|
1769
1806
|
})();
|
|
1770
1807
|
|
|
1771
|
-
var
|
|
1772
|
-
var _nodePath = require$$1$1;
|
|
1808
|
+
var _constants = constants.constants;
|
|
1773
1809
|
var _arborist = arborist;
|
|
1774
1810
|
var _link = link.link;
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
const binPath = _nodePath.join(rootPath, 'bin');
|
|
1778
|
-
|
|
1779
|
-
// shadow `npm` and `npx` to mitigate subshells
|
|
1780
|
-
(0, _link.installLinks)((0, _nodeFs.realpathSync)(binPath), 'npm');
|
|
1811
|
+
// Shadow `npm` and `npx` to mitigate subshells.
|
|
1812
|
+
(0, _link.installLinks)(_constants.shadowBinPath, 'npm');
|
|
1781
1813
|
(0, _arborist.installSafeArborist)();
|
|
1782
1814
|
|
|
1783
1815
|
(function (exports) {
|
|
@@ -1793,7 +1825,7 @@ const binPath = _nodePath.join(rootPath, 'bin');
|
|
|
1793
1825
|
return _npmInjection.default;
|
|
1794
1826
|
}
|
|
1795
1827
|
});
|
|
1796
|
-
var _npmInjection = _interopRequireWildcard(npmInjection, true);
|
|
1828
|
+
var _npmInjection = _interopRequireWildcard(npmInjection$1, true);
|
|
1797
1829
|
Object.keys(_npmInjection).forEach(function (key) {
|
|
1798
1830
|
if (key === "default" || key === "__esModule") return;
|
|
1799
1831
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -1805,6 +1837,8 @@ const binPath = _nodePath.join(rootPath, 'bin');
|
|
|
1805
1837
|
}
|
|
1806
1838
|
});
|
|
1807
1839
|
});
|
|
1808
|
-
} (npmInjection$
|
|
1840
|
+
} (npmInjection$2));
|
|
1841
|
+
|
|
1842
|
+
var npmInjection = /*@__PURE__*/vendor.getDefaultExportFromCjs(npmInjection$2);
|
|
1809
1843
|
|
|
1810
|
-
module.exports = npmInjection
|
|
1844
|
+
module.exports = npmInjection;
|