@socketsecurity/cli-with-sentry 1.0.20 → 1.0.22
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/cli.js +349 -326
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +4 -4
- package/dist/constants.js.map +1 -1
- package/dist/shadow-npm-inject.js +64 -7
- package/dist/shadow-npm-inject.js.map +1 -1
- package/dist/types/commands/audit-log/output-audit-log.d.mts.map +1 -1
- package/dist/types/commands/fix/agent-fix.d.mts +3 -5
- package/dist/types/commands/fix/agent-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/fix-branch-helpers.d.mts +3 -4
- package/dist/types/commands/fix/fix-branch-helpers.d.mts.map +1 -1
- package/dist/types/commands/fix/fix-env-helpers.d.mts +9 -9
- package/dist/types/commands/fix/fix-env-helpers.d.mts.map +1 -1
- package/dist/types/commands/fix/git.d.mts +1 -0
- package/dist/types/commands/fix/git.d.mts.map +1 -1
- package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/npm-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/pnpm-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/{open-pr.d.mts → pull-request.d.mts} +11 -6
- package/dist/types/commands/fix/pull-request.d.mts.map +1 -0
- package/dist/types/commands/fix/shared.d.mts +1 -2
- package/dist/types/commands/fix/shared.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-gradle.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-kotlin.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-scala.d.mts.map +1 -1
- package/dist/types/commands/manifest/detect-manifest-actions.d.mts.map +1 -1
- package/dist/types/commands/optimize/update-lockfile.d.mts.map +1 -1
- package/dist/types/commands/repository/fetch-list-all-repos.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-report-data.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-scan.d.mts.map +1 -1
- package/dist/types/commands/wrapper/postinstall-wrapper.d.mts.map +1 -1
- package/dist/types/shadow/npm/arborist-helpers.d.mts.map +1 -1
- package/dist/types/utils/alerts-map.d.mts +0 -1
- package/dist/types/utils/alerts-map.d.mts.map +1 -1
- package/dist/types/utils/api.d.mts.map +1 -1
- package/dist/types/utils/npm-config.d.mts +14 -0
- package/dist/types/utils/npm-config.d.mts.map +1 -0
- package/dist/types/utils/npm-paths.d.mts +2 -2
- package/dist/types/utils/npm-paths.d.mts.map +1 -1
- package/dist/types/utils/package-environment.d.mts.map +1 -1
- package/dist/types/utils/path-resolve.d.mts.map +1 -1
- package/dist/types/utils/socket-package-alert.d.mts +1 -2
- package/dist/types/utils/socket-package-alert.d.mts.map +1 -1
- package/dist/types/utils/socketjson.d.mts.map +1 -1
- package/dist/utils.js +148 -70
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +66962 -66962
- package/external/@coana-tech/cli/cli.mjs +60278 -55993
- package/external/@socketsecurity/registry/external/@inquirer/confirm.js +1 -1
- package/external/@socketsecurity/registry/external/@inquirer/input.js +10 -2
- package/external/@socketsecurity/registry/external/@inquirer/password.js +1 -1
- package/external/@socketsecurity/registry/external/@inquirer/search.js +1 -1
- package/external/@socketsecurity/registry/external/@inquirer/select.js +1 -1
- package/external/@socketsecurity/registry/external/browserslist.js +572 -570
- package/external/@socketsecurity/registry/external/debug.js +1163 -0
- package/external/@socketsecurity/registry/lib/constants/env.js +9 -4
- package/external/@socketsecurity/registry/lib/debug.js +139 -47
- package/external/@socketsecurity/registry/lib/logger.js +2 -2
- package/external/@socketsecurity/registry/lib/packages.js +1 -2
- package/package.json +18 -18
- package/dist/types/commands/fix/open-pr.d.mts.map +0 -1
- package/dist/types/shadow/npm/proc-log/index.d.mts +0 -3
- package/dist/types/shadow/npm/proc-log/index.d.mts.map +0 -1
package/dist/utils.js
CHANGED
|
@@ -391,7 +391,7 @@ let _cachedConfig;
|
|
|
391
391
|
// When using --config or SOCKET_CLI_CONFIG, do not persist the config.
|
|
392
392
|
let _readOnlyConfig = false;
|
|
393
393
|
function overrideCachedConfig(jsonConfig) {
|
|
394
|
-
debug.debugFn('override: full config (not stored)');
|
|
394
|
+
debug.debugFn('notice', 'override: full config (not stored)');
|
|
395
395
|
let config;
|
|
396
396
|
try {
|
|
397
397
|
config = JSON.parse(String(jsonConfig));
|
|
@@ -432,7 +432,7 @@ function overrideCachedConfig(jsonConfig) {
|
|
|
432
432
|
};
|
|
433
433
|
}
|
|
434
434
|
function overrideConfigApiToken(apiToken) {
|
|
435
|
-
debug.debugFn('override: API token (not stored)');
|
|
435
|
+
debug.debugFn('notice', 'override: API token (not stored)');
|
|
436
436
|
|
|
437
437
|
// Set token to the local cached config and mark it read-only so it doesn't persist
|
|
438
438
|
_cachedConfig = {
|
|
@@ -516,7 +516,7 @@ function captureExceptionSync(exception, hint) {
|
|
|
516
516
|
if (!Sentry) {
|
|
517
517
|
return '';
|
|
518
518
|
}
|
|
519
|
-
debug.debugFn('send: exception to Sentry');
|
|
519
|
+
debug.debugFn('notice', 'send: exception to Sentry');
|
|
520
520
|
return Sentry.captureException(exception, hint);
|
|
521
521
|
}
|
|
522
522
|
|
|
@@ -639,7 +639,10 @@ async function handleApiCall(value, fetchingDesc) {
|
|
|
639
639
|
spinner.failAndStop(`An error was thrown while requesting ${fetchingDesc}`);
|
|
640
640
|
const message = `${e || 'No error message returned'}`;
|
|
641
641
|
const reason = `${e || 'No error message returned'}`;
|
|
642
|
-
debug.debugFn(`
|
|
642
|
+
debug.debugFn('error', `caught: ${fetchingDesc} error`);
|
|
643
|
+
debug.debugDir('inspect', {
|
|
644
|
+
error: e
|
|
645
|
+
});
|
|
643
646
|
return {
|
|
644
647
|
ok: false,
|
|
645
648
|
message: 'Socket API returned an error',
|
|
@@ -651,12 +654,15 @@ async function handleApiCall(value, fetchingDesc) {
|
|
|
651
654
|
|
|
652
655
|
// Note: TS can't narrow down the type of result due to generics
|
|
653
656
|
if (result.success === false) {
|
|
654
|
-
const
|
|
655
|
-
const message = `${
|
|
657
|
+
const error = result;
|
|
658
|
+
const message = `${error.error || 'No error message returned'}`;
|
|
656
659
|
const {
|
|
657
660
|
cause: reason
|
|
658
|
-
} =
|
|
659
|
-
debug.debugFn(`fail: ${fetchingDesc} bad response
|
|
661
|
+
} = error;
|
|
662
|
+
debug.debugFn('error', `fail: ${fetchingDesc} bad response`);
|
|
663
|
+
debug.debugDir('inspect', {
|
|
664
|
+
error
|
|
665
|
+
});
|
|
660
666
|
return {
|
|
661
667
|
ok: false,
|
|
662
668
|
message: 'Socket API returned an error',
|
|
@@ -680,7 +686,10 @@ async function handleApiCallNoSpinner(value, description) {
|
|
|
680
686
|
} catch (e) {
|
|
681
687
|
const message = `${e || 'No error message returned'}`;
|
|
682
688
|
const reason = `${e || 'No error message returned'}`;
|
|
683
|
-
debug.debugFn(`
|
|
689
|
+
debug.debugFn('error', `caught: ${description} error`);
|
|
690
|
+
debug.debugDir('inspect', {
|
|
691
|
+
error: e
|
|
692
|
+
});
|
|
684
693
|
return {
|
|
685
694
|
ok: false,
|
|
686
695
|
message: 'Socket API returned an error',
|
|
@@ -690,13 +699,16 @@ async function handleApiCallNoSpinner(value, description) {
|
|
|
690
699
|
|
|
691
700
|
// Note: TS can't narrow down the type of result due to generics
|
|
692
701
|
if (result.success === false) {
|
|
693
|
-
const
|
|
694
|
-
const message = `${
|
|
695
|
-
debug.debugFn(`fail: ${description} bad response
|
|
702
|
+
const error = result;
|
|
703
|
+
const message = `${error.error || 'No error message returned'}`;
|
|
704
|
+
debug.debugFn('error', `fail: ${description} bad response`);
|
|
705
|
+
debug.debugDir('inspect', {
|
|
706
|
+
error
|
|
707
|
+
});
|
|
696
708
|
return {
|
|
697
709
|
ok: false,
|
|
698
710
|
message: 'Socket API returned an error',
|
|
699
|
-
cause: `${message}${
|
|
711
|
+
cause: `${message}${error.cause ? ` ( Reason: ${error.cause} )` : ''}`,
|
|
700
712
|
data: {
|
|
701
713
|
code: result.status
|
|
702
714
|
}
|
|
@@ -777,7 +789,10 @@ async function queryApiSafeText(path, fetchSpinnerDesc) {
|
|
|
777
789
|
spinner.failAndStop(`An error was thrown while requesting ${fetchSpinnerDesc}.`);
|
|
778
790
|
}
|
|
779
791
|
const cause = e?.message;
|
|
780
|
-
debug.debugFn('
|
|
792
|
+
debug.debugFn('error', 'caught: queryApi() error');
|
|
793
|
+
debug.debugDir('inspect', {
|
|
794
|
+
error: e
|
|
795
|
+
});
|
|
781
796
|
return {
|
|
782
797
|
ok: false,
|
|
783
798
|
message: 'API Request failed to complete',
|
|
@@ -801,7 +816,10 @@ async function queryApiSafeText(path, fetchSpinnerDesc) {
|
|
|
801
816
|
data
|
|
802
817
|
};
|
|
803
818
|
} catch (e) {
|
|
804
|
-
debug.debugFn('
|
|
819
|
+
debug.debugFn('error', 'caught: await result.text() error');
|
|
820
|
+
debug.debugDir('inspect', {
|
|
821
|
+
error: e
|
|
822
|
+
});
|
|
805
823
|
return {
|
|
806
824
|
ok: false,
|
|
807
825
|
message: 'API Request failed to complete',
|
|
@@ -922,9 +940,9 @@ cols) {
|
|
|
922
940
|
function serializeResultJson(data) {
|
|
923
941
|
if (typeof data !== 'object' || !data) {
|
|
924
942
|
process.exitCode = 1;
|
|
925
|
-
debug.debugFn('typeof data=', typeof data);
|
|
943
|
+
debug.debugFn('inspect', 'typeof data=', typeof data);
|
|
926
944
|
if (typeof data !== 'object' && data) {
|
|
927
|
-
debug.debugFn('data:\n', data);
|
|
945
|
+
debug.debugFn('inspect', 'data:\n', data);
|
|
928
946
|
}
|
|
929
947
|
|
|
930
948
|
// We should not allow the json value to be "null", or a boolean/number/string,
|
|
@@ -939,12 +957,14 @@ function serializeResultJson(data) {
|
|
|
939
957
|
try {
|
|
940
958
|
return JSON.stringify(data, null, 2).trim() + '\n';
|
|
941
959
|
} catch (e) {
|
|
942
|
-
debug.debugFn('catch: unexpected\n', e);
|
|
943
960
|
process.exitCode = 1;
|
|
944
961
|
|
|
945
962
|
// This could be caused by circular references, which is an "us" problem
|
|
946
963
|
const message = 'There was a problem converting the data set to JSON. Please try again without --json';
|
|
947
964
|
logger.logger.fail(message);
|
|
965
|
+
debug.debugDir('inspect', {
|
|
966
|
+
error: e
|
|
967
|
+
});
|
|
948
968
|
return JSON.stringify({
|
|
949
969
|
ok: false,
|
|
950
970
|
message: 'Unable to serialize JSON',
|
|
@@ -1720,7 +1740,7 @@ function findNpmPathSync(npmBinPath) {
|
|
|
1720
1740
|
}
|
|
1721
1741
|
}
|
|
1722
1742
|
async function getPackageFilesForScan(cwd, inputPaths, supportedFiles, config) {
|
|
1723
|
-
debug.debugFn(`resolve: ${inputPaths.length} paths`, inputPaths);
|
|
1743
|
+
debug.debugFn('notice', `resolve: ${inputPaths.length} paths`, inputPaths);
|
|
1724
1744
|
|
|
1725
1745
|
// Lazily access constants.spinner.
|
|
1726
1746
|
const {
|
|
@@ -1732,16 +1752,16 @@ async function getPackageFilesForScan(cwd, inputPaths, supportedFiles, config) {
|
|
|
1732
1752
|
cwd,
|
|
1733
1753
|
socketConfig: config
|
|
1734
1754
|
});
|
|
1735
|
-
if (debug.isDebug()) {
|
|
1755
|
+
if (debug.isDebug('notice')) {
|
|
1736
1756
|
spinner.stop();
|
|
1737
|
-
debug.debugFn(`Resolved ${inputPaths.length} paths to ${entries.length} local paths:\n`, entries);
|
|
1757
|
+
debug.debugFn('notice', `Resolved ${inputPaths.length} paths to ${entries.length} local paths:\n`, entries);
|
|
1738
1758
|
spinner.start('Searching for files now...');
|
|
1739
1759
|
} else {
|
|
1740
1760
|
spinner.start(`Resolved ${inputPaths.length} paths to ${entries.length} local paths, searching for files now...`);
|
|
1741
1761
|
}
|
|
1742
1762
|
const packageFiles = await filterGlobResultToSupportedFiles(entries, supportedFiles);
|
|
1743
1763
|
spinner.successAndStop(`Found ${packageFiles.length} local ${words.pluralize('file', packageFiles.length)}`);
|
|
1744
|
-
debug.debugFn('paths: absolute', packageFiles);
|
|
1764
|
+
debug.debugFn('inspect', 'paths: absolute', packageFiles);
|
|
1745
1765
|
return packageFiles;
|
|
1746
1766
|
}
|
|
1747
1767
|
|
|
@@ -1765,7 +1785,7 @@ function getDefaultSocketJson() {
|
|
|
1765
1785
|
async function readSocketJson(cwd, defaultOnError = false) {
|
|
1766
1786
|
const sockJsonPath = path.join(cwd, 'socket.json');
|
|
1767
1787
|
if (!fs.existsSync(sockJsonPath)) {
|
|
1768
|
-
debug.debugFn(`miss: file not found ${sockJsonPath}`);
|
|
1788
|
+
debug.debugFn('notice', `miss: file not found ${sockJsonPath}`);
|
|
1769
1789
|
return {
|
|
1770
1790
|
ok: true,
|
|
1771
1791
|
data: getDefaultSocketJson()
|
|
@@ -1775,8 +1795,9 @@ async function readSocketJson(cwd, defaultOnError = false) {
|
|
|
1775
1795
|
try {
|
|
1776
1796
|
json = await fs.promises.readFile(sockJsonPath, 'utf8');
|
|
1777
1797
|
} catch (e) {
|
|
1778
|
-
debug.
|
|
1779
|
-
|
|
1798
|
+
debug.debugDir('inspect', {
|
|
1799
|
+
error: e
|
|
1800
|
+
});
|
|
1780
1801
|
if (defaultOnError) {
|
|
1781
1802
|
logger.logger.warn('Warning: failed to read file, using default');
|
|
1782
1803
|
return {
|
|
@@ -1795,7 +1816,10 @@ async function readSocketJson(cwd, defaultOnError = false) {
|
|
|
1795
1816
|
try {
|
|
1796
1817
|
obj = JSON.parse(json);
|
|
1797
1818
|
} catch {
|
|
1798
|
-
debug.debugFn('fail: parse JSON
|
|
1819
|
+
debug.debugFn('error', 'fail: parse JSON');
|
|
1820
|
+
debug.debugDir('inspect', {
|
|
1821
|
+
json
|
|
1822
|
+
});
|
|
1799
1823
|
if (defaultOnError) {
|
|
1800
1824
|
logger.logger.warn('Warning: failed to parse file, using default');
|
|
1801
1825
|
return {
|
|
@@ -1830,8 +1854,13 @@ async function writeSocketJson(cwd, sockJson) {
|
|
|
1830
1854
|
try {
|
|
1831
1855
|
json = JSON.stringify(sockJson, null, 2);
|
|
1832
1856
|
} catch (e) {
|
|
1833
|
-
debug.debugFn('fail: stringify JSON
|
|
1834
|
-
debug.
|
|
1857
|
+
debug.debugFn('error', 'fail: stringify JSON');
|
|
1858
|
+
debug.debugDir('inspect', {
|
|
1859
|
+
error: e
|
|
1860
|
+
});
|
|
1861
|
+
debug.debugDir('inspect', {
|
|
1862
|
+
sockJson
|
|
1863
|
+
});
|
|
1835
1864
|
return {
|
|
1836
1865
|
ok: false,
|
|
1837
1866
|
message: 'Failed to serialize to JSON',
|
|
@@ -1859,26 +1888,6 @@ function exitWithBinPathError(binName) {
|
|
|
1859
1888
|
// eslint-disable-next-line n/no-process-exit
|
|
1860
1889
|
process.exit(127);
|
|
1861
1890
|
}
|
|
1862
|
-
let _npmBinPathDetails;
|
|
1863
|
-
function getNpmBinPathDetails() {
|
|
1864
|
-
if (_npmBinPathDetails === undefined) {
|
|
1865
|
-
_npmBinPathDetails = findBinPathDetailsSync(NPM$3);
|
|
1866
|
-
}
|
|
1867
|
-
return _npmBinPathDetails;
|
|
1868
|
-
}
|
|
1869
|
-
let _npxBinPathDetails;
|
|
1870
|
-
function getNpxBinPathDetails() {
|
|
1871
|
-
if (_npxBinPathDetails === undefined) {
|
|
1872
|
-
_npxBinPathDetails = findBinPathDetailsSync(NPX);
|
|
1873
|
-
}
|
|
1874
|
-
return _npxBinPathDetails;
|
|
1875
|
-
}
|
|
1876
|
-
function isNpmBinPathShadowed() {
|
|
1877
|
-
return getNpmBinPathDetails().shadowed;
|
|
1878
|
-
}
|
|
1879
|
-
function isNpxBinPathShadowed() {
|
|
1880
|
-
return getNpxBinPathDetails().shadowed;
|
|
1881
|
-
}
|
|
1882
1891
|
let _npmBinPath;
|
|
1883
1892
|
function getNpmBinPath() {
|
|
1884
1893
|
if (_npmBinPath === undefined) {
|
|
@@ -1889,6 +1898,13 @@ function getNpmBinPath() {
|
|
|
1889
1898
|
}
|
|
1890
1899
|
return _npmBinPath;
|
|
1891
1900
|
}
|
|
1901
|
+
let _npmBinPathDetails;
|
|
1902
|
+
function getNpmBinPathDetails() {
|
|
1903
|
+
if (_npmBinPathDetails === undefined) {
|
|
1904
|
+
_npmBinPathDetails = findBinPathDetailsSync(NPM$3);
|
|
1905
|
+
}
|
|
1906
|
+
return _npmBinPathDetails;
|
|
1907
|
+
}
|
|
1892
1908
|
let _npmPath;
|
|
1893
1909
|
function getNpmPath() {
|
|
1894
1910
|
if (_npmPath === undefined) {
|
|
@@ -1928,6 +1944,19 @@ function getNpxBinPath() {
|
|
|
1928
1944
|
}
|
|
1929
1945
|
return _npxBinPath;
|
|
1930
1946
|
}
|
|
1947
|
+
let _npxBinPathDetails;
|
|
1948
|
+
function getNpxBinPathDetails() {
|
|
1949
|
+
if (_npxBinPathDetails === undefined) {
|
|
1950
|
+
_npxBinPathDetails = findBinPathDetailsSync(NPX);
|
|
1951
|
+
}
|
|
1952
|
+
return _npxBinPathDetails;
|
|
1953
|
+
}
|
|
1954
|
+
function isNpmBinPathShadowed() {
|
|
1955
|
+
return getNpmBinPathDetails().shadowed;
|
|
1956
|
+
}
|
|
1957
|
+
function isNpxBinPathShadowed() {
|
|
1958
|
+
return getNpxBinPathDetails().shadowed;
|
|
1959
|
+
}
|
|
1931
1960
|
|
|
1932
1961
|
const {
|
|
1933
1962
|
ALERT_TYPE_CRITICAL_CVE,
|
|
@@ -2262,20 +2291,20 @@ function getAlertSeverityOrder(alert) {
|
|
|
2262
2291
|
function getAlertsSeverityOrder(alerts) {
|
|
2263
2292
|
return alertsHaveBlocked(alerts) || alertsHaveSeverity(alerts, ALERT_SEVERITY.critical) ? 0 : alertsHaveSeverity(alerts, ALERT_SEVERITY.high) ? 1 : alertsHaveSeverity(alerts, ALERT_SEVERITY.middle) ? 2 : alertsHaveSeverity(alerts, ALERT_SEVERITY.low) ? 3 : 4;
|
|
2264
2293
|
}
|
|
2265
|
-
function getCveInfoFromAlertsMap(alertsMap,
|
|
2266
|
-
const
|
|
2294
|
+
function getCveInfoFromAlertsMap(alertsMap, options) {
|
|
2295
|
+
const {
|
|
2296
|
+
exclude: exclude_
|
|
2297
|
+
} = {
|
|
2267
2298
|
__proto__: null,
|
|
2268
|
-
|
|
2269
|
-
limit: Infinity,
|
|
2270
|
-
...options_
|
|
2299
|
+
...options
|
|
2271
2300
|
};
|
|
2272
|
-
|
|
2301
|
+
const exclude = {
|
|
2273
2302
|
__proto__: null,
|
|
2274
|
-
...
|
|
2303
|
+
...exclude_
|
|
2275
2304
|
};
|
|
2276
|
-
let count = 0;
|
|
2277
2305
|
let infoByPartialPurl = null;
|
|
2278
|
-
|
|
2306
|
+
// eslint-disable-next-line no-unused-labels
|
|
2307
|
+
for (const {
|
|
2279
2308
|
0: purl,
|
|
2280
2309
|
1: sockPkgAlerts
|
|
2281
2310
|
} of alertsMap) {
|
|
@@ -2284,7 +2313,7 @@ function getCveInfoFromAlertsMap(alertsMap, options_) {
|
|
|
2284
2313
|
const name = packages.resolvePackageName(purlObj);
|
|
2285
2314
|
sockPkgAlertsLoop: for (const sockPkgAlert of sockPkgAlerts) {
|
|
2286
2315
|
const alert = sockPkgAlert.raw;
|
|
2287
|
-
if (alert.fix?.type !== ALERT_FIX_TYPE.cve ||
|
|
2316
|
+
if (alert.fix?.type !== ALERT_FIX_TYPE.cve || exclude.upgradable && registry.getManifestData(sockPkgAlert.ecosystem, name)) {
|
|
2288
2317
|
continue sockPkgAlertsLoop;
|
|
2289
2318
|
}
|
|
2290
2319
|
if (!infoByPartialPurl) {
|
|
@@ -2314,18 +2343,19 @@ function getCveInfoFromAlertsMap(alertsMap, options_) {
|
|
|
2314
2343
|
// semver.Range will parse it without erroring.
|
|
2315
2344
|
vulnerableVersionRange.replace(/, +/g, ' ').replace(/; +/g, ' || ')).format()
|
|
2316
2345
|
});
|
|
2317
|
-
if (++count >= options.limit) {
|
|
2318
|
-
break alertsMapLoop;
|
|
2319
|
-
}
|
|
2320
2346
|
continue sockPkgAlertsLoop;
|
|
2321
2347
|
} catch (e) {
|
|
2322
2348
|
error = e;
|
|
2323
2349
|
}
|
|
2324
2350
|
}
|
|
2325
|
-
debug.debugFn('fail: invalid SocketPackageAlert
|
|
2351
|
+
debug.debugFn('error', 'fail: invalid SocketPackageAlert');
|
|
2352
|
+
debug.debugDir('inspect', {
|
|
2353
|
+
alert
|
|
2354
|
+
});
|
|
2326
2355
|
if (error) {
|
|
2327
|
-
|
|
2328
|
-
|
|
2356
|
+
debug.debugDir('inspect', {
|
|
2357
|
+
error: error.message ?? error
|
|
2358
|
+
});
|
|
2329
2359
|
}
|
|
2330
2360
|
}
|
|
2331
2361
|
}
|
|
@@ -2583,7 +2613,7 @@ async function getAlertsMapFromPurls(purls, options_) {
|
|
|
2583
2613
|
spinner
|
|
2584
2614
|
} = options;
|
|
2585
2615
|
const uniqPurls = arrays.arrayUnique(purls);
|
|
2586
|
-
debug.
|
|
2616
|
+
debug.debugDir('inspect', {
|
|
2587
2617
|
purls: uniqPurls
|
|
2588
2618
|
});
|
|
2589
2619
|
let {
|
|
@@ -2630,7 +2660,7 @@ async function getAlertsMapFromPurls(purls, options_) {
|
|
|
2630
2660
|
} else {
|
|
2631
2661
|
spinner?.stop();
|
|
2632
2662
|
logger.logger.fail(`Received a ${batchResult.status} response from Socket API which we consider a permanent failure:`, batchResult.error, batchResult.cause ? `( ${batchResult.cause} )` : '');
|
|
2633
|
-
debug.
|
|
2663
|
+
debug.debugDir('inspect', {
|
|
2634
2664
|
batchResult
|
|
2635
2665
|
});
|
|
2636
2666
|
break;
|
|
@@ -2815,9 +2845,53 @@ function runAgentInstall(pkgEnvDetails, options) {
|
|
|
2815
2845
|
});
|
|
2816
2846
|
}
|
|
2817
2847
|
|
|
2848
|
+
async function getNpmConfig(options) {
|
|
2849
|
+
const {
|
|
2850
|
+
cwd = process.cwd(),
|
|
2851
|
+
env = process.env,
|
|
2852
|
+
execPath = process.execPath,
|
|
2853
|
+
nodeVersion = process.version,
|
|
2854
|
+
npmCommand = 'install',
|
|
2855
|
+
npmPath = getNpmPath(),
|
|
2856
|
+
npmVersion,
|
|
2857
|
+
platform = process.platform
|
|
2858
|
+
} = {
|
|
2859
|
+
__proto__: null,
|
|
2860
|
+
...options
|
|
2861
|
+
};
|
|
2862
|
+
const config = new vendor.libExports$2({
|
|
2863
|
+
argv: [],
|
|
2864
|
+
cwd,
|
|
2865
|
+
definitions: vendor.definitionsExports.definitions,
|
|
2866
|
+
execPath,
|
|
2867
|
+
env: {
|
|
2868
|
+
...env
|
|
2869
|
+
},
|
|
2870
|
+
flatten: vendor.definitionsExports.flatten,
|
|
2871
|
+
npmPath,
|
|
2872
|
+
platform,
|
|
2873
|
+
shorthands: vendor.definitionsExports.shorthands
|
|
2874
|
+
});
|
|
2875
|
+
await config.load();
|
|
2876
|
+
const flatConfig = {
|
|
2877
|
+
__proto__: null,
|
|
2878
|
+
...config.flat
|
|
2879
|
+
};
|
|
2880
|
+
if (nodeVersion) {
|
|
2881
|
+
flatConfig.nodeVersion = nodeVersion;
|
|
2882
|
+
}
|
|
2883
|
+
if (npmCommand) {
|
|
2884
|
+
flatConfig.npmCommand = npmCommand;
|
|
2885
|
+
}
|
|
2886
|
+
if (npmVersion) {
|
|
2887
|
+
flatConfig.npmVersion = npmVersion.toString();
|
|
2888
|
+
}
|
|
2889
|
+
return flatConfig;
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2818
2892
|
async function spawnCoana(args, options, extra) {
|
|
2819
2893
|
const {
|
|
2820
|
-
env:
|
|
2894
|
+
env: spawnEnv
|
|
2821
2895
|
} = {
|
|
2822
2896
|
__proto__: null,
|
|
2823
2897
|
...options
|
|
@@ -2831,7 +2905,7 @@ async function spawnCoana(args, options, extra) {
|
|
|
2831
2905
|
...options,
|
|
2832
2906
|
env: {
|
|
2833
2907
|
...process.env,
|
|
2834
|
-
...
|
|
2908
|
+
...spawnEnv,
|
|
2835
2909
|
SOCKET_CLI_API_BASE_URL: constants.ENV.SOCKET_CLI_API_BASE_URL || undefined,
|
|
2836
2910
|
SOCKET_CLI_API_TOKEN: getDefaultToken()
|
|
2837
2911
|
}
|
|
@@ -2950,7 +3024,10 @@ async function getAgentVersion(agentExecPath, cwd) {
|
|
|
2950
3024
|
shell: constants.WIN32
|
|
2951
3025
|
})).stdout) ?? undefined;
|
|
2952
3026
|
} catch (e) {
|
|
2953
|
-
debug.debugFn('
|
|
3027
|
+
debug.debugFn('error', 'caught: unexpected error');
|
|
3028
|
+
debug.debugDir('inspect', {
|
|
3029
|
+
error: e
|
|
3030
|
+
});
|
|
2954
3031
|
}
|
|
2955
3032
|
return result;
|
|
2956
3033
|
}
|
|
@@ -3269,6 +3346,7 @@ exports.getFlagListOutput = getFlagListOutput;
|
|
|
3269
3346
|
exports.getMajor = getMajor;
|
|
3270
3347
|
exports.getMinVersion = getMinVersion;
|
|
3271
3348
|
exports.getNpmBinPath = getNpmBinPath;
|
|
3349
|
+
exports.getNpmConfig = getNpmConfig;
|
|
3272
3350
|
exports.getNpmRequire = getNpmRequire;
|
|
3273
3351
|
exports.getNpxBinPath = getNpxBinPath;
|
|
3274
3352
|
exports.getOutputKind = getOutputKind;
|
|
@@ -3319,5 +3397,5 @@ exports.tildify = tildify;
|
|
|
3319
3397
|
exports.updateConfigValue = updateConfigValue;
|
|
3320
3398
|
exports.walkNestedMap = walkNestedMap;
|
|
3321
3399
|
exports.writeSocketJson = writeSocketJson;
|
|
3322
|
-
//# debugId=
|
|
3400
|
+
//# debugId=ad76cecb-5b19-4d94-97e3-1d71fa1d1902
|
|
3323
3401
|
//# sourceMappingURL=utils.js.map
|