socket 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} +123 -103
- 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 +52 -17
- 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 = "socket";
|
|
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,9 +43,43 @@ var author = {
|
|
|
42
43
|
url: "https://socket.dev"
|
|
43
44
|
};
|
|
44
45
|
var bin = {
|
|
45
|
-
socket: "
|
|
46
|
-
"socket-npm": "
|
|
47
|
-
"socket-npx": "
|
|
46
|
+
socket: "./bin/cli.js",
|
|
47
|
+
"socket-npm": "./bin/npm-cli.js",
|
|
48
|
+
"socket-npx": "./bin/npx-cli.js"
|
|
49
|
+
};
|
|
50
|
+
var exports$1 = {
|
|
51
|
+
"./bin/cli.js": {
|
|
52
|
+
"module-sync": {
|
|
53
|
+
types: "./dist/module-sync/cli.d.ts",
|
|
54
|
+
"default": "./dist/module-sync/cli.js"
|
|
55
|
+
},
|
|
56
|
+
require: {
|
|
57
|
+
types: "./dist/require/cli.d.ts",
|
|
58
|
+
"default": "./dist/require/cli.js"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"./bin/npm-cli.js": {
|
|
62
|
+
"module-sync": {
|
|
63
|
+
types: "./dist/module-sync/npm-cli.d.ts",
|
|
64
|
+
"default": "./dist/module-sync/npm-cli.js"
|
|
65
|
+
},
|
|
66
|
+
require: {
|
|
67
|
+
types: "./dist/require/npm-cli.d.ts",
|
|
68
|
+
"default": "./dist/require/npm-cli.js"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"./bin/npx-cli.js": {
|
|
72
|
+
"module-sync": {
|
|
73
|
+
types: "./dist/module-sync/npx-cli.d.ts",
|
|
74
|
+
"default": "./dist/module-sync/npx-cli.js"
|
|
75
|
+
},
|
|
76
|
+
require: {
|
|
77
|
+
types: "./dist/require/npx-cli.d.ts",
|
|
78
|
+
"default": "./dist/require/npx-cli.js"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"./package.json": "./package.json",
|
|
82
|
+
"./translations.json": "./translations.json"
|
|
48
83
|
};
|
|
49
84
|
var scripts = {
|
|
50
85
|
build: "run-s build:*",
|
|
@@ -59,22 +94,22 @@ var scripts = {
|
|
|
59
94
|
lint: "oxlint -c=./.oxlintrc.json --ignore-path=./.prettierignore --tsconfig=./tsconfig.json .",
|
|
60
95
|
"lint:fix": "npm run lint -- --fix && npm run lint:fix:fast",
|
|
61
96
|
"lint:fix:fast": "prettier --cache --log-level warn --write .",
|
|
62
|
-
prepare: "husky",
|
|
97
|
+
prepare: "husky && custompatch",
|
|
63
98
|
test: "run-s check build:* test:*",
|
|
64
99
|
"test:c8": "c8 --reporter=none node --test 'test/socket-npm.test.cjs'",
|
|
65
100
|
"test-ci": "run-s build:* test:*",
|
|
66
|
-
"test:unit": "tap",
|
|
67
|
-
"test:coverage": "cp -r .tap/coverage/*.json coverage/tmp && c8 --reporter=lcov --reporter=text --include 'dist/*.js' --exclude 'dist/vendor.js' report"
|
|
101
|
+
"test:unit": "tap-run",
|
|
102
|
+
"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"
|
|
68
103
|
};
|
|
69
104
|
var dependencies = {
|
|
70
105
|
"@apideck/better-ajv-errors": "^0.3.6",
|
|
71
|
-
"@cyclonedx/cdxgen": "^11.0.
|
|
106
|
+
"@cyclonedx/cdxgen": "^11.0.5",
|
|
72
107
|
"@inquirer/prompts": "^7.1.0",
|
|
73
108
|
"@npmcli/promise-spawn": "^8.0.2",
|
|
74
109
|
"@socketregistry/hyrious__bun.lockb": "1.0.5",
|
|
75
110
|
"@socketregistry/yocto-spinner": "^1.0.1",
|
|
76
111
|
"@socketsecurity/config": "^2.1.3",
|
|
77
|
-
"@socketsecurity/registry": "^1.0.
|
|
112
|
+
"@socketsecurity/registry": "^1.0.33",
|
|
78
113
|
"@socketsecurity/sdk": "^1.3.0",
|
|
79
114
|
blessed: "^0.1.81",
|
|
80
115
|
"blessed-contrib": "^4.11.0",
|
|
@@ -99,18 +134,19 @@ var devDependencies = {
|
|
|
99
134
|
"@babel/plugin-proposal-export-default-from": "^7.25.9",
|
|
100
135
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
101
136
|
"@babel/plugin-transform-export-namespace-from": "^7.25.9",
|
|
102
|
-
"@babel/plugin-transform-modules-commonjs": "^7.
|
|
137
|
+
"@babel/plugin-transform-modules-commonjs": "^7.26.3",
|
|
103
138
|
"@babel/plugin-transform-runtime": "^7.25.9",
|
|
104
139
|
"@babel/preset-env": "^7.26.0",
|
|
105
140
|
"@babel/preset-typescript": "^7.26.0",
|
|
106
141
|
"@babel/runtime": "^7.26.0",
|
|
107
|
-
"@eslint/compat": "^1.2.
|
|
142
|
+
"@eslint/compat": "^1.2.4",
|
|
108
143
|
"@eslint/js": "^9.16.0",
|
|
109
144
|
"@rollup/plugin-commonjs": "^28.0.1",
|
|
110
145
|
"@rollup/plugin-json": "^6.1.0",
|
|
111
146
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
112
147
|
"@rollup/plugin-replace": "^6.0.1",
|
|
113
148
|
"@rollup/pluginutils": "^5.1.3",
|
|
149
|
+
"@tapjs/run": "^4.0.1",
|
|
114
150
|
"@types/blessed": "^0.1.25",
|
|
115
151
|
"@types/micromatch": "^4.0.9",
|
|
116
152
|
"@types/mocha": "^10.0.10",
|
|
@@ -126,29 +162,29 @@ var devDependencies = {
|
|
|
126
162
|
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
|
127
163
|
"@typescript-eslint/parser": "^8.17.0",
|
|
128
164
|
c8: "^10.1.2",
|
|
165
|
+
custompatch: "^1.0.28",
|
|
129
166
|
eslint: "^9.16.0",
|
|
130
|
-
"eslint-import-resolver-oxc": "^0.
|
|
167
|
+
"eslint-import-resolver-oxc": "^0.6.0",
|
|
131
168
|
"eslint-plugin-depend": "^0.12.0",
|
|
132
|
-
"eslint-plugin-import-x": "^4.
|
|
169
|
+
"eslint-plugin-import-x": "^4.5.0",
|
|
133
170
|
"eslint-plugin-n": "^17.14.0",
|
|
134
171
|
"eslint-plugin-sort-destructure-keys": "^2.0.0",
|
|
135
172
|
"eslint-plugin-unicorn": "^56.0.1",
|
|
136
173
|
husky: "^9.1.7",
|
|
137
174
|
"is-interactive": "^2.0.0",
|
|
138
175
|
"is-unicode-supported": "^2.1.0",
|
|
139
|
-
knip: "^5.39.
|
|
176
|
+
knip: "^5.39.2",
|
|
140
177
|
"magic-string": "^0.30.14",
|
|
141
178
|
meow: "^13.2.0",
|
|
142
179
|
"mock-fs": "^5.4.1",
|
|
143
180
|
nock: "^13.5.6",
|
|
144
181
|
"npm-run-all2": "^7.0.1",
|
|
145
182
|
open: "^10.1.0",
|
|
146
|
-
oxlint: "0.14.
|
|
147
|
-
prettier: "3.4.
|
|
183
|
+
oxlint: "0.14.1",
|
|
184
|
+
prettier: "3.4.2",
|
|
148
185
|
"read-package-up": "^11.0.0",
|
|
149
|
-
rollup: "4.28.
|
|
186
|
+
rollup: "4.28.1",
|
|
150
187
|
"rollup-plugin-ts": "^3.4.5",
|
|
151
|
-
tap: "^21.0.1",
|
|
152
188
|
"terminal-link": "^3.0.0",
|
|
153
189
|
"tiny-updater": "^3.5.2",
|
|
154
190
|
"type-coverage": "^2.29.7",
|
|
@@ -219,6 +255,7 @@ var require$$6 = {
|
|
|
219
255
|
repository: repository,
|
|
220
256
|
author: author,
|
|
221
257
|
bin: bin,
|
|
258
|
+
exports: exports$1,
|
|
222
259
|
scripts: scripts,
|
|
223
260
|
dependencies: dependencies,
|
|
224
261
|
devDependencies: devDependencies,
|
|
@@ -232,10 +269,10 @@ Object.defineProperty(ttyServer$1, "__esModule", {
|
|
|
232
269
|
value: true
|
|
233
270
|
});
|
|
234
271
|
ttyServer$1.createTTYServer = createTTYServer;
|
|
235
|
-
var _nodeFs$
|
|
272
|
+
var _nodeFs$1 = require$$0;
|
|
236
273
|
var _nodeNet = require$$1$2;
|
|
237
274
|
var _nodeOs = require$$1;
|
|
238
|
-
var _nodePath$
|
|
275
|
+
var _nodePath$1 = require$$1$1;
|
|
239
276
|
var _nodeReadline$1 = require$$3;
|
|
240
277
|
var _nodeStream$1 = require$$5;
|
|
241
278
|
var _package = require$$6;
|
|
@@ -243,7 +280,7 @@ var _misc$1 = sdk.misc;
|
|
|
243
280
|
const NEWLINE_CHAR_CODE = 10; /*'\n'*/
|
|
244
281
|
|
|
245
282
|
const TTY_IPC = process.env['SOCKET_SECURITY_TTY_IPC'];
|
|
246
|
-
const sock = _nodePath$
|
|
283
|
+
const sock = _nodePath$1.join(_nodeOs.tmpdir(), `socket-security-tty-${process.pid}.sock`);
|
|
247
284
|
process.env['SOCKET_SECURITY_TTY_IPC'] = sock;
|
|
248
285
|
function createNonStandardTTYServer() {
|
|
249
286
|
return {
|
|
@@ -416,7 +453,7 @@ function createStandardTTYServer(isInteractive, npmlog) {
|
|
|
416
453
|
}
|
|
417
454
|
function tryUnlinkSync(filepath) {
|
|
418
455
|
try {
|
|
419
|
-
(0, _nodeFs$
|
|
456
|
+
(0, _nodeFs$1.unlinkSync)(filepath);
|
|
420
457
|
} catch (e) {
|
|
421
458
|
if ((0, _misc$1.isErrnoException)(e) && e.code !== 'ENOENT') {
|
|
422
459
|
throw e;
|
|
@@ -582,20 +619,20 @@ Object.defineProperty(arborist, "__esModule", {
|
|
|
582
619
|
arborist.SafeArborist = void 0;
|
|
583
620
|
arborist.installSafeArborist = installSafeArborist;
|
|
584
621
|
var _nodeEvents = require$$1$3;
|
|
585
|
-
var _nodeFs
|
|
586
|
-
var _nodeHttps = require$$3$
|
|
587
|
-
var _nodePath
|
|
622
|
+
var _nodeFs = require$$0;
|
|
623
|
+
var _nodeHttps = require$$3$2;
|
|
624
|
+
var _nodePath = require$$1$1;
|
|
588
625
|
var _nodeReadline = require$$3;
|
|
589
626
|
var _nodeStream = require$$5;
|
|
590
627
|
var _promises = require$$7$1;
|
|
591
628
|
var _isInteractive = _interopRequireDefault(vendor.isInteractive);
|
|
592
629
|
var _npmPackageArg = require$$5$1;
|
|
593
|
-
var _yoctoSpinner = require$$3$
|
|
594
|
-
var _semver = require$$
|
|
630
|
+
var _yoctoSpinner = require$$3$1;
|
|
631
|
+
var _semver = require$$4;
|
|
595
632
|
var _config = require$$6$1;
|
|
596
633
|
var _objects = require$$7;
|
|
597
634
|
var _ttyServer = ttyServer$1;
|
|
598
|
-
var _constants =
|
|
635
|
+
var _constants$1 = constants.constants;
|
|
599
636
|
var _colorOrMarkdown = sdk.colorOrMarkdown;
|
|
600
637
|
var _issueRules = issueRules;
|
|
601
638
|
var _misc = sdk.misc;
|
|
@@ -603,10 +640,8 @@ var _pathResolve = pathResolve.pathResolve;
|
|
|
603
640
|
var _sdk = sdk.sdk;
|
|
604
641
|
var _settings = sdk.settings;
|
|
605
642
|
const POTENTIALLY_BUG_ERROR_SNIPPET = 'this is potentially a bug with socket-npm caused by changes to the npm cli';
|
|
606
|
-
const
|
|
607
|
-
const
|
|
608
|
-
const npmEntrypoint = (0, _nodeFs$1.realpathSync)(process.argv[1]);
|
|
609
|
-
const npmRootPath = (0, _pathResolve.findRoot)(_nodePath$1.dirname(npmEntrypoint));
|
|
643
|
+
const npmEntrypoint = (0, _nodeFs.realpathSync)(process.argv[1]);
|
|
644
|
+
const npmRootPath = (0, _pathResolve.findRoot)(_nodePath.dirname(npmEntrypoint));
|
|
610
645
|
function tryRequire(...ids) {
|
|
611
646
|
for (const data of ids) {
|
|
612
647
|
let id;
|
|
@@ -636,26 +671,26 @@ if (npmRootPath === undefined) {
|
|
|
636
671
|
}
|
|
637
672
|
const LOOP_SENTINEL = 1_000_000;
|
|
638
673
|
const NPM_REGISTRY_URL = 'https://registry.npmjs.org';
|
|
639
|
-
const npmNmPath = _nodePath
|
|
640
|
-
const arboristPkgPath = _nodePath
|
|
641
|
-
const arboristClassPath = _nodePath
|
|
642
|
-
const arboristDepValidPath = _nodePath
|
|
643
|
-
const arboristEdgeClassPath = _nodePath
|
|
644
|
-
const arboristNodeClassPath = _nodePath
|
|
645
|
-
const arboristOverrideSetClassPatch = _nodePath
|
|
646
|
-
const log = tryRequire([_nodePath
|
|
674
|
+
const npmNmPath = _nodePath.join(npmRootPath, 'node_modules');
|
|
675
|
+
const arboristPkgPath = _nodePath.join(npmNmPath, '@npmcli/arborist');
|
|
676
|
+
const arboristClassPath = _nodePath.join(arboristPkgPath, 'lib/arborist/index.js');
|
|
677
|
+
const arboristDepValidPath = _nodePath.join(arboristPkgPath, 'lib/dep-valid.js');
|
|
678
|
+
const arboristEdgeClassPath = _nodePath.join(arboristPkgPath, 'lib/edge.js');
|
|
679
|
+
const arboristNodeClassPath = _nodePath.join(arboristPkgPath, 'lib/node.js');
|
|
680
|
+
const arboristOverrideSetClassPatch = _nodePath.join(arboristPkgPath, 'lib/override-set.js');
|
|
681
|
+
const log = tryRequire([_nodePath.join(npmNmPath, 'proc-log/lib/index.js'),
|
|
647
682
|
// The proc-log DefinitelyTyped definition is incorrect. The type definition
|
|
648
683
|
// is really that of its export log.
|
|
649
|
-
mod => mod.log], _nodePath
|
|
684
|
+
mod => mod.log], _nodePath.join(npmNmPath, 'npmlog/lib/log.js'));
|
|
650
685
|
if (log === undefined) {
|
|
651
686
|
console.error(`Unable to integrate with npm cli logging infrastructure, ${POTENTIALLY_BUG_ERROR_SNIPPET}.`);
|
|
652
687
|
process.exit(127);
|
|
653
688
|
}
|
|
654
|
-
const pacote = tryRequire(_nodePath
|
|
689
|
+
const pacote = tryRequire(_nodePath.join(npmNmPath, 'pacote'), 'pacote');
|
|
655
690
|
const {
|
|
656
691
|
tarball
|
|
657
692
|
} = pacote;
|
|
658
|
-
const translations = require(_nodePath
|
|
693
|
+
const translations = require(_nodePath.join(_constants$1.rootPath, 'translations.json'));
|
|
659
694
|
const abortController = new AbortController();
|
|
660
695
|
const {
|
|
661
696
|
signal: abortSignal
|
|
@@ -684,11 +719,11 @@ async function uxLookup(settings) {
|
|
|
684
719
|
}
|
|
685
720
|
async function* batchScan(pkgIds) {
|
|
686
721
|
const query = {
|
|
687
|
-
packages: pkgIds.map(
|
|
722
|
+
packages: pkgIds.map(id => {
|
|
688
723
|
const {
|
|
689
724
|
name,
|
|
690
725
|
version
|
|
691
|
-
} = pkgidParts(
|
|
726
|
+
} = pkgidParts(id);
|
|
692
727
|
return {
|
|
693
728
|
eco: 'npm',
|
|
694
729
|
pkg: name,
|
|
@@ -698,7 +733,7 @@ async function* batchScan(pkgIds) {
|
|
|
698
733
|
})
|
|
699
734
|
};
|
|
700
735
|
// TODO: Migrate to SDK.
|
|
701
|
-
const pkgDataReq = _nodeHttps.request(`${_constants.API_V0_URL}/scan/batch`, {
|
|
736
|
+
const pkgDataReq = _nodeHttps.request(`${_constants$1.API_V0_URL}/scan/batch`, {
|
|
702
737
|
method: 'POST',
|
|
703
738
|
headers: {
|
|
704
739
|
Authorization: `Basic ${Buffer.from(`${pubToken}:`).toString('base64url')}`
|
|
@@ -730,10 +765,10 @@ function findSocketYmlSync() {
|
|
|
730
765
|
let prevDir = null;
|
|
731
766
|
let dir = process.cwd();
|
|
732
767
|
while (dir !== prevDir) {
|
|
733
|
-
let ymlPath = _nodePath
|
|
768
|
+
let ymlPath = _nodePath.join(dir, 'socket.yml');
|
|
734
769
|
let yml = maybeReadfileSync(ymlPath);
|
|
735
770
|
if (yml === undefined) {
|
|
736
|
-
ymlPath = _nodePath
|
|
771
|
+
ymlPath = _nodePath.join(dir, 'socket.yaml');
|
|
737
772
|
yml = maybeReadfileSync(ymlPath);
|
|
738
773
|
}
|
|
739
774
|
if (typeof yml === 'string') {
|
|
@@ -747,7 +782,7 @@ function findSocketYmlSync() {
|
|
|
747
782
|
}
|
|
748
783
|
}
|
|
749
784
|
prevDir = dir;
|
|
750
|
-
dir = _nodePath
|
|
785
|
+
dir = _nodePath.join(dir, '..');
|
|
751
786
|
}
|
|
752
787
|
return null;
|
|
753
788
|
}
|
|
@@ -775,28 +810,33 @@ function findSpecificOverrideSet(first, second) {
|
|
|
775
810
|
}
|
|
776
811
|
function maybeReadfileSync(filepath) {
|
|
777
812
|
try {
|
|
778
|
-
return (0, _nodeFs
|
|
813
|
+
return (0, _nodeFs.readFileSync)(filepath, 'utf8');
|
|
779
814
|
} catch {}
|
|
780
815
|
return undefined;
|
|
781
816
|
}
|
|
782
817
|
async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
|
|
818
|
+
const spinner = _yoctoSpinner({
|
|
819
|
+
stream: output
|
|
820
|
+
});
|
|
783
821
|
let result = false;
|
|
784
|
-
let
|
|
822
|
+
let {
|
|
823
|
+
length: remaining
|
|
824
|
+
} = pkgs;
|
|
785
825
|
if (!remaining) {
|
|
786
|
-
|
|
826
|
+
spinner.success('No changes detected');
|
|
787
827
|
return result;
|
|
788
828
|
}
|
|
789
829
|
const getText = () => `Looking up data for ${remaining} packages`;
|
|
790
|
-
|
|
791
|
-
stream: output
|
|
792
|
-
}).start(getText());
|
|
830
|
+
spinner.start(getText());
|
|
793
831
|
try {
|
|
794
|
-
for await (const pkgData of batchScan(pkgs.map(
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
832
|
+
for await (const pkgData of batchScan(pkgs.map(p => p.pkgid))) {
|
|
833
|
+
const {
|
|
834
|
+
pkg: name,
|
|
835
|
+
ver: version
|
|
836
|
+
} = pkgData;
|
|
799
837
|
const id = `${name}@${version}`;
|
|
838
|
+
let displayWarning = false;
|
|
839
|
+
let failures = [];
|
|
800
840
|
if (pkgData.type === 'missing') {
|
|
801
841
|
result = true;
|
|
802
842
|
failures.push({
|
|
@@ -822,7 +862,7 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
|
|
|
822
862
|
});
|
|
823
863
|
// Before we ask about problematic issues, check to see if they
|
|
824
864
|
// already existed in the old version if they did, be quiet.
|
|
825
|
-
const pkg = pkgs.find(
|
|
865
|
+
const pkg = pkgs.find(p => p.pkgid === id && p.existing?.startsWith(`${name}@`));
|
|
826
866
|
if (pkg?.existing) {
|
|
827
867
|
// eslint-disable-next-line no-await-in-loop
|
|
828
868
|
for await (const oldPkgData of batchScan([pkg.existing])) {
|
|
@@ -841,7 +881,7 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
|
|
|
841
881
|
}
|
|
842
882
|
}
|
|
843
883
|
if (!blocked) {
|
|
844
|
-
const pkg = pkgs.find(
|
|
884
|
+
const pkg = pkgs.find(p => p.pkgid === id);
|
|
845
885
|
if (pkg) {
|
|
846
886
|
await tarball.stream(id, stream => {
|
|
847
887
|
stream.resume();
|
|
@@ -853,8 +893,7 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
|
|
|
853
893
|
}
|
|
854
894
|
}
|
|
855
895
|
if (displayWarning) {
|
|
856
|
-
spinner.stop();
|
|
857
|
-
output?.write(`(socket) ${formatter.hyperlink(id, `https://socket.dev/npm/package/${name}/overview/${version}`)} contains risks:\n`);
|
|
896
|
+
spinner.stop(`(socket) ${formatter.hyperlink(id, `https://socket.dev/npm/package/${name}/overview/${version}`)} contains risks:`);
|
|
858
897
|
failures.sort((a, b) => a.raw.type < b.raw.type ? -1 : 1);
|
|
859
898
|
const lines = new Set();
|
|
860
899
|
for (const failure of failures) {
|
|
@@ -875,9 +914,7 @@ async function packagesHaveRiskyIssues(safeArb, _registry, pkgs, output) {
|
|
|
875
914
|
}
|
|
876
915
|
return result;
|
|
877
916
|
} finally {
|
|
878
|
-
|
|
879
|
-
spinner.stop();
|
|
880
|
-
}
|
|
917
|
+
spinner.stop();
|
|
881
918
|
}
|
|
882
919
|
}
|
|
883
920
|
function pkgidParts(pkgid) {
|
|
@@ -889,18 +926,8 @@ function pkgidParts(pkgid) {
|
|
|
889
926
|
version
|
|
890
927
|
};
|
|
891
928
|
}
|
|
892
|
-
function
|
|
893
|
-
|
|
894
|
-
const {
|
|
895
|
-
name,
|
|
896
|
-
version
|
|
897
|
-
} = pkgidParts(pkgid);
|
|
898
|
-
return {
|
|
899
|
-
type: 'npm',
|
|
900
|
-
namespace_and_name: name,
|
|
901
|
-
version,
|
|
902
|
-
repository_url: repo
|
|
903
|
-
};
|
|
929
|
+
function toRepoUrl(resolved) {
|
|
930
|
+
return resolved.replace(/#[\s\S]*$/, '').replace(/\?[\s\S]*$/, '').replace(/\/[^/]*\/-\/[\s\S]*$/, '');
|
|
904
931
|
}
|
|
905
932
|
function walk(diff_, needInfoOn = []) {
|
|
906
933
|
const queue = [diff_];
|
|
@@ -931,12 +958,8 @@ function walk(diff_, needInfoOn = []) {
|
|
|
931
958
|
if (keep && diff.ideal?.pkgid && diff.ideal.resolved && (!diff.actual || diff.actual.resolved)) {
|
|
932
959
|
needInfoOn.push({
|
|
933
960
|
existing,
|
|
934
|
-
action: diff.action,
|
|
935
|
-
location: diff.ideal.location,
|
|
936
961
|
pkgid: diff.ideal.pkgid,
|
|
937
|
-
|
|
938
|
-
oldPackage: diff.actual && diff.actual.resolved ? toPURL(diff.actual.pkgid, diff.actual.resolved) : null,
|
|
939
|
-
resolved: diff.ideal.resolved
|
|
962
|
+
repository_url: toRepoUrl(diff.ideal.resolved)
|
|
940
963
|
});
|
|
941
964
|
}
|
|
942
965
|
}
|
|
@@ -1627,10 +1650,10 @@ class SafeArborist extends Arborist {
|
|
|
1627
1650
|
options['save'] = old.save;
|
|
1628
1651
|
options['saveBundle'] = old.saveBundle;
|
|
1629
1652
|
// Nothing to check, mmm already installed or all private?
|
|
1630
|
-
if (diff.findIndex(c => c.
|
|
1653
|
+
if (diff.findIndex(c => c.repository_url === NPM_REGISTRY_URL) === -1) {
|
|
1631
1654
|
return await this[kRiskyReify](...args);
|
|
1632
1655
|
}
|
|
1633
|
-
let proceed = _constants.ENV.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE;
|
|
1656
|
+
let proceed = _constants$1.ENV.UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE;
|
|
1634
1657
|
if (!proceed) {
|
|
1635
1658
|
proceed = await ttyServer.captureTTY(async (input, output) => {
|
|
1636
1659
|
if (input && output) {
|
|
@@ -1767,16 +1790,11 @@ void (async () => {
|
|
|
1767
1790
|
_uxLookup = (0, _issueRules.createIssueUXLookup)(settings);
|
|
1768
1791
|
})();
|
|
1769
1792
|
|
|
1770
|
-
var
|
|
1771
|
-
var _nodePath = require$$1$1;
|
|
1793
|
+
var _constants = constants.constants;
|
|
1772
1794
|
var _arborist = arborist;
|
|
1773
1795
|
var _link = link.link;
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
const binPath = _nodePath.join(rootPath, 'bin');
|
|
1777
|
-
|
|
1778
|
-
// shadow `npm` and `npx` to mitigate subshells
|
|
1779
|
-
(0, _link.installLinks)((0, _nodeFs.realpathSync)(binPath), 'npm');
|
|
1796
|
+
// Shadow `npm` and `npx` to mitigate subshells.
|
|
1797
|
+
(0, _link.installLinks)(_constants.shadowBinPath, 'npm');
|
|
1780
1798
|
(0, _arborist.installSafeArborist)();
|
|
1781
1799
|
|
|
1782
1800
|
(function (exports) {
|
|
@@ -1792,7 +1810,7 @@ const binPath = _nodePath.join(rootPath, 'bin');
|
|
|
1792
1810
|
return _npmInjection.default;
|
|
1793
1811
|
}
|
|
1794
1812
|
});
|
|
1795
|
-
var _npmInjection = _interopRequireWildcard(npmInjection, true);
|
|
1813
|
+
var _npmInjection = _interopRequireWildcard(npmInjection$1, true);
|
|
1796
1814
|
Object.keys(_npmInjection).forEach(function (key) {
|
|
1797
1815
|
if (key === "default" || key === "__esModule") return;
|
|
1798
1816
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -1804,6 +1822,8 @@ const binPath = _nodePath.join(rootPath, 'bin');
|
|
|
1804
1822
|
}
|
|
1805
1823
|
});
|
|
1806
1824
|
});
|
|
1807
|
-
} (npmInjection$
|
|
1825
|
+
} (npmInjection$2));
|
|
1826
|
+
|
|
1827
|
+
var npmInjection = /*@__PURE__*/vendor.getDefaultExportFromCjs(npmInjection$2);
|
|
1808
1828
|
|
|
1809
|
-
module.exports = npmInjection
|
|
1829
|
+
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 };
|