@socketsecurity/cli-with-sentry 1.1.147 → 1.1.151
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/CHANGELOG.md +11 -0
- package/dist/cli.js +680 -485
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +6 -6
- package/dist/constants.js.map +1 -1
- package/dist/instrument-with-sentry.js +3 -3
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/manifest-scripts/maven-extension/coana-maven-extension.jar +0 -0
- package/dist/shadow-npm-bin2.js +6 -6
- package/dist/shadow-npm-bin2.js.map +1 -1
- package/dist/shadow-npm-inject.js +10 -10
- package/dist/shadow-npm-inject.js.map +1 -1
- package/dist/shadow-pnpm-bin2.js +13 -13
- package/dist/shadow-pnpm-bin2.js.map +1 -1
- package/dist/shadow-yarn-bin.js +3 -3
- package/dist/shadow-yarn-bin.js.map +1 -1
- package/dist/socket-completion.bash +0 -0
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/audit-log/output-audit-log.d.mts.map +1 -1
- package/dist/types/commands/ci/handle-ci.d.mts.map +1 -1
- package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-auto.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-scala.d.mts.map +1 -1
- package/dist/types/commands/manifest/convert-sbt-to-facts.d.mts +3 -1
- package/dist/types/commands/manifest/convert-sbt-to-facts.d.mts.map +1 -1
- package/dist/types/commands/manifest/generate_auto_manifest.d.mts +4 -1
- package/dist/types/commands/manifest/generate_auto_manifest.d.mts.map +1 -1
- package/dist/types/commands/manifest/run-manifest-facts.d.mts +3 -1
- package/dist/types/commands/manifest/run-manifest-facts.d.mts.map +1 -1
- package/dist/types/commands/manifest/scripts/run.d.mts +8 -0
- package/dist/types/commands/manifest/scripts/run.d.mts.map +1 -1
- package/dist/types/commands/organization/fetch-organization-list.d.mts +2 -2
- package/dist/types/commands/organization/fetch-organization-list.d.mts.map +1 -1
- package/dist/types/commands/package/output-purls-shallow-score.d.mts.map +1 -1
- package/dist/types/commands/repository/fetch-create-repo.d.mts +2 -2
- package/dist/types/commands/repository/fetch-create-repo.d.mts.map +1 -1
- package/dist/types/commands/repository/fetch-delete-repo.d.mts +2 -2
- package/dist/types/commands/repository/fetch-delete-repo.d.mts.map +1 -1
- package/dist/types/commands/repository/fetch-list-all-repos.d.mts +2 -2
- package/dist/types/commands/repository/fetch-list-all-repos.d.mts.map +1 -1
- package/dist/types/commands/repository/fetch-list-repos.d.mts +2 -2
- package/dist/types/commands/repository/fetch-list-repos.d.mts.map +1 -1
- package/dist/types/commands/repository/fetch-update-repo.d.mts +2 -2
- package/dist/types/commands/repository/fetch-update-repo.d.mts.map +1 -1
- package/dist/types/commands/repository/fetch-view-repo.d.mts +2 -2
- package/dist/types/commands/repository/fetch-view-repo.d.mts.map +1 -1
- package/dist/types/commands/repository/handle-list-repos.d.mts.map +1 -1
- package/dist/types/commands/repository/output-create-repo.d.mts +2 -2
- package/dist/types/commands/repository/output-create-repo.d.mts.map +1 -1
- package/dist/types/commands/repository/output-delete-repo.d.mts +2 -2
- package/dist/types/commands/repository/output-delete-repo.d.mts.map +1 -1
- package/dist/types/commands/repository/output-list-repos.d.mts +2 -2
- package/dist/types/commands/repository/output-list-repos.d.mts.map +1 -1
- package/dist/types/commands/repository/output-update-repo.d.mts +2 -2
- package/dist/types/commands/repository/output-update-repo.d.mts.map +1 -1
- package/dist/types/commands/repository/output-view-repo.d.mts +2 -2
- package/dist/types/commands/repository/output-view-repo.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-create.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-reach.d.mts.map +1 -1
- package/dist/types/commands/scan/create-scan-from-github.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts +2 -2
- package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-delete-org-full-scan.d.mts +2 -2
- package/dist/types/commands/scan/fetch-delete-org-full-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-list-scans.d.mts +2 -2
- package/dist/types/commands/scan/fetch-list-scans.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-scan-metadata.d.mts +2 -2
- package/dist/types/commands/scan/fetch-scan-metadata.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-scan.d.mts +4 -0
- package/dist/types/commands/scan/fetch-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts +2 -1
- package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts.map +1 -1
- package/dist/types/commands/scan/handle-create-new-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/handle-scan-reach.d.mts.map +1 -1
- package/dist/types/commands/scan/output-create-new-scan.d.mts +2 -2
- package/dist/types/commands/scan/output-create-new-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/output-delete-scan.d.mts +2 -2
- package/dist/types/commands/scan/output-delete-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/output-list-scans.d.mts +2 -2
- package/dist/types/commands/scan/output-list-scans.d.mts.map +1 -1
- package/dist/types/commands/scan/output-scan-metadata.d.mts +2 -2
- package/dist/types/commands/scan/output-scan-metadata.d.mts.map +1 -1
- package/dist/types/commands/scan/perform-reachability-analysis.d.mts +1 -0
- package/dist/types/commands/scan/perform-reachability-analysis.d.mts.map +1 -1
- package/dist/types/commands/scan/reachability-flags.d.mts.map +1 -1
- package/dist/types/commands/scan/stream-scan.d.mts +3 -1
- package/dist/types/commands/scan/stream-scan.d.mts.map +1 -1
- package/dist/types/utils/api.d.mts +49 -4
- package/dist/types/utils/api.d.mts.map +1 -1
- package/dist/types/utils/ecosystem.d.mts +1 -1
- package/dist/types/utils/ecosystem.d.mts.map +1 -1
- package/dist/types/utils/fs.d.mts +1 -0
- package/dist/types/utils/fs.d.mts.map +1 -1
- package/dist/types/utils/glob.d.mts +4 -4
- package/dist/types/utils/glob.d.mts.map +1 -1
- package/dist/types/utils/path-resolve.d.mts +1 -1
- package/dist/types/utils/path-resolve.d.mts.map +1 -1
- package/dist/types/utils/sdk.d.mts +5 -0
- package/dist/types/utils/sdk.d.mts.map +1 -1
- package/dist/types/utils/socket-package-alert.d.mts.map +1 -1
- package/dist/utils.js +268 -188
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +9530 -1726
- package/package.json +59 -133
- package/shadow-bin/npm +0 -0
- package/shadow-bin/npx +0 -0
- package/shadow-bin/pnpm +0 -0
- package/shadow-bin/yarn +0 -0
package/dist/utils.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var vendor = require('./vendor.js');
|
|
4
4
|
var logger = require('../external/@socketsecurity/registry/lib/logger');
|
|
5
5
|
var strings = require('../external/@socketsecurity/registry/lib/strings');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var debug$2 = require('../external/@socketsecurity/registry/lib/debug');
|
|
7
|
+
var objects = require('../external/@socketsecurity/registry/lib/objects');
|
|
8
8
|
var constants = require('./constants.js');
|
|
9
9
|
var arrays = require('../external/@socketsecurity/registry/lib/arrays');
|
|
10
10
|
var path$1 = require('../external/@socketsecurity/registry/lib/path');
|
|
@@ -18,23 +18,23 @@ var prompts = require('../external/@socketsecurity/registry/lib/prompts');
|
|
|
18
18
|
var spawn = require('../external/@socketsecurity/registry/lib/spawn');
|
|
19
19
|
var fs = require('node:fs');
|
|
20
20
|
var fs$2 = require('node:fs/promises');
|
|
21
|
-
var
|
|
22
|
-
var
|
|
21
|
+
var require$$9 = require('node:stream/promises');
|
|
22
|
+
var require$$11 = require('node:zlib');
|
|
23
23
|
var fs$1 = require('../external/@socketsecurity/registry/lib/fs');
|
|
24
|
-
var require$$
|
|
24
|
+
var require$$1 = require('node:module');
|
|
25
25
|
var os = require('node:os');
|
|
26
|
-
var require$$
|
|
26
|
+
var require$$13 = require('node:https');
|
|
27
27
|
var web = require('node:stream/web');
|
|
28
|
-
var
|
|
28
|
+
var url = require('../external/@socketsecurity/registry/lib/url');
|
|
29
29
|
var agent = require('../external/@socketsecurity/registry/lib/agent');
|
|
30
30
|
var bin = require('../external/@socketsecurity/registry/lib/bin');
|
|
31
31
|
var packages = require('../external/@socketsecurity/registry/lib/packages');
|
|
32
32
|
var require$$0$1 = require('node:url');
|
|
33
33
|
var globs = require('../external/@socketsecurity/registry/lib/globs');
|
|
34
34
|
var streams = require('../external/@socketsecurity/registry/lib/streams');
|
|
35
|
-
var
|
|
36
|
-
var require$$
|
|
37
|
-
var require$$
|
|
35
|
+
var require$$7 = require('node:timers/promises');
|
|
36
|
+
var require$$10 = require('node:util');
|
|
37
|
+
var require$$12 = require('node:http');
|
|
38
38
|
var node_tls = require('node:tls');
|
|
39
39
|
var process$1 = require('node:process');
|
|
40
40
|
var require$$0 = require('node:crypto');
|
|
@@ -99,13 +99,13 @@ function debugApiResponse(method, endpoint, status, error, duration, headers) {
|
|
|
99
99
|
*/
|
|
100
100
|
function debugFileOp(operation, filepath, error) {
|
|
101
101
|
if (error) {
|
|
102
|
-
|
|
102
|
+
debug$2.debugDir('warn', {
|
|
103
103
|
operation,
|
|
104
104
|
filepath,
|
|
105
105
|
error: error instanceof Error ? error.message : 'Unknown error'
|
|
106
106
|
});
|
|
107
|
-
} else if (
|
|
108
|
-
|
|
107
|
+
} else if (debug$2.isDebug('silly')) {
|
|
108
|
+
debug$2.debugFn('silly', `File ${operation}: ${filepath}`);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -117,19 +117,19 @@ function debugScan(phase, packageCount, details) {
|
|
|
117
117
|
switch (phase) {
|
|
118
118
|
case 'start':
|
|
119
119
|
if (packageCount) {
|
|
120
|
-
|
|
120
|
+
debug$2.debugFn('notice', `Scanning ${packageCount} packages`);
|
|
121
121
|
}
|
|
122
122
|
break;
|
|
123
123
|
case 'progress':
|
|
124
|
-
if (
|
|
125
|
-
|
|
124
|
+
if (debug$2.isDebug('silly') && packageCount) {
|
|
125
|
+
debug$2.debugFn('silly', `Scan progress: ${packageCount} packages processed`);
|
|
126
126
|
}
|
|
127
127
|
break;
|
|
128
128
|
case 'complete':
|
|
129
|
-
|
|
129
|
+
debug$2.debugFn('notice', `Scan complete${packageCount ? `: ${packageCount} packages` : ''}`);
|
|
130
130
|
break;
|
|
131
131
|
case 'error':
|
|
132
|
-
|
|
132
|
+
debug$2.debugDir('error', {
|
|
133
133
|
phase: 'scan_error',
|
|
134
134
|
details
|
|
135
135
|
});
|
|
@@ -142,14 +142,14 @@ function debugScan(phase, packageCount, details) {
|
|
|
142
142
|
*/
|
|
143
143
|
function debugConfig(source, found, error) {
|
|
144
144
|
if (error) {
|
|
145
|
-
|
|
145
|
+
debug$2.debugDir('warn', {
|
|
146
146
|
source,
|
|
147
147
|
error: error instanceof Error ? error.message : 'Unknown error'
|
|
148
148
|
});
|
|
149
149
|
} else if (found) {
|
|
150
|
-
|
|
151
|
-
} else if (
|
|
152
|
-
|
|
150
|
+
debug$2.debugFn('notice', `Config loaded: ${source}`);
|
|
151
|
+
} else if (debug$2.isDebug('silly')) {
|
|
152
|
+
debug$2.debugFn('silly', `Config not found: ${source}`);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
|
|
@@ -159,15 +159,15 @@ function debugConfig(source, found, error) {
|
|
|
159
159
|
*/
|
|
160
160
|
function debugGit(operation, success, details) {
|
|
161
161
|
if (!success) {
|
|
162
|
-
|
|
162
|
+
debug$2.debugDir('warn', {
|
|
163
163
|
git_op: operation,
|
|
164
164
|
...details
|
|
165
165
|
});
|
|
166
|
-
} else if (
|
|
166
|
+
} else if (debug$2.isDebug('notice') && operation.includes('push') || operation.includes('commit')) {
|
|
167
167
|
// Only log important operations like push and commit.
|
|
168
|
-
|
|
169
|
-
} else if (
|
|
170
|
-
|
|
168
|
+
debug$2.debugFn('notice', `Git ${operation} succeeded`);
|
|
169
|
+
} else if (debug$2.isDebug('silly')) {
|
|
170
|
+
debug$2.debugFn('silly', `Git ${operation}`);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
@@ -281,7 +281,7 @@ function shouldSave(currentContent, originalContent, originalFileContent, option
|
|
|
281
281
|
const sortedContent = sort ? sortKeys(content) : content;
|
|
282
282
|
const origContent = originalContent ? stripFormattingSymbols(originalContent) : {};
|
|
283
283
|
if (ignoreWhitespace) {
|
|
284
|
-
return !require$$
|
|
284
|
+
return !require$$10.isDeepStrictEqual(sortedContent, origContent);
|
|
285
285
|
}
|
|
286
286
|
const formatting = getFormattingFromContent(currentContent);
|
|
287
287
|
const newFileContent = stringifyWithFormatting(sortedContent, formatting);
|
|
@@ -298,7 +298,7 @@ async function retryWrite(filepath, content, retries = 3, baseDelay = 10) {
|
|
|
298
298
|
await fs.promises.writeFile(filepath, content);
|
|
299
299
|
if (process.platform === 'win32') {
|
|
300
300
|
// eslint-disable-next-line no-await-in-loop
|
|
301
|
-
await
|
|
301
|
+
await require$$7.setTimeout(50);
|
|
302
302
|
let accessRetries = 0;
|
|
303
303
|
const maxAccessRetries = 5;
|
|
304
304
|
while (accessRetries < maxAccessRetries) {
|
|
@@ -306,12 +306,12 @@ async function retryWrite(filepath, content, retries = 3, baseDelay = 10) {
|
|
|
306
306
|
// eslint-disable-next-line no-await-in-loop
|
|
307
307
|
await fs.promises.access(filepath);
|
|
308
308
|
// eslint-disable-next-line no-await-in-loop
|
|
309
|
-
await
|
|
309
|
+
await require$$7.setTimeout(10);
|
|
310
310
|
break;
|
|
311
311
|
} catch {
|
|
312
312
|
const delay = 20 * (accessRetries + 1);
|
|
313
313
|
// eslint-disable-next-line no-await-in-loop
|
|
314
|
-
await
|
|
314
|
+
await require$$7.setTimeout(delay);
|
|
315
315
|
accessRetries++;
|
|
316
316
|
}
|
|
317
317
|
}
|
|
@@ -325,7 +325,7 @@ async function retryWrite(filepath, content, retries = 3, baseDelay = 10) {
|
|
|
325
325
|
}
|
|
326
326
|
const delay = baseDelay * 2 ** attempt;
|
|
327
327
|
// eslint-disable-next-line no-await-in-loop
|
|
328
|
-
await
|
|
328
|
+
await require$$7.setTimeout(delay);
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
}
|
|
@@ -354,7 +354,7 @@ async function readFile(filepath) {
|
|
|
354
354
|
}
|
|
355
355
|
const delay = process.platform === 'win32' ? 50 * (attempt + 1) : 20;
|
|
356
356
|
// eslint-disable-next-line no-await-in-loop
|
|
357
|
-
await
|
|
357
|
+
await require$$7.setTimeout(delay);
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
throw new Error('Unreachable code');
|
|
@@ -525,7 +525,7 @@ class InputError extends Error {
|
|
|
525
525
|
async function captureException(exception, hint) {
|
|
526
526
|
const result = captureExceptionSync(exception, hint);
|
|
527
527
|
// "Sleep" for a second, just in case, hopefully enough time to initiate fetch.
|
|
528
|
-
await
|
|
528
|
+
await require$$7.setTimeout(1000);
|
|
529
529
|
return result;
|
|
530
530
|
}
|
|
531
531
|
function captureExceptionSync(exception, hint) {
|
|
@@ -533,7 +533,7 @@ function captureExceptionSync(exception, hint) {
|
|
|
533
533
|
if (!Sentry) {
|
|
534
534
|
return '';
|
|
535
535
|
}
|
|
536
|
-
|
|
536
|
+
debug$2.debugFn('notice', 'send: exception to Sentry');
|
|
537
537
|
return Sentry.captureException(exception, hint);
|
|
538
538
|
}
|
|
539
539
|
|
|
@@ -695,8 +695,8 @@ function findSocketYmlSync(dir = process.cwd()) {
|
|
|
695
695
|
}
|
|
696
696
|
};
|
|
697
697
|
} catch (e) {
|
|
698
|
-
|
|
699
|
-
|
|
698
|
+
debug$2.debugFn('error', `Failed to parse config file: ${ymlPath}`);
|
|
699
|
+
debug$2.debugDir('error', e);
|
|
700
700
|
return {
|
|
701
701
|
ok: false,
|
|
702
702
|
message: `Found file but was unable to parse ${ymlPath}`,
|
|
@@ -760,7 +760,7 @@ let _cachedConfig;
|
|
|
760
760
|
// When using --config or SOCKET_CLI_CONFIG, do not persist the config.
|
|
761
761
|
let _configFromFlag = false;
|
|
762
762
|
function overrideCachedConfig(jsonConfig) {
|
|
763
|
-
|
|
763
|
+
debug$2.debugFn('notice', 'override: full config (not stored)');
|
|
764
764
|
let config;
|
|
765
765
|
try {
|
|
766
766
|
config = JSON.parse(String(jsonConfig));
|
|
@@ -802,7 +802,7 @@ function overrideCachedConfig(jsonConfig) {
|
|
|
802
802
|
};
|
|
803
803
|
}
|
|
804
804
|
function overrideConfigApiToken(apiToken) {
|
|
805
|
-
|
|
805
|
+
debug$2.debugFn('notice', 'override: Socket API token (not stored)');
|
|
806
806
|
if (apiToken === undefined) {
|
|
807
807
|
// SOCKET_CLI_NO_API_TOKEN: operate with no token and lock the config to
|
|
808
808
|
// read-only so nothing is persisted for this run.
|
|
@@ -939,7 +939,7 @@ function updateConfigValue(configKey, value) {
|
|
|
939
939
|
* - Used for permission validation and help text
|
|
940
940
|
*/
|
|
941
941
|
|
|
942
|
-
const require$3 = require$$
|
|
942
|
+
const require$3 = require$$1.createRequire((typeof document === 'undefined' ? require$$0$1.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils.js', document.baseURI).href)));
|
|
943
943
|
let _requirements;
|
|
944
944
|
function getRequirements() {
|
|
945
945
|
if (_requirements === undefined) {
|
|
@@ -1003,14 +1003,14 @@ function getRequirementsKey(cmdPath) {
|
|
|
1003
1003
|
* Wraps debugFn to provide a simpler API.
|
|
1004
1004
|
*/
|
|
1005
1005
|
const debug$1 = message => {
|
|
1006
|
-
|
|
1006
|
+
debug$2.debugFn('socket:telemetry:service', message);
|
|
1007
1007
|
};
|
|
1008
1008
|
|
|
1009
1009
|
/**
|
|
1010
1010
|
* DebugDir wrapper for telemetry service.
|
|
1011
1011
|
*/
|
|
1012
1012
|
const debugDirWrapper = obj => {
|
|
1013
|
-
|
|
1013
|
+
debug$2.debugDir('socket:telemetry:service', obj);
|
|
1014
1014
|
};
|
|
1015
1015
|
|
|
1016
1016
|
/**
|
|
@@ -1375,7 +1375,7 @@ class TelemetryService {
|
|
|
1375
1375
|
* Debug wrapper for telemetry integration.
|
|
1376
1376
|
*/
|
|
1377
1377
|
const debug = message => {
|
|
1378
|
-
|
|
1378
|
+
debug$2.debugFn('socket:telemetry:integration', message);
|
|
1379
1379
|
};
|
|
1380
1380
|
|
|
1381
1381
|
/**
|
|
@@ -1824,6 +1824,20 @@ async function trackSubprocessError(command, startTime, error, exitCode, metadat
|
|
|
1824
1824
|
* - Includes CLI version and platform information
|
|
1825
1825
|
*/
|
|
1826
1826
|
|
|
1827
|
+
// SDK v4 rejects request timeouts outside this range (see the SDK's
|
|
1828
|
+
// MIN_HTTP_TIMEOUT / MAX_HTTP_TIMEOUT). The SDK does not re-export those
|
|
1829
|
+
// constants, so the bounds are mirrored here.
|
|
1830
|
+
const MIN_API_TIMEOUT_MS = 5_000;
|
|
1831
|
+
const MAX_API_TIMEOUT_MS = 300_000;
|
|
1832
|
+
|
|
1833
|
+
// Clamp a SOCKET_CLI_API_TIMEOUT value into the SDK's accepted range. The SDK
|
|
1834
|
+
// throws a TypeError on out-of-range timeouts, so an out-of-range user value
|
|
1835
|
+
// would otherwise make every API call fail; clamping preserves intent (a small
|
|
1836
|
+
// value maps to the floor, a huge value to the ceiling) while staying valid.
|
|
1837
|
+
function clampApiTimeout(timeout) {
|
|
1838
|
+
return Math.min(Math.max(timeout, MIN_API_TIMEOUT_MS), MAX_API_TIMEOUT_MS);
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1827
1841
|
// Lazy-evaluated full CLI user agent for direct (non-SDK) API calls.
|
|
1828
1842
|
// Includes the CLI product token, Node.js version, and OS platform/arch.
|
|
1829
1843
|
// e.g. "socket/1.1.96 node/v22.0.0 linux/arm64"
|
|
@@ -1843,13 +1857,13 @@ const TOKEN_VISIBLE_LENGTH = 5;
|
|
|
1843
1857
|
// The Socket API server that should be used for operations.
|
|
1844
1858
|
function getDefaultApiBaseUrl$1() {
|
|
1845
1859
|
const baseUrl = constants.default.ENV.SOCKET_CLI_API_BASE_URL || getConfigValueOrUndef(constants.CONFIG_KEY_API_BASE_URL);
|
|
1846
|
-
return
|
|
1860
|
+
return url.isUrl(baseUrl) ? baseUrl : undefined;
|
|
1847
1861
|
}
|
|
1848
1862
|
|
|
1849
1863
|
// The Socket API server that should be used for operations.
|
|
1850
1864
|
function getDefaultProxyUrl() {
|
|
1851
1865
|
const apiProxy = constants.default.ENV.SOCKET_CLI_API_PROXY || getConfigValueOrUndef(constants.CONFIG_KEY_API_PROXY);
|
|
1852
|
-
return
|
|
1866
|
+
return url.isUrl(apiProxy) ? apiProxy : undefined;
|
|
1853
1867
|
}
|
|
1854
1868
|
|
|
1855
1869
|
// Cached extra CA certificates for SSL_CERT_FILE support.
|
|
@@ -1882,7 +1896,7 @@ function getExtraCaCerts() {
|
|
|
1882
1896
|
_extraCaCerts = [...node_tls.rootCertificates, extraCerts];
|
|
1883
1897
|
return _extraCaCerts;
|
|
1884
1898
|
} catch (e) {
|
|
1885
|
-
|
|
1899
|
+
debug$2.debugFn('warn', `Failed to read certificate file: ${certPath}`, e);
|
|
1886
1900
|
return undefined;
|
|
1887
1901
|
}
|
|
1888
1902
|
}
|
|
@@ -1932,7 +1946,7 @@ async function setupSdk(options) {
|
|
|
1932
1946
|
let {
|
|
1933
1947
|
apiProxy
|
|
1934
1948
|
} = opts;
|
|
1935
|
-
if (!
|
|
1949
|
+
if (!url.isUrl(apiProxy)) {
|
|
1936
1950
|
apiProxy = getDefaultProxyUrl();
|
|
1937
1951
|
}
|
|
1938
1952
|
const {
|
|
@@ -1966,13 +1980,20 @@ async function setupSdk(options) {
|
|
|
1966
1980
|
ca
|
|
1967
1981
|
}
|
|
1968
1982
|
} : {})
|
|
1969
|
-
}) : isHttp ? new require$$
|
|
1983
|
+
}) : isHttp ? new require$$12.Agent() : new require$$13.Agent(ca ? {
|
|
1970
1984
|
ca
|
|
1971
1985
|
} : undefined),
|
|
1972
1986
|
...(apiBaseUrl ? {
|
|
1973
1987
|
baseUrl: apiBaseUrl
|
|
1974
1988
|
} : {}),
|
|
1975
|
-
timeout
|
|
1989
|
+
// SDK v4 validates the request timeout to be within [5000, 300000] ms and
|
|
1990
|
+
// throws otherwise. Only forward a truthy timeout; when unset (0) omit it
|
|
1991
|
+
// so the SDK applies its own default instead of rejecting the value. A
|
|
1992
|
+
// truthy-but-out-of-range value is clamped into the accepted range rather
|
|
1993
|
+
// than forwarded, which would make every SDK call throw.
|
|
1994
|
+
...(constants.default.ENV.SOCKET_CLI_API_TIMEOUT ? {
|
|
1995
|
+
timeout: clampApiTimeout(constants.default.ENV.SOCKET_CLI_API_TIMEOUT)
|
|
1996
|
+
} : {}),
|
|
1976
1997
|
userAgent: vendor.distExports.createUserAgentFromPkgJson({
|
|
1977
1998
|
name: constants.default.ENV.INLINED_SOCKET_CLI_NAME,
|
|
1978
1999
|
version: constants.default.ENV.INLINED_SOCKET_CLI_VERSION,
|
|
@@ -2078,9 +2099,9 @@ function getHttpsAgent() {
|
|
|
2078
2099
|
return _httpsAgent;
|
|
2079
2100
|
}
|
|
2080
2101
|
const ca = getExtraCaCerts();
|
|
2081
|
-
const agent = ca ? new require$$
|
|
2102
|
+
const agent = ca ? new require$$13.Agent({
|
|
2082
2103
|
ca
|
|
2083
|
-
}) : new require$$
|
|
2104
|
+
}) : new require$$13.Agent();
|
|
2084
2105
|
_httpsAgent = agent;
|
|
2085
2106
|
return agent;
|
|
2086
2107
|
}
|
|
@@ -2102,7 +2123,7 @@ function _httpsRequestFetch(url, init, agent, redirectCount) {
|
|
|
2102
2123
|
if (init.body) {
|
|
2103
2124
|
headers['content-length'] = String(Buffer.byteLength(init.body));
|
|
2104
2125
|
}
|
|
2105
|
-
const req = require$$
|
|
2126
|
+
const req = require$$13.request(url, {
|
|
2106
2127
|
method: init.method || 'GET',
|
|
2107
2128
|
headers,
|
|
2108
2129
|
agent
|
|
@@ -2251,6 +2272,26 @@ async function getErrorMessageForHttpStatusCode(code) {
|
|
|
2251
2272
|
}
|
|
2252
2273
|
return `Server responded with status code ${code}`;
|
|
2253
2274
|
}
|
|
2275
|
+
|
|
2276
|
+
/**
|
|
2277
|
+
* The subset of a Socket SDK result that {@link handleApiCall} reads. Both the
|
|
2278
|
+
* OpenAPI-derived `SocketSdkResult<T>` family and the SDK 4.x strict result
|
|
2279
|
+
* types (`OrganizationsResult`, `RepositoryResult`, `DeleteResult`, ...)
|
|
2280
|
+
* structurally satisfy this shape, so a caller can pass whichever result a
|
|
2281
|
+
* given SDK method returns without forcing a (sometimes stale) operation-key
|
|
2282
|
+
* shape onto the strict return types.
|
|
2283
|
+
*/
|
|
2284
|
+
|
|
2285
|
+
/**
|
|
2286
|
+
* The success `data` type carried by a Socket SDK result union `R`. The
|
|
2287
|
+
* conditional distributes over `R`'s members, so only the success member(s)
|
|
2288
|
+
* contribute their `data`; the error member resolves to `never` and drops out.
|
|
2289
|
+
* Inferring the whole result `R` and extracting here (rather than inferring a
|
|
2290
|
+
* bare `Data` from a `Promise<{ data: Data } | ...>`) avoids `Data` absorbing
|
|
2291
|
+
* the error branch's `data?: undefined` — which would otherwise widen every
|
|
2292
|
+
* result to `CResult<Data | undefined>`.
|
|
2293
|
+
*/
|
|
2294
|
+
|
|
2254
2295
|
/**
|
|
2255
2296
|
* Handle Socket SDK API calls with error handling and permission logging.
|
|
2256
2297
|
*/
|
|
@@ -2299,25 +2340,25 @@ async function handleApiCall(value, options) {
|
|
|
2299
2340
|
if (description && !silence) {
|
|
2300
2341
|
logger.logger.fail(`An error was thrown while requesting ${description}`);
|
|
2301
2342
|
}
|
|
2302
|
-
|
|
2343
|
+
debug$2.debugDir('inspect', {
|
|
2303
2344
|
socketSdkErrorResult
|
|
2304
2345
|
});
|
|
2305
2346
|
return socketSdkErrorResult;
|
|
2306
2347
|
}
|
|
2307
2348
|
|
|
2308
|
-
//
|
|
2349
|
+
// The `success` discriminant is a concrete boolean literal in both branches,
|
|
2350
|
+
// so this narrows the result to its error branch regardless of `R`.
|
|
2309
2351
|
if (sdkResult.success === false) {
|
|
2310
2352
|
const endpoint = description || 'Socket API';
|
|
2311
2353
|
debugApiResponse('API', endpoint, sdkResult.status);
|
|
2312
|
-
|
|
2354
|
+
debug$2.debugDir('inspect', {
|
|
2313
2355
|
sdkResult
|
|
2314
2356
|
});
|
|
2315
|
-
const
|
|
2316
|
-
const errStr = errCResult.error ? String(errCResult.error).trim() : '';
|
|
2357
|
+
const errStr = sdkResult.error ? String(sdkResult.error).trim() : '';
|
|
2317
2358
|
const message = errStr || NO_ERROR_MESSAGE;
|
|
2318
|
-
const reason =
|
|
2359
|
+
const reason = sdkResult.cause || NO_ERROR_MESSAGE;
|
|
2319
2360
|
const baseCause = reason && message !== reason ? `${message} (reason: ${reason})` : message;
|
|
2320
|
-
const cause =
|
|
2361
|
+
const cause = sdkResult.url ? `${baseCause} (url: ${sdkResult.url})` : baseCause;
|
|
2321
2362
|
const socketSdkErrorResult = {
|
|
2322
2363
|
ok: false,
|
|
2323
2364
|
message: 'Socket API error',
|
|
@@ -2333,6 +2374,9 @@ async function handleApiCall(value, options) {
|
|
|
2333
2374
|
}
|
|
2334
2375
|
return socketSdkErrorResult;
|
|
2335
2376
|
}
|
|
2377
|
+
// Narrowing a type parameter by its `success` discriminant resolves `.data`
|
|
2378
|
+
// through the constraint's success branch (`unknown`); re-apply the precise
|
|
2379
|
+
// per-call success type the return contract already guarantees.
|
|
2336
2380
|
const socketSdkSuccessResult = {
|
|
2337
2381
|
ok: true,
|
|
2338
2382
|
data: sdkResult.data
|
|
@@ -2344,8 +2388,8 @@ async function handleApiCallNoSpinner(value, description) {
|
|
|
2344
2388
|
try {
|
|
2345
2389
|
sdkResult = await value;
|
|
2346
2390
|
} catch (e) {
|
|
2347
|
-
|
|
2348
|
-
|
|
2391
|
+
debug$2.debugFn('error', `API request failed: ${description}`);
|
|
2392
|
+
debug$2.debugDir('error', e);
|
|
2349
2393
|
const errStr = e ? String(e).trim() : '';
|
|
2350
2394
|
const message = 'Socket API error';
|
|
2351
2395
|
const rawCause = errStr || NO_ERROR_MESSAGE;
|
|
@@ -2359,18 +2403,18 @@ async function handleApiCallNoSpinner(value, description) {
|
|
|
2359
2403
|
};
|
|
2360
2404
|
}
|
|
2361
2405
|
|
|
2362
|
-
//
|
|
2406
|
+
// The `success` discriminant is a concrete boolean literal in both branches,
|
|
2407
|
+
// so this narrows the result to its error branch regardless of `R`.
|
|
2363
2408
|
if (sdkResult.success === false) {
|
|
2364
|
-
|
|
2365
|
-
|
|
2409
|
+
debug$2.debugFn('error', `fail: ${description} bad response`);
|
|
2410
|
+
debug$2.debugDir('inspect', {
|
|
2366
2411
|
sdkResult
|
|
2367
2412
|
});
|
|
2368
|
-
const
|
|
2369
|
-
const errStr = sdkErrorResult.error ? String(sdkErrorResult.error).trim() : '';
|
|
2413
|
+
const errStr = sdkResult.error ? String(sdkResult.error).trim() : '';
|
|
2370
2414
|
const message = errStr || NO_ERROR_MESSAGE;
|
|
2371
|
-
const reason =
|
|
2415
|
+
const reason = sdkResult.cause || NO_ERROR_MESSAGE;
|
|
2372
2416
|
const baseCause = reason && message !== reason ? `${message} (reason: ${reason})` : message;
|
|
2373
|
-
const cause =
|
|
2417
|
+
const cause = sdkResult.url ? `${baseCause} (url: ${sdkResult.url})` : baseCause;
|
|
2374
2418
|
return {
|
|
2375
2419
|
ok: false,
|
|
2376
2420
|
message: 'Socket API error',
|
|
@@ -2380,10 +2424,12 @@ async function handleApiCallNoSpinner(value, description) {
|
|
|
2380
2424
|
}
|
|
2381
2425
|
};
|
|
2382
2426
|
} else {
|
|
2383
|
-
|
|
2427
|
+
// Narrowing a type parameter by its `success` discriminant resolves `.data`
|
|
2428
|
+
// through the constraint's success branch (`unknown`); re-apply the precise
|
|
2429
|
+
// per-call success type the return contract already guarantees.
|
|
2384
2430
|
return {
|
|
2385
2431
|
ok: true,
|
|
2386
|
-
data:
|
|
2432
|
+
data: sdkResult.data
|
|
2387
2433
|
};
|
|
2388
2434
|
}
|
|
2389
2435
|
}
|
|
@@ -2402,11 +2448,13 @@ async function queryApi(path, apiToken) {
|
|
|
2402
2448
|
});
|
|
2403
2449
|
return result;
|
|
2404
2450
|
}
|
|
2405
|
-
|
|
2406
2451
|
/**
|
|
2407
|
-
* Query Socket API endpoint and return
|
|
2452
|
+
* Query a Socket API endpoint and return the HTTP status alongside the text
|
|
2453
|
+
* body, with error handling. Unlike queryApiSafeText this surfaces the status
|
|
2454
|
+
* on success (including 2xx statuses like 202 Accepted), so callers can drive
|
|
2455
|
+
* status-dependent flows such as the cached-scan 202 poll loop.
|
|
2408
2456
|
*/
|
|
2409
|
-
async function
|
|
2457
|
+
async function queryApiSafeTextWithStatus(path, description, commandPath) {
|
|
2410
2458
|
const apiToken = getDefaultApiToken();
|
|
2411
2459
|
if (!apiToken) {
|
|
2412
2460
|
return {
|
|
@@ -2437,8 +2485,8 @@ async function queryApiSafeText(path, description, commandPath) {
|
|
|
2437
2485
|
spinner.failAndStop(`An error was thrown while requesting ${description}.`);
|
|
2438
2486
|
debugApiResponse('GET', path, undefined, e, duration);
|
|
2439
2487
|
}
|
|
2440
|
-
|
|
2441
|
-
|
|
2488
|
+
debug$2.debugFn('error', 'Query API request failed');
|
|
2489
|
+
debug$2.debugDir('error', e);
|
|
2442
2490
|
const errStr = e ? String(e).trim() : '';
|
|
2443
2491
|
const message = 'API request failed';
|
|
2444
2492
|
const rawCause = errStr || NO_ERROR_MESSAGE;
|
|
@@ -2464,14 +2512,17 @@ async function queryApiSafeText(path, description, commandPath) {
|
|
|
2464
2512
|
};
|
|
2465
2513
|
}
|
|
2466
2514
|
try {
|
|
2467
|
-
const
|
|
2515
|
+
const text = await result.text();
|
|
2468
2516
|
return {
|
|
2469
2517
|
ok: true,
|
|
2470
|
-
data
|
|
2518
|
+
data: {
|
|
2519
|
+
status: result.status,
|
|
2520
|
+
text
|
|
2521
|
+
}
|
|
2471
2522
|
};
|
|
2472
2523
|
} catch (e) {
|
|
2473
|
-
|
|
2474
|
-
|
|
2524
|
+
debug$2.debugFn('error', 'Failed to read API response text');
|
|
2525
|
+
debug$2.debugDir('error', e);
|
|
2475
2526
|
return {
|
|
2476
2527
|
ok: false,
|
|
2477
2528
|
message: 'API request failed',
|
|
@@ -2480,6 +2531,17 @@ async function queryApiSafeText(path, description, commandPath) {
|
|
|
2480
2531
|
}
|
|
2481
2532
|
}
|
|
2482
2533
|
|
|
2534
|
+
/**
|
|
2535
|
+
* Query Socket API endpoint and return text response with error handling.
|
|
2536
|
+
*/
|
|
2537
|
+
async function queryApiSafeText(path, description, commandPath) {
|
|
2538
|
+
const result = await queryApiSafeTextWithStatus(path, description);
|
|
2539
|
+
return result.ok ? {
|
|
2540
|
+
ok: true,
|
|
2541
|
+
data: result.data.text
|
|
2542
|
+
} : result;
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2483
2545
|
/**
|
|
2484
2546
|
* Query Socket API endpoint and return parsed JSON response.
|
|
2485
2547
|
*/
|
|
@@ -2557,8 +2619,8 @@ async function sendApiRequest(path, options) {
|
|
|
2557
2619
|
if (description) {
|
|
2558
2620
|
spinner.failAndStop(`An error was thrown while requesting ${description}.`);
|
|
2559
2621
|
}
|
|
2560
|
-
|
|
2561
|
-
|
|
2622
|
+
debug$2.debugFn('error', `API ${method} request failed`);
|
|
2623
|
+
debug$2.debugDir('error', e);
|
|
2562
2624
|
const errStr = e ? String(e).trim() : '';
|
|
2563
2625
|
const message = 'API request failed';
|
|
2564
2626
|
const rawCause = errStr || NO_ERROR_MESSAGE;
|
|
@@ -2594,8 +2656,8 @@ async function sendApiRequest(path, options) {
|
|
|
2594
2656
|
data: data
|
|
2595
2657
|
};
|
|
2596
2658
|
} catch (e) {
|
|
2597
|
-
|
|
2598
|
-
|
|
2659
|
+
debug$2.debugFn('error', 'Failed to parse API response JSON');
|
|
2660
|
+
debug$2.debugDir('error', e);
|
|
2599
2661
|
return {
|
|
2600
2662
|
ok: false,
|
|
2601
2663
|
message: 'API request failed',
|
|
@@ -2726,9 +2788,9 @@ cols) {
|
|
|
2726
2788
|
// Serialize the final result object before printing it
|
|
2727
2789
|
// All commands that support the --json flag should call this before printing
|
|
2728
2790
|
function serializeResultJson(data) {
|
|
2729
|
-
if (!
|
|
2791
|
+
if (!objects.isObject(data)) {
|
|
2730
2792
|
process.exitCode = 1;
|
|
2731
|
-
|
|
2793
|
+
debug$2.debugFn('inspect', {
|
|
2732
2794
|
data
|
|
2733
2795
|
});
|
|
2734
2796
|
|
|
@@ -2746,8 +2808,8 @@ function serializeResultJson(data) {
|
|
|
2746
2808
|
process.exitCode = 1;
|
|
2747
2809
|
const message = 'There was a problem converting the data set to JSON. Please try again without --json';
|
|
2748
2810
|
logger.logger.fail(message);
|
|
2749
|
-
|
|
2750
|
-
|
|
2811
|
+
debug$2.debugFn('error', 'JSON serialization failed');
|
|
2812
|
+
debug$2.debugDir('error', e);
|
|
2751
2813
|
|
|
2752
2814
|
// This could be caused by circular references, which is an "us" problem.
|
|
2753
2815
|
return `${JSON.stringify({
|
|
@@ -3012,7 +3074,7 @@ function getHelpListOutput(list, options) {
|
|
|
3012
3074
|
const names = Object.keys(list).sort(sorts.naturalCompare);
|
|
3013
3075
|
for (const name of names) {
|
|
3014
3076
|
const entry = list[name];
|
|
3015
|
-
const entryIsObj =
|
|
3077
|
+
const entryIsObj = objects.isObject(entry);
|
|
3016
3078
|
if (entryIsObj && 'hidden' in entry && entry?.hidden) {
|
|
3017
3079
|
continue;
|
|
3018
3080
|
}
|
|
@@ -3110,9 +3172,9 @@ function getAsciiHeader(command, orgFlag, compactMode = false) {
|
|
|
3110
3172
|
// Version display: show hash in debug mode, otherwise show semantic version.
|
|
3111
3173
|
const fullVersion = constants.default.ENV.INLINED_SOCKET_CLI_VERSION;
|
|
3112
3174
|
const versionHash = constants.default.ENV.INLINED_SOCKET_CLI_VERSION_HASH;
|
|
3113
|
-
const cliVersion = redacting ? REDACTED :
|
|
3175
|
+
const cliVersion = redacting ? REDACTED : debug$2.isDebug() ? versionHash : `v${fullVersion}`;
|
|
3114
3176
|
const nodeVersion = redacting ? REDACTED : process.version;
|
|
3115
|
-
const showNodeVersion = !redacting &&
|
|
3177
|
+
const showNodeVersion = !redacting && debug$2.isDebug();
|
|
3116
3178
|
const defaultOrg = getConfigValueOrUndef(constants.CONFIG_KEY_DEFAULT_ORG);
|
|
3117
3179
|
const configFromFlagDot = isConfigFromFlag() ? '*' : '.';
|
|
3118
3180
|
|
|
@@ -3230,7 +3292,7 @@ async function meowWithSubcommands(config, options) {
|
|
|
3230
3292
|
hidden: true,
|
|
3231
3293
|
description: 'Print the app version'
|
|
3232
3294
|
},
|
|
3233
|
-
...
|
|
3295
|
+
...objects.getOwn(additionalOptions, 'flags')
|
|
3234
3296
|
};
|
|
3235
3297
|
const [commandOrAliasName_, ...rawCommandArgv] = argv;
|
|
3236
3298
|
let commandOrAliasName = commandOrAliasName_;
|
|
@@ -3265,7 +3327,7 @@ async function meowWithSubcommands(config, options) {
|
|
|
3265
3327
|
}
|
|
3266
3328
|
}
|
|
3267
3329
|
if (isRootCommand) {
|
|
3268
|
-
const hiddenDebugFlag = !
|
|
3330
|
+
const hiddenDebugFlag = !debug$2.isDebug();
|
|
3269
3331
|
flags$1['compactHeader'] = {
|
|
3270
3332
|
...flags$1['compactHeader'],
|
|
3271
3333
|
hidden: false
|
|
@@ -3328,7 +3390,7 @@ async function meowWithSubcommands(config, options) {
|
|
|
3328
3390
|
spinner: spinnerFlag
|
|
3329
3391
|
} = cli1.flags;
|
|
3330
3392
|
const compactMode = compactHeaderFlag || constants.default.ENV.CI && !constants.default.ENV.VITEST;
|
|
3331
|
-
const noSpinner = spinnerFlag === false ||
|
|
3393
|
+
const noSpinner = spinnerFlag === false || debug$2.isDebug();
|
|
3332
3394
|
|
|
3333
3395
|
// Use CI spinner style when --no-spinner is passed or debug mode is enabled.
|
|
3334
3396
|
// This prevents the spinner from interfering with debug output.
|
|
@@ -3428,10 +3490,10 @@ async function meowWithSubcommands(config, options) {
|
|
|
3428
3490
|
} else {
|
|
3429
3491
|
lines.push('Commands');
|
|
3430
3492
|
lines.push(` ${getHelpListOutput({
|
|
3431
|
-
...
|
|
3493
|
+
...objects.toSortedObject(Object.fromEntries(Object.entries(subcommands).filter(({
|
|
3432
3494
|
1: subcommand
|
|
3433
3495
|
}) => !subcommand.hidden))),
|
|
3434
|
-
...
|
|
3496
|
+
...objects.toSortedObject(Object.fromEntries(Object.entries(aliases).filter(({
|
|
3435
3497
|
1: alias
|
|
3436
3498
|
}) => {
|
|
3437
3499
|
const {
|
|
@@ -3576,7 +3638,7 @@ function meowOrExit(config, options) {
|
|
|
3576
3638
|
version: versionFlag
|
|
3577
3639
|
} = cli.flags;
|
|
3578
3640
|
const compactMode = compactHeaderFlag || constants.default.ENV.CI && !constants.default.ENV.VITEST;
|
|
3579
|
-
const noSpinner = spinnerFlag === false ||
|
|
3641
|
+
const noSpinner = spinnerFlag === false || debug$2.isDebug();
|
|
3580
3642
|
|
|
3581
3643
|
// Use CI spinner style when --no-spinner is passed.
|
|
3582
3644
|
// This prevents the spinner from interfering with debug output.
|
|
@@ -3613,7 +3675,7 @@ function meowOrExit(config, options) {
|
|
|
3613
3675
|
}
|
|
3614
3676
|
|
|
3615
3677
|
// Meow doesn't detect 'version' as an unknown flag, so we do the leg work here.
|
|
3616
|
-
if (versionFlag && !
|
|
3678
|
+
if (versionFlag && !objects.hasOwn(cliConfig.flags, 'version')) {
|
|
3617
3679
|
// Use `console.error` here instead of `logger.error` to match Meow behavior.
|
|
3618
3680
|
console.error('Unknown flag\n--version');
|
|
3619
3681
|
// eslint-disable-next-line n/no-process-exit
|
|
@@ -3684,7 +3746,7 @@ async function fetchOrganization(options) {
|
|
|
3684
3746
|
}
|
|
3685
3747
|
sockSdk = sockSdkCResult.data;
|
|
3686
3748
|
}
|
|
3687
|
-
const orgsCResult = await handleApiCall(sockSdk.
|
|
3749
|
+
const orgsCResult = await handleApiCall(sockSdk.listOrganizations(), {
|
|
3688
3750
|
description,
|
|
3689
3751
|
silence
|
|
3690
3752
|
});
|
|
@@ -3813,7 +3875,7 @@ async function determineOrgSlug(orgFlag, interactive, dryRun) {
|
|
|
3813
3875
|
async function getDefaultOrgSlug(silence) {
|
|
3814
3876
|
const defaultOrgResult = getConfigValueOrUndef('defaultOrg');
|
|
3815
3877
|
if (defaultOrgResult) {
|
|
3816
|
-
|
|
3878
|
+
debug$2.debugFn('notice', 'use: org from "defaultOrg" value of socket/settings local app data', defaultOrgResult);
|
|
3817
3879
|
return {
|
|
3818
3880
|
ok: true,
|
|
3819
3881
|
data: defaultOrgResult
|
|
@@ -3821,7 +3883,7 @@ async function getDefaultOrgSlug(silence) {
|
|
|
3821
3883
|
}
|
|
3822
3884
|
const envOrgSlug = constants.default.ENV.SOCKET_CLI_ORG_SLUG;
|
|
3823
3885
|
if (envOrgSlug) {
|
|
3824
|
-
|
|
3886
|
+
debug$2.debugFn('notice', 'use: org from SOCKET_CLI_ORG_SLUG environment variable', envOrgSlug);
|
|
3825
3887
|
return {
|
|
3826
3888
|
ok: true,
|
|
3827
3889
|
data: envOrgSlug
|
|
@@ -3857,7 +3919,7 @@ async function getDefaultOrgSlug(silence) {
|
|
|
3857
3919
|
data: `Cannot determine the default organization for the API token. Unable to continue.`
|
|
3858
3920
|
};
|
|
3859
3921
|
}
|
|
3860
|
-
|
|
3922
|
+
debug$2.debugFn('notice', 'resolve: org from Socket API', slug);
|
|
3861
3923
|
return {
|
|
3862
3924
|
ok: true,
|
|
3863
3925
|
message: 'Retrieved default org from server',
|
|
@@ -3994,14 +4056,14 @@ async function getRepoInfo(cwd = process.cwd()) {
|
|
|
3994
4056
|
})).stdout;
|
|
3995
4057
|
info = parseGitRemoteUrl(remoteUrl);
|
|
3996
4058
|
if (!info) {
|
|
3997
|
-
|
|
3998
|
-
|
|
4059
|
+
debug$2.debugFn('warn', `Unmatched git remote URL format: ${remoteUrl}`);
|
|
4060
|
+
debug$2.debugDir('warn', {
|
|
3999
4061
|
remoteUrl
|
|
4000
4062
|
});
|
|
4001
4063
|
}
|
|
4002
4064
|
} catch (e) {
|
|
4003
4065
|
// Expected failure when not in a git repo.
|
|
4004
|
-
|
|
4066
|
+
debug$2.debugDir('inspect', {
|
|
4005
4067
|
message: 'git remote get-url failed',
|
|
4006
4068
|
error: e
|
|
4007
4069
|
});
|
|
@@ -4027,7 +4089,7 @@ async function gitBranch(cwd = process.cwd()) {
|
|
|
4027
4089
|
return gitSymbolicRefResult.stdout;
|
|
4028
4090
|
} catch (e) {
|
|
4029
4091
|
// Expected in detached HEAD state, fallback to rev-parse.
|
|
4030
|
-
|
|
4092
|
+
debug$2.debugDir('inspect', {
|
|
4031
4093
|
message: 'In detached HEAD state',
|
|
4032
4094
|
error: e
|
|
4033
4095
|
});
|
|
@@ -4039,7 +4101,7 @@ async function gitBranch(cwd = process.cwd()) {
|
|
|
4039
4101
|
return gitRevParseResult.stdout;
|
|
4040
4102
|
} catch (e) {
|
|
4041
4103
|
// Both methods failed, likely not in a git repo.
|
|
4042
|
-
|
|
4104
|
+
debug$2.debugDir('inspect', {
|
|
4043
4105
|
message: 'Unable to determine git branch',
|
|
4044
4106
|
error: e
|
|
4045
4107
|
});
|
|
@@ -4071,7 +4133,7 @@ async function detectDefaultBranch(cwd = process.cwd()) {
|
|
|
4071
4133
|
async function gitCleanFdx(cwd = process.cwd()) {
|
|
4072
4134
|
const stdioIgnoreOptions = {
|
|
4073
4135
|
cwd,
|
|
4074
|
-
stdio:
|
|
4136
|
+
stdio: debug$2.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
4075
4137
|
};
|
|
4076
4138
|
try {
|
|
4077
4139
|
await spawn.spawn('git', ['clean', '-fdx'], stdioIgnoreOptions);
|
|
@@ -4087,7 +4149,7 @@ async function gitCleanFdx(cwd = process.cwd()) {
|
|
|
4087
4149
|
async function gitCheckoutBranch(branch, cwd = process.cwd()) {
|
|
4088
4150
|
const stdioIgnoreOptions = {
|
|
4089
4151
|
cwd,
|
|
4090
|
-
stdio:
|
|
4152
|
+
stdio: debug$2.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
4091
4153
|
};
|
|
4092
4154
|
try {
|
|
4093
4155
|
await spawn.spawn('git', ['checkout', branch], stdioIgnoreOptions);
|
|
@@ -4106,7 +4168,7 @@ async function gitCreateBranch(branch, cwd = process.cwd()) {
|
|
|
4106
4168
|
}
|
|
4107
4169
|
const stdioIgnoreOptions = {
|
|
4108
4170
|
cwd,
|
|
4109
|
-
stdio:
|
|
4171
|
+
stdio: debug$2.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
4110
4172
|
};
|
|
4111
4173
|
try {
|
|
4112
4174
|
await spawn.spawn('git', ['branch', branch], stdioIgnoreOptions);
|
|
@@ -4122,7 +4184,7 @@ async function gitCreateBranch(branch, cwd = process.cwd()) {
|
|
|
4122
4184
|
async function gitPushBranch(branch, cwd = process.cwd()) {
|
|
4123
4185
|
const stdioIgnoreOptions = {
|
|
4124
4186
|
cwd,
|
|
4125
|
-
stdio:
|
|
4187
|
+
stdio: debug$2.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
4126
4188
|
};
|
|
4127
4189
|
try {
|
|
4128
4190
|
await spawn.spawn('git', ['push', '--force', '--set-upstream', 'origin', branch], stdioIgnoreOptions);
|
|
@@ -4130,9 +4192,9 @@ async function gitPushBranch(branch, cwd = process.cwd()) {
|
|
|
4130
4192
|
return true;
|
|
4131
4193
|
} catch (e) {
|
|
4132
4194
|
if (spawn.isSpawnError(e) && e.code === 128) {
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4195
|
+
debug$2.debugFn('error', "Push denied: token requires write permissions for 'contents' and 'pull-requests'");
|
|
4196
|
+
debug$2.debugDir('error', e);
|
|
4197
|
+
debug$2.debugDir('inspect', {
|
|
4136
4198
|
branch
|
|
4137
4199
|
});
|
|
4138
4200
|
} else {
|
|
@@ -4145,7 +4207,7 @@ async function gitPushBranch(branch, cwd = process.cwd()) {
|
|
|
4145
4207
|
}
|
|
4146
4208
|
async function gitCommit(commitMsg, filepaths, options) {
|
|
4147
4209
|
if (!filepaths.length) {
|
|
4148
|
-
|
|
4210
|
+
debug$2.debugFn('notice', `miss: no filepaths to add`);
|
|
4149
4211
|
return false;
|
|
4150
4212
|
}
|
|
4151
4213
|
const {
|
|
@@ -4159,7 +4221,7 @@ async function gitCommit(commitMsg, filepaths, options) {
|
|
|
4159
4221
|
await gitEnsureIdentity(user, email, cwd);
|
|
4160
4222
|
const stdioIgnoreOptions = {
|
|
4161
4223
|
cwd,
|
|
4162
|
-
stdio:
|
|
4224
|
+
stdio: debug$2.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
4163
4225
|
};
|
|
4164
4226
|
try {
|
|
4165
4227
|
await spawn.spawn('git', ['add', ...filepaths], stdioIgnoreOptions);
|
|
@@ -4170,7 +4232,7 @@ async function gitCommit(commitMsg, filepaths, options) {
|
|
|
4170
4232
|
debugGit('add', false, {
|
|
4171
4233
|
error: e
|
|
4172
4234
|
});
|
|
4173
|
-
|
|
4235
|
+
debug$2.debugDir('inspect', {
|
|
4174
4236
|
filepaths
|
|
4175
4237
|
});
|
|
4176
4238
|
return false;
|
|
@@ -4183,7 +4245,7 @@ async function gitCommit(commitMsg, filepaths, options) {
|
|
|
4183
4245
|
debugGit('commit', false, {
|
|
4184
4246
|
error: e
|
|
4185
4247
|
});
|
|
4186
|
-
|
|
4248
|
+
debug$2.debugDir('inspect', {
|
|
4187
4249
|
commitMsg
|
|
4188
4250
|
});
|
|
4189
4251
|
}
|
|
@@ -4192,7 +4254,7 @@ async function gitCommit(commitMsg, filepaths, options) {
|
|
|
4192
4254
|
async function gitDeleteBranch(branch, cwd = process.cwd()) {
|
|
4193
4255
|
const stdioIgnoreOptions = {
|
|
4194
4256
|
cwd,
|
|
4195
|
-
stdio:
|
|
4257
|
+
stdio: debug$2.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
4196
4258
|
};
|
|
4197
4259
|
try {
|
|
4198
4260
|
// Will throw with exit code 1 if branch does not exist.
|
|
@@ -4200,7 +4262,7 @@ async function gitDeleteBranch(branch, cwd = process.cwd()) {
|
|
|
4200
4262
|
return true;
|
|
4201
4263
|
} catch (e) {
|
|
4202
4264
|
// Expected failure when branch doesn't exist.
|
|
4203
|
-
|
|
4265
|
+
debug$2.debugDir('inspect', {
|
|
4204
4266
|
message: `Branch deletion failed (may not exist): ${branch}`,
|
|
4205
4267
|
error: e
|
|
4206
4268
|
});
|
|
@@ -4210,7 +4272,7 @@ async function gitDeleteBranch(branch, cwd = process.cwd()) {
|
|
|
4210
4272
|
async function gitDeleteRemoteBranch(branch, cwd = process.cwd()) {
|
|
4211
4273
|
const stdioIgnoreOptions = {
|
|
4212
4274
|
cwd,
|
|
4213
|
-
stdio:
|
|
4275
|
+
stdio: debug$2.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
4214
4276
|
};
|
|
4215
4277
|
try {
|
|
4216
4278
|
// Will throw with exit code 1 if branch does not exist.
|
|
@@ -4218,7 +4280,7 @@ async function gitDeleteRemoteBranch(branch, cwd = process.cwd()) {
|
|
|
4218
4280
|
return true;
|
|
4219
4281
|
} catch (e) {
|
|
4220
4282
|
// Expected failure when remote branch doesn't exist.
|
|
4221
|
-
|
|
4283
|
+
debug$2.debugDir('inspect', {
|
|
4222
4284
|
message: `Remote branch deletion failed (may not exist): ${branch}`,
|
|
4223
4285
|
error: e
|
|
4224
4286
|
});
|
|
@@ -4241,7 +4303,7 @@ async function gitEnsureIdentity(name, email, cwd = process.cwd()) {
|
|
|
4241
4303
|
configValue = gitConfigResult.stdout;
|
|
4242
4304
|
} catch (e) {
|
|
4243
4305
|
// Expected when config property is not set.
|
|
4244
|
-
|
|
4306
|
+
debug$2.debugDir('inspect', {
|
|
4245
4307
|
message: `Git config property not set: ${prop}`,
|
|
4246
4308
|
error: e
|
|
4247
4309
|
});
|
|
@@ -4249,14 +4311,14 @@ async function gitEnsureIdentity(name, email, cwd = process.cwd()) {
|
|
|
4249
4311
|
if (configValue !== value) {
|
|
4250
4312
|
const stdioIgnoreOptions = {
|
|
4251
4313
|
cwd,
|
|
4252
|
-
stdio:
|
|
4314
|
+
stdio: debug$2.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
4253
4315
|
};
|
|
4254
4316
|
try {
|
|
4255
4317
|
await spawn.spawn('git', ['config', prop, value], stdioIgnoreOptions);
|
|
4256
4318
|
} catch (e) {
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4319
|
+
debug$2.debugFn('warn', `Failed to set git config: ${prop}`);
|
|
4320
|
+
debug$2.debugDir('warn', e);
|
|
4321
|
+
debug$2.debugDir('inspect', {
|
|
4260
4322
|
value
|
|
4261
4323
|
});
|
|
4262
4324
|
}
|
|
@@ -4266,7 +4328,7 @@ async function gitEnsureIdentity(name, email, cwd = process.cwd()) {
|
|
|
4266
4328
|
async function gitLocalBranchExists(branch, cwd = process.cwd()) {
|
|
4267
4329
|
const stdioIgnoreOptions = {
|
|
4268
4330
|
cwd,
|
|
4269
|
-
stdio:
|
|
4331
|
+
stdio: debug$2.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
4270
4332
|
};
|
|
4271
4333
|
try {
|
|
4272
4334
|
// Will throw with exit code 1 if the branch does not exist.
|
|
@@ -4286,7 +4348,7 @@ async function gitRemoteBranchExists(branch, cwd = process.cwd()) {
|
|
|
4286
4348
|
return lsRemoteResult.stdout.length > 0;
|
|
4287
4349
|
} catch (e) {
|
|
4288
4350
|
// Expected when remote is not accessible or branch doesn't exist.
|
|
4289
|
-
|
|
4351
|
+
debug$2.debugDir('inspect', {
|
|
4290
4352
|
message: `Remote branch check failed: ${branch}`,
|
|
4291
4353
|
error: e
|
|
4292
4354
|
});
|
|
@@ -4302,7 +4364,7 @@ async function gitResetAndClean(branch = 'HEAD', cwd = process.cwd()) {
|
|
|
4302
4364
|
async function gitResetHard(branch = 'HEAD', cwd = process.cwd()) {
|
|
4303
4365
|
const stdioIgnoreOptions = {
|
|
4304
4366
|
cwd,
|
|
4305
|
-
stdio:
|
|
4367
|
+
stdio: debug$2.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
4306
4368
|
};
|
|
4307
4369
|
try {
|
|
4308
4370
|
await spawn.spawn('git', ['reset', '--hard', branch], stdioIgnoreOptions);
|
|
@@ -4328,8 +4390,8 @@ async function gitUnstagedModifiedFiles(cwd = process.cwd()) {
|
|
|
4328
4390
|
data: relPaths.map(p => path$1.normalizePath(p))
|
|
4329
4391
|
};
|
|
4330
4392
|
} catch (e) {
|
|
4331
|
-
|
|
4332
|
-
|
|
4393
|
+
debug$2.debugFn('error', 'Failed to get unstaged modified files');
|
|
4394
|
+
debug$2.debugDir('error', e);
|
|
4333
4395
|
return {
|
|
4334
4396
|
ok: false,
|
|
4335
4397
|
message: 'Git Error',
|
|
@@ -4691,14 +4753,14 @@ function pathsToGlobPatterns(paths, cwd) {
|
|
|
4691
4753
|
|
|
4692
4754
|
function createPurlObject(type, name, options) {
|
|
4693
4755
|
let opts;
|
|
4694
|
-
if (
|
|
4756
|
+
if (objects.isObjectObject(type)) {
|
|
4695
4757
|
opts = {
|
|
4696
4758
|
__proto__: null,
|
|
4697
4759
|
...type
|
|
4698
4760
|
};
|
|
4699
4761
|
type = opts.type;
|
|
4700
4762
|
name = opts.name;
|
|
4701
|
-
} else if (
|
|
4763
|
+
} else if (objects.isObjectObject(name)) {
|
|
4702
4764
|
opts = {
|
|
4703
4765
|
__proto__: null,
|
|
4704
4766
|
...name
|
|
@@ -4895,7 +4957,7 @@ async function compressSocketFactsForUpload(scanPaths) {
|
|
|
4895
4957
|
// `rm({ force: true })` no-ops on missing files, so tracking before
|
|
4896
4958
|
// creation is safe.
|
|
4897
4959
|
brPaths.push(brPath);
|
|
4898
|
-
await
|
|
4960
|
+
await require$$9.pipeline(fs.createReadStream(p), require$$11.createBrotliCompress(), fs.createWriteStream(brPath));
|
|
4899
4961
|
return brPath;
|
|
4900
4962
|
}));
|
|
4901
4963
|
const failure = results.find(r => r.status === 'rejected');
|
|
@@ -5013,6 +5075,17 @@ async function findUp(name, options) {
|
|
|
5013
5075
|
}
|
|
5014
5076
|
return undefined;
|
|
5015
5077
|
}
|
|
5078
|
+
async function withTmpDir(prefix, fn) {
|
|
5079
|
+
const tmpDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), prefix));
|
|
5080
|
+
try {
|
|
5081
|
+
return await fn(tmpDir);
|
|
5082
|
+
} finally {
|
|
5083
|
+
await fs.promises.rm(tmpDir, {
|
|
5084
|
+
recursive: true,
|
|
5085
|
+
force: true
|
|
5086
|
+
}).catch(() => {});
|
|
5087
|
+
}
|
|
5088
|
+
}
|
|
5016
5089
|
|
|
5017
5090
|
function findBinPathDetailsSync(binName) {
|
|
5018
5091
|
const rawBinPaths = bin.whichBinSync(binName, {
|
|
@@ -5209,7 +5282,7 @@ function isYarnBerry() {
|
|
|
5209
5282
|
* - Configures environment for third-party tools
|
|
5210
5283
|
*/
|
|
5211
5284
|
|
|
5212
|
-
const require$2 = require$$
|
|
5285
|
+
const require$2 = require$$1.createRequire((typeof document === 'undefined' ? require$$0$1.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils.js', document.baseURI).href)));
|
|
5213
5286
|
const {
|
|
5214
5287
|
PACKAGE_LOCK_JSON,
|
|
5215
5288
|
PNPM_LOCK_YAML,
|
|
@@ -5280,7 +5353,7 @@ async function spawnDlx(packageSpec, args, options, spawnExtra) {
|
|
|
5280
5353
|
// this only as a config setting, not as a `dlx` CLI flag, so it must be set
|
|
5281
5354
|
// via the npm_config_ env var. See: https://pnpm.io/npmrc#settings
|
|
5282
5355
|
const pnpmEnv = {
|
|
5283
|
-
...
|
|
5356
|
+
...objects.getOwn(finalShadowOptions, 'env'),
|
|
5284
5357
|
npm_config_ignore_pnpmfile: 'true'
|
|
5285
5358
|
};
|
|
5286
5359
|
if (force) {
|
|
@@ -5308,7 +5381,7 @@ async function spawnDlx(packageSpec, args, options, spawnExtra) {
|
|
|
5308
5381
|
finalShadowOptions = {
|
|
5309
5382
|
...finalShadowOptions,
|
|
5310
5383
|
env: {
|
|
5311
|
-
...
|
|
5384
|
+
...objects.getOwn(finalShadowOptions, 'env'),
|
|
5312
5385
|
YARN_NODE_LINKER: 'node-modules'
|
|
5313
5386
|
}
|
|
5314
5387
|
};
|
|
@@ -5547,7 +5620,7 @@ async function spawnCoanaDlx(args, orgSlug, options, spawnExtra) {
|
|
|
5547
5620
|
// requested stdio from either argument and honor it on every launch path:
|
|
5548
5621
|
// dlx, local-path, and npm-install (e.g. `socket fix --silence` requests
|
|
5549
5622
|
// `stdio: 'pipe'` via options).
|
|
5550
|
-
const requestedStdio = spawnExtra?.['stdio'] ??
|
|
5623
|
+
const requestedStdio = spawnExtra?.['stdio'] ?? objects.getOwn(dlxOptions, 'stdio');
|
|
5551
5624
|
const localCoanaPath = process.env['SOCKET_CLI_COANA_LOCAL_PATH'];
|
|
5552
5625
|
// Use local Coana CLI if path is provided.
|
|
5553
5626
|
if (localCoanaPath) {
|
|
@@ -5836,7 +5909,7 @@ function getDefaultSocketJson() {
|
|
|
5836
5909
|
function readSocketJsonSync(cwd, defaultOnError = false) {
|
|
5837
5910
|
const sockJsonPath = path.join(cwd, constants.SOCKET_JSON);
|
|
5838
5911
|
if (!fs.existsSync(sockJsonPath)) {
|
|
5839
|
-
|
|
5912
|
+
debug$2.debugFn('notice', `miss: ${constants.SOCKET_JSON} not found at ${cwd}`);
|
|
5840
5913
|
return {
|
|
5841
5914
|
ok: true,
|
|
5842
5915
|
data: getDefaultSocketJson()
|
|
@@ -5848,16 +5921,16 @@ function readSocketJsonSync(cwd, defaultOnError = false) {
|
|
|
5848
5921
|
} catch (e) {
|
|
5849
5922
|
if (defaultOnError) {
|
|
5850
5923
|
logger.logger.warn(`Failed to read ${constants.SOCKET_JSON}, using default`);
|
|
5851
|
-
|
|
5852
|
-
|
|
5924
|
+
debug$2.debugFn('warn', `Failed to read ${constants.SOCKET_JSON} sync`);
|
|
5925
|
+
debug$2.debugDir('warn', e);
|
|
5853
5926
|
return {
|
|
5854
5927
|
ok: true,
|
|
5855
5928
|
data: getDefaultSocketJson()
|
|
5856
5929
|
};
|
|
5857
5930
|
}
|
|
5858
5931
|
const cause = formatErrorWithDetail(`An error occurred while trying to read ${constants.SOCKET_JSON}`, e);
|
|
5859
|
-
|
|
5860
|
-
|
|
5932
|
+
debug$2.debugFn('error', `Failed to read ${constants.SOCKET_JSON} sync`);
|
|
5933
|
+
debug$2.debugDir('error', e);
|
|
5861
5934
|
return {
|
|
5862
5935
|
ok: false,
|
|
5863
5936
|
message: `Failed to read ${constants.SOCKET_JSON}`,
|
|
@@ -5868,11 +5941,11 @@ function readSocketJsonSync(cwd, defaultOnError = false) {
|
|
|
5868
5941
|
try {
|
|
5869
5942
|
jsonObj = JSON.parse(jsonContent);
|
|
5870
5943
|
} catch (e) {
|
|
5871
|
-
|
|
5872
|
-
|
|
5944
|
+
debug$2.debugFn('error', `Failed to parse ${constants.SOCKET_JSON} as JSON (sync)`);
|
|
5945
|
+
debug$2.debugDir('inspect', {
|
|
5873
5946
|
jsonContent
|
|
5874
5947
|
});
|
|
5875
|
-
|
|
5948
|
+
debug$2.debugDir('error', e);
|
|
5876
5949
|
if (defaultOnError) {
|
|
5877
5950
|
logger.logger.warn(`Failed to parse ${constants.SOCKET_JSON}, using default`);
|
|
5878
5951
|
return {
|
|
@@ -5906,11 +5979,11 @@ async function writeSocketJson(cwd, sockJson) {
|
|
|
5906
5979
|
try {
|
|
5907
5980
|
jsonContent = JSON.stringify(sockJson, null, 2);
|
|
5908
5981
|
} catch (e) {
|
|
5909
|
-
|
|
5910
|
-
|
|
5982
|
+
debug$2.debugFn('error', `Failed to serialize ${constants.SOCKET_JSON} to JSON`);
|
|
5983
|
+
debug$2.debugDir('inspect', {
|
|
5911
5984
|
sockJson
|
|
5912
5985
|
});
|
|
5913
|
-
|
|
5986
|
+
debug$2.debugDir('error', e);
|
|
5914
5987
|
return {
|
|
5915
5988
|
ok: false,
|
|
5916
5989
|
message: 'Failed to serialize to JSON',
|
|
@@ -6026,12 +6099,12 @@ async function fetchGhsaDetails(ids) {
|
|
|
6026
6099
|
if (advisory && advisory.ghsaId) {
|
|
6027
6100
|
results.set(id, advisory);
|
|
6028
6101
|
} else {
|
|
6029
|
-
|
|
6102
|
+
debug$2.debugFn('notice', `miss: no advisory found for ${id}`);
|
|
6030
6103
|
}
|
|
6031
6104
|
}
|
|
6032
6105
|
} catch (e) {
|
|
6033
|
-
|
|
6034
|
-
|
|
6106
|
+
debug$2.debugFn('error', formatErrorWithDetail('Failed to fetch GHSA details', e));
|
|
6107
|
+
debug$2.debugDir('error', e);
|
|
6035
6108
|
}
|
|
6036
6109
|
return results;
|
|
6037
6110
|
}
|
|
@@ -6042,13 +6115,13 @@ function getOctokit() {
|
|
|
6042
6115
|
SOCKET_CLI_GITHUB_TOKEN
|
|
6043
6116
|
} = constants.default.ENV;
|
|
6044
6117
|
if (!SOCKET_CLI_GITHUB_TOKEN) {
|
|
6045
|
-
|
|
6118
|
+
debug$2.debugFn('notice', 'miss: SOCKET_CLI_GITHUB_TOKEN env var');
|
|
6046
6119
|
}
|
|
6047
6120
|
const octokitOptions = {
|
|
6048
6121
|
auth: SOCKET_CLI_GITHUB_TOKEN,
|
|
6049
6122
|
baseUrl: constants.default.ENV.GITHUB_API_URL
|
|
6050
6123
|
};
|
|
6051
|
-
|
|
6124
|
+
debug$2.debugDir('inspect', {
|
|
6052
6125
|
octokitOptions
|
|
6053
6126
|
});
|
|
6054
6127
|
_octokit = new vendor.Octokit(octokitOptions);
|
|
@@ -6062,7 +6135,7 @@ function getOctokitGraphql() {
|
|
|
6062
6135
|
SOCKET_CLI_GITHUB_TOKEN
|
|
6063
6136
|
} = constants.default.ENV;
|
|
6064
6137
|
if (!SOCKET_CLI_GITHUB_TOKEN) {
|
|
6065
|
-
|
|
6138
|
+
debug$2.debugFn('notice', 'miss: SOCKET_CLI_GITHUB_TOKEN env var');
|
|
6066
6139
|
}
|
|
6067
6140
|
_octokitGraphql = vendor.graphql2.defaults({
|
|
6068
6141
|
headers: {
|
|
@@ -6115,31 +6188,31 @@ async function setGitRemoteGithubRepoUrl(owner, repo, token, cwd = process.cwd()
|
|
|
6115
6188
|
const {
|
|
6116
6189
|
GITHUB_SERVER_URL
|
|
6117
6190
|
} = constants.default.ENV;
|
|
6118
|
-
const urlObj =
|
|
6191
|
+
const urlObj = url.parseUrl(GITHUB_SERVER_URL);
|
|
6119
6192
|
const host = urlObj?.host;
|
|
6120
6193
|
if (!host) {
|
|
6121
|
-
|
|
6122
|
-
|
|
6194
|
+
debug$2.debugFn('error', 'invalid: GITHUB_SERVER_URL env var');
|
|
6195
|
+
debug$2.debugDir('inspect', {
|
|
6123
6196
|
GITHUB_SERVER_URL
|
|
6124
6197
|
});
|
|
6125
6198
|
return false;
|
|
6126
6199
|
}
|
|
6127
|
-
const url = `https://x-access-token:${token}@${host}/${owner}/${repo}`;
|
|
6200
|
+
const url$1 = `https://x-access-token:${token}@${host}/${owner}/${repo}`;
|
|
6128
6201
|
const stdioIgnoreOptions = {
|
|
6129
6202
|
cwd,
|
|
6130
|
-
stdio:
|
|
6203
|
+
stdio: debug$2.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
6131
6204
|
};
|
|
6132
|
-
const quotedCmd = `\`git remote set-url origin ${url}\``;
|
|
6133
|
-
|
|
6205
|
+
const quotedCmd = `\`git remote set-url origin ${url$1}\``;
|
|
6206
|
+
debug$2.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
6134
6207
|
try {
|
|
6135
|
-
await spawn.spawn('git', ['remote', 'set-url', 'origin', url], stdioIgnoreOptions);
|
|
6208
|
+
await spawn.spawn('git', ['remote', 'set-url', 'origin', url$1], stdioIgnoreOptions);
|
|
6136
6209
|
return true;
|
|
6137
6210
|
} catch (e) {
|
|
6138
|
-
|
|
6139
|
-
|
|
6211
|
+
debug$2.debugFn('error', `Git command failed: ${quotedCmd}`);
|
|
6212
|
+
debug$2.debugDir('inspect', {
|
|
6140
6213
|
cmd: quotedCmd
|
|
6141
6214
|
});
|
|
6142
|
-
|
|
6215
|
+
debug$2.debugDir('error', e);
|
|
6143
6216
|
}
|
|
6144
6217
|
return false;
|
|
6145
6218
|
}
|
|
@@ -6432,7 +6505,7 @@ function isPnpmLockfileScanCommand(command) {
|
|
|
6432
6505
|
// export type _Check_EcosystemString_has_all_purl_types =
|
|
6433
6506
|
// ExpectNever<MissingInEcosystemString>
|
|
6434
6507
|
|
|
6435
|
-
const ALL_ECOSYSTEMS = ['alpm', 'apk', 'bitbucket', 'cargo', 'chrome', 'cocoapods', 'composer', 'conan', 'conda', 'cran', 'deb', 'docker', 'gem', 'generic', 'github', 'golang', 'hackage', 'hex', 'huggingface', 'maven', 'mlflow', constants.NPM, 'nuget', 'oci', 'pub', 'pypi', 'qpkg', 'rpm', 'swift', 'swid', 'unknown', 'vscode'];
|
|
6508
|
+
const ALL_ECOSYSTEMS = ['alpm', 'apk', 'bitbucket', 'cargo', 'chrome', 'clawhub', 'cocoapods', 'composer', 'conan', 'conda', 'cran', 'deb', 'docker', 'gem', 'generic', 'github', 'golang', 'hackage', 'hex', 'huggingface', 'maven', 'mlflow', constants.NPM, 'nuget', 'oci', 'pub', 'pypi', 'qpkg', 'rpm', 'socket', 'swift', 'swid', 'unknown', 'vscode'];
|
|
6436
6509
|
new Set(ALL_ECOSYSTEMS);
|
|
6437
6510
|
|
|
6438
6511
|
// Purl types accepted by Coana's reachability `--purl-types` gate
|
|
@@ -6635,7 +6708,7 @@ function getNpmRequire() {
|
|
|
6635
6708
|
if (_npmRequire === undefined) {
|
|
6636
6709
|
const npmDirPath = getNpmDirPath();
|
|
6637
6710
|
const npmNmPath = path.join(npmDirPath, `${constants.NODE_MODULES}/npm`);
|
|
6638
|
-
_npmRequire = require$$
|
|
6711
|
+
_npmRequire = require$$1.createRequire(path.join(fs.existsSync(npmNmPath) ? npmNmPath : npmDirPath, '<dummy-basename>'));
|
|
6639
6712
|
}
|
|
6640
6713
|
return _npmRequire;
|
|
6641
6714
|
}
|
|
@@ -6687,7 +6760,7 @@ function shadowNpmInstall(options) {
|
|
|
6687
6760
|
__proto__: null,
|
|
6688
6761
|
...options
|
|
6689
6762
|
};
|
|
6690
|
-
const useDebug =
|
|
6763
|
+
const useDebug = debug$2.isDebug('stdio');
|
|
6691
6764
|
const terminatorPos = args.indexOf('--');
|
|
6692
6765
|
const rawBinArgs = terminatorPos === -1 ? args : args.slice(0, terminatorPos);
|
|
6693
6766
|
const binArgs = rawBinArgs.filter(a => !agent.isNpmAuditFlag(a) && !agent.isNpmFundFlag(a) && !agent.isNpmProgressFlag(a));
|
|
@@ -6695,12 +6768,12 @@ function shadowNpmInstall(options) {
|
|
|
6695
6768
|
const progressArg = rawBinArgs.findLast(agent.isNpmProgressFlag) !== '--no-progress';
|
|
6696
6769
|
const isSilent = !useDebug && !binArgs.some(agent.isNpmLoglevelFlag);
|
|
6697
6770
|
const logLevelArgs = isSilent ? [constants.FLAG_LOGLEVEL, 'silent'] : [];
|
|
6698
|
-
const useIpc =
|
|
6771
|
+
const useIpc = objects.isObject(ipc);
|
|
6699
6772
|
|
|
6700
6773
|
// Include 'ipc' in the spawnOpts.stdio when an options.ipc object is provided.
|
|
6701
6774
|
// See https://github.com/nodejs/node/blob/v23.6.0/lib/child_process.js#L161-L166
|
|
6702
6775
|
// and https://github.com/nodejs/node/blob/v23.6.0/lib/internal/child_process.js#L238.
|
|
6703
|
-
let stdio =
|
|
6776
|
+
let stdio = objects.getOwn(spawnOpts, 'stdio');
|
|
6704
6777
|
if (typeof stdio === 'string') {
|
|
6705
6778
|
stdio = useIpc ? [stdio, stdio, stdio, 'ipc'] : [stdio, stdio, stdio];
|
|
6706
6779
|
} else if (Array.isArray(stdio)) {
|
|
@@ -6722,7 +6795,7 @@ function shadowNpmInstall(options) {
|
|
|
6722
6795
|
env: {
|
|
6723
6796
|
...process.env,
|
|
6724
6797
|
...constants.default.processEnv,
|
|
6725
|
-
...
|
|
6798
|
+
...objects.getOwn(spawnOpts, 'env')
|
|
6726
6799
|
},
|
|
6727
6800
|
spinner,
|
|
6728
6801
|
stdio
|
|
@@ -6803,7 +6876,7 @@ function runAgentInstall(pkgEnvDetails, options) {
|
|
|
6803
6876
|
CI: '1'
|
|
6804
6877
|
} : {}),
|
|
6805
6878
|
NODE_OPTIONS: cmdFlagsToString([...(skipNodeHardenFlags ? [] : constants.default.nodeHardenFlags), ...constants.default.nodeNoWarningsFlags]),
|
|
6806
|
-
...
|
|
6879
|
+
...objects.getOwn(spawnOpts, 'env')
|
|
6807
6880
|
}
|
|
6808
6881
|
});
|
|
6809
6882
|
}
|
|
@@ -6985,7 +7058,7 @@ async function getAgentExecPath(agent) {
|
|
|
6985
7058
|
async function getAgentVersion(agent, agentExecPath, cwd) {
|
|
6986
7059
|
let result;
|
|
6987
7060
|
const quotedCmd = `\`${agent} ${constants.FLAG_VERSION}\``;
|
|
6988
|
-
|
|
7061
|
+
debug$2.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
6989
7062
|
try {
|
|
6990
7063
|
let stdout;
|
|
6991
7064
|
|
|
@@ -7001,8 +7074,8 @@ async function getAgentVersion(agent, agentExecPath, cwd) {
|
|
|
7001
7074
|
shouldRunWithNode = resolved;
|
|
7002
7075
|
}
|
|
7003
7076
|
} catch (e) {
|
|
7004
|
-
|
|
7005
|
-
|
|
7077
|
+
debug$2.debugFn('warn', `Failed to resolve bin path for ${agentExecPath}, falling back to direct spawn.`);
|
|
7078
|
+
debug$2.debugDir('error', e);
|
|
7006
7079
|
}
|
|
7007
7080
|
}
|
|
7008
7081
|
if (shouldRunWithNode) {
|
|
@@ -7024,11 +7097,11 @@ async function getAgentVersion(agent, agentExecPath, cwd) {
|
|
|
7024
7097
|
// and tildes (~).
|
|
7025
7098
|
vendor.semverExports.coerce(stdout) ?? undefined;
|
|
7026
7099
|
} catch (e) {
|
|
7027
|
-
|
|
7028
|
-
|
|
7100
|
+
debug$2.debugFn('error', `Package manager command failed: ${quotedCmd}`);
|
|
7101
|
+
debug$2.debugDir('inspect', {
|
|
7029
7102
|
cmd: quotedCmd
|
|
7030
7103
|
});
|
|
7031
|
-
|
|
7104
|
+
debug$2.debugDir('error', e);
|
|
7032
7105
|
}
|
|
7033
7106
|
return result;
|
|
7034
7107
|
}
|
|
@@ -7557,7 +7630,7 @@ function toFilterConfig(obj) {
|
|
|
7557
7630
|
const normalized = {
|
|
7558
7631
|
__proto__: null
|
|
7559
7632
|
};
|
|
7560
|
-
const keys =
|
|
7633
|
+
const keys = objects.isObject(obj) ? Object.keys(obj) : [];
|
|
7561
7634
|
for (const key of keys) {
|
|
7562
7635
|
const value = obj[key];
|
|
7563
7636
|
if (typeof value === 'boolean' || Array.isArray(value)) {
|
|
@@ -7610,7 +7683,7 @@ function parsePnpmLockfile(lockfileContent) {
|
|
|
7610
7683
|
result = vendor.jsYaml.load(strings.stripBom(lockfileContent));
|
|
7611
7684
|
} catch {}
|
|
7612
7685
|
}
|
|
7613
|
-
return
|
|
7686
|
+
return objects.isObjectObject(result) ? result : null;
|
|
7614
7687
|
}
|
|
7615
7688
|
async function readPnpmLockfile(lockfilePath) {
|
|
7616
7689
|
return fs.existsSync(lockfilePath) ? await fs$1.readFileUtf8(lockfilePath) : undefined;
|
|
@@ -7711,7 +7784,7 @@ class ColorOrMarkdown {
|
|
|
7711
7784
|
}
|
|
7712
7785
|
}
|
|
7713
7786
|
|
|
7714
|
-
const require$1 = require$$
|
|
7787
|
+
const require$1 = require$$1.createRequire((typeof document === 'undefined' ? require$$0$1.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils.js', document.baseURI).href)));
|
|
7715
7788
|
let _translations;
|
|
7716
7789
|
function getTranslations() {
|
|
7717
7790
|
if (_translations === undefined) {
|
|
@@ -7821,8 +7894,13 @@ async function addArtifactToAlertsMap(artifact, alertsByPurl, options) {
|
|
|
7821
7894
|
blocked: true,
|
|
7822
7895
|
critical: true,
|
|
7823
7896
|
cve: true,
|
|
7824
|
-
...
|
|
7897
|
+
...objects.getOwn(options, 'filter')
|
|
7825
7898
|
});
|
|
7899
|
+
|
|
7900
|
+
// `issueRules` is a user-provided YAML map typed as
|
|
7901
|
+
// `{ [issueName: string]: boolean }`, so key by `string` here. A string
|
|
7902
|
+
// index signature also keeps the `enabledState[alert.type]` lookup below
|
|
7903
|
+
// well-typed regardless of how `alert.type` resolves.
|
|
7826
7904
|
const enabledState = {
|
|
7827
7905
|
__proto__: null,
|
|
7828
7906
|
...socketYml?.issueRules
|
|
@@ -7841,7 +7919,7 @@ async function addArtifactToAlertsMap(artifact, alertsByPurl, options) {
|
|
|
7841
7919
|
const fixableCve = fixType === ALERT_FIX_TYPE.cve;
|
|
7842
7920
|
const fixableUpgrade = fixType === ALERT_FIX_TYPE.upgrade;
|
|
7843
7921
|
const fixable = fixableCve || fixableUpgrade;
|
|
7844
|
-
const upgradable = fixableUpgrade && !
|
|
7922
|
+
const upgradable = fixableUpgrade && !objects.hasOwn(overrides, name);
|
|
7845
7923
|
if (filterConfig.blocked && blocked || filterConfig.critical && critical || filterConfig.cve && cve || filterConfig.fixable && fixable || filterConfig.upgradable && upgradable) {
|
|
7846
7924
|
sockPkgAlerts.push({
|
|
7847
7925
|
name,
|
|
@@ -8115,7 +8193,7 @@ async function getAlertsMapFromPnpmLockfile(lockfile, options) {
|
|
|
8115
8193
|
}
|
|
8116
8194
|
async function getAlertsMapFromPurls(purls, options) {
|
|
8117
8195
|
const uniqPurls = arrays.arrayUnique(purls);
|
|
8118
|
-
|
|
8196
|
+
debug$2.debugDir('silly', {
|
|
8119
8197
|
purls: uniqPurls
|
|
8120
8198
|
});
|
|
8121
8199
|
let {
|
|
@@ -8130,7 +8208,7 @@ async function getAlertsMapFromPurls(purls, options) {
|
|
|
8130
8208
|
consolidate: false,
|
|
8131
8209
|
nothrow: false,
|
|
8132
8210
|
...options,
|
|
8133
|
-
filter: toFilterConfig(
|
|
8211
|
+
filter: toFilterConfig(objects.getOwn(options, 'filter'))
|
|
8134
8212
|
};
|
|
8135
8213
|
if (opts.onlyFixable) {
|
|
8136
8214
|
opts.filter.fixable = true;
|
|
@@ -8188,7 +8266,7 @@ async function getAlertsMapFromPurls(purls, options) {
|
|
|
8188
8266
|
} else {
|
|
8189
8267
|
spinner?.stop();
|
|
8190
8268
|
logger.logger.fail(`Received a ${batchResult.status} response from Socket API which we consider a permanent failure:`, batchResult.error, batchResult.cause ? `( ${batchResult.cause} )` : '');
|
|
8191
|
-
|
|
8269
|
+
debug$2.debugDir('inspect', {
|
|
8192
8270
|
batchResult
|
|
8193
8271
|
});
|
|
8194
8272
|
break;
|
|
@@ -8444,6 +8522,7 @@ exports.parsePnpmLockfile = parsePnpmLockfile;
|
|
|
8444
8522
|
exports.parseReachEcosystems = parseReachEcosystems;
|
|
8445
8523
|
exports.queryApiSafeJson = queryApiSafeJson;
|
|
8446
8524
|
exports.queryApiSafeText = queryApiSafeText;
|
|
8525
|
+
exports.queryApiSafeTextWithStatus = queryApiSafeTextWithStatus;
|
|
8447
8526
|
exports.readOrDefaultSocketJson = readOrDefaultSocketJson;
|
|
8448
8527
|
exports.readOrDefaultSocketJsonUp = readOrDefaultSocketJsonUp;
|
|
8449
8528
|
exports.readPnpmLockfile = readPnpmLockfile;
|
|
@@ -8475,6 +8554,7 @@ exports.trackSubprocessStart = trackSubprocessStart;
|
|
|
8475
8554
|
exports.updateConfigValue = updateConfigValue;
|
|
8476
8555
|
exports.walkNestedMap = walkNestedMap;
|
|
8477
8556
|
exports.webLink = webLink;
|
|
8557
|
+
exports.withTmpDir = withTmpDir;
|
|
8478
8558
|
exports.writeSocketJson = writeSocketJson;
|
|
8479
|
-
//# debugId=
|
|
8559
|
+
//# debugId=42fc0b13-4cfc-491d-a46f-94274b113cbc
|
|
8480
8560
|
//# sourceMappingURL=utils.js.map
|