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