@socketsecurity/cli-with-sentry 1.1.9 → 1.1.13
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 +49 -28
- package/bin/cli.js +2 -1
- package/bin/npm-cli.js +2 -1
- package/bin/npx-cli.js +2 -1
- package/bin/pnpm-cli.js +29 -0
- package/bin/yarn-cli.js +29 -0
- package/dist/cli.js +786 -566
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +31 -9
- package/dist/constants.js.map +1 -1
- package/dist/flags.js +16 -17
- package/dist/flags.js.map +1 -1
- package/dist/instrument-with-sentry.js +3 -3
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/npm-cli.js +26 -0
- package/dist/npm-cli.js.map +1 -0
- package/dist/npx-cli.js +26 -0
- package/dist/npx-cli.js.map +1 -0
- package/dist/pnpm-cli.js +26 -0
- package/dist/pnpm-cli.js.map +1 -0
- package/dist/shadow-npm-inject.js +4 -4
- package/dist/shadow-npm-inject.js.map +1 -1
- package/dist/shadow-pnpm-bin.js +235 -0
- package/dist/shadow-pnpm-bin.js.map +1 -0
- package/dist/shadow-yarn-bin.js +200 -0
- package/dist/shadow-yarn-bin.js.map +1 -0
- package/dist/socket-completion.bash +0 -0
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/analytics/cmd-analytics.d.mts +2 -3
- package/dist/types/commands/analytics/cmd-analytics.d.mts.map +1 -1
- package/dist/types/commands/audit-log/cmd-audit-log.d.mts +2 -3
- package/dist/types/commands/audit-log/cmd-audit-log.d.mts.map +1 -1
- package/dist/types/commands/ci/cmd-ci.d.mts +2 -3
- package/dist/types/commands/ci/cmd-ci.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-auto.d.mts +2 -3
- package/dist/types/commands/config/cmd-config-auto.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-get.d.mts +2 -3
- package/dist/types/commands/config/cmd-config-get.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-list.d.mts +2 -3
- package/dist/types/commands/config/cmd-config-list.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-set.d.mts +2 -3
- package/dist/types/commands/config/cmd-config-set.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-unset.d.mts +2 -3
- package/dist/types/commands/config/cmd-config-unset.d.mts.map +1 -1
- package/dist/types/commands/fix/cmd-fix.d.mts +2 -3
- package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/env-helpers.d.mts +1 -1
- package/dist/types/commands/fix/env-helpers.d.mts.map +1 -1
- package/dist/types/commands/fix/git.d.mts +1 -1
- package/dist/types/commands/fix/git.d.mts.map +1 -1
- package/dist/types/commands/fix/handle-fix.d.mts +3 -1
- package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/pull-request.d.mts +1 -1
- package/dist/types/commands/fix/pull-request.d.mts.map +1 -1
- package/dist/types/commands/fix/types.d.mts +2 -0
- package/dist/types/commands/fix/types.d.mts.map +1 -1
- package/dist/types/commands/install/cmd-install-completion.d.mts +2 -3
- package/dist/types/commands/install/cmd-install-completion.d.mts.map +1 -1
- package/dist/types/commands/json/cmd-json.d.mts +2 -3
- package/dist/types/commands/json/cmd-json.d.mts.map +1 -1
- package/dist/types/commands/login/cmd-login.d.mts +2 -3
- package/dist/types/commands/login/cmd-login.d.mts.map +1 -1
- package/dist/types/commands/logout/cmd-logout.d.mts +2 -3
- package/dist/types/commands/logout/cmd-logout.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-auto.d.mts +2 -3
- package/dist/types/commands/manifest/cmd-manifest-auto.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts +2 -3
- package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-conda.d.mts +2 -3
- package/dist/types/commands/manifest/cmd-manifest-conda.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-gradle.d.mts +2 -3
- package/dist/types/commands/manifest/cmd-manifest-gradle.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-kotlin.d.mts +2 -3
- package/dist/types/commands/manifest/cmd-manifest-kotlin.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-scala.d.mts +2 -3
- package/dist/types/commands/manifest/cmd-manifest-scala.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-setup.d.mts +2 -3
- package/dist/types/commands/manifest/cmd-manifest-setup.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest.d.mts +2 -3
- package/dist/types/commands/manifest/cmd-manifest.d.mts.map +1 -1
- package/dist/types/commands/manifest/detect-manifest-actions.d.mts.map +1 -1
- package/dist/types/commands/manifest/generate_auto_manifest.d.mts.map +1 -1
- package/dist/types/commands/manifest/output-requirements.d.mts.map +1 -1
- package/dist/types/commands/manifest/run-cdxgen.d.mts.map +1 -1
- package/dist/types/commands/manifest/setup-manifest-config.d.mts.map +1 -1
- package/dist/types/commands/npm/cmd-npm.d.mts +2 -3
- package/dist/types/commands/npm/cmd-npm.d.mts.map +1 -1
- package/dist/types/commands/npx/cmd-npx.d.mts +2 -3
- package/dist/types/commands/npx/cmd-npx.d.mts.map +1 -1
- package/dist/types/commands/oops/cmd-oops.d.mts +2 -3
- package/dist/types/commands/oops/cmd-oops.d.mts.map +1 -1
- package/dist/types/commands/optimize/cmd-optimize.d.mts +2 -3
- package/dist/types/commands/optimize/cmd-optimize.d.mts.map +1 -1
- package/dist/types/commands/organization/cmd-organization-dependencies.d.mts +2 -3
- package/dist/types/commands/organization/cmd-organization-dependencies.d.mts.map +1 -1
- package/dist/types/commands/organization/cmd-organization-list.d.mts +2 -3
- package/dist/types/commands/organization/cmd-organization-list.d.mts.map +1 -1
- package/dist/types/commands/organization/cmd-organization-policy-license.d.mts +2 -3
- package/dist/types/commands/organization/cmd-organization-policy-license.d.mts.map +1 -1
- package/dist/types/commands/organization/cmd-organization-policy-security.d.mts +2 -3
- package/dist/types/commands/organization/cmd-organization-policy-security.d.mts.map +1 -1
- package/dist/types/commands/organization/cmd-organization-quota.d.mts +2 -3
- package/dist/types/commands/organization/cmd-organization-quota.d.mts.map +1 -1
- package/dist/types/commands/package/cmd-package-score.d.mts +2 -3
- package/dist/types/commands/package/cmd-package-score.d.mts.map +1 -1
- package/dist/types/commands/package/cmd-package-shallow.d.mts +2 -3
- package/dist/types/commands/package/cmd-package-shallow.d.mts.map +1 -1
- package/dist/types/commands/patch/cmd-patch.d.mts +2 -3
- package/dist/types/commands/patch/cmd-patch.d.mts.map +1 -1
- package/dist/types/commands/pnpm/cmd-pnpm.d.mts +10 -0
- package/dist/types/commands/pnpm/cmd-pnpm.d.mts.map +1 -0
- package/dist/types/commands/raw-npm/cmd-raw-npm.d.mts +2 -3
- package/dist/types/commands/raw-npm/cmd-raw-npm.d.mts.map +1 -1
- package/dist/types/commands/raw-npx/cmd-raw-npx.d.mts +2 -3
- package/dist/types/commands/raw-npx/cmd-raw-npx.d.mts.map +1 -1
- package/dist/types/commands/repository/cmd-repository-create.d.mts +2 -3
- package/dist/types/commands/repository/cmd-repository-create.d.mts.map +1 -1
- package/dist/types/commands/repository/cmd-repository-del.d.mts +2 -3
- package/dist/types/commands/repository/cmd-repository-del.d.mts.map +1 -1
- package/dist/types/commands/repository/cmd-repository-list.d.mts +2 -3
- package/dist/types/commands/repository/cmd-repository-list.d.mts.map +1 -1
- package/dist/types/commands/repository/cmd-repository-update.d.mts +2 -3
- package/dist/types/commands/repository/cmd-repository-update.d.mts.map +1 -1
- package/dist/types/commands/repository/cmd-repository-view.d.mts +2 -3
- package/dist/types/commands/repository/cmd-repository-view.d.mts.map +1 -1
- package/dist/types/commands/repository/handle-list-repos.d.mts +2 -1
- package/dist/types/commands/repository/handle-list-repos.d.mts.map +1 -1
- package/dist/types/commands/repository/output-list-repos.d.mts +2 -1
- package/dist/types/commands/repository/output-list-repos.d.mts.map +1 -1
- package/dist/types/commands/repository/types.d.mts +2 -0
- package/dist/types/commands/repository/types.d.mts.map +1 -0
- package/dist/types/commands/scan/cmd-scan-create.d.mts +2 -3
- package/dist/types/commands/scan/cmd-scan-create.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-del.d.mts +2 -3
- package/dist/types/commands/scan/cmd-scan-del.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-diff.d.mts +2 -3
- package/dist/types/commands/scan/cmd-scan-diff.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-github.d.mts +2 -3
- package/dist/types/commands/scan/cmd-scan-github.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-list.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-metadata.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-reach.d.mts +2 -3
- package/dist/types/commands/scan/cmd-scan-reach.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-report.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-setup.d.mts +2 -3
- package/dist/types/commands/scan/cmd-scan-setup.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-view.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts +1 -1
- package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts.map +1 -1
- package/dist/types/commands/threat-feed/cmd-threat-feed.d.mts +2 -3
- package/dist/types/commands/threat-feed/cmd-threat-feed.d.mts.map +1 -1
- package/dist/types/commands/uninstall/cmd-uninstall-completion.d.mts +2 -3
- package/dist/types/commands/uninstall/cmd-uninstall-completion.d.mts.map +1 -1
- package/dist/types/commands/wrapper/cmd-wrapper.d.mts +2 -3
- package/dist/types/commands/wrapper/cmd-wrapper.d.mts.map +1 -1
- package/dist/types/commands/yarn/cmd-yarn.d.mts +10 -0
- package/dist/types/commands/yarn/cmd-yarn.d.mts.map +1 -0
- package/dist/types/commands.d.mts +31 -63
- package/dist/types/commands.d.mts.map +1 -1
- package/dist/types/constants.d.mts +15 -1
- package/dist/types/constants.d.mts.map +1 -1
- package/dist/types/flags.d.mts.map +1 -1
- package/dist/types/npm-cli.d.mts +3 -0
- package/dist/types/npm-cli.d.mts.map +1 -0
- package/dist/types/npx-cli.d.mts +3 -0
- package/dist/types/npx-cli.d.mts.map +1 -0
- package/dist/types/pnpm-cli.d.mts +3 -0
- package/dist/types/pnpm-cli.d.mts.map +1 -0
- package/dist/types/shadow/npm/install.d.mts +1 -1
- package/dist/types/shadow/npm/install.d.mts.map +1 -1
- package/dist/types/shadow/pnpm/bin.d.mts +10 -0
- package/dist/types/shadow/pnpm/bin.d.mts.map +1 -0
- package/dist/types/shadow/pnpm/link.d.mts +2 -0
- package/dist/types/shadow/pnpm/link.d.mts.map +1 -0
- package/dist/types/shadow/yarn/bin.d.mts +10 -0
- package/dist/types/shadow/yarn/bin.d.mts.map +1 -0
- package/dist/types/shadow/yarn/link.d.mts +2 -0
- package/dist/types/shadow/yarn/link.d.mts.map +1 -0
- package/dist/types/utils/alerts-map.d.mts.map +1 -1
- package/dist/types/utils/cmd.d.mts +25 -1
- package/dist/types/utils/cmd.d.mts.map +1 -1
- package/dist/types/utils/coana.d.mts.map +1 -1
- package/dist/types/utils/config.d.mts +1 -1
- package/dist/types/utils/config.d.mts.map +1 -1
- package/dist/types/utils/git.d.mts +4 -4
- package/dist/types/utils/git.d.mts.map +1 -1
- package/dist/types/utils/github.d.mts.map +1 -1
- package/dist/types/utils/lockfile.d.mts +1 -1
- package/dist/types/utils/lockfile.d.mts.map +1 -1
- package/dist/types/utils/meow-with-subcommands.d.mts +16 -1
- package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
- package/dist/types/utils/npm-config.d.mts +1 -1
- package/dist/types/utils/npm-config.d.mts.map +1 -1
- package/dist/types/utils/npm-package-arg.d.mts +1 -1
- package/dist/types/utils/npm-package-arg.d.mts.map +1 -1
- package/dist/types/utils/output-formatting.d.mts.map +1 -1
- package/dist/types/utils/package-environment.d.mts.map +1 -1
- package/dist/types/utils/pnpm-paths.d.mts +5 -0
- package/dist/types/utils/pnpm-paths.d.mts.map +1 -0
- package/dist/types/utils/pnpm.d.mts +2 -2
- package/dist/types/utils/pnpm.d.mts.map +1 -1
- package/dist/types/utils/purl.d.mts +6 -6
- package/dist/types/utils/purl.d.mts.map +1 -1
- package/dist/types/utils/sdk.d.mts.map +1 -1
- package/dist/types/utils/semver.d.mts +2 -2
- package/dist/types/utils/semver.d.mts.map +1 -1
- package/dist/types/utils/socket-json.d.mts +3 -0
- package/dist/types/utils/socket-json.d.mts.map +1 -1
- package/dist/types/utils/strings.d.mts +2 -0
- package/dist/types/utils/strings.d.mts.map +1 -0
- package/dist/types/utils/yarn-paths.d.mts +5 -0
- package/dist/types/utils/yarn-paths.d.mts.map +1 -0
- package/dist/types/utils/yarn-version.d.mts +2 -0
- package/dist/types/utils/yarn-version.d.mts.map +1 -0
- package/dist/types/yarn-cli.d.mts +3 -0
- package/dist/types/yarn-cli.d.mts.map +1 -0
- package/dist/utils.js +404 -104
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +58633 -64690
- package/dist/yarn-cli.js +26 -0
- package/dist/yarn-cli.js.map +1 -0
- package/external/blessed/lib/tput.js +13 -13
- package/external/blessed/lib/widgets/ansiimage.js +1 -1
- package/external/blessed/lib/widgets/bigtext.js +1 -1
- package/external/blessed/lib/widgets/box.js +1 -1
- package/external/blessed/lib/widgets/button.js +1 -1
- package/external/blessed/lib/widgets/checkbox.js +1 -1
- package/external/blessed/lib/widgets/element.js +1 -1
- package/external/blessed/lib/widgets/filemanager.js +1 -1
- package/external/blessed/lib/widgets/form.js +1 -1
- package/external/blessed/lib/widgets/image.js +1 -1
- package/external/blessed/lib/widgets/input.js +1 -1
- package/external/blessed/lib/widgets/layout.js +1 -1
- package/external/blessed/lib/widgets/line.js +1 -1
- package/external/blessed/lib/widgets/list.js +1 -1
- package/external/blessed/lib/widgets/listbar.js +1 -1
- package/external/blessed/lib/widgets/listtable.js +1 -1
- package/external/blessed/lib/widgets/loading.js +1 -1
- package/external/blessed/lib/widgets/log.js +1 -1
- package/external/blessed/lib/widgets/message.js +1 -1
- package/external/blessed/lib/widgets/node.js +3 -2
- package/external/blessed/lib/widgets/overlayimage.js +1 -1
- package/external/blessed/lib/widgets/progressbar.js +1 -1
- package/external/blessed/lib/widgets/prompt.js +1 -1
- package/external/blessed/lib/widgets/question.js +1 -1
- package/external/blessed/lib/widgets/radiobutton.js +1 -1
- package/external/blessed/lib/widgets/radioset.js +1 -1
- package/external/blessed/lib/widgets/screen.js +8 -6
- package/external/blessed/lib/widgets/scrollablebox.js +1 -1
- package/external/blessed/lib/widgets/scrollabletext.js +1 -1
- package/external/blessed/lib/widgets/table.js +1 -1
- package/external/blessed/lib/widgets/terminal.js +1 -1
- package/external/blessed/lib/widgets/text.js +1 -1
- package/external/blessed/lib/widgets/textarea.js +1 -1
- package/external/blessed/lib/widgets/textbox.js +1 -1
- package/external/blessed/lib/widgets/video.js +1 -1
- package/external/blessed/vendor/tng.js +11 -4
- package/external/blessed-contrib/lib/widget/charts/bar.js +4 -4
- package/external/blessed-contrib/lib/widget/charts/line.js +4 -4
- package/logo-dark.png +0 -0
- package/logo-light.png +0 -0
- package/package.json +67 -94
- package/shadow-bin/npm +1 -1
- package/shadow-bin/npx +1 -1
- package/shadow-bin/pnpm +27 -0
- package/shadow-bin/yarn +27 -0
package/dist/utils.js
CHANGED
|
@@ -17,14 +17,14 @@ var regexps = require('../external/@socketsecurity/registry/lib/regexps');
|
|
|
17
17
|
var prompts = require('../external/@socketsecurity/registry/lib/prompts');
|
|
18
18
|
var spawn = require('../external/@socketsecurity/registry/lib/spawn');
|
|
19
19
|
var fs = require('../external/@socketsecurity/registry/lib/fs');
|
|
20
|
-
var
|
|
20
|
+
var require$$5 = require('node:module');
|
|
21
21
|
var shadowNpmBin = require('./shadow-npm-bin.js');
|
|
22
22
|
var fs$1 = require('node:fs');
|
|
23
23
|
var require$$13 = require('../external/@socketsecurity/registry/lib/url');
|
|
24
24
|
var promises = require('node:timers/promises');
|
|
25
25
|
var npm = require('../external/@socketsecurity/registry/lib/npm');
|
|
26
|
-
var globs = require('../external/@socketsecurity/registry/lib/globs');
|
|
27
26
|
var packages = require('../external/@socketsecurity/registry/lib/packages');
|
|
27
|
+
var globs = require('../external/@socketsecurity/registry/lib/globs');
|
|
28
28
|
var streams = require('../external/@socketsecurity/registry/lib/streams');
|
|
29
29
|
|
|
30
30
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
@@ -92,20 +92,30 @@ function findSocketYmlSync(dir = process.cwd()) {
|
|
|
92
92
|
if (typeof yml === 'string') {
|
|
93
93
|
try {
|
|
94
94
|
return {
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
ok: true,
|
|
96
|
+
data: {
|
|
97
|
+
path: ymlPath,
|
|
98
|
+
parsed: vendor.configExports.parseSocketConfig(yml)
|
|
99
|
+
}
|
|
97
100
|
};
|
|
98
101
|
} catch (e) {
|
|
99
102
|
require$$9.debugDir('inspect', {
|
|
100
103
|
error: e
|
|
101
104
|
});
|
|
102
|
-
|
|
105
|
+
return {
|
|
106
|
+
ok: false,
|
|
107
|
+
message: `Found file but was unable to parse ${ymlPath}`,
|
|
108
|
+
cause: e instanceof Error ? e.message : String(e)
|
|
109
|
+
};
|
|
103
110
|
}
|
|
104
111
|
}
|
|
105
112
|
prevDir = dir;
|
|
106
113
|
dir = path.join(dir, '..');
|
|
107
114
|
}
|
|
108
|
-
return
|
|
115
|
+
return {
|
|
116
|
+
ok: true,
|
|
117
|
+
data: undefined
|
|
118
|
+
};
|
|
109
119
|
}
|
|
110
120
|
function getConfigValue(key) {
|
|
111
121
|
const localConfig = getConfigValues();
|
|
@@ -256,7 +266,7 @@ function updateConfigValue(configKey, value) {
|
|
|
256
266
|
};
|
|
257
267
|
}
|
|
258
268
|
|
|
259
|
-
const require$2 =
|
|
269
|
+
const require$2 = require$$5.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils.js', document.baseURI).href)));
|
|
260
270
|
let _requirements;
|
|
261
271
|
function getRequirements() {
|
|
262
272
|
if (_requirements === undefined) {
|
|
@@ -555,7 +565,7 @@ async function handleApiCallNoSpinner(value, description) {
|
|
|
555
565
|
async function queryApi(path, apiToken) {
|
|
556
566
|
const baseUrl = getDefaultApiBaseUrl();
|
|
557
567
|
if (!baseUrl) {
|
|
558
|
-
throw new Error('Socket API
|
|
568
|
+
throw new Error('Socket API base URL is not configured.');
|
|
559
569
|
}
|
|
560
570
|
return await fetch(`${baseUrl}${baseUrl.endsWith('/') ? '' : '/'}${path}`, {
|
|
561
571
|
method: 'GET',
|
|
@@ -964,9 +974,10 @@ function getOutputKind(json, markdown) {
|
|
|
964
974
|
return constants.OUTPUT_TEXT;
|
|
965
975
|
}
|
|
966
976
|
|
|
967
|
-
function camelToKebab(
|
|
968
|
-
return
|
|
977
|
+
function camelToKebab(str) {
|
|
978
|
+
return str === '' ? '' : str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
969
979
|
}
|
|
980
|
+
|
|
970
981
|
function getFlagApiRequirementsOutput(cmdPath, options) {
|
|
971
982
|
const {
|
|
972
983
|
indent = 6
|
|
@@ -1049,6 +1060,10 @@ function tildify(cwd) {
|
|
|
1049
1060
|
|
|
1050
1061
|
const HELP_INDENT = 2;
|
|
1051
1062
|
const HELP_PAD_NAME = 28;
|
|
1063
|
+
|
|
1064
|
+
/**
|
|
1065
|
+
* Format a command description for help output.
|
|
1066
|
+
*/
|
|
1052
1067
|
function description(command) {
|
|
1053
1068
|
const description = command?.description;
|
|
1054
1069
|
const str = typeof description === 'string' ? description : String(description);
|
|
@@ -1073,6 +1088,10 @@ function findBestCommandMatch(input, subcommands, aliases) {
|
|
|
1073
1088
|
}
|
|
1074
1089
|
return bestMatch;
|
|
1075
1090
|
}
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* Generate the ASCII banner header for Socket CLI commands.
|
|
1094
|
+
*/
|
|
1076
1095
|
function getAsciiHeader(command, orgFlag) {
|
|
1077
1096
|
// Note: In tests we return <redacted> because otherwise snapshots will fail.
|
|
1078
1097
|
const {
|
|
@@ -1116,19 +1135,28 @@ function levenshteinDistance(a, b) {
|
|
|
1116
1135
|
for (let i = 1; i <= a.length; i++) {
|
|
1117
1136
|
for (let j = 1; j <= b.length; j++) {
|
|
1118
1137
|
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
1119
|
-
matrix[i][j] = Math.min(
|
|
1138
|
+
matrix[i][j] = Math.min(
|
|
1120
1139
|
// Deletion.
|
|
1121
|
-
matrix[i
|
|
1140
|
+
matrix[i - 1][j] + 1,
|
|
1122
1141
|
// Insertion.
|
|
1123
|
-
matrix[i
|
|
1124
|
-
|
|
1142
|
+
matrix[i][j - 1] + 1,
|
|
1143
|
+
// Substitution.
|
|
1144
|
+
matrix[i - 1][j - 1] + cost);
|
|
1125
1145
|
}
|
|
1126
1146
|
}
|
|
1127
1147
|
return matrix[a.length][b.length];
|
|
1128
1148
|
}
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* Determine if the banner should be suppressed based on output flags.
|
|
1152
|
+
*/
|
|
1129
1153
|
function shouldSuppressBanner(flags) {
|
|
1130
|
-
return Boolean(flags['json'] || flags['markdown'] || flags['
|
|
1154
|
+
return Boolean(flags['json'] || flags['markdown'] || flags['banner'] === false);
|
|
1131
1155
|
}
|
|
1156
|
+
|
|
1157
|
+
/**
|
|
1158
|
+
* Emit the Socket CLI banner to stderr for branding and debugging.
|
|
1159
|
+
*/
|
|
1132
1160
|
function emitBanner(name, orgFlag) {
|
|
1133
1161
|
// Print a banner at the top of each command.
|
|
1134
1162
|
// This helps with brand recognition and marketing.
|
|
@@ -1140,6 +1168,10 @@ function emitBanner(name, orgFlag) {
|
|
|
1140
1168
|
// The spinner also emits over stderr for example.
|
|
1141
1169
|
logger.logger.error(getAsciiHeader(name, orgFlag));
|
|
1142
1170
|
}
|
|
1171
|
+
|
|
1172
|
+
/**
|
|
1173
|
+
* Main function for handling CLI with subcommands using meow.
|
|
1174
|
+
*/
|
|
1143
1175
|
async function meowWithSubcommands(subcommands, options) {
|
|
1144
1176
|
const {
|
|
1145
1177
|
aliases = {},
|
|
@@ -1152,11 +1184,6 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1152
1184
|
__proto__: null,
|
|
1153
1185
|
...options
|
|
1154
1186
|
};
|
|
1155
|
-
const [commandOrAliasName_, ...rawCommandArgv] = argv;
|
|
1156
|
-
let commandOrAliasName = commandOrAliasName_;
|
|
1157
|
-
if (!commandOrAliasName && defaultSub) {
|
|
1158
|
-
commandOrAliasName = defaultSub;
|
|
1159
|
-
}
|
|
1160
1187
|
const flags$1 = {
|
|
1161
1188
|
...flags.commonFlags,
|
|
1162
1189
|
version: {
|
|
@@ -1164,13 +1191,18 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1164
1191
|
hidden: true,
|
|
1165
1192
|
description: 'Print the app version'
|
|
1166
1193
|
},
|
|
1167
|
-
...additionalOptions
|
|
1194
|
+
...require$$11.getOwn(additionalOptions, 'flags')
|
|
1168
1195
|
};
|
|
1196
|
+
const [commandOrAliasName_, ...rawCommandArgv] = argv;
|
|
1197
|
+
let commandOrAliasName = commandOrAliasName_;
|
|
1198
|
+
if (!commandOrAliasName && defaultSub) {
|
|
1199
|
+
commandOrAliasName = defaultSub;
|
|
1200
|
+
}
|
|
1169
1201
|
|
|
1170
|
-
// No further args or first arg is a flag (shrug)
|
|
1202
|
+
// No further args or first arg is a flag (shrug).
|
|
1171
1203
|
const isRootCommand = name === 'socket' && (!commandOrAliasName || commandOrAliasName?.startsWith('-'));
|
|
1172
1204
|
|
|
1173
|
-
// Try to support `socket <purl>` as a shorthand for `socket package score <purl
|
|
1205
|
+
// Try to support `socket <purl>` as a shorthand for `socket package score <purl>`.
|
|
1174
1206
|
if (!isRootCommand) {
|
|
1175
1207
|
if (commandOrAliasName?.startsWith('pkg:')) {
|
|
1176
1208
|
logger.logger.info('Invoking `socket package score`.');
|
|
@@ -1243,7 +1275,6 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1243
1275
|
if (noSpinner) {
|
|
1244
1276
|
constants.default.spinner.spinner = spinner.getCliSpinners('ci');
|
|
1245
1277
|
}
|
|
1246
|
-
|
|
1247
1278
|
// Hard override the config if instructed to do so.
|
|
1248
1279
|
// The env var overrides the --flag, which overrides the persisted config
|
|
1249
1280
|
// Also, when either of these are used, config updates won't persist.
|
|
@@ -1251,7 +1282,7 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1251
1282
|
if (constants.default.ENV.SOCKET_CLI_CONFIG) {
|
|
1252
1283
|
configOverrideResult = overrideCachedConfig(constants.default.ENV.SOCKET_CLI_CONFIG);
|
|
1253
1284
|
} else if (cli1.flags['config']) {
|
|
1254
|
-
configOverrideResult = overrideCachedConfig(
|
|
1285
|
+
configOverrideResult = overrideCachedConfig(cli1.flags['config']);
|
|
1255
1286
|
}
|
|
1256
1287
|
if (constants.default.ENV.SOCKET_CLI_NO_API_TOKEN) {
|
|
1257
1288
|
// This overrides the config override and even the explicit token env var.
|
|
@@ -1285,6 +1316,8 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1285
1316
|
const commandDefinition = commandName ? subcommands[commandName] : undefined;
|
|
1286
1317
|
// Third: If a valid command has been found, then we run it...
|
|
1287
1318
|
if (commandDefinition) {
|
|
1319
|
+
// Extract the original command arguments from the full argv
|
|
1320
|
+
// by skipping the command name
|
|
1288
1321
|
return await commandDefinition.run(commandArgv, importMeta, {
|
|
1289
1322
|
parentName: name
|
|
1290
1323
|
});
|
|
@@ -1311,9 +1344,12 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1311
1344
|
//'json',
|
|
1312
1345
|
'license', 'login', 'logout', 'manifest', constants.NPM, constants.NPX, 'optimize', 'organization', 'package',
|
|
1313
1346
|
//'patch',
|
|
1347
|
+
// PNPM,
|
|
1314
1348
|
'raw-npm', 'raw-npx', 'repository', 'scan',
|
|
1315
1349
|
//'security',
|
|
1316
|
-
'threat-feed', 'uninstall', 'wrapper'
|
|
1350
|
+
'threat-feed', 'uninstall', 'wrapper'
|
|
1351
|
+
// YARN,
|
|
1352
|
+
]);
|
|
1317
1353
|
Object.entries(subcommands).filter(([_name, subcommand]) => !subcommand.hidden).map(([name]) => name).forEach(name => {
|
|
1318
1354
|
if (commands.has(name)) {
|
|
1319
1355
|
commands.delete(name);
|
|
@@ -1357,6 +1393,11 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1357
1393
|
}
|
|
1358
1394
|
lines.push(` ${getFlagListOutput({
|
|
1359
1395
|
...flags$1,
|
|
1396
|
+
// Explicitly document the negated --no-banner variant.
|
|
1397
|
+
noBanner: {
|
|
1398
|
+
...flags$1['banner'],
|
|
1399
|
+
hidden: false
|
|
1400
|
+
},
|
|
1360
1401
|
// Explicitly document the negated --no-spinner variant.
|
|
1361
1402
|
noSpinner: {
|
|
1362
1403
|
...flags$1['spinner'],
|
|
@@ -1367,12 +1408,12 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1367
1408
|
padName: HELP_PAD_NAME
|
|
1368
1409
|
})}`);
|
|
1369
1410
|
if (isRootCommand) {
|
|
1370
|
-
lines.push('', 'Environment variables', ' SOCKET_CLI_API_TOKEN Set the Socket API token', ' SOCKET_CLI_CONFIG A JSON stringified Socket configuration object', ' SOCKET_CLI_GITHUB_API_URL Change the base URL for GitHub REST API calls', ' SOCKET_CLI_GIT_USER_EMAIL The git config `user.email` used by Socket CLI', ` ${vendor.yoctocolorsCjsExports.italic('Defaults:')} github-actions[bot]@users.noreply.github.com`, ' SOCKET_CLI_GIT_USER_NAME The git config `user.name` used by Socket CLI', ` ${vendor.yoctocolorsCjsExports.italic('Defaults:')} github-actions[bot]`, ` SOCKET_CLI_GITHUB_TOKEN A classic or fine-grained ${vendor.terminalLinkExports('GitHub personal access token', 'https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens')}`, ` ${vendor.yoctocolorsCjsExports.italic('Aliases:')} GITHUB_TOKEN`, ' SOCKET_CLI_NO_API_TOKEN Make the default API token `undefined`', ' SOCKET_CLI_NPM_PATH The absolute location of the npm directory', ' SOCKET_CLI_ORG_SLUG Specify the Socket organization slug', '', ' SOCKET_CLI_ACCEPT_RISKS Accept risks of a Socket wrapped npm/npx run', ' SOCKET_CLI_VIEW_ALL_RISKS View all risks of a Socket wrapped npm/npx run', '', 'Environment variables for development', ' SOCKET_CLI_API_BASE_URL Change the base URL for Socket API calls', ` ${vendor.yoctocolorsCjsExports.italic('Defaults:')} The "apiBaseUrl" value of socket/settings local app data`,
|
|
1411
|
+
lines.push('', 'Environment variables', ' SOCKET_CLI_API_TOKEN Set the Socket API token', ' SOCKET_CLI_CONFIG A JSON stringified Socket configuration object', ' SOCKET_CLI_GITHUB_API_URL Change the base URL for GitHub REST API calls', ' SOCKET_CLI_GIT_USER_EMAIL The git config `user.email` used by Socket CLI', ` ${vendor.yoctocolorsCjsExports.italic('Defaults:')} github-actions[bot]@users.noreply.github.com`, ' SOCKET_CLI_GIT_USER_NAME The git config `user.name` used by Socket CLI', ` ${vendor.yoctocolorsCjsExports.italic('Defaults:')} github-actions[bot]`, ` SOCKET_CLI_GITHUB_TOKEN A classic or fine-grained ${vendor.terminalLinkExports('GitHub personal access token', 'https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens')}`, ` ${vendor.yoctocolorsCjsExports.italic('Aliases:')} GITHUB_TOKEN`, ' SOCKET_CLI_NO_API_TOKEN Make the default API token `undefined`', ' SOCKET_CLI_NPM_PATH The absolute location of the npm directory', ' SOCKET_CLI_ORG_SLUG Specify the Socket organization slug', '', ' SOCKET_CLI_ACCEPT_RISKS Accept risks of a Socket wrapped npm/npx run', ' SOCKET_CLI_VIEW_ALL_RISKS View all risks of a Socket wrapped npm/npx run', '', 'Environment variables for development', ' SOCKET_CLI_API_BASE_URL Change the base URL for Socket API calls', ` ${vendor.yoctocolorsCjsExports.italic('Defaults:')} The "apiBaseUrl" value of socket/settings local app data`, ` if present, else ${constants.API_V0_URL}`, ' SOCKET_CLI_API_PROXY Set the proxy Socket API requests are routed through, e.g. if set to', ` ${vendor.terminalLinkExports('http://127.0.0.1:9090', 'https://docs.proxyman.io/troubleshooting/couldnt-see-any-requests-from-3rd-party-network-libraries')} then all request are passed through that proxy`, ` ${vendor.yoctocolorsCjsExports.italic('Aliases:')} HTTPS_PROXY, https_proxy, HTTP_PROXY, and http_proxy`, ' SOCKET_CLI_API_TIMEOUT Set the timeout in milliseconds for Socket API requests', ' SOCKET_CLI_DEBUG Enable debug logging in Socket CLI', ` DEBUG Enable debug logging based on the ${vendor.terminalLinkExports('debug', `${constants.SOCKET_WEBSITE_URL}/npm/package/debug`)} package`);
|
|
1371
1412
|
}
|
|
1372
1413
|
|
|
1373
1414
|
// Parse it again. Config overrides should now be applied (may affect help).
|
|
1374
1415
|
// Note: this is displayed as help screen if the command does not override it
|
|
1375
|
-
// (which is the case for most sub-commands with sub-commands)
|
|
1416
|
+
// (which is the case for most sub-commands with sub-commands).
|
|
1376
1417
|
const cli2 = vendor.meow({
|
|
1377
1418
|
argv,
|
|
1378
1419
|
importMeta,
|
|
@@ -1392,7 +1433,7 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1392
1433
|
// ...else we provide basic instructions and help.
|
|
1393
1434
|
if (!shouldSuppressBanner(cli2.flags)) {
|
|
1394
1435
|
emitBanner(name, orgFlag);
|
|
1395
|
-
//
|
|
1436
|
+
// Meow will add newline so don't add stderr spacing here.
|
|
1396
1437
|
}
|
|
1397
1438
|
if (!cli2.flags['help'] && cli2.flags['dryRun']) {
|
|
1398
1439
|
process.exitCode = 0;
|
|
@@ -1405,7 +1446,8 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1405
1446
|
}
|
|
1406
1447
|
|
|
1407
1448
|
/**
|
|
1408
|
-
*
|
|
1449
|
+
* Create meow CLI instance or exit with help/error (meow will exit immediately
|
|
1450
|
+
* if it calls .showHelp()).
|
|
1409
1451
|
*/
|
|
1410
1452
|
function meowOrExit({
|
|
1411
1453
|
allowUnknownFlags = true,
|
|
@@ -1430,14 +1472,19 @@ function meowOrExit({
|
|
|
1430
1472
|
help: strings.trimNewlines(config.help(command, config)),
|
|
1431
1473
|
importMeta
|
|
1432
1474
|
});
|
|
1433
|
-
const
|
|
1475
|
+
const {
|
|
1476
|
+
help: helpFlag,
|
|
1477
|
+
org: orgFlag,
|
|
1478
|
+
spinner: spinnerFlag,
|
|
1479
|
+
version: versionFlag
|
|
1480
|
+
} = cli.flags;
|
|
1481
|
+
const noSpinner = spinnerFlag === false;
|
|
1434
1482
|
|
|
1435
1483
|
// Use CI spinner style when --no-spinner is passed.
|
|
1436
1484
|
if (noSpinner) {
|
|
1437
1485
|
constants.default.spinner.spinner = spinner.getCliSpinners('ci');
|
|
1438
1486
|
}
|
|
1439
1487
|
if (!shouldSuppressBanner(cli.flags)) {
|
|
1440
|
-
const orgFlag = String(cli.flags['org'] || '').trim() || undefined;
|
|
1441
1488
|
emitBanner(command, orgFlag);
|
|
1442
1489
|
// Add newline in stderr.
|
|
1443
1490
|
// Meow help adds a newline too so we do it here.
|
|
@@ -1462,12 +1509,12 @@ function meowOrExit({
|
|
|
1462
1509
|
// })
|
|
1463
1510
|
// }
|
|
1464
1511
|
|
|
1465
|
-
if (
|
|
1512
|
+
if (helpFlag) {
|
|
1466
1513
|
cli.showHelp(0);
|
|
1467
1514
|
}
|
|
1468
1515
|
|
|
1469
1516
|
// Meow doesn't detect 'version' as an unknown flag, so we do the leg work here.
|
|
1470
|
-
if (!require$$11.hasOwn(config.flags, 'version')
|
|
1517
|
+
if (versionFlag && !require$$11.hasOwn(config.flags, 'version')) {
|
|
1471
1518
|
// Use `console.error` here instead of `logger.error` to match Meow behavior.
|
|
1472
1519
|
console.error('Unknown flag\n--version');
|
|
1473
1520
|
// eslint-disable-next-line n/no-process-exit
|
|
@@ -1477,7 +1524,6 @@ function meowOrExit({
|
|
|
1477
1524
|
// Now test for help state. Run Meow again. If it exits now, it must be due
|
|
1478
1525
|
// to wanting to print the help screen. But it would exit(0) and we want a
|
|
1479
1526
|
// consistent exit(2) for that case (missing input).
|
|
1480
|
-
// TODO: Move away from meow.
|
|
1481
1527
|
process.exitCode = 2;
|
|
1482
1528
|
vendor.meow({
|
|
1483
1529
|
argv,
|
|
@@ -1748,7 +1794,7 @@ async function getBaseBranch(cwd = process.cwd()) {
|
|
|
1748
1794
|
return 'main';
|
|
1749
1795
|
}
|
|
1750
1796
|
async function getRepoInfo(cwd = process.cwd()) {
|
|
1751
|
-
let info
|
|
1797
|
+
let info;
|
|
1752
1798
|
const quotedCmd = '`git remote get-url origin`';
|
|
1753
1799
|
require$$9.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
1754
1800
|
try {
|
|
@@ -1814,7 +1860,7 @@ async function gitBranch(cwd = process.cwd()) {
|
|
|
1814
1860
|
});
|
|
1815
1861
|
}
|
|
1816
1862
|
}
|
|
1817
|
-
return
|
|
1863
|
+
return undefined;
|
|
1818
1864
|
}
|
|
1819
1865
|
|
|
1820
1866
|
/**
|
|
@@ -2125,7 +2171,7 @@ async function gitUnstagedModifiedFiles(cwd = process.cwd()) {
|
|
|
2125
2171
|
}
|
|
2126
2172
|
const parsedGitRemoteUrlCache = new Map();
|
|
2127
2173
|
function parseGitRemoteUrl(remoteUrl) {
|
|
2128
|
-
let result = parsedGitRemoteUrlCache.get(remoteUrl)
|
|
2174
|
+
let result = parsedGitRemoteUrlCache.get(remoteUrl);
|
|
2129
2175
|
if (result) {
|
|
2130
2176
|
return {
|
|
2131
2177
|
...result
|
|
@@ -2177,7 +2223,7 @@ function getPurlObject(purl, options) {
|
|
|
2177
2223
|
if (shouldThrow) {
|
|
2178
2224
|
throw e;
|
|
2179
2225
|
}
|
|
2180
|
-
return
|
|
2226
|
+
return undefined;
|
|
2181
2227
|
}
|
|
2182
2228
|
}
|
|
2183
2229
|
function normalizePurl(rawPurl) {
|
|
@@ -2517,7 +2563,7 @@ async function getPackageFilesForScan(inputPaths, supportedFiles, options) {
|
|
|
2517
2563
|
return filterBySupportedScanFiles(filepaths, supportedFiles);
|
|
2518
2564
|
}
|
|
2519
2565
|
|
|
2520
|
-
function exitWithBinPathError(binName) {
|
|
2566
|
+
function exitWithBinPathError$2(binName) {
|
|
2521
2567
|
logger.logger.fail(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable`);
|
|
2522
2568
|
// The exit code 127 indicates that the command or binary being executed
|
|
2523
2569
|
// could not be found.
|
|
@@ -2529,7 +2575,7 @@ function getNpmBinPath() {
|
|
|
2529
2575
|
if (_npmBinPath === undefined) {
|
|
2530
2576
|
_npmBinPath = getNpmBinPathDetails().path;
|
|
2531
2577
|
if (!_npmBinPath) {
|
|
2532
|
-
exitWithBinPathError(constants.NPM);
|
|
2578
|
+
exitWithBinPathError$2(constants.NPM);
|
|
2533
2579
|
}
|
|
2534
2580
|
}
|
|
2535
2581
|
return _npmBinPath;
|
|
@@ -2570,7 +2616,7 @@ function getNpmRequire() {
|
|
|
2570
2616
|
if (_npmRequire === undefined) {
|
|
2571
2617
|
const npmDirPath = getNpmDirPath();
|
|
2572
2618
|
const npmNmPath = path.join(npmDirPath, `${constants.NODE_MODULES}/npm`);
|
|
2573
|
-
_npmRequire =
|
|
2619
|
+
_npmRequire = require$$5.createRequire(path.join(fs$1.existsSync(npmNmPath) ? npmNmPath : npmDirPath, '<dummy-basename>'));
|
|
2574
2620
|
}
|
|
2575
2621
|
return _npmRequire;
|
|
2576
2622
|
}
|
|
@@ -2579,7 +2625,7 @@ function getNpxBinPath() {
|
|
|
2579
2625
|
if (_npxBinPath === undefined) {
|
|
2580
2626
|
_npxBinPath = getNpxBinPathDetails().path;
|
|
2581
2627
|
if (!_npxBinPath) {
|
|
2582
|
-
exitWithBinPathError('npx');
|
|
2628
|
+
exitWithBinPathError$2('npx');
|
|
2583
2629
|
}
|
|
2584
2630
|
}
|
|
2585
2631
|
return _npxBinPath;
|
|
@@ -2599,23 +2645,33 @@ function isNpxBinPathShadowed() {
|
|
|
2599
2645
|
}
|
|
2600
2646
|
|
|
2601
2647
|
const helpFlags = new Set(['--help', '-h']);
|
|
2648
|
+
|
|
2649
|
+
/**
|
|
2650
|
+
* Convert command arguments to a properly formatted string representation.
|
|
2651
|
+
*/
|
|
2602
2652
|
function cmdFlagsToString(args) {
|
|
2603
2653
|
const result = [];
|
|
2604
2654
|
for (let i = 0, {
|
|
2605
2655
|
length
|
|
2606
2656
|
} = args; i < length; i += 1) {
|
|
2607
|
-
|
|
2657
|
+
const arg = args[i].trim();
|
|
2658
|
+
if (arg.startsWith('--')) {
|
|
2659
|
+
const nextArg = i + 1 < length ? args[i + 1].trim() : undefined;
|
|
2608
2660
|
// Check if the next item exists and is NOT another flag.
|
|
2609
|
-
if (
|
|
2610
|
-
result.push(`${
|
|
2661
|
+
if (nextArg?.startsWith('--')) {
|
|
2662
|
+
result.push(`${arg}=${nextArg}`);
|
|
2611
2663
|
i += 1;
|
|
2612
2664
|
} else {
|
|
2613
|
-
result.push(
|
|
2665
|
+
result.push(arg);
|
|
2614
2666
|
}
|
|
2615
2667
|
}
|
|
2616
2668
|
}
|
|
2617
2669
|
return result.join(' ');
|
|
2618
2670
|
}
|
|
2671
|
+
|
|
2672
|
+
/**
|
|
2673
|
+
* Convert flag values to array format for processing.
|
|
2674
|
+
*/
|
|
2619
2675
|
function cmdFlagValueToArray(value) {
|
|
2620
2676
|
if (typeof value === 'string') {
|
|
2621
2677
|
return value.trim().split(/, */).filter(Boolean);
|
|
@@ -2625,10 +2681,81 @@ function cmdFlagValueToArray(value) {
|
|
|
2625
2681
|
}
|
|
2626
2682
|
return [];
|
|
2627
2683
|
}
|
|
2684
|
+
|
|
2685
|
+
/**
|
|
2686
|
+
* Add command name prefix to message text.
|
|
2687
|
+
*/
|
|
2628
2688
|
function cmdPrefixMessage(cmdName, text) {
|
|
2629
2689
|
const cmdPrefix = cmdName ? `${cmdName}: ` : '';
|
|
2630
2690
|
return `${cmdPrefix}${text}`;
|
|
2631
2691
|
}
|
|
2692
|
+
|
|
2693
|
+
/**
|
|
2694
|
+
* Filter out Socket flags from argv before passing to subcommands.
|
|
2695
|
+
*/
|
|
2696
|
+
function filterFlags(argv, flagsToFilter, exceptions) {
|
|
2697
|
+
const filtered = [];
|
|
2698
|
+
|
|
2699
|
+
// Build set of flags to filter from the provided flag objects.
|
|
2700
|
+
const flagsToFilterSet = new Set();
|
|
2701
|
+
const flagsWithValueSet = new Set();
|
|
2702
|
+
for (const [flagName, flag] of Object.entries(flagsToFilter)) {
|
|
2703
|
+
const longFlag = `--${camelToKebab(flagName)}`;
|
|
2704
|
+
// Special case for negated booleans.
|
|
2705
|
+
if (flagName === 'spinner' || flagName === 'banner') {
|
|
2706
|
+
flagsToFilterSet.add(`--no-${flagName}`);
|
|
2707
|
+
} else {
|
|
2708
|
+
flagsToFilterSet.add(longFlag);
|
|
2709
|
+
}
|
|
2710
|
+
if (flag?.shortFlag) {
|
|
2711
|
+
flagsToFilterSet.add(`-${flag.shortFlag}`);
|
|
2712
|
+
}
|
|
2713
|
+
// Track flags that take values.
|
|
2714
|
+
if (flag.type !== 'boolean') {
|
|
2715
|
+
flagsWithValueSet.add(longFlag);
|
|
2716
|
+
if (flag?.shortFlag) {
|
|
2717
|
+
flagsWithValueSet.add(`-${flag.shortFlag}`);
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
for (let i = 0, {
|
|
2722
|
+
length
|
|
2723
|
+
} = argv; i < length; i += 1) {
|
|
2724
|
+
const arg = argv[i];
|
|
2725
|
+
// Check if this flag should be kept as an exception.
|
|
2726
|
+
if (exceptions?.includes(arg)) {
|
|
2727
|
+
filtered.push(arg);
|
|
2728
|
+
// Handle flags that take values.
|
|
2729
|
+
if (flagsWithValueSet.has(arg)) {
|
|
2730
|
+
// Include the next argument (the flag value).
|
|
2731
|
+
i += 1;
|
|
2732
|
+
if (i < length) {
|
|
2733
|
+
filtered.push(argv[i]);
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
} else if (flagsToFilterSet.has(arg)) {
|
|
2737
|
+
// Skip flags that take values.
|
|
2738
|
+
if (flagsWithValueSet.has(arg)) {
|
|
2739
|
+
// Skip the next argument (the flag value).
|
|
2740
|
+
i += 1;
|
|
2741
|
+
}
|
|
2742
|
+
// Skip boolean flags (no additional argument to skip).
|
|
2743
|
+
} else if (arg && Array.from(flagsWithValueSet).some(flag => arg.startsWith(`${flag}=`))) {
|
|
2744
|
+
// Skip --flag=value format for Socket flags unless it's an exception.
|
|
2745
|
+
if (exceptions?.some(exc => arg.startsWith(`${exc}=`))) {
|
|
2746
|
+
filtered.push(arg);
|
|
2747
|
+
}
|
|
2748
|
+
// Otherwise skip it.
|
|
2749
|
+
} else {
|
|
2750
|
+
filtered.push(arg);
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
return filtered;
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
/**
|
|
2757
|
+
* Check if argument is a help flag.
|
|
2758
|
+
*/
|
|
2632
2759
|
function isHelpFlag(cmdArg) {
|
|
2633
2760
|
return helpFlags.has(cmdArg);
|
|
2634
2761
|
}
|
|
@@ -2739,7 +2866,8 @@ async function spawnCoana(args, orgSlug, options, extra) {
|
|
|
2739
2866
|
};
|
|
2740
2867
|
} catch (e) {
|
|
2741
2868
|
const stderr = e?.stderr;
|
|
2742
|
-
const
|
|
2869
|
+
const cause = e?.message || constants.UNKNOWN_ERROR;
|
|
2870
|
+
const message = stderr ? stderr : cause;
|
|
2743
2871
|
return {
|
|
2744
2872
|
ok: false,
|
|
2745
2873
|
data: e,
|
|
@@ -2764,30 +2892,45 @@ function readOrDefaultSocketJson(cwd) {
|
|
|
2764
2892
|
// This should be unreachable but it makes TS happy.
|
|
2765
2893
|
getDefaultSocketJson();
|
|
2766
2894
|
}
|
|
2895
|
+
async function findSocketJsonUp(cwd) {
|
|
2896
|
+
return await findUp(constants.SOCKET_JSON, {
|
|
2897
|
+
onlyFiles: true,
|
|
2898
|
+
cwd
|
|
2899
|
+
});
|
|
2900
|
+
}
|
|
2901
|
+
async function readOrDefaultSocketJsonUp(cwd) {
|
|
2902
|
+
const socketJsonPath = await findSocketJsonUp(cwd);
|
|
2903
|
+
if (socketJsonPath) {
|
|
2904
|
+
const socketJsonDir = path.dirname(socketJsonPath);
|
|
2905
|
+
const jsonCResult = readSocketJsonSync(socketJsonDir, true);
|
|
2906
|
+
return jsonCResult.ok ? jsonCResult.data : getDefaultSocketJson();
|
|
2907
|
+
}
|
|
2908
|
+
return getDefaultSocketJson();
|
|
2909
|
+
}
|
|
2767
2910
|
function getDefaultSocketJson() {
|
|
2768
2911
|
return {
|
|
2769
|
-
' _____ _ _ ':
|
|
2912
|
+
' _____ _ _ ': `Local config file for Socket CLI tool ( ${constants.SOCKET_WEBSITE_URL}/npm/package/${constants.SOCKET_JSON.replace('.json', '')} ), to work with ${constants.SOCKET_WEBSITE_URL}`,
|
|
2770
2913
|
'| __|___ ___| |_ ___| |_ ': ' The config in this file is used to set as defaults for flags or command args when using the CLI',
|
|
2771
2914
|
"|__ | . | _| '_| -_| _| ": ' in this dir, often a repo root. You can choose commit or .ignore this file, both works.',
|
|
2772
|
-
'|_____|___|___|_,_|___|_|.dev':
|
|
2915
|
+
'|_____|___|___|_,_|___|_|.dev': `Warning: This file may be overwritten without warning by \`${constants.SOCKET_JSON.replace('.json', '')} manifest setup\` or other commands`,
|
|
2773
2916
|
version: 1
|
|
2774
2917
|
};
|
|
2775
2918
|
}
|
|
2776
2919
|
function readSocketJsonSync(cwd, defaultOnError = false) {
|
|
2777
|
-
const sockJsonPath = path.join(cwd,
|
|
2920
|
+
const sockJsonPath = path.join(cwd, constants.SOCKET_JSON);
|
|
2778
2921
|
if (!fs$1.existsSync(sockJsonPath)) {
|
|
2779
|
-
require$$9.debugFn('notice', `miss:
|
|
2922
|
+
require$$9.debugFn('notice', `miss: ${constants.SOCKET_JSON} not found at ${cwd}`);
|
|
2780
2923
|
return {
|
|
2781
2924
|
ok: true,
|
|
2782
2925
|
data: getDefaultSocketJson()
|
|
2783
2926
|
};
|
|
2784
2927
|
}
|
|
2785
|
-
let
|
|
2928
|
+
let jsonContent = null;
|
|
2786
2929
|
try {
|
|
2787
|
-
|
|
2930
|
+
jsonContent = fs$1.readFileSync(sockJsonPath, 'utf8');
|
|
2788
2931
|
} catch (e) {
|
|
2789
2932
|
if (defaultOnError) {
|
|
2790
|
-
logger.logger.warn(
|
|
2933
|
+
logger.logger.warn(`Failed to read ${constants.SOCKET_JSON}, using default`);
|
|
2791
2934
|
require$$9.debugDir('inspect', {
|
|
2792
2935
|
error: e
|
|
2793
2936
|
});
|
|
@@ -2796,27 +2939,29 @@ function readSocketJsonSync(cwd, defaultOnError = false) {
|
|
|
2796
2939
|
data: getDefaultSocketJson()
|
|
2797
2940
|
};
|
|
2798
2941
|
}
|
|
2799
|
-
const
|
|
2942
|
+
const cause = e?.message;
|
|
2800
2943
|
require$$9.debugDir('inspect', {
|
|
2801
2944
|
error: e
|
|
2802
2945
|
});
|
|
2803
2946
|
return {
|
|
2804
2947
|
ok: false,
|
|
2805
|
-
message:
|
|
2806
|
-
cause: `An error occurred while trying to read
|
|
2948
|
+
message: `Failed to read ${constants.SOCKET_JSON}`,
|
|
2949
|
+
cause: `An error occurred while trying to read ${constants.SOCKET_JSON}${cause ? `: ${cause}` : ''}`
|
|
2807
2950
|
};
|
|
2808
2951
|
}
|
|
2809
|
-
let
|
|
2952
|
+
let jsonObj;
|
|
2810
2953
|
try {
|
|
2811
|
-
|
|
2954
|
+
jsonObj = JSON.parse(jsonContent);
|
|
2812
2955
|
} catch (e) {
|
|
2813
2956
|
require$$9.debugFn('error', 'caught: JSON.parse error');
|
|
2814
2957
|
require$$9.debugDir('inspect', {
|
|
2815
|
-
|
|
2816
|
-
|
|
2958
|
+
jsonContent
|
|
2959
|
+
});
|
|
2960
|
+
require$$9.debugDir('inspect', {
|
|
2961
|
+
error: e
|
|
2817
2962
|
});
|
|
2818
2963
|
if (defaultOnError) {
|
|
2819
|
-
logger.logger.warn(
|
|
2964
|
+
logger.logger.warn(`Failed to parse ${constants.SOCKET_JSON}, using default`);
|
|
2820
2965
|
return {
|
|
2821
2966
|
ok: true,
|
|
2822
2967
|
data: getDefaultSocketJson()
|
|
@@ -2824,11 +2969,11 @@ function readSocketJsonSync(cwd, defaultOnError = false) {
|
|
|
2824
2969
|
}
|
|
2825
2970
|
return {
|
|
2826
2971
|
ok: false,
|
|
2827
|
-
message:
|
|
2828
|
-
cause:
|
|
2972
|
+
message: `Failed to parse ${constants.SOCKET_JSON}`,
|
|
2973
|
+
cause: `${constants.SOCKET_JSON} does not contain valid JSON, please verify`
|
|
2829
2974
|
};
|
|
2830
2975
|
}
|
|
2831
|
-
if (!
|
|
2976
|
+
if (!jsonObj) {
|
|
2832
2977
|
logger.logger.warn('Warning: file contents was empty, using default');
|
|
2833
2978
|
return {
|
|
2834
2979
|
ok: true,
|
|
@@ -2836,17 +2981,17 @@ function readSocketJsonSync(cwd, defaultOnError = false) {
|
|
|
2836
2981
|
};
|
|
2837
2982
|
}
|
|
2838
2983
|
|
|
2839
|
-
// Do we
|
|
2840
|
-
// to check every step of the way regardless.
|
|
2984
|
+
// TODO: Do we need to validate? All properties are optional so code will have
|
|
2985
|
+
// to check every step of the way regardless.
|
|
2841
2986
|
return {
|
|
2842
2987
|
ok: true,
|
|
2843
|
-
data:
|
|
2988
|
+
data: jsonObj
|
|
2844
2989
|
};
|
|
2845
2990
|
}
|
|
2846
2991
|
async function writeSocketJson(cwd, sockJson) {
|
|
2847
|
-
let
|
|
2992
|
+
let jsonContent = '';
|
|
2848
2993
|
try {
|
|
2849
|
-
|
|
2994
|
+
jsonContent = JSON.stringify(sockJson, null, 2);
|
|
2850
2995
|
} catch (e) {
|
|
2851
2996
|
require$$9.debugFn('error', 'caught: JSON.stringify error');
|
|
2852
2997
|
require$$9.debugDir('inspect', {
|
|
@@ -2856,11 +3001,11 @@ async function writeSocketJson(cwd, sockJson) {
|
|
|
2856
3001
|
return {
|
|
2857
3002
|
ok: false,
|
|
2858
3003
|
message: 'Failed to serialize to JSON',
|
|
2859
|
-
cause:
|
|
3004
|
+
cause: `There was an unexpected problem converting the ${constants.SOCKET_JSON} object to a JSON string. Unable to store it.`
|
|
2860
3005
|
};
|
|
2861
3006
|
}
|
|
2862
|
-
const filepath = path.join(cwd,
|
|
2863
|
-
await fs$1.promises.writeFile(filepath,
|
|
3007
|
+
const filepath = path.join(cwd, constants.SOCKET_JSON);
|
|
3008
|
+
await fs$1.promises.writeFile(filepath, `${jsonContent}\n`, 'utf8');
|
|
2864
3009
|
return {
|
|
2865
3010
|
ok: true,
|
|
2866
3011
|
data: undefined
|
|
@@ -2878,7 +3023,7 @@ ttlMs = 5 * 60 * 1000) {
|
|
|
2878
3023
|
return await fs.readJson(cacheJsonPath);
|
|
2879
3024
|
}
|
|
2880
3025
|
}
|
|
2881
|
-
return
|
|
3026
|
+
return undefined;
|
|
2882
3027
|
}
|
|
2883
3028
|
async function writeCache(key, data) {
|
|
2884
3029
|
const {
|
|
@@ -2946,7 +3091,11 @@ async function fetchGhsaDetails(ids) {
|
|
|
2946
3091
|
}
|
|
2947
3092
|
}
|
|
2948
3093
|
} catch (e) {
|
|
2949
|
-
|
|
3094
|
+
const cause = e?.message;
|
|
3095
|
+
require$$9.debugFn('error', `Failed to fetch GHSA details${cause ? `: ${cause}` : ''}`);
|
|
3096
|
+
require$$9.debugDir('inspect', {
|
|
3097
|
+
error: e
|
|
3098
|
+
});
|
|
2950
3099
|
}
|
|
2951
3100
|
return results;
|
|
2952
3101
|
}
|
|
@@ -3155,9 +3304,9 @@ const RangeStyles = ['pin', 'preserve'];
|
|
|
3155
3304
|
function getMajor(version) {
|
|
3156
3305
|
try {
|
|
3157
3306
|
const coerced = vendor.semverExports.coerce(version);
|
|
3158
|
-
return coerced ? vendor.semverExports.major(coerced) :
|
|
3307
|
+
return coerced ? vendor.semverExports.major(coerced) : undefined;
|
|
3159
3308
|
} catch {}
|
|
3160
|
-
return
|
|
3309
|
+
return undefined;
|
|
3161
3310
|
}
|
|
3162
3311
|
|
|
3163
3312
|
const COMPLETION_CMD_PREFIX = 'complete -F _socket_completion';
|
|
@@ -3245,11 +3394,63 @@ function captureExceptionSync(exception, hint) {
|
|
|
3245
3394
|
return Sentry.captureException(exception, hint);
|
|
3246
3395
|
}
|
|
3247
3396
|
|
|
3397
|
+
function exitWithBinPathError$1(binName) {
|
|
3398
|
+
logger.logger.fail(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable`);
|
|
3399
|
+
// The exit code 127 indicates that the command or binary being executed
|
|
3400
|
+
// could not be found.
|
|
3401
|
+
// eslint-disable-next-line n/no-process-exit
|
|
3402
|
+
process.exit(127);
|
|
3403
|
+
}
|
|
3404
|
+
let _yarnBinPath;
|
|
3405
|
+
function getYarnBinPath() {
|
|
3406
|
+
if (_yarnBinPath === undefined) {
|
|
3407
|
+
_yarnBinPath = getYarnBinPathDetails().path;
|
|
3408
|
+
if (!_yarnBinPath) {
|
|
3409
|
+
exitWithBinPathError$1(constants.default.YARN);
|
|
3410
|
+
}
|
|
3411
|
+
}
|
|
3412
|
+
return _yarnBinPath;
|
|
3413
|
+
}
|
|
3414
|
+
let _yarnBinPathDetails;
|
|
3415
|
+
function getYarnBinPathDetails() {
|
|
3416
|
+
if (_yarnBinPathDetails === undefined) {
|
|
3417
|
+
_yarnBinPathDetails = findBinPathDetailsSync(constants.default.YARN);
|
|
3418
|
+
}
|
|
3419
|
+
return _yarnBinPathDetails;
|
|
3420
|
+
}
|
|
3421
|
+
function isYarnBinPathShadowed() {
|
|
3422
|
+
return getYarnBinPathDetails().shadowed;
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3425
|
+
let _isYarnBerry;
|
|
3426
|
+
function isYarnBerry() {
|
|
3427
|
+
if (_isYarnBerry === undefined) {
|
|
3428
|
+
try {
|
|
3429
|
+
const yarnBinPath = getYarnBinPath();
|
|
3430
|
+
const result = spawn.spawnSync(yarnBinPath, ['--version'], {
|
|
3431
|
+
encoding: 'utf8',
|
|
3432
|
+
shell: constants.default.WIN32
|
|
3433
|
+
});
|
|
3434
|
+
if (result.status === 0 && result.stdout) {
|
|
3435
|
+
const version = result.stdout;
|
|
3436
|
+
// Yarn Berry starts from version 2.x
|
|
3437
|
+
const majorVersion = parseInt(version.split('.')[0], 10);
|
|
3438
|
+
_isYarnBerry = majorVersion >= 2;
|
|
3439
|
+
} else {
|
|
3440
|
+
_isYarnBerry = false;
|
|
3441
|
+
}
|
|
3442
|
+
} catch {
|
|
3443
|
+
_isYarnBerry = false;
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
return _isYarnBerry;
|
|
3447
|
+
}
|
|
3448
|
+
|
|
3248
3449
|
function npa(...args) {
|
|
3249
3450
|
try {
|
|
3250
3451
|
return Reflect.apply(vendor.npaExports, undefined, args);
|
|
3251
3452
|
} catch {}
|
|
3252
|
-
return
|
|
3453
|
+
return undefined;
|
|
3253
3454
|
}
|
|
3254
3455
|
|
|
3255
3456
|
function shadowNpmInstall(options) {
|
|
@@ -3413,10 +3614,10 @@ const LOCKS = {
|
|
|
3413
3614
|
// will be ignored.
|
|
3414
3615
|
// https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#package-lockjson-vs-npm-shrinkwrapjson
|
|
3415
3616
|
'npm-shrinkwrap.json': NPM,
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
'pnpm-lock.yml': PNPM,
|
|
3419
|
-
[
|
|
3617
|
+
[constants.PACKAGE_LOCK_JSON]: NPM,
|
|
3618
|
+
[constants.PNPM_LOCK_YAML]: PNPM,
|
|
3619
|
+
['pnpm-lock.yml']: PNPM,
|
|
3620
|
+
[constants.YARN_LOCK]: YARN_CLASSIC,
|
|
3420
3621
|
'vlt-lock.json': VLT,
|
|
3421
3622
|
// Lastly, look for a hidden lock file which is present if .npmrc has package-lock=false:
|
|
3422
3623
|
// https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#hidden-lockfiles
|
|
@@ -3688,6 +3889,105 @@ function getEcosystemChoicesForMeow() {
|
|
|
3688
3889
|
return [...ALL_ECOSYSTEMS];
|
|
3689
3890
|
}
|
|
3690
3891
|
|
|
3892
|
+
function exitWithBinPathError(binName) {
|
|
3893
|
+
logger.logger.fail(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable`);
|
|
3894
|
+
// The exit code 127 indicates that the command or binary being executed
|
|
3895
|
+
// could not be found.
|
|
3896
|
+
// eslint-disable-next-line n/no-process-exit
|
|
3897
|
+
process.exit(127);
|
|
3898
|
+
}
|
|
3899
|
+
let _pnpmBinPath;
|
|
3900
|
+
function getPnpmBinPath() {
|
|
3901
|
+
if (_pnpmBinPath === undefined) {
|
|
3902
|
+
_pnpmBinPath = getPnpmBinPathDetails().path;
|
|
3903
|
+
if (!_pnpmBinPath) {
|
|
3904
|
+
exitWithBinPathError('pnpm');
|
|
3905
|
+
}
|
|
3906
|
+
}
|
|
3907
|
+
return _pnpmBinPath;
|
|
3908
|
+
}
|
|
3909
|
+
let _pnpmBinPathDetails;
|
|
3910
|
+
function getPnpmBinPathDetails() {
|
|
3911
|
+
if (_pnpmBinPathDetails === undefined) {
|
|
3912
|
+
_pnpmBinPathDetails = findBinPathDetailsSync('pnpm');
|
|
3913
|
+
}
|
|
3914
|
+
return _pnpmBinPathDetails;
|
|
3915
|
+
}
|
|
3916
|
+
function isPnpmBinPathShadowed() {
|
|
3917
|
+
return getPnpmBinPathDetails().shadowed;
|
|
3918
|
+
}
|
|
3919
|
+
|
|
3920
|
+
function toFilterConfig(obj) {
|
|
3921
|
+
const normalized = {
|
|
3922
|
+
__proto__: null
|
|
3923
|
+
};
|
|
3924
|
+
const keys = require$$11.isObject(obj) ? Object.keys(obj) : [];
|
|
3925
|
+
for (const key of keys) {
|
|
3926
|
+
const value = obj[key];
|
|
3927
|
+
if (typeof value === 'boolean' || Array.isArray(value)) {
|
|
3928
|
+
normalized[key] = value;
|
|
3929
|
+
}
|
|
3930
|
+
}
|
|
3931
|
+
return normalized;
|
|
3932
|
+
}
|
|
3933
|
+
|
|
3934
|
+
function idToNpmPurl(id) {
|
|
3935
|
+
return `pkg:${constants.NPM}/${id}`;
|
|
3936
|
+
}
|
|
3937
|
+
|
|
3938
|
+
async function extractPurlsFromPnpmLockfile(lockfile) {
|
|
3939
|
+
const packages = lockfile?.packages ?? {};
|
|
3940
|
+
const seen = new Set();
|
|
3941
|
+
const visit = pkgPath => {
|
|
3942
|
+
if (seen.has(pkgPath)) {
|
|
3943
|
+
return;
|
|
3944
|
+
}
|
|
3945
|
+
const pkg = packages[pkgPath];
|
|
3946
|
+
if (!pkg) {
|
|
3947
|
+
return;
|
|
3948
|
+
}
|
|
3949
|
+
seen.add(pkgPath);
|
|
3950
|
+
const deps = {
|
|
3951
|
+
__proto__: null,
|
|
3952
|
+
...pkg.dependencies,
|
|
3953
|
+
...pkg.optionalDependencies,
|
|
3954
|
+
...pkg.devDependencies
|
|
3955
|
+
};
|
|
3956
|
+
for (const depName in deps) {
|
|
3957
|
+
const ref = deps[depName];
|
|
3958
|
+
const subKey = isPnpmDepPath(ref) ? ref : `/${depName}@${ref}`;
|
|
3959
|
+
visit(subKey);
|
|
3960
|
+
}
|
|
3961
|
+
};
|
|
3962
|
+
for (const pkgPath of Object.keys(packages)) {
|
|
3963
|
+
visit(pkgPath);
|
|
3964
|
+
}
|
|
3965
|
+
return Array.from(seen).map(p => idToNpmPurl(stripPnpmPeerSuffix(stripLeadingPnpmDepPathSlash(p))));
|
|
3966
|
+
}
|
|
3967
|
+
function isPnpmDepPath(maybeDepPath) {
|
|
3968
|
+
return maybeDepPath.length > 0 && maybeDepPath.charCodeAt(0) === 47; /*'/'*/
|
|
3969
|
+
}
|
|
3970
|
+
function parsePnpmLockfile(lockfileContent) {
|
|
3971
|
+
let result;
|
|
3972
|
+
if (typeof lockfileContent === 'string') {
|
|
3973
|
+
try {
|
|
3974
|
+
result = vendor.jsYaml.load(strings.stripBom(lockfileContent));
|
|
3975
|
+
} catch {}
|
|
3976
|
+
}
|
|
3977
|
+
return require$$11.isObjectObject(result) ? result : null;
|
|
3978
|
+
}
|
|
3979
|
+
async function readPnpmLockfile(lockfilePath) {
|
|
3980
|
+
return fs$1.existsSync(lockfilePath) ? await fs.readFileUtf8(lockfilePath) : undefined;
|
|
3981
|
+
}
|
|
3982
|
+
function stripLeadingPnpmDepPathSlash(depPath) {
|
|
3983
|
+
return isPnpmDepPath(depPath) ? depPath.slice(1) : depPath;
|
|
3984
|
+
}
|
|
3985
|
+
function stripPnpmPeerSuffix(depPath) {
|
|
3986
|
+
const parenIndex = depPath.indexOf('(');
|
|
3987
|
+
const index = parenIndex === -1 ? depPath.indexOf('_') : parenIndex;
|
|
3988
|
+
return index === -1 ? depPath : depPath.slice(0, index);
|
|
3989
|
+
}
|
|
3990
|
+
|
|
3691
3991
|
function isArtifactAlertCve(alert) {
|
|
3692
3992
|
const {
|
|
3693
3993
|
type
|
|
@@ -3751,21 +4051,7 @@ class ColorOrMarkdown {
|
|
|
3751
4051
|
}
|
|
3752
4052
|
}
|
|
3753
4053
|
|
|
3754
|
-
|
|
3755
|
-
const normalized = {
|
|
3756
|
-
__proto__: null
|
|
3757
|
-
};
|
|
3758
|
-
const keys = require$$11.isObject(obj) ? Object.keys(obj) : [];
|
|
3759
|
-
for (const key of keys) {
|
|
3760
|
-
const value = obj[key];
|
|
3761
|
-
if (typeof value === 'boolean' || Array.isArray(value)) {
|
|
3762
|
-
normalized[key] = value;
|
|
3763
|
-
}
|
|
3764
|
-
}
|
|
3765
|
-
return normalized;
|
|
3766
|
-
}
|
|
3767
|
-
|
|
3768
|
-
const require$1 = Module.createRequire(require('node:url').pathToFileURL(__filename).href);
|
|
4054
|
+
const require$1 = require$$5.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils.js', document.baseURI).href)));
|
|
3769
4055
|
let _translations;
|
|
3770
4056
|
function getTranslations() {
|
|
3771
4057
|
if (_translations === undefined) {
|
|
@@ -4118,10 +4404,13 @@ function logAlertsMap(alertsMap, options) {
|
|
|
4118
4404
|
output.write('\n');
|
|
4119
4405
|
}
|
|
4120
4406
|
|
|
4121
|
-
function
|
|
4122
|
-
|
|
4407
|
+
async function getAlertsMapFromPnpmLockfile(lockfile, options) {
|
|
4408
|
+
const purls = await extractPurlsFromPnpmLockfile(lockfile);
|
|
4409
|
+
return await getAlertsMapFromPurls(purls, {
|
|
4410
|
+
overrides: lockfile.overrides,
|
|
4411
|
+
...options
|
|
4412
|
+
});
|
|
4123
4413
|
}
|
|
4124
|
-
|
|
4125
4414
|
async function getAlertsMapFromPurls(purls, options) {
|
|
4126
4415
|
const uniqPurls = arrays.arrayUnique(purls);
|
|
4127
4416
|
require$$9.debugDir('silly', {
|
|
@@ -4155,10 +4444,11 @@ async function getAlertsMapFromPurls(purls, options) {
|
|
|
4155
4444
|
});
|
|
4156
4445
|
if (!sockSdkCResult.ok) {
|
|
4157
4446
|
spinner?.stop();
|
|
4158
|
-
throw new Error('Auth error: Run `socket login` first');
|
|
4447
|
+
throw new Error('Auth error: Run `socket login` first.');
|
|
4159
4448
|
}
|
|
4160
4449
|
const sockSdk = sockSdkCResult.data;
|
|
4161
|
-
const
|
|
4450
|
+
const socketYmlResult = findSocketYmlSync();
|
|
4451
|
+
const socketYml = socketYmlResult.ok && socketYmlResult.data ? socketYmlResult.data.parsed : undefined;
|
|
4162
4452
|
const alertsMapOptions = {
|
|
4163
4453
|
consolidate: opts.consolidate,
|
|
4164
4454
|
filter: opts.filter,
|
|
@@ -4235,7 +4525,9 @@ exports.extractTier1ReachabilityScanId = extractTier1ReachabilityScanId;
|
|
|
4235
4525
|
exports.failMsgWithBadge = failMsgWithBadge;
|
|
4236
4526
|
exports.fetchGhsaDetails = fetchGhsaDetails;
|
|
4237
4527
|
exports.fetchOrganization = fetchOrganization;
|
|
4528
|
+
exports.filterFlags = filterFlags;
|
|
4238
4529
|
exports.findUp = findUp;
|
|
4530
|
+
exports.getAlertsMapFromPnpmLockfile = getAlertsMapFromPnpmLockfile;
|
|
4239
4531
|
exports.getAlertsMapFromPurls = getAlertsMapFromPurls;
|
|
4240
4532
|
exports.getBaseBranch = getBaseBranch;
|
|
4241
4533
|
exports.getBashrcDetails = getBashrcDetails;
|
|
@@ -4255,6 +4547,7 @@ exports.getOctokitGraphql = getOctokitGraphql;
|
|
|
4255
4547
|
exports.getOrgSlugs = getOrgSlugs;
|
|
4256
4548
|
exports.getOutputKind = getOutputKind;
|
|
4257
4549
|
exports.getPackageFilesForScan = getPackageFilesForScan;
|
|
4550
|
+
exports.getPnpmBinPath = getPnpmBinPath;
|
|
4258
4551
|
exports.getPublicApiToken = getPublicApiToken;
|
|
4259
4552
|
exports.getPurlObject = getPurlObject;
|
|
4260
4553
|
exports.getRepoInfo = getRepoInfo;
|
|
@@ -4263,6 +4556,7 @@ exports.getSocketDevPackageOverviewUrlFromPurl = getSocketDevPackageOverviewUrlF
|
|
|
4263
4556
|
exports.getSupportedConfigEntries = getSupportedConfigEntries;
|
|
4264
4557
|
exports.getSupportedConfigKeys = getSupportedConfigKeys;
|
|
4265
4558
|
exports.getVisibleTokenPrefix = getVisibleTokenPrefix;
|
|
4559
|
+
exports.getYarnBinPath = getYarnBinPath;
|
|
4266
4560
|
exports.gitBranch = gitBranch;
|
|
4267
4561
|
exports.gitCheckoutBranch = gitCheckoutBranch;
|
|
4268
4562
|
exports.gitCommit = gitCommit;
|
|
@@ -4281,10 +4575,13 @@ exports.idToNpmPurl = idToNpmPurl;
|
|
|
4281
4575
|
exports.isHelpFlag = isHelpFlag;
|
|
4282
4576
|
exports.isNpmBinPathShadowed = isNpmBinPathShadowed;
|
|
4283
4577
|
exports.isNpxBinPathShadowed = isNpxBinPathShadowed;
|
|
4578
|
+
exports.isPnpmBinPathShadowed = isPnpmBinPathShadowed;
|
|
4284
4579
|
exports.isReadOnlyConfig = isReadOnlyConfig;
|
|
4285
4580
|
exports.isReportSupportedFile = isReportSupportedFile;
|
|
4286
4581
|
exports.isSensitiveConfigKey = isSensitiveConfigKey;
|
|
4287
4582
|
exports.isSupportedConfigKey = isSupportedConfigKey;
|
|
4583
|
+
exports.isYarnBerry = isYarnBerry;
|
|
4584
|
+
exports.isYarnBinPathShadowed = isYarnBinPathShadowed;
|
|
4288
4585
|
exports.logAlertsMap = logAlertsMap;
|
|
4289
4586
|
exports.mapToObject = mapToObject;
|
|
4290
4587
|
exports.mdTable = mdTable;
|
|
@@ -4295,9 +4592,12 @@ exports.meowWithSubcommands = meowWithSubcommands;
|
|
|
4295
4592
|
exports.msAtHome = msAtHome;
|
|
4296
4593
|
exports.normalizePurl = normalizePurl;
|
|
4297
4594
|
exports.npa = npa;
|
|
4595
|
+
exports.parsePnpmLockfile = parsePnpmLockfile;
|
|
4298
4596
|
exports.queryApiSafeJson = queryApiSafeJson;
|
|
4299
4597
|
exports.queryApiSafeText = queryApiSafeText;
|
|
4300
4598
|
exports.readOrDefaultSocketJson = readOrDefaultSocketJson;
|
|
4599
|
+
exports.readOrDefaultSocketJsonUp = readOrDefaultSocketJsonUp;
|
|
4600
|
+
exports.readPnpmLockfile = readPnpmLockfile;
|
|
4301
4601
|
exports.readSocketJsonSync = readSocketJsonSync;
|
|
4302
4602
|
exports.runAgentInstall = runAgentInstall;
|
|
4303
4603
|
exports.sendApiRequest = sendApiRequest;
|
|
@@ -4311,5 +4611,5 @@ exports.toFilterConfig = toFilterConfig;
|
|
|
4311
4611
|
exports.updateConfigValue = updateConfigValue;
|
|
4312
4612
|
exports.walkNestedMap = walkNestedMap;
|
|
4313
4613
|
exports.writeSocketJson = writeSocketJson;
|
|
4314
|
-
//# debugId=
|
|
4614
|
+
//# debugId=1da7b4a0-f584-4be9-bf6b-9269a66c830
|
|
4315
4615
|
//# sourceMappingURL=utils.js.map
|