@socketsecurity/cli 0.14.28 → 0.14.29
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 +9 -0
- package/bin/npm-cli.js +9 -0
- package/bin/npx-cli.js +9 -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 +5256 -0
- package/dist/module-sync/constants.d.ts +15 -0
- package/dist/module-sync/constants.js +62 -0
- package/dist/module-sync/npm-cli.js +85 -0
- package/dist/module-sync/npm-injection.js +1595 -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} +70 -74
- package/dist/require/color-or-markdown.d.ts +23 -0
- package/dist/require/constants.d.ts +15 -0
- package/dist/require/constants.js +57 -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} +124 -104
- 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 +53 -18
- 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
|
@@ -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.29";
|
|
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,20 +620,20 @@ 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;
|
|
@@ -604,10 +641,8 @@ var _pathResolve = pathResolve.pathResolve;
|
|
|
604
641
|
var _sdk = sdk.sdk;
|
|
605
642
|
var _settings = sdk.settings;
|
|
606
643
|
const POTENTIALLY_BUG_ERROR_SNIPPET = 'this is potentially a bug with socket-npm caused by changes to the npm cli';
|
|
607
|
-
const
|
|
608
|
-
const
|
|
609
|
-
const npmEntrypoint = (0, _nodeFs$1.realpathSync)(process.argv[1]);
|
|
610
|
-
const npmRootPath = (0, _pathResolve.findRoot)(_nodePath$1.dirname(npmEntrypoint));
|
|
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;
|
|
@@ -637,26 +672,26 @@ if (npmRootPath === undefined) {
|
|
|
637
672
|
}
|
|
638
673
|
const LOOP_SENTINEL = 1_000_000;
|
|
639
674
|
const NPM_REGISTRY_URL = 'https://registry.npmjs.org';
|
|
640
|
-
const npmNmPath = _nodePath
|
|
641
|
-
const arboristPkgPath = _nodePath
|
|
642
|
-
const arboristClassPath = _nodePath
|
|
643
|
-
const arboristDepValidPath = _nodePath
|
|
644
|
-
const arboristEdgeClassPath = _nodePath
|
|
645
|
-
const arboristNodeClassPath = _nodePath
|
|
646
|
-
const arboristOverrideSetClassPatch = _nodePath
|
|
647
|
-
const log = tryRequire([_nodePath
|
|
675
|
+
const npmNmPath = _nodePath.join(npmRootPath, 'node_modules');
|
|
676
|
+
const arboristPkgPath = _nodePath.join(npmNmPath, '@npmcli/arborist');
|
|
677
|
+
const arboristClassPath = _nodePath.join(arboristPkgPath, 'lib/arborist/index.js');
|
|
678
|
+
const arboristDepValidPath = _nodePath.join(arboristPkgPath, 'lib/dep-valid.js');
|
|
679
|
+
const arboristEdgeClassPath = _nodePath.join(arboristPkgPath, 'lib/edge.js');
|
|
680
|
+
const arboristNodeClassPath = _nodePath.join(arboristPkgPath, 'lib/node.js');
|
|
681
|
+
const arboristOverrideSetClassPatch = _nodePath.join(arboristPkgPath, 'lib/override-set.js');
|
|
682
|
+
const log = tryRequire([_nodePath.join(npmNmPath, 'proc-log/lib/index.js'),
|
|
648
683
|
// The proc-log DefinitelyTyped definition is incorrect. The type definition
|
|
649
684
|
// is really that of its export log.
|
|
650
|
-
mod => mod.log], _nodePath
|
|
685
|
+
mod => mod.log], _nodePath.join(npmNmPath, 'npmlog/lib/log.js'));
|
|
651
686
|
if (log === undefined) {
|
|
652
687
|
console.error(`Unable to integrate with npm cli logging infrastructure, ${POTENTIALLY_BUG_ERROR_SNIPPET}.`);
|
|
653
688
|
process.exit(127);
|
|
654
689
|
}
|
|
655
|
-
const pacote = tryRequire(_nodePath
|
|
690
|
+
const pacote = tryRequire(_nodePath.join(npmNmPath, 'pacote'), 'pacote');
|
|
656
691
|
const {
|
|
657
692
|
tarball
|
|
658
693
|
} = pacote;
|
|
659
|
-
const translations = require(_nodePath
|
|
694
|
+
const translations = require(_nodePath.join(_constants$1.rootPath, 'translations.json'));
|
|
660
695
|
const abortController = new AbortController();
|
|
661
696
|
const {
|
|
662
697
|
signal: abortSignal
|
|
@@ -685,11 +720,11 @@ async function uxLookup(settings) {
|
|
|
685
720
|
}
|
|
686
721
|
async function* batchScan(pkgIds) {
|
|
687
722
|
const query = {
|
|
688
|
-
packages: pkgIds.map(
|
|
723
|
+
packages: pkgIds.map(id => {
|
|
689
724
|
const {
|
|
690
725
|
name,
|
|
691
726
|
version
|
|
692
|
-
} = pkgidParts(
|
|
727
|
+
} = pkgidParts(id);
|
|
693
728
|
return {
|
|
694
729
|
eco: 'npm',
|
|
695
730
|
pkg: name,
|
|
@@ -699,7 +734,7 @@ async function* batchScan(pkgIds) {
|
|
|
699
734
|
})
|
|
700
735
|
};
|
|
701
736
|
// TODO: Migrate to SDK.
|
|
702
|
-
const pkgDataReq = _nodeHttps.request(`${_constants.API_V0_URL}/scan/batch`, {
|
|
737
|
+
const pkgDataReq = _nodeHttps.request(`${_constants$1.API_V0_URL}/scan/batch`, {
|
|
703
738
|
method: 'POST',
|
|
704
739
|
headers: {
|
|
705
740
|
Authorization: `Basic ${Buffer.from(`${pubToken}:`).toString('base64url')}`
|
|
@@ -731,10 +766,10 @@ function findSocketYmlSync() {
|
|
|
731
766
|
let prevDir = null;
|
|
732
767
|
let dir = process.cwd();
|
|
733
768
|
while (dir !== prevDir) {
|
|
734
|
-
let ymlPath = _nodePath
|
|
769
|
+
let ymlPath = _nodePath.join(dir, 'socket.yml');
|
|
735
770
|
let yml = maybeReadfileSync(ymlPath);
|
|
736
771
|
if (yml === undefined) {
|
|
737
|
-
ymlPath = _nodePath
|
|
772
|
+
ymlPath = _nodePath.join(dir, 'socket.yaml');
|
|
738
773
|
yml = maybeReadfileSync(ymlPath);
|
|
739
774
|
}
|
|
740
775
|
if (typeof yml === 'string') {
|
|
@@ -748,7 +783,7 @@ function findSocketYmlSync() {
|
|
|
748
783
|
}
|
|
749
784
|
}
|
|
750
785
|
prevDir = dir;
|
|
751
|
-
dir = _nodePath
|
|
786
|
+
dir = _nodePath.join(dir, '..');
|
|
752
787
|
}
|
|
753
788
|
return null;
|
|
754
789
|
}
|
|
@@ -776,28 +811,33 @@ function findSpecificOverrideSet(first, second) {
|
|
|
776
811
|
}
|
|
777
812
|
function maybeReadfileSync(filepath) {
|
|
778
813
|
try {
|
|
779
|
-
return (0, _nodeFs
|
|
814
|
+
return (0, _nodeFs.readFileSync)(filepath, 'utf8');
|
|
780
815
|
} catch {}
|
|
781
816
|
return undefined;
|
|
782
817
|
}
|
|
783
818
|
async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
|
|
819
|
+
const spinner = _yoctoSpinner({
|
|
820
|
+
stream: output
|
|
821
|
+
});
|
|
784
822
|
let result = false;
|
|
785
|
-
let
|
|
823
|
+
let {
|
|
824
|
+
length: remaining
|
|
825
|
+
} = pkgs;
|
|
786
826
|
if (!remaining) {
|
|
787
|
-
|
|
827
|
+
spinner.success('No changes detected');
|
|
788
828
|
return result;
|
|
789
829
|
}
|
|
790
830
|
const getText = () => `Looking up data for ${remaining} packages`;
|
|
791
|
-
|
|
792
|
-
stream: output
|
|
793
|
-
}).start(getText());
|
|
831
|
+
spinner.start(getText());
|
|
794
832
|
try {
|
|
795
|
-
for await (const pkgData of batchScan(pkgs.map(
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
833
|
+
for await (const pkgData of batchScan(pkgs.map(p => p.pkgid))) {
|
|
834
|
+
const {
|
|
835
|
+
pkg: name,
|
|
836
|
+
ver: version
|
|
837
|
+
} = pkgData;
|
|
800
838
|
const id = `${name}@${version}`;
|
|
839
|
+
let displayWarning = false;
|
|
840
|
+
let failures = [];
|
|
801
841
|
if (pkgData.type === 'missing') {
|
|
802
842
|
result = true;
|
|
803
843
|
failures.push({
|
|
@@ -823,7 +863,7 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
|
|
|
823
863
|
});
|
|
824
864
|
// Before we ask about problematic issues, check to see if they
|
|
825
865
|
// already existed in the old version if they did, be quiet.
|
|
826
|
-
const pkg = pkgs.find(
|
|
866
|
+
const pkg = pkgs.find(p => p.pkgid === id && p.existing?.startsWith(`${name}@`));
|
|
827
867
|
if (pkg?.existing) {
|
|
828
868
|
// eslint-disable-next-line no-await-in-loop
|
|
829
869
|
for await (const oldPkgData of batchScan([pkg.existing])) {
|
|
@@ -842,7 +882,7 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
|
|
|
842
882
|
}
|
|
843
883
|
}
|
|
844
884
|
if (!blocked) {
|
|
845
|
-
const pkg = pkgs.find(
|
|
885
|
+
const pkg = pkgs.find(p => p.pkgid === id);
|
|
846
886
|
if (pkg) {
|
|
847
887
|
await tarball.stream(id, stream => {
|
|
848
888
|
stream.resume();
|
|
@@ -854,8 +894,7 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
|
|
|
854
894
|
}
|
|
855
895
|
}
|
|
856
896
|
if (displayWarning) {
|
|
857
|
-
spinner.stop();
|
|
858
|
-
output?.write(`(socket) ${formatter.hyperlink(id, `https://socket.dev/npm/package/${name}/overview/${version}`)} contains risks:\n`);
|
|
897
|
+
spinner.stop(`(socket) ${formatter.hyperlink(id, `https://socket.dev/npm/package/${name}/overview/${version}`)} contains risks:`);
|
|
859
898
|
failures.sort((a, b) => a.raw.type < b.raw.type ? -1 : 1);
|
|
860
899
|
const lines = new Set();
|
|
861
900
|
for (const failure of failures) {
|
|
@@ -876,9 +915,7 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
|
|
|
876
915
|
}
|
|
877
916
|
return result;
|
|
878
917
|
} finally {
|
|
879
|
-
|
|
880
|
-
spinner.stop();
|
|
881
|
-
}
|
|
918
|
+
spinner.stop();
|
|
882
919
|
}
|
|
883
920
|
}
|
|
884
921
|
function pkgidParts(pkgid) {
|
|
@@ -890,18 +927,8 @@ function pkgidParts(pkgid) {
|
|
|
890
927
|
version
|
|
891
928
|
};
|
|
892
929
|
}
|
|
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
|
-
};
|
|
930
|
+
function toRepoUrl(resolved) {
|
|
931
|
+
return resolved.replace(/#[\s\S]*$/, '').replace(/\?[\s\S]*$/, '').replace(/\/[^/]*\/-\/[\s\S]*$/, '');
|
|
905
932
|
}
|
|
906
933
|
function walk(diff_, needInfoOn = []) {
|
|
907
934
|
const queue = [diff_];
|
|
@@ -932,12 +959,8 @@ function walk(diff_, needInfoOn = []) {
|
|
|
932
959
|
if (keep && diff.ideal?.pkgid && diff.ideal.resolved && (!diff.actual || diff.actual.resolved)) {
|
|
933
960
|
needInfoOn.push({
|
|
934
961
|
existing,
|
|
935
|
-
action: diff.action,
|
|
936
|
-
location: diff.ideal.location,
|
|
937
962
|
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
|
|
963
|
+
repository_url: toRepoUrl(diff.ideal.resolved)
|
|
941
964
|
});
|
|
942
965
|
}
|
|
943
966
|
}
|
|
@@ -1628,10 +1651,10 @@ class SafeArborist extends Arborist {
|
|
|
1628
1651
|
options['save'] = old.save;
|
|
1629
1652
|
options['saveBundle'] = old.saveBundle;
|
|
1630
1653
|
// Nothing to check, mmm already installed or all private?
|
|
1631
|
-
if (diff.findIndex(c => c.
|
|
1654
|
+
if (diff.findIndex(c => c.repository_url === NPM_REGISTRY_URL) === -1) {
|
|
1632
1655
|
return await this[kRiskyReify](...args);
|
|
1633
1656
|
}
|
|
1634
|
-
let proceed = _constants.ENV.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE;
|
|
1657
|
+
let proceed = _constants$1.ENV.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE;
|
|
1635
1658
|
if (!proceed) {
|
|
1636
1659
|
proceed = await ttyServer.captureTTY(async (input, output) => {
|
|
1637
1660
|
if (input && output) {
|
|
@@ -1768,16 +1791,11 @@ void (async () => {
|
|
|
1768
1791
|
_uxLookup = (0, _issueRules.createIssueUXLookup)(settings);
|
|
1769
1792
|
})();
|
|
1770
1793
|
|
|
1771
|
-
var
|
|
1772
|
-
var _nodePath = require$$1$1;
|
|
1794
|
+
var _constants = constants.constants;
|
|
1773
1795
|
var _arborist = arborist;
|
|
1774
1796
|
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');
|
|
1797
|
+
// Shadow `npm` and `npx` to mitigate subshells.
|
|
1798
|
+
(0, _link.installLinks)(_constants.shadowBinPath, 'npm');
|
|
1781
1799
|
(0, _arborist.installSafeArborist)();
|
|
1782
1800
|
|
|
1783
1801
|
(function (exports) {
|
|
@@ -1793,7 +1811,7 @@ const binPath = _nodePath.join(rootPath, 'bin');
|
|
|
1793
1811
|
return _npmInjection.default;
|
|
1794
1812
|
}
|
|
1795
1813
|
});
|
|
1796
|
-
var _npmInjection = _interopRequireWildcard(npmInjection, true);
|
|
1814
|
+
var _npmInjection = _interopRequireWildcard(npmInjection$1, true);
|
|
1797
1815
|
Object.keys(_npmInjection).forEach(function (key) {
|
|
1798
1816
|
if (key === "default" || key === "__esModule") return;
|
|
1799
1817
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -1805,6 +1823,8 @@ const binPath = _nodePath.join(rootPath, 'bin');
|
|
|
1805
1823
|
}
|
|
1806
1824
|
});
|
|
1807
1825
|
});
|
|
1808
|
-
} (npmInjection$
|
|
1826
|
+
} (npmInjection$2));
|
|
1827
|
+
|
|
1828
|
+
var npmInjection = /*@__PURE__*/vendor.getDefaultExportFromCjs(npmInjection$2);
|
|
1809
1829
|
|
|
1810
|
-
module.exports = npmInjection
|
|
1830
|
+
module.exports = npmInjection;
|
|
@@ -2,25 +2,23 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var vendor = require('./vendor.js');
|
|
5
|
-
var require$$0 = require('node:fs');
|
|
6
5
|
var require$$1 = require('node:path');
|
|
7
6
|
var require$$1$1 = require('@npmcli/promise-spawn');
|
|
7
|
+
var constants = require('./constants.js');
|
|
8
8
|
var link = require('./link.js');
|
|
9
9
|
|
|
10
|
-
var npxCli$
|
|
10
|
+
var npxCli$2 = {};
|
|
11
11
|
|
|
12
|
-
var npxCli = {};
|
|
12
|
+
var npxCli$1 = {};
|
|
13
13
|
|
|
14
|
-
var _nodeFs = require$$0;
|
|
15
14
|
var _nodePath = require$$1;
|
|
16
15
|
var _promiseSpawn = require$$1$1;
|
|
16
|
+
var _constants = constants.constants;
|
|
17
17
|
var _link = link.link;
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const npxPath = (0, _link.installLinks)(_nodePath.join(realDirname, 'bin'), 'npx');
|
|
21
|
-
const injectionPath = _nodePath.join(realDirname, 'npm-injection.js');
|
|
18
|
+
const npxPath = (0, _link.installLinks)(_constants.shadowBinPath, 'npx');
|
|
19
|
+
const injectionPath = _nodePath.join(_constants.distPath, 'npm-injection.js');
|
|
22
20
|
process.exitCode = 1;
|
|
23
|
-
const spawnPromise = _promiseSpawn(process.execPath, ['--require', injectionPath, npxPath, ...process.argv.slice(2)], {
|
|
21
|
+
const spawnPromise = _promiseSpawn(process.execPath, ['--disable-warning', 'ExperimentalWarning', '--require', injectionPath, npxPath, ...process.argv.slice(2)], {
|
|
24
22
|
stdio: 'inherit'
|
|
25
23
|
});
|
|
26
24
|
spawnPromise.process.on('exit', (code, signal) => {
|
|
@@ -44,7 +42,7 @@ spawnPromise.process.on('exit', (code, signal) => {
|
|
|
44
42
|
return _npxCli.default;
|
|
45
43
|
}
|
|
46
44
|
});
|
|
47
|
-
var _npxCli = _interopRequireWildcard(npxCli, true);
|
|
45
|
+
var _npxCli = _interopRequireWildcard(npxCli$1, true);
|
|
48
46
|
Object.keys(_npxCli).forEach(function (key) {
|
|
49
47
|
if (key === "default" || key === "__esModule") return;
|
|
50
48
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -56,6 +54,8 @@ spawnPromise.process.on('exit', (code, signal) => {
|
|
|
56
54
|
}
|
|
57
55
|
});
|
|
58
56
|
});
|
|
59
|
-
} (npxCli$
|
|
57
|
+
} (npxCli$2));
|
|
58
|
+
|
|
59
|
+
var npxCli = /*@__PURE__*/vendor.getDefaultExportFromCjs(npxCli$2);
|
|
60
60
|
|
|
61
|
-
module.exports = npxCli
|
|
61
|
+
module.exports = npxCli;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SocketYml } from '@socketsecurity/config';
|
|
3
|
+
import { SocketSdkReturnType } from '@socketsecurity/sdk';
|
|
4
|
+
declare function directoryPatterns(): string[];
|
|
5
|
+
declare function findRoot(filepath: string): string | undefined;
|
|
6
|
+
declare function getPackageFiles(cwd: string, inputPaths: string[], config: SocketYml | undefined, supportedFiles: SocketSdkReturnType<'getReportSupportedFiles'>['data'], debugLog?: typeof console.error): Promise<string[]>;
|
|
7
|
+
declare function getPackageFilesFullScans(cwd: string, inputPaths: string[], supportedFiles: SocketSdkReturnType<'getReportSupportedFiles'>['data'], debugLog?: typeof console.error): Promise<string[]>;
|
|
8
|
+
export { directoryPatterns, findRoot, getPackageFiles, getPackageFilesFullScans };
|