@socketsecurity/cli-with-sentry 0.14.49 → 0.14.51
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/dist/constants.d.ts +2 -0
- package/dist/constants.js +6 -2
- package/dist/constants.js.map +1 -1
- package/dist/instrument-with-sentry.js +2 -2
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/module-sync/cli.js +372 -152
- package/dist/module-sync/cli.js.map +1 -1
- package/dist/module-sync/index.d.ts +1 -1
- package/dist/module-sync/index.js +32 -24
- package/dist/module-sync/index.js.map +1 -1
- package/dist/module-sync/npm-paths.js +3 -43
- package/dist/module-sync/npm-paths.js.map +1 -1
- package/dist/require/cli.js +372 -152
- package/dist/require/cli.js.map +1 -1
- package/package.json +7 -7
- package/dist/module-sync/logging.d.ts +0 -16
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { SafeEdge } from "./edge.js";
|
|
3
3
|
import { SafeNode } from "./node.js";
|
|
4
4
|
import indentString from "@socketregistry/indent-string/index.cjs";
|
|
5
|
-
import { LogSymbols } from "
|
|
5
|
+
import { LogSymbols } from "@socketsecurity/registry/lib/logger";
|
|
6
6
|
import { SocketSdkResultType } from "@socketsecurity/sdk";
|
|
7
7
|
import { Diff, ArboristClass } from "./types.js";
|
|
8
8
|
import { ObjectEncodingOptions, OpenMode, PathLike } from "node:fs";
|
|
@@ -34,6 +34,7 @@ var npmPaths = require('./npm-paths.js');
|
|
|
34
34
|
var fs = require('node:fs');
|
|
35
35
|
var os = require('node:os');
|
|
36
36
|
var config = require('@socketsecurity/config');
|
|
37
|
+
var logger = require('@socketsecurity/registry/lib/logger');
|
|
37
38
|
var terminalLink = _socketInterop(require('terminal-link'));
|
|
38
39
|
var colors = _socketInterop(require('yoctocolors-cjs'));
|
|
39
40
|
var indentString = require('@socketregistry/indent-string/index.cjs');
|
|
@@ -134,7 +135,7 @@ function getSettings() {
|
|
|
134
135
|
try {
|
|
135
136
|
Object.assign(_settings, JSON.parse(Buffer.from(raw, 'base64').toString()));
|
|
136
137
|
} catch {
|
|
137
|
-
|
|
138
|
+
logger.logger.warn(`Failed to parse settings at ${settingsPath}`);
|
|
138
139
|
}
|
|
139
140
|
} else {
|
|
140
141
|
fs.mkdirSync(path.dirname(settingsPath), {
|
|
@@ -158,7 +159,7 @@ function getSettingsPath() {
|
|
|
158
159
|
if (WIN32) {
|
|
159
160
|
if (!_warnedSettingPathWin32Missing) {
|
|
160
161
|
_warnedSettingPathWin32Missing = true;
|
|
161
|
-
|
|
162
|
+
logger.logger.warn(`Missing %${LOCALAPPDATA}%`);
|
|
162
163
|
}
|
|
163
164
|
} else {
|
|
164
165
|
dataHome = path.join(os.homedir(), ...(process.platform === 'darwin' ? ['Library', 'Application Support'] : ['.local', 'share']));
|
|
@@ -219,6 +220,10 @@ function updateSetting(key, value) {
|
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
222
|
|
|
223
|
+
const {
|
|
224
|
+
SOCKET_CLI_NO_API_TOKEN
|
|
225
|
+
} = constants;
|
|
226
|
+
|
|
222
227
|
// The API server that should be used for operations.
|
|
223
228
|
function getDefaultApiBaseUrl() {
|
|
224
229
|
const baseUrl = process.env['SOCKET_SECURITY_API_BASE_URL'] || getSetting('apiBaseUrl');
|
|
@@ -234,11 +239,16 @@ function getDefaultHttpProxy() {
|
|
|
234
239
|
// This API key should be stored globally for the duration of the CLI execution.
|
|
235
240
|
let _defaultToken;
|
|
236
241
|
function getDefaultToken() {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
// Lazily access constants.ENV[SOCKET_CLI_NO_API_TOKEN].
|
|
243
|
+
if (constants.ENV[SOCKET_CLI_NO_API_TOKEN]) {
|
|
244
|
+
_defaultToken = undefined;
|
|
245
|
+
} else {
|
|
246
|
+
const key = process.env['SOCKET_SECURITY_API_TOKEN'] ||
|
|
247
|
+
// Keep 'SOCKET_SECURITY_API_KEY' as an alias of 'SOCKET_SECURITY_API_TOKEN'.
|
|
248
|
+
// TODO: Remove 'SOCKET_SECURITY_API_KEY' alias.
|
|
249
|
+
process.env['SOCKET_SECURITY_API_KEY'] || getSetting('apiToken') || _defaultToken;
|
|
250
|
+
_defaultToken = strings.isNonEmptyString(key) ? key : undefined;
|
|
251
|
+
}
|
|
242
252
|
return _defaultToken;
|
|
243
253
|
}
|
|
244
254
|
function getPublicToken() {
|
|
@@ -366,7 +376,7 @@ const {
|
|
|
366
376
|
ALERT_TYPE_SOCKET_UPGRADE_AVAILABLE,
|
|
367
377
|
CVE_ALERT_PROPS_FIRST_PATCHED_VERSION_IDENTIFIER: CVE_ALERT_PROPS_FIRST_PATCHED_VERSION_IDENTIFIER$1,
|
|
368
378
|
CVE_ALERT_PROPS_VULNERABLE_VERSION_RANGE,
|
|
369
|
-
abortSignal: abortSignal$
|
|
379
|
+
abortSignal: abortSignal$1
|
|
370
380
|
} = constants;
|
|
371
381
|
async function* createBatchGenerator(chunk) {
|
|
372
382
|
// Adds the first 'abort' listener to abortSignal.
|
|
@@ -377,7 +387,7 @@ async function* createBatchGenerator(chunk) {
|
|
|
377
387
|
headers: {
|
|
378
388
|
Authorization: `Basic ${btoa(`${getPublicToken()}:`)}`
|
|
379
389
|
},
|
|
380
|
-
signal: abortSignal$
|
|
390
|
+
signal: abortSignal$1
|
|
381
391
|
}).end(JSON.stringify({
|
|
382
392
|
components: chunk.map(id => ({
|
|
383
393
|
purl: `pkg:npm/${id}`
|
|
@@ -387,7 +397,7 @@ async function* createBatchGenerator(chunk) {
|
|
|
387
397
|
const {
|
|
388
398
|
0: res
|
|
389
399
|
} = await events.once(req, 'response', {
|
|
390
|
-
signal: abortSignal$
|
|
400
|
+
signal: abortSignal$1
|
|
391
401
|
});
|
|
392
402
|
const ok = res.statusCode >= 200 && res.statusCode <= 299;
|
|
393
403
|
if (!ok) {
|
|
@@ -396,7 +406,7 @@ async function* createBatchGenerator(chunk) {
|
|
|
396
406
|
const rli = readline.createInterface({
|
|
397
407
|
input: res,
|
|
398
408
|
crlfDelay: Infinity,
|
|
399
|
-
signal: abortSignal$
|
|
409
|
+
signal: abortSignal$1
|
|
400
410
|
});
|
|
401
411
|
for await (const line of rli) {
|
|
402
412
|
yield JSON.parse(line);
|
|
@@ -407,11 +417,11 @@ async function* batchScan(pkgIds, concurrencyLimit = 50) {
|
|
|
407
417
|
// abortSignal so we multiply the concurrencyLimit by 2.
|
|
408
418
|
const neededMaxListeners = concurrencyLimit * 2;
|
|
409
419
|
// Increase abortSignal max listeners count to avoid Node's MaxListenersExceededWarning.
|
|
410
|
-
const oldAbortSignalMaxListeners = events.getMaxListeners(abortSignal$
|
|
420
|
+
const oldAbortSignalMaxListeners = events.getMaxListeners(abortSignal$1);
|
|
411
421
|
let abortSignalMaxListeners = oldAbortSignalMaxListeners;
|
|
412
422
|
if (oldAbortSignalMaxListeners < neededMaxListeners) {
|
|
413
423
|
abortSignalMaxListeners = oldAbortSignalMaxListeners + neededMaxListeners;
|
|
414
|
-
events.setMaxListeners(abortSignalMaxListeners, abortSignal$
|
|
424
|
+
events.setMaxListeners(abortSignalMaxListeners, abortSignal$1);
|
|
415
425
|
}
|
|
416
426
|
const {
|
|
417
427
|
length: pkgIdsCount
|
|
@@ -462,7 +472,7 @@ async function* batchScan(pkgIds, concurrencyLimit = 50) {
|
|
|
462
472
|
}
|
|
463
473
|
// Reset abortSignal max listeners count.
|
|
464
474
|
if (abortSignalMaxListeners > oldAbortSignalMaxListeners) {
|
|
465
|
-
events.setMaxListeners(oldAbortSignalMaxListeners, abortSignal$
|
|
475
|
+
events.setMaxListeners(oldAbortSignalMaxListeners, abortSignal$1);
|
|
466
476
|
}
|
|
467
477
|
}
|
|
468
478
|
function isArtifactAlertCveFixable(alert) {
|
|
@@ -476,7 +486,7 @@ function isArtifactAlertUpgradeFixable(alert) {
|
|
|
476
486
|
}
|
|
477
487
|
|
|
478
488
|
const {
|
|
479
|
-
abortSignal
|
|
489
|
+
abortSignal
|
|
480
490
|
} = constants;
|
|
481
491
|
const ERROR_UX = {
|
|
482
492
|
block: true,
|
|
@@ -613,7 +623,7 @@ async function uxLookup(settings) {
|
|
|
613
623
|
while (_uxLookup === undefined) {
|
|
614
624
|
// eslint-disable-next-line no-await-in-loop
|
|
615
625
|
await promises.setTimeout(1, {
|
|
616
|
-
signal: abortSignal
|
|
626
|
+
signal: abortSignal
|
|
617
627
|
});
|
|
618
628
|
}
|
|
619
629
|
return _uxLookup(settings);
|
|
@@ -688,13 +698,13 @@ void (async () => {
|
|
|
688
698
|
_uxLookup = createAlertUXLookup(settings);
|
|
689
699
|
})();
|
|
690
700
|
|
|
691
|
-
const markdownLogSymbols = {
|
|
701
|
+
const markdownLogSymbols = Object.freeze({
|
|
692
702
|
__proto__: null,
|
|
693
703
|
info: ':information_source:',
|
|
694
704
|
error: ':stop_sign:',
|
|
695
705
|
success: ':white_check_mark:',
|
|
696
706
|
warning: ':warning:'
|
|
697
|
-
};
|
|
707
|
+
});
|
|
698
708
|
class ColorOrMarkdown {
|
|
699
709
|
constructor(useMarkdown) {
|
|
700
710
|
this.useMarkdown = !!useMarkdown;
|
|
@@ -730,7 +740,7 @@ class ColorOrMarkdown {
|
|
|
730
740
|
return this.useMarkdown ? `* ${indentedContent.join('\n* ')}\n` : `${indentedContent.join('\n')}\n`;
|
|
731
741
|
}
|
|
732
742
|
get logSymbols() {
|
|
733
|
-
return this.useMarkdown ? markdownLogSymbols :
|
|
743
|
+
return this.useMarkdown ? markdownLogSymbols : logger.Logger.LOG_SYMBOLS;
|
|
734
744
|
}
|
|
735
745
|
}
|
|
736
746
|
|
|
@@ -1446,8 +1456,7 @@ const {
|
|
|
1446
1456
|
NPM_REGISTRY_URL,
|
|
1447
1457
|
OVERRIDES,
|
|
1448
1458
|
PNPM,
|
|
1449
|
-
RESOLUTIONS
|
|
1450
|
-
abortSignal
|
|
1459
|
+
RESOLUTIONS
|
|
1451
1460
|
} = constants;
|
|
1452
1461
|
const formatter = new ColorOrMarkdown(false);
|
|
1453
1462
|
function findBestPatchVersion(node, availableVersions, vulnerableVersionRange, _firstPatchedVersionIdentifier) {
|
|
@@ -1755,8 +1764,7 @@ async function reify(...args) {
|
|
|
1755
1764
|
default: false
|
|
1756
1765
|
}, {
|
|
1757
1766
|
input,
|
|
1758
|
-
output
|
|
1759
|
-
signal: abortSignal
|
|
1767
|
+
output
|
|
1760
1768
|
}))) {
|
|
1761
1769
|
throw new Error('Socket npm exiting due to risks');
|
|
1762
1770
|
}
|
|
@@ -1858,5 +1866,5 @@ exports.safeReadFile = safeReadFile;
|
|
|
1858
1866
|
exports.setupSdk = setupSdk;
|
|
1859
1867
|
exports.updateNode = updateNode;
|
|
1860
1868
|
exports.updateSetting = updateSetting;
|
|
1861
|
-
//# debugId=
|
|
1869
|
+
//# debugId=d413b96a-751b-43c9-8ce7-50c11ea5826
|
|
1862
1870
|
//# sourceMappingURL=index.js.map
|