@socketsecurity/cli 1.15.0 → 1.16.0
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 +18 -0
- package/README.md +16 -9
- package/dist/.config/tsconfig.dts.tsbuildinfo +1 -0
- package/dist/cli.js +2461 -948
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +50 -19
- package/dist/constants.js.map +1 -1
- package/dist/manifest-scripts/dotnet-tool/socket-facts-dotnet.deps.json +2 -1
- package/dist/manifest-scripts/dotnet-tool/socket-facts-dotnet.dll +0 -0
- package/dist/manifest-scripts/maven-extension/coana-maven-extension.jar +0 -0
- package/dist/types/cli.d.mts +0 -1
- package/dist/types/commands/analytics/cmd-analytics.d.mts +0 -1
- package/dist/types/commands/analytics/fetch-org-analytics.d.mts +0 -1
- package/dist/types/commands/analytics/fetch-repo-analytics.d.mts +0 -1
- package/dist/types/commands/analytics/handle-analytics.d.mts +0 -1
- package/dist/types/commands/analytics/output-analytics.d.mts +0 -1
- package/dist/types/commands/audit-log/cmd-audit-log.d.mts +0 -1
- package/dist/types/commands/audit-log/fetch-audit-log.d.mts +0 -1
- package/dist/types/commands/audit-log/handle-audit-log.d.mts +0 -1
- package/dist/types/commands/audit-log/output-audit-log.d.mts +0 -1
- package/dist/types/commands/ci/cmd-ci.d.mts +0 -1
- package/dist/types/commands/ci/fetch-default-org-slug.d.mts +0 -1
- package/dist/types/commands/ci/handle-ci.d.mts +0 -1
- package/dist/types/commands/config/cmd-config-auto.d.mts +0 -1
- package/dist/types/commands/config/cmd-config-get.d.mts +0 -1
- package/dist/types/commands/config/cmd-config-list.d.mts +0 -1
- package/dist/types/commands/config/cmd-config-set.d.mts +0 -1
- package/dist/types/commands/config/cmd-config-unset.d.mts +0 -1
- package/dist/types/commands/config/cmd-config.d.mts +0 -1
- package/dist/types/commands/config/discover-config-value.d.mts +0 -1
- package/dist/types/commands/config/handle-config-auto.d.mts +0 -1
- package/dist/types/commands/config/handle-config-get.d.mts +0 -1
- package/dist/types/commands/config/handle-config-set.d.mts +0 -1
- package/dist/types/commands/config/handle-config-unset.d.mts +0 -1
- package/dist/types/commands/config/output-config-auto.d.mts +0 -1
- package/dist/types/commands/config/output-config-get.d.mts +0 -1
- package/dist/types/commands/config/output-config-list.d.mts +0 -1
- package/dist/types/commands/config/output-config-set.d.mts +0 -1
- package/dist/types/commands/config/output-config-unset.d.mts +0 -1
- package/dist/types/commands/fix/branch-cleanup.d.mts +0 -1
- package/dist/types/commands/fix/cmd-fix.d.mts +0 -1
- package/dist/types/commands/fix/coana-fix.d.mts +0 -1
- package/dist/types/commands/fix/env-helpers.d.mts +0 -1
- package/dist/types/commands/fix/generated-socket-facts.d.mts +2 -1
- package/dist/types/commands/fix/git.d.mts +0 -1
- package/dist/types/commands/fix/handle-fix.d.mts +0 -1
- package/dist/types/commands/fix/output-fix-result.d.mts +0 -1
- package/dist/types/commands/fix/pull-request.d.mts +0 -1
- package/dist/types/commands/fix/types.d.mts +0 -1
- package/dist/types/commands/install/cmd-install-completion.d.mts +0 -1
- package/dist/types/commands/install/cmd-install.d.mts +0 -1
- package/dist/types/commands/install/handle-install-completion.d.mts +0 -1
- package/dist/types/commands/install/output-install-completion.d.mts +0 -1
- package/dist/types/commands/install/setup-tab-completion.d.mts +0 -1
- package/dist/types/commands/json/cmd-json.d.mts +0 -1
- package/dist/types/commands/json/handle-cmd-json.d.mts +0 -1
- package/dist/types/commands/json/output-cmd-json.d.mts +0 -1
- package/dist/types/commands/login/apply-login.d.mts +0 -1
- package/dist/types/commands/login/attempt-login.d.mts +0 -1
- package/dist/types/commands/login/cmd-login.d.mts +0 -1
- package/dist/types/commands/logout/apply-logout.d.mts +0 -1
- package/dist/types/commands/logout/attempt-logout.d.mts +0 -1
- package/dist/types/commands/logout/cmd-logout.d.mts +0 -1
- package/dist/types/commands/manifest/bazel/bazel-socket-json-trust.d.mts +0 -1
- package/dist/types/commands/manifest/bazel/{bazel-bin-detect.d.mts → bin-detect.d.mts} +0 -1
- package/dist/types/commands/manifest/bazel/{bazel-cleanup.d.mts → cleanup.d.mts} +1 -2
- package/dist/types/commands/manifest/bazel/cmd-manifest-bazel.d.mts +0 -1
- package/dist/types/commands/manifest/bazel/{bazel-cquery.d.mts → cquery.d.mts} +1 -2
- package/dist/types/commands/manifest/bazel/extract_bazel_to_maven.d.mts +1 -2
- package/dist/types/commands/manifest/bazel/extract_bazel_to_pypi.d.mts +1 -1
- package/dist/types/commands/manifest/bazel/{bazel-java-shim.d.mts → java-shim.d.mts} +0 -1
- package/dist/types/commands/manifest/bazel/{bazel-output-base-check.d.mts → output-base-check.d.mts} +0 -1
- package/dist/types/commands/manifest/bazel/paths/manifest.d.mts +7 -0
- package/dist/types/commands/manifest/bazel/{bazel-process.d.mts → process.d.mts} +1 -1
- package/dist/types/commands/manifest/bazel/{bazel-pypi-discovery.d.mts → pypi-discovery.d.mts} +1 -2
- package/dist/types/commands/manifest/bazel/{bazel-pypi-parser.d.mts → pypi-parser.d.mts} +0 -1
- package/dist/types/commands/manifest/bazel/{bazel-python-shim.d.mts → python-shim.d.mts} +0 -1
- package/dist/types/commands/manifest/bazel/{bazel-query-runner.d.mts → query-runner.d.mts} +5 -6
- package/dist/types/commands/manifest/bazel/{bazel-repo-discovery.d.mts → repo-discovery.d.mts} +0 -1
- package/dist/types/commands/manifest/bazel/{bazel-workspace-detect.d.mts → workspace-detect.d.mts} +0 -1
- package/dist/types/commands/manifest/bazel/{bazel-workspace-walk.d.mts → workspace-walk.d.mts} +0 -1
- package/dist/types/commands/manifest/build-root-config.d.mts +27 -0
- package/dist/types/commands/manifest/cmd-manifest-auto.d.mts +0 -1
- package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts +0 -1
- package/dist/types/commands/manifest/cmd-manifest-conda.d.mts +0 -1
- package/dist/types/commands/manifest/cmd-manifest-dotnet.d.mts +0 -1
- package/dist/types/commands/manifest/cmd-manifest-dynamic-sbom-inference.d.mts +0 -1
- package/dist/types/commands/manifest/cmd-manifest-gradle.d.mts +0 -1
- package/dist/types/commands/manifest/cmd-manifest-kotlin.d.mts +0 -1
- package/dist/types/commands/manifest/cmd-manifest-maven.d.mts +0 -1
- package/dist/types/commands/manifest/cmd-manifest-scala.d.mts +0 -1
- package/dist/types/commands/manifest/cmd-manifest-setup.d.mts +0 -1
- package/dist/types/commands/manifest/cmd-manifest.d.mts +0 -1
- package/dist/types/commands/manifest/convert-conda-to-requirements.d.mts +0 -1
- package/dist/types/commands/manifest/convert-dotnet-to-facts.d.mts +0 -1
- package/dist/types/commands/manifest/convert-gradle-to-facts.d.mts +0 -1
- package/dist/types/commands/manifest/convert-maven-to-facts.d.mts +0 -1
- package/dist/types/commands/manifest/convert-sbt-to-facts.d.mts +0 -1
- package/dist/types/commands/manifest/convert_gradle_to_maven.d.mts +0 -1
- package/dist/types/commands/manifest/convert_sbt_to_maven.d.mts +0 -1
- package/dist/types/commands/manifest/detect-manifest-actions.d.mts +0 -1
- package/dist/types/commands/manifest/discover-manifest-roots.d.mts +23 -8
- package/dist/types/commands/manifest/enumerate-workspaces.d.mts +3 -5
- package/dist/types/commands/manifest/expand-env-var-refs.d.mts +0 -1
- package/dist/types/commands/manifest/generate-recursive-manifests.d.mts +15 -7
- package/dist/types/commands/manifest/generate_auto_manifest.d.mts +0 -1
- package/dist/types/commands/manifest/handle-manifest-conda.d.mts +0 -1
- package/dist/types/commands/manifest/handle-manifest-dynamic-sbom-inference.d.mts +0 -1
- package/dist/types/commands/manifest/handle-manifest-setup.d.mts +0 -1
- package/dist/types/commands/manifest/load-build.d.mts +19 -0
- package/dist/types/commands/manifest/manifest-flags.d.mts +0 -1
- package/dist/types/commands/manifest/output-manifest-dynamic-sbom-inference.d.mts +0 -1
- package/dist/types/commands/manifest/output-manifest-setup.d.mts +0 -1
- package/dist/types/commands/manifest/output-requirements.d.mts +0 -1
- package/dist/types/commands/manifest/parse-build-tool-opts.d.mts +0 -1
- package/dist/types/commands/manifest/run-cdxgen.d.mts +0 -1
- package/dist/types/commands/manifest/run-manifest-facts.d.mts +3 -1
- package/dist/types/commands/manifest/scripts/assemble.d.mts +0 -1
- package/dist/types/commands/manifest/scripts/build-tool.d.mts +9 -5
- package/dist/types/commands/manifest/scripts/exclude-paths-glob.d.mts +0 -1
- package/dist/types/commands/manifest/scripts/facts.d.mts +4 -3
- package/dist/types/commands/manifest/scripts/records.d.mts +2 -1
- package/dist/types/commands/manifest/scripts/resolution-report-gradle.d.mts +0 -1
- package/dist/types/commands/manifest/scripts/resolution-report-ivy.d.mts +0 -1
- package/dist/types/commands/manifest/scripts/resolution-report-maven.d.mts +0 -1
- package/dist/types/commands/manifest/scripts/resolution-report-nuget.d.mts +0 -1
- package/dist/types/commands/manifest/scripts/resolution-report-render.d.mts +0 -1
- package/dist/types/commands/manifest/scripts/resolution-report.d.mts +0 -1
- package/dist/types/commands/manifest/scripts/run.d.mts +0 -1
- package/dist/types/commands/manifest/scripts/sidecar.d.mts +1 -3
- package/dist/types/commands/manifest/scripts/test/assemble-records.d.mts +1 -0
- package/dist/types/commands/manifest/setup-manifest-config.d.mts +0 -1
- package/dist/types/commands/manifest/setup-recursive-manifest-config.d.mts +10 -65
- package/dist/types/commands/npm/cmd-npm.d.mts +0 -1
- package/dist/types/commands/npx/cmd-npx.d.mts +0 -1
- package/dist/types/commands/oops/cmd-oops.d.mts +0 -1
- package/dist/types/commands/optimize/add-overrides.d.mts +0 -1
- package/dist/types/commands/optimize/apply-optimization.d.mts +0 -1
- package/dist/types/commands/optimize/cmd-optimize.d.mts +0 -1
- package/dist/types/commands/optimize/deps-includes-by-agent.d.mts +0 -1
- package/dist/types/commands/optimize/get-dependency-entries.d.mts +0 -1
- package/dist/types/commands/optimize/get-overrides-by-agent.d.mts +0 -1
- package/dist/types/commands/optimize/handle-optimize.d.mts +0 -1
- package/dist/types/commands/optimize/lockfile-includes-by-agent.d.mts +0 -1
- package/dist/types/commands/optimize/ls-by-agent.d.mts +0 -1
- package/dist/types/commands/optimize/output-optimize-result.d.mts +0 -1
- package/dist/types/commands/optimize/shared.d.mts +0 -1
- package/dist/types/commands/optimize/types.d.mts +0 -1
- package/dist/types/commands/optimize/update-lockfile.d.mts +0 -1
- package/dist/types/commands/optimize/update-manifest-by-agent.d.mts +0 -1
- package/dist/types/commands/organization/cmd-organization-dependencies.d.mts +0 -1
- package/dist/types/commands/organization/cmd-organization-list.d.mts +0 -1
- package/dist/types/commands/organization/cmd-organization-policy-license.d.mts +0 -1
- package/dist/types/commands/organization/cmd-organization-policy-security.d.mts +0 -1
- package/dist/types/commands/organization/cmd-organization-policy.d.mts +0 -1
- package/dist/types/commands/organization/cmd-organization-quota.d.mts +0 -1
- package/dist/types/commands/organization/cmd-organization.d.mts +0 -1
- package/dist/types/commands/organization/dependencies-filters.d.mts +10 -0
- package/dist/types/commands/organization/fetch-dependencies.d.mts +1 -1
- package/dist/types/commands/organization/fetch-license-policy.d.mts +0 -1
- package/dist/types/commands/organization/fetch-organization-list.d.mts +0 -1
- package/dist/types/commands/organization/fetch-quota.d.mts +0 -1
- package/dist/types/commands/organization/fetch-security-policy.d.mts +0 -1
- package/dist/types/commands/organization/handle-dependencies.d.mts +2 -2
- package/dist/types/commands/organization/handle-license-policy.d.mts +0 -1
- package/dist/types/commands/organization/handle-organization-list.d.mts +0 -1
- package/dist/types/commands/organization/handle-quota.d.mts +0 -1
- package/dist/types/commands/organization/handle-security-policy.d.mts +0 -1
- package/dist/types/commands/organization/output-dependencies.d.mts +0 -1
- package/dist/types/commands/organization/output-license-policy.d.mts +0 -1
- package/dist/types/commands/organization/output-organization-list.d.mts +0 -1
- package/dist/types/commands/organization/output-quota.d.mts +0 -1
- package/dist/types/commands/organization/output-security-policy.d.mts +0 -1
- package/dist/types/commands/package/cmd-package-score.d.mts +0 -1
- package/dist/types/commands/package/cmd-package-shallow.d.mts +0 -1
- package/dist/types/commands/package/cmd-package.d.mts +0 -1
- package/dist/types/commands/package/fetch-purl-deep-score.d.mts +0 -1
- package/dist/types/commands/package/fetch-purls-shallow-score.d.mts +0 -1
- package/dist/types/commands/package/handle-purl-deep-score.d.mts +0 -1
- package/dist/types/commands/package/handle-purls-shallow-score.d.mts +0 -1
- package/dist/types/commands/package/output-purls-deep-score.d.mts +0 -1
- package/dist/types/commands/package/output-purls-shallow-score.d.mts +0 -1
- package/dist/types/commands/package/parse-package-specifiers.d.mts +0 -1
- package/dist/types/commands/patch/cmd-patch.d.mts +0 -1
- package/dist/types/commands/pnpm/cmd-pnpm.d.mts +0 -1
- package/dist/types/commands/raw-npm/cmd-raw-npm.d.mts +0 -1
- package/dist/types/commands/raw-npm/run-raw-npm.d.mts +0 -1
- package/dist/types/commands/raw-npx/cmd-raw-npx.d.mts +0 -1
- package/dist/types/commands/raw-npx/run-raw-npx.d.mts +0 -1
- package/dist/types/commands/repository/cmd-repository-create.d.mts +0 -1
- package/dist/types/commands/repository/cmd-repository-del.d.mts +0 -1
- package/dist/types/commands/repository/cmd-repository-list.d.mts +0 -1
- package/dist/types/commands/repository/cmd-repository-update.d.mts +0 -1
- package/dist/types/commands/repository/cmd-repository-view.d.mts +0 -1
- package/dist/types/commands/repository/cmd-repository.d.mts +0 -1
- package/dist/types/commands/repository/fetch-create-repo.d.mts +0 -1
- package/dist/types/commands/repository/fetch-delete-repo.d.mts +0 -1
- package/dist/types/commands/repository/fetch-list-all-repos.d.mts +0 -1
- package/dist/types/commands/repository/fetch-list-repos.d.mts +0 -1
- package/dist/types/commands/repository/fetch-update-repo.d.mts +0 -1
- package/dist/types/commands/repository/fetch-view-repo.d.mts +0 -1
- package/dist/types/commands/repository/handle-create-repo.d.mts +0 -1
- package/dist/types/commands/repository/handle-delete-repo.d.mts +0 -1
- package/dist/types/commands/repository/handle-list-repos.d.mts +0 -1
- package/dist/types/commands/repository/handle-update-repo.d.mts +0 -1
- package/dist/types/commands/repository/handle-view-repo.d.mts +0 -1
- package/dist/types/commands/repository/output-create-repo.d.mts +0 -1
- package/dist/types/commands/repository/output-delete-repo.d.mts +0 -1
- package/dist/types/commands/repository/output-list-repos.d.mts +0 -1
- package/dist/types/commands/repository/output-update-repo.d.mts +0 -1
- package/dist/types/commands/repository/output-view-repo.d.mts +0 -1
- package/dist/types/commands/repository/types.d.mts +0 -1
- package/dist/types/commands/scan/cmd-scan-create.d.mts +0 -1
- package/dist/types/commands/scan/cmd-scan-del.d.mts +0 -1
- package/dist/types/commands/scan/cmd-scan-diff.d.mts +0 -1
- package/dist/types/commands/scan/cmd-scan-github.d.mts +0 -1
- package/dist/types/commands/scan/cmd-scan-list.d.mts +0 -1
- package/dist/types/commands/scan/cmd-scan-metadata.d.mts +0 -1
- package/dist/types/commands/scan/cmd-scan-reach.d.mts +0 -1
- package/dist/types/commands/scan/cmd-scan-report.d.mts +0 -1
- package/dist/types/commands/scan/cmd-scan-setup.d.mts +0 -1
- package/dist/types/commands/scan/cmd-scan-view.d.mts +0 -1
- package/dist/types/commands/scan/cmd-scan.d.mts +0 -1
- package/dist/types/commands/scan/create-scan-from-github.d.mts +0 -1
- package/dist/types/commands/scan/exclude-paths.d.mts +0 -1
- package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts +0 -1
- package/dist/types/commands/scan/fetch-delete-org-full-scan.d.mts +0 -1
- package/dist/types/commands/scan/fetch-diff-scan.d.mts +0 -1
- package/dist/types/commands/scan/fetch-list-scans.d.mts +0 -1
- package/dist/types/commands/scan/fetch-report-data.d.mts +0 -1
- package/dist/types/commands/scan/fetch-scan-metadata.d.mts +0 -1
- package/dist/types/commands/scan/fetch-scan.d.mts +0 -1
- package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts +0 -1
- package/dist/types/commands/scan/finalize-tier1-scan.d.mts +0 -1
- package/dist/types/commands/scan/generate-report.d.mts +0 -1
- package/dist/types/commands/scan/generate-uv-member-sboms.d.mts +0 -1
- package/dist/types/commands/scan/handle-create-github-scan.d.mts +0 -1
- package/dist/types/commands/scan/handle-create-new-scan.d.mts +0 -1
- package/dist/types/commands/scan/handle-delete-scan.d.mts +0 -1
- package/dist/types/commands/scan/handle-diff-scan.d.mts +0 -1
- package/dist/types/commands/scan/handle-list-scans.d.mts +0 -1
- package/dist/types/commands/scan/handle-scan-config.d.mts +0 -1
- package/dist/types/commands/scan/handle-scan-metadata.d.mts +0 -1
- package/dist/types/commands/scan/handle-scan-reach.d.mts +0 -1
- package/dist/types/commands/scan/handle-scan-report.d.mts +0 -1
- package/dist/types/commands/scan/handle-scan-view.d.mts +0 -1
- package/dist/types/commands/scan/output-create-new-scan.d.mts +0 -1
- package/dist/types/commands/scan/output-delete-scan.d.mts +0 -1
- package/dist/types/commands/scan/output-diff-scan.d.mts +0 -1
- package/dist/types/commands/scan/output-list-scans.d.mts +0 -1
- package/dist/types/commands/scan/output-scan-config-result.d.mts +0 -1
- package/dist/types/commands/scan/output-scan-github.d.mts +0 -1
- package/dist/types/commands/scan/output-scan-metadata.d.mts +0 -1
- package/dist/types/commands/scan/output-scan-reach.d.mts +0 -1
- package/dist/types/commands/scan/output-scan-report.d.mts +12 -1
- package/dist/types/commands/scan/output-scan-view.d.mts +0 -1
- package/dist/types/commands/scan/perform-reachability-analysis.d.mts +0 -2
- package/dist/types/commands/scan/reach-advisories.d.mts +0 -1
- package/dist/types/commands/scan/reachability-flags.d.mts +0 -1
- package/dist/types/commands/scan/reachability-units.d.mts +0 -1
- package/dist/types/commands/scan/run-dynamic-sbom-inference.d.mts +5 -1
- package/dist/types/commands/scan/setup-scan-config.d.mts +0 -1
- package/dist/types/commands/scan/stream-scan.d.mts +0 -1
- package/dist/types/commands/scan/suggest-org-slug.d.mts +0 -1
- package/dist/types/commands/scan/suggest-to-persist-orgslug.d.mts +0 -1
- package/dist/types/commands/scan/suggest_branch_slug.d.mts +0 -1
- package/dist/types/commands/scan/suggest_target.d.mts +0 -1
- package/dist/types/commands/scan/types.d.mts +0 -1
- package/dist/types/commands/scan/validate-reachability-target.d.mts +0 -1
- package/dist/types/commands/scan/warn-socket-json-only-flags.d.mts +0 -1
- package/dist/types/commands/threat-feed/cmd-threat-feed.d.mts +0 -1
- package/dist/types/commands/threat-feed/fetch-threat-feed.d.mts +0 -1
- package/dist/types/commands/threat-feed/handle-threat-feed.d.mts +0 -1
- package/dist/types/commands/threat-feed/output-threat-feed.d.mts +0 -1
- package/dist/types/commands/threat-feed/types.d.mts +0 -1
- package/dist/types/commands/uninstall/cmd-uninstall-completion.d.mts +0 -1
- package/dist/types/commands/uninstall/cmd-uninstall.d.mts +0 -1
- package/dist/types/commands/uninstall/handle-uninstall-completion.d.mts +0 -1
- package/dist/types/commands/uninstall/output-uninstall-completion.d.mts +0 -1
- package/dist/types/commands/uninstall/teardown-tab-completion.d.mts +0 -1
- package/dist/types/commands/wrapper/add-socket-wrapper.d.mts +0 -1
- package/dist/types/commands/wrapper/check-socket-wrapper-setup.d.mts +0 -1
- package/dist/types/commands/wrapper/cmd-wrapper.d.mts +0 -1
- package/dist/types/commands/wrapper/postinstall-wrapper.d.mts +0 -1
- package/dist/types/commands/wrapper/remove-socket-wrapper.d.mts +0 -1
- package/dist/types/commands/yarn/cmd-yarn.d.mts +0 -1
- package/dist/types/commands.d.mts +0 -1
- package/dist/types/constants.d.mts +7 -6
- package/dist/types/flags.d.mts +0 -1
- package/dist/types/instrument-with-sentry.d.mts +0 -1
- package/dist/types/npm-cli.d.mts +0 -1
- package/dist/types/npx-cli.d.mts +0 -1
- package/dist/types/pnpm-cli.d.mts +0 -1
- package/dist/types/sea/adapters/cdxgen.d.mts +8 -0
- package/dist/types/sea/adapters/synp.d.mts +9 -0
- package/dist/types/sea/archive-paths.d.mts +6 -0
- package/dist/types/sea/bootstrap.d.mts +0 -1
- package/dist/types/sea/build/lock.d.mts +2 -0
- package/dist/types/sea/build/publish.d.mts +13 -0
- package/dist/types/sea/build-sea.d.mts +14 -24
- package/dist/types/sea/capabilities.d.mts +21 -0
- package/dist/types/sea/download-bytes.d.mts +14 -0
- package/dist/types/sea/download-cache.d.mts +15 -0
- package/dist/types/sea/node-version.d.mts +1 -0
- package/dist/types/sea/readme-version.d.mts +4 -0
- package/dist/types/sea/runtime.d.mts +34 -0
- package/dist/types/sea/stage/synp.d.mts +15 -0
- package/dist/types/sea/stage/uv.d.mts +34 -0
- package/dist/types/sea/version.d.mts +34 -0
- package/dist/types/shadow/common.d.mts +0 -1
- package/dist/types/shadow/npm/arborist/index.d.mts +0 -1
- package/dist/types/shadow/npm/arborist/lib/arborist/index.d.mts +0 -1
- package/dist/types/shadow/npm/arborist/types.d.mts +0 -1
- package/dist/types/shadow/npm/arborist-helpers.d.mts +0 -1
- package/dist/types/shadow/npm/bin.d.mts +0 -1
- package/dist/types/shadow/npm/inject.d.mts +0 -1
- package/dist/types/shadow/npm/install.d.mts +0 -1
- package/dist/types/shadow/npm/paths.d.mts +0 -1
- package/dist/types/shadow/npm-base.d.mts +0 -1
- package/dist/types/shadow/npx/bin.d.mts +0 -1
- package/dist/types/shadow/pnpm/bin.d.mts +0 -1
- package/dist/types/shadow/stdio-ipc.d.mts +0 -1
- package/dist/types/shadow/yarn/bin.d.mts +0 -1
- package/dist/types/test/json-output-validation.d.mts +0 -1
- package/dist/types/test/mocks/socket-auth.d.mts +0 -1
- package/dist/types/types.d.mts +0 -1
- package/dist/types/utils/advisory-ids.d.mts +0 -1
- package/dist/types/utils/agent.d.mts +5 -11
- package/dist/types/utils/alert/artifact.d.mts +0 -1
- package/dist/types/utils/alert/fix.d.mts +0 -1
- package/dist/types/utils/alert/severity.d.mts +0 -1
- package/dist/types/utils/alerts-map.d.mts +0 -1
- package/dist/types/utils/api-transport.d.mts +0 -1
- package/dist/types/utils/api.d.mts +2 -1
- package/dist/types/utils/check-input.d.mts +0 -1
- package/dist/types/utils/cmd.d.mts +0 -1
- package/dist/types/utils/coana-release.d.mts +5 -1
- package/dist/types/utils/coana.d.mts +0 -1
- package/dist/types/utils/color-or-markdown.d.mts +0 -1
- package/dist/types/utils/completion.d.mts +0 -1
- package/dist/types/utils/config.d.mts +0 -1
- package/dist/types/utils/cve-to-ghsa.d.mts +0 -1
- package/dist/types/utils/debug.d.mts +0 -1
- package/dist/types/utils/determine-org-slug.d.mts +0 -1
- package/dist/types/utils/dlx-detection.d.mts +0 -1
- package/dist/types/utils/dlx.d.mts +0 -1
- package/dist/types/utils/ecosystem.d.mts +0 -1
- package/dist/types/utils/editable-json.d.mts +0 -1
- package/dist/types/utils/errors.d.mts +0 -1
- package/dist/types/utils/extract-names.d.mts +0 -1
- package/dist/types/utils/fail-msg-with-badge.d.mts +0 -1
- package/dist/types/utils/filter-config.d.mts +0 -1
- package/dist/types/utils/fs.d.mts +0 -1
- package/dist/types/utils/get-or-insert.d.mts +0 -1
- package/dist/types/utils/get-output-kind.d.mts +0 -1
- package/dist/types/utils/git.d.mts +0 -1
- package/dist/types/utils/github-errors.d.mts +0 -1
- package/dist/types/utils/github.d.mts +0 -1
- package/dist/types/utils/glob.d.mts +0 -1
- package/dist/types/utils/lockfile.d.mts +0 -1
- package/dist/types/utils/map-to-object.d.mts +0 -1
- package/dist/types/utils/markdown.d.mts +0 -1
- package/dist/types/utils/meow-with-subcommands.d.mts +0 -1
- package/dist/types/utils/ms-at-home.d.mts +0 -1
- package/dist/types/utils/npm-config.d.mts +0 -1
- package/dist/types/utils/npm-package-arg.d.mts +0 -1
- package/dist/types/utils/npm-paths.d.mts +0 -1
- package/dist/types/utils/npm-spec.d.mts +0 -1
- package/dist/types/utils/oauth.d.mts +0 -1
- package/dist/types/utils/objects.d.mts +0 -1
- package/dist/types/utils/organization.d.mts +0 -1
- package/dist/types/utils/output-formatting.d.mts +0 -1
- package/dist/types/utils/package-environment.d.mts +0 -1
- package/dist/types/utils/package-manager.d.mts +0 -1
- package/dist/types/utils/path-resolve.d.mts +0 -1
- package/dist/types/utils/pnpm-paths.d.mts +0 -1
- package/dist/types/utils/pnpm.d.mts +0 -1
- package/dist/types/utils/purl-to-ghsa.d.mts +0 -1
- package/dist/types/utils/purl.d.mts +0 -1
- package/dist/types/utils/quote-powershell.d.mts +2 -0
- package/dist/types/utils/requirements.d.mts +0 -1
- package/dist/types/utils/sdk.d.mts +0 -1
- package/dist/types/utils/self-update.d.mts +2 -1
- package/dist/types/utils/semver.d.mts +0 -1
- package/dist/types/utils/serialize-result-json.d.mts +0 -1
- package/dist/types/utils/shadow-links.d.mts +0 -1
- package/dist/types/utils/socket-json.d.mts +15 -5
- package/dist/types/utils/socket-package-alert.d.mts +0 -1
- package/dist/types/utils/socket-url.d.mts +0 -1
- package/dist/types/utils/spec.d.mts +0 -1
- package/dist/types/utils/strings.d.mts +0 -1
- package/dist/types/utils/telemetry/integration.d.mts +0 -1
- package/dist/types/utils/telemetry/service.d.mts +0 -1
- package/dist/types/utils/telemetry/types.d.mts +0 -1
- package/dist/types/utils/terminal-link.d.mts +0 -1
- package/dist/types/utils/tildify.d.mts +0 -1
- package/dist/types/utils/translations.d.mts +0 -1
- package/dist/types/utils/walk-nested-map.d.mts +0 -1
- package/dist/types/utils/yarn-paths.d.mts +0 -1
- package/dist/types/utils/yarn-version.d.mts +0 -1
- package/dist/types/yarn-cli.d.mts +0 -1
- package/dist/utils.js +513 -120
- package/dist/utils.js.map +1 -1
- package/external/@socketsecurity/registry/lib/packages.js +12 -9
- package/package.json +30 -10
- package/dist/tsconfig.dts.tsbuildinfo +0 -1
- package/dist/types/cli.d.mts.map +0 -1
- package/dist/types/commands/analytics/cmd-analytics.d.mts.map +0 -1
- package/dist/types/commands/analytics/fetch-org-analytics.d.mts.map +0 -1
- package/dist/types/commands/analytics/fetch-repo-analytics.d.mts.map +0 -1
- package/dist/types/commands/analytics/handle-analytics.d.mts.map +0 -1
- package/dist/types/commands/analytics/output-analytics.d.mts.map +0 -1
- package/dist/types/commands/audit-log/cmd-audit-log.d.mts.map +0 -1
- package/dist/types/commands/audit-log/fetch-audit-log.d.mts.map +0 -1
- package/dist/types/commands/audit-log/handle-audit-log.d.mts.map +0 -1
- package/dist/types/commands/audit-log/output-audit-log.d.mts.map +0 -1
- package/dist/types/commands/ci/cmd-ci.d.mts.map +0 -1
- package/dist/types/commands/ci/fetch-default-org-slug.d.mts.map +0 -1
- package/dist/types/commands/ci/handle-ci.d.mts.map +0 -1
- package/dist/types/commands/config/cmd-config-auto.d.mts.map +0 -1
- package/dist/types/commands/config/cmd-config-get.d.mts.map +0 -1
- package/dist/types/commands/config/cmd-config-list.d.mts.map +0 -1
- package/dist/types/commands/config/cmd-config-set.d.mts.map +0 -1
- package/dist/types/commands/config/cmd-config-unset.d.mts.map +0 -1
- package/dist/types/commands/config/cmd-config.d.mts.map +0 -1
- package/dist/types/commands/config/discover-config-value.d.mts.map +0 -1
- package/dist/types/commands/config/handle-config-auto.d.mts.map +0 -1
- package/dist/types/commands/config/handle-config-get.d.mts.map +0 -1
- package/dist/types/commands/config/handle-config-set.d.mts.map +0 -1
- package/dist/types/commands/config/handle-config-unset.d.mts.map +0 -1
- package/dist/types/commands/config/output-config-auto.d.mts.map +0 -1
- package/dist/types/commands/config/output-config-get.d.mts.map +0 -1
- package/dist/types/commands/config/output-config-list.d.mts.map +0 -1
- package/dist/types/commands/config/output-config-set.d.mts.map +0 -1
- package/dist/types/commands/config/output-config-unset.d.mts.map +0 -1
- package/dist/types/commands/fix/branch-cleanup.d.mts.map +0 -1
- package/dist/types/commands/fix/cmd-fix.d.mts.map +0 -1
- package/dist/types/commands/fix/coana-fix.d.mts.map +0 -1
- package/dist/types/commands/fix/env-helpers.d.mts.map +0 -1
- package/dist/types/commands/fix/generated-socket-facts.d.mts.map +0 -1
- package/dist/types/commands/fix/git.d.mts.map +0 -1
- package/dist/types/commands/fix/handle-fix.d.mts.map +0 -1
- package/dist/types/commands/fix/output-fix-result.d.mts.map +0 -1
- package/dist/types/commands/fix/pull-request.d.mts.map +0 -1
- package/dist/types/commands/fix/types.d.mts.map +0 -1
- package/dist/types/commands/install/cmd-install-completion.d.mts.map +0 -1
- package/dist/types/commands/install/cmd-install.d.mts.map +0 -1
- package/dist/types/commands/install/handle-install-completion.d.mts.map +0 -1
- package/dist/types/commands/install/output-install-completion.d.mts.map +0 -1
- package/dist/types/commands/install/setup-tab-completion.d.mts.map +0 -1
- package/dist/types/commands/json/cmd-json.d.mts.map +0 -1
- package/dist/types/commands/json/handle-cmd-json.d.mts.map +0 -1
- package/dist/types/commands/json/output-cmd-json.d.mts.map +0 -1
- package/dist/types/commands/login/apply-login.d.mts.map +0 -1
- package/dist/types/commands/login/attempt-login.d.mts.map +0 -1
- package/dist/types/commands/login/cmd-login.d.mts.map +0 -1
- package/dist/types/commands/logout/apply-logout.d.mts.map +0 -1
- package/dist/types/commands/logout/attempt-logout.d.mts.map +0 -1
- package/dist/types/commands/logout/cmd-logout.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/bazel-bin-detect.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/bazel-cleanup.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/bazel-cquery.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/bazel-java-shim.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/bazel-output-base-check.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/bazel-process.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/bazel-pypi-discovery.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/bazel-pypi-parser.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/bazel-python-shim.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/bazel-query-runner.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/bazel-repo-discovery.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/bazel-socket-json-trust.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/bazel-workspace-detect.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/bazel-workspace-walk.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/cmd-manifest-bazel.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/extract_bazel_to_maven.d.mts.map +0 -1
- package/dist/types/commands/manifest/bazel/extract_bazel_to_pypi.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-auto.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-conda.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-dotnet.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-dynamic-sbom-inference.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-gradle.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-kotlin.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-maven.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-scala.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest-setup.d.mts.map +0 -1
- package/dist/types/commands/manifest/cmd-manifest.d.mts.map +0 -1
- package/dist/types/commands/manifest/convert-conda-to-requirements.d.mts.map +0 -1
- package/dist/types/commands/manifest/convert-dotnet-to-facts.d.mts.map +0 -1
- package/dist/types/commands/manifest/convert-gradle-to-facts.d.mts.map +0 -1
- package/dist/types/commands/manifest/convert-maven-to-facts.d.mts.map +0 -1
- package/dist/types/commands/manifest/convert-sbt-to-facts.d.mts.map +0 -1
- package/dist/types/commands/manifest/convert_gradle_to_maven.d.mts.map +0 -1
- package/dist/types/commands/manifest/convert_sbt_to_maven.d.mts.map +0 -1
- package/dist/types/commands/manifest/detect-manifest-actions.d.mts.map +0 -1
- package/dist/types/commands/manifest/discover-manifest-roots.d.mts.map +0 -1
- package/dist/types/commands/manifest/enumerate-workspaces.d.mts.map +0 -1
- package/dist/types/commands/manifest/expand-env-var-refs.d.mts.map +0 -1
- package/dist/types/commands/manifest/generate-recursive-manifests.d.mts.map +0 -1
- package/dist/types/commands/manifest/generate_auto_manifest.d.mts.map +0 -1
- package/dist/types/commands/manifest/handle-manifest-conda.d.mts.map +0 -1
- package/dist/types/commands/manifest/handle-manifest-dynamic-sbom-inference.d.mts.map +0 -1
- package/dist/types/commands/manifest/handle-manifest-setup.d.mts.map +0 -1
- package/dist/types/commands/manifest/manifest-flags.d.mts.map +0 -1
- package/dist/types/commands/manifest/output-manifest-dynamic-sbom-inference.d.mts.map +0 -1
- package/dist/types/commands/manifest/output-manifest-setup.d.mts.map +0 -1
- package/dist/types/commands/manifest/output-requirements.d.mts.map +0 -1
- package/dist/types/commands/manifest/parse-build-tool-opts.d.mts.map +0 -1
- package/dist/types/commands/manifest/run-cdxgen.d.mts.map +0 -1
- package/dist/types/commands/manifest/run-manifest-facts.d.mts.map +0 -1
- package/dist/types/commands/manifest/scripts/assemble.d.mts.map +0 -1
- package/dist/types/commands/manifest/scripts/build-tool.d.mts.map +0 -1
- package/dist/types/commands/manifest/scripts/exclude-paths-glob.d.mts.map +0 -1
- package/dist/types/commands/manifest/scripts/facts.d.mts.map +0 -1
- package/dist/types/commands/manifest/scripts/records.d.mts.map +0 -1
- package/dist/types/commands/manifest/scripts/resolution-report-gradle.d.mts.map +0 -1
- package/dist/types/commands/manifest/scripts/resolution-report-ivy.d.mts.map +0 -1
- package/dist/types/commands/manifest/scripts/resolution-report-maven.d.mts.map +0 -1
- package/dist/types/commands/manifest/scripts/resolution-report-nuget.d.mts.map +0 -1
- package/dist/types/commands/manifest/scripts/resolution-report-render.d.mts.map +0 -1
- package/dist/types/commands/manifest/scripts/resolution-report.d.mts.map +0 -1
- package/dist/types/commands/manifest/scripts/run.d.mts.map +0 -1
- package/dist/types/commands/manifest/scripts/sidecar.d.mts.map +0 -1
- package/dist/types/commands/manifest/setup-manifest-config.d.mts.map +0 -1
- package/dist/types/commands/manifest/setup-recursive-manifest-config.d.mts.map +0 -1
- package/dist/types/commands/npm/cmd-npm.d.mts.map +0 -1
- package/dist/types/commands/npx/cmd-npx.d.mts.map +0 -1
- package/dist/types/commands/oops/cmd-oops.d.mts.map +0 -1
- package/dist/types/commands/optimize/add-overrides.d.mts.map +0 -1
- package/dist/types/commands/optimize/apply-optimization.d.mts.map +0 -1
- package/dist/types/commands/optimize/cmd-optimize.d.mts.map +0 -1
- package/dist/types/commands/optimize/deps-includes-by-agent.d.mts.map +0 -1
- package/dist/types/commands/optimize/get-dependency-entries.d.mts.map +0 -1
- package/dist/types/commands/optimize/get-overrides-by-agent.d.mts.map +0 -1
- package/dist/types/commands/optimize/handle-optimize.d.mts.map +0 -1
- package/dist/types/commands/optimize/lockfile-includes-by-agent.d.mts.map +0 -1
- package/dist/types/commands/optimize/ls-by-agent.d.mts.map +0 -1
- package/dist/types/commands/optimize/output-optimize-result.d.mts.map +0 -1
- package/dist/types/commands/optimize/shared.d.mts.map +0 -1
- package/dist/types/commands/optimize/types.d.mts.map +0 -1
- package/dist/types/commands/optimize/update-lockfile.d.mts.map +0 -1
- package/dist/types/commands/optimize/update-manifest-by-agent.d.mts.map +0 -1
- package/dist/types/commands/organization/cmd-organization-dependencies.d.mts.map +0 -1
- package/dist/types/commands/organization/cmd-organization-list.d.mts.map +0 -1
- package/dist/types/commands/organization/cmd-organization-policy-license.d.mts.map +0 -1
- package/dist/types/commands/organization/cmd-organization-policy-security.d.mts.map +0 -1
- package/dist/types/commands/organization/cmd-organization-policy.d.mts.map +0 -1
- package/dist/types/commands/organization/cmd-organization-quota.d.mts.map +0 -1
- package/dist/types/commands/organization/cmd-organization.d.mts.map +0 -1
- package/dist/types/commands/organization/fetch-dependencies.d.mts.map +0 -1
- package/dist/types/commands/organization/fetch-license-policy.d.mts.map +0 -1
- package/dist/types/commands/organization/fetch-organization-list.d.mts.map +0 -1
- package/dist/types/commands/organization/fetch-quota.d.mts.map +0 -1
- package/dist/types/commands/organization/fetch-security-policy.d.mts.map +0 -1
- package/dist/types/commands/organization/handle-dependencies.d.mts.map +0 -1
- package/dist/types/commands/organization/handle-license-policy.d.mts.map +0 -1
- package/dist/types/commands/organization/handle-organization-list.d.mts.map +0 -1
- package/dist/types/commands/organization/handle-quota.d.mts.map +0 -1
- package/dist/types/commands/organization/handle-security-policy.d.mts.map +0 -1
- package/dist/types/commands/organization/output-dependencies.d.mts.map +0 -1
- package/dist/types/commands/organization/output-license-policy.d.mts.map +0 -1
- package/dist/types/commands/organization/output-organization-list.d.mts.map +0 -1
- package/dist/types/commands/organization/output-quota.d.mts.map +0 -1
- package/dist/types/commands/organization/output-security-policy.d.mts.map +0 -1
- package/dist/types/commands/package/cmd-package-score.d.mts.map +0 -1
- package/dist/types/commands/package/cmd-package-shallow.d.mts.map +0 -1
- package/dist/types/commands/package/cmd-package.d.mts.map +0 -1
- package/dist/types/commands/package/fetch-purl-deep-score.d.mts.map +0 -1
- package/dist/types/commands/package/fetch-purls-shallow-score.d.mts.map +0 -1
- package/dist/types/commands/package/handle-purl-deep-score.d.mts.map +0 -1
- package/dist/types/commands/package/handle-purls-shallow-score.d.mts.map +0 -1
- package/dist/types/commands/package/output-purls-deep-score.d.mts.map +0 -1
- package/dist/types/commands/package/output-purls-shallow-score.d.mts.map +0 -1
- package/dist/types/commands/package/parse-package-specifiers.d.mts.map +0 -1
- package/dist/types/commands/patch/cmd-patch.d.mts.map +0 -1
- package/dist/types/commands/pnpm/cmd-pnpm.d.mts.map +0 -1
- package/dist/types/commands/raw-npm/cmd-raw-npm.d.mts.map +0 -1
- package/dist/types/commands/raw-npm/run-raw-npm.d.mts.map +0 -1
- package/dist/types/commands/raw-npx/cmd-raw-npx.d.mts.map +0 -1
- package/dist/types/commands/raw-npx/run-raw-npx.d.mts.map +0 -1
- package/dist/types/commands/repository/cmd-repository-create.d.mts.map +0 -1
- package/dist/types/commands/repository/cmd-repository-del.d.mts.map +0 -1
- package/dist/types/commands/repository/cmd-repository-list.d.mts.map +0 -1
- package/dist/types/commands/repository/cmd-repository-update.d.mts.map +0 -1
- package/dist/types/commands/repository/cmd-repository-view.d.mts.map +0 -1
- package/dist/types/commands/repository/cmd-repository.d.mts.map +0 -1
- package/dist/types/commands/repository/fetch-create-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/fetch-delete-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/fetch-list-all-repos.d.mts.map +0 -1
- package/dist/types/commands/repository/fetch-list-repos.d.mts.map +0 -1
- package/dist/types/commands/repository/fetch-update-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/fetch-view-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/handle-create-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/handle-delete-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/handle-list-repos.d.mts.map +0 -1
- package/dist/types/commands/repository/handle-update-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/handle-view-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/output-create-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/output-delete-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/output-list-repos.d.mts.map +0 -1
- package/dist/types/commands/repository/output-update-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/output-view-repo.d.mts.map +0 -1
- package/dist/types/commands/repository/types.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-create.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-del.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-diff.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-github.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-list.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-metadata.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-reach.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-report.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-setup.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan-view.d.mts.map +0 -1
- package/dist/types/commands/scan/cmd-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/create-scan-from-github.d.mts.map +0 -1
- package/dist/types/commands/scan/exclude-paths.d.mts.map +0 -1
- package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/fetch-delete-org-full-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/fetch-diff-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/fetch-list-scans.d.mts.map +0 -1
- package/dist/types/commands/scan/fetch-report-data.d.mts.map +0 -1
- package/dist/types/commands/scan/fetch-scan-metadata.d.mts.map +0 -1
- package/dist/types/commands/scan/fetch-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts.map +0 -1
- package/dist/types/commands/scan/finalize-tier1-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/generate-report.d.mts.map +0 -1
- package/dist/types/commands/scan/generate-uv-member-sboms.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-create-github-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-create-new-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-delete-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-diff-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-list-scans.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-scan-config.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-scan-metadata.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-scan-reach.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-scan-report.d.mts.map +0 -1
- package/dist/types/commands/scan/handle-scan-view.d.mts.map +0 -1
- package/dist/types/commands/scan/output-create-new-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/output-delete-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/output-diff-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/output-list-scans.d.mts.map +0 -1
- package/dist/types/commands/scan/output-scan-config-result.d.mts.map +0 -1
- package/dist/types/commands/scan/output-scan-github.d.mts.map +0 -1
- package/dist/types/commands/scan/output-scan-metadata.d.mts.map +0 -1
- package/dist/types/commands/scan/output-scan-reach.d.mts.map +0 -1
- package/dist/types/commands/scan/output-scan-report.d.mts.map +0 -1
- package/dist/types/commands/scan/output-scan-view.d.mts.map +0 -1
- package/dist/types/commands/scan/perform-reachability-analysis.d.mts.map +0 -1
- package/dist/types/commands/scan/reach-advisories.d.mts.map +0 -1
- package/dist/types/commands/scan/reachability-flags.d.mts.map +0 -1
- package/dist/types/commands/scan/reachability-units.d.mts.map +0 -1
- package/dist/types/commands/scan/run-dynamic-sbom-inference.d.mts.map +0 -1
- package/dist/types/commands/scan/setup-scan-config.d.mts.map +0 -1
- package/dist/types/commands/scan/stream-scan.d.mts.map +0 -1
- package/dist/types/commands/scan/suggest-org-slug.d.mts.map +0 -1
- package/dist/types/commands/scan/suggest-to-persist-orgslug.d.mts.map +0 -1
- package/dist/types/commands/scan/suggest_branch_slug.d.mts.map +0 -1
- package/dist/types/commands/scan/suggest_target.d.mts.map +0 -1
- package/dist/types/commands/scan/types.d.mts.map +0 -1
- package/dist/types/commands/scan/validate-reachability-target.d.mts.map +0 -1
- package/dist/types/commands/scan/warn-socket-json-only-flags.d.mts.map +0 -1
- package/dist/types/commands/threat-feed/cmd-threat-feed.d.mts.map +0 -1
- package/dist/types/commands/threat-feed/fetch-threat-feed.d.mts.map +0 -1
- package/dist/types/commands/threat-feed/handle-threat-feed.d.mts.map +0 -1
- package/dist/types/commands/threat-feed/output-threat-feed.d.mts.map +0 -1
- package/dist/types/commands/threat-feed/types.d.mts.map +0 -1
- package/dist/types/commands/uninstall/cmd-uninstall-completion.d.mts.map +0 -1
- package/dist/types/commands/uninstall/cmd-uninstall.d.mts.map +0 -1
- package/dist/types/commands/uninstall/handle-uninstall-completion.d.mts.map +0 -1
- package/dist/types/commands/uninstall/output-uninstall-completion.d.mts.map +0 -1
- package/dist/types/commands/uninstall/teardown-tab-completion.d.mts.map +0 -1
- package/dist/types/commands/wrapper/add-socket-wrapper.d.mts.map +0 -1
- package/dist/types/commands/wrapper/check-socket-wrapper-setup.d.mts.map +0 -1
- package/dist/types/commands/wrapper/cmd-wrapper.d.mts.map +0 -1
- package/dist/types/commands/wrapper/postinstall-wrapper.d.mts.map +0 -1
- package/dist/types/commands/wrapper/remove-socket-wrapper.d.mts.map +0 -1
- package/dist/types/commands/yarn/cmd-yarn.d.mts.map +0 -1
- package/dist/types/commands.d.mts.map +0 -1
- package/dist/types/constants.d.mts.map +0 -1
- package/dist/types/flags.d.mts.map +0 -1
- package/dist/types/instrument-with-sentry.d.mts.map +0 -1
- package/dist/types/npm-cli.d.mts.map +0 -1
- package/dist/types/npx-cli.d.mts.map +0 -1
- package/dist/types/pnpm-cli.d.mts.map +0 -1
- package/dist/types/sea/bootstrap.d.mts.map +0 -1
- package/dist/types/sea/build-sea.d.mts.map +0 -1
- package/dist/types/shadow/common.d.mts.map +0 -1
- package/dist/types/shadow/npm/arborist/index.d.mts.map +0 -1
- package/dist/types/shadow/npm/arborist/lib/arborist/index.d.mts.map +0 -1
- package/dist/types/shadow/npm/arborist/types.d.mts.map +0 -1
- package/dist/types/shadow/npm/arborist-helpers.d.mts.map +0 -1
- package/dist/types/shadow/npm/bin.d.mts.map +0 -1
- package/dist/types/shadow/npm/inject.d.mts.map +0 -1
- package/dist/types/shadow/npm/install.d.mts.map +0 -1
- package/dist/types/shadow/npm/paths.d.mts.map +0 -1
- package/dist/types/shadow/npm-base.d.mts.map +0 -1
- package/dist/types/shadow/npx/bin.d.mts.map +0 -1
- package/dist/types/shadow/pnpm/bin.d.mts.map +0 -1
- package/dist/types/shadow/stdio-ipc.d.mts.map +0 -1
- package/dist/types/shadow/yarn/bin.d.mts.map +0 -1
- package/dist/types/test/json-output-validation.d.mts.map +0 -1
- package/dist/types/test/mocks/socket-auth.d.mts.map +0 -1
- package/dist/types/types.d.mts.map +0 -1
- package/dist/types/utils/advisory-ids.d.mts.map +0 -1
- package/dist/types/utils/agent.d.mts.map +0 -1
- package/dist/types/utils/alert/artifact.d.mts.map +0 -1
- package/dist/types/utils/alert/fix.d.mts.map +0 -1
- package/dist/types/utils/alert/severity.d.mts.map +0 -1
- package/dist/types/utils/alerts-map.d.mts.map +0 -1
- package/dist/types/utils/api-transport.d.mts.map +0 -1
- package/dist/types/utils/api.d.mts.map +0 -1
- package/dist/types/utils/check-input.d.mts.map +0 -1
- package/dist/types/utils/cmd.d.mts.map +0 -1
- package/dist/types/utils/coana-release.d.mts.map +0 -1
- package/dist/types/utils/coana.d.mts.map +0 -1
- package/dist/types/utils/color-or-markdown.d.mts.map +0 -1
- package/dist/types/utils/completion.d.mts.map +0 -1
- package/dist/types/utils/config.d.mts.map +0 -1
- package/dist/types/utils/cve-to-ghsa.d.mts.map +0 -1
- package/dist/types/utils/debug.d.mts.map +0 -1
- package/dist/types/utils/determine-org-slug.d.mts.map +0 -1
- package/dist/types/utils/dlx-binary.d.mts +0 -58
- package/dist/types/utils/dlx-binary.d.mts.map +0 -1
- package/dist/types/utils/dlx-detection.d.mts.map +0 -1
- package/dist/types/utils/dlx.d.mts.map +0 -1
- package/dist/types/utils/ecosystem.d.mts.map +0 -1
- package/dist/types/utils/editable-json.d.mts.map +0 -1
- package/dist/types/utils/errors.d.mts.map +0 -1
- package/dist/types/utils/extract-names.d.mts.map +0 -1
- package/dist/types/utils/fail-msg-with-badge.d.mts.map +0 -1
- package/dist/types/utils/filter-config.d.mts.map +0 -1
- package/dist/types/utils/fs.d.mts.map +0 -1
- package/dist/types/utils/get-or-insert.d.mts.map +0 -1
- package/dist/types/utils/get-output-kind.d.mts.map +0 -1
- package/dist/types/utils/git.d.mts.map +0 -1
- package/dist/types/utils/github-errors.d.mts.map +0 -1
- package/dist/types/utils/github.d.mts.map +0 -1
- package/dist/types/utils/glob.d.mts.map +0 -1
- package/dist/types/utils/lockfile.d.mts.map +0 -1
- package/dist/types/utils/map-to-object.d.mts.map +0 -1
- package/dist/types/utils/markdown.d.mts.map +0 -1
- package/dist/types/utils/meow-with-subcommands.d.mts.map +0 -1
- package/dist/types/utils/ms-at-home.d.mts.map +0 -1
- package/dist/types/utils/npm-config.d.mts.map +0 -1
- package/dist/types/utils/npm-package-arg.d.mts.map +0 -1
- package/dist/types/utils/npm-paths.d.mts.map +0 -1
- package/dist/types/utils/npm-spec.d.mts.map +0 -1
- package/dist/types/utils/oauth.d.mts.map +0 -1
- package/dist/types/utils/objects.d.mts.map +0 -1
- package/dist/types/utils/organization.d.mts.map +0 -1
- package/dist/types/utils/output-formatting.d.mts.map +0 -1
- package/dist/types/utils/package-environment.d.mts.map +0 -1
- package/dist/types/utils/package-manager.d.mts.map +0 -1
- package/dist/types/utils/path-resolve.d.mts.map +0 -1
- package/dist/types/utils/pnpm-paths.d.mts.map +0 -1
- package/dist/types/utils/pnpm.d.mts.map +0 -1
- package/dist/types/utils/purl-to-ghsa.d.mts.map +0 -1
- package/dist/types/utils/purl.d.mts.map +0 -1
- package/dist/types/utils/requirements.d.mts.map +0 -1
- package/dist/types/utils/sdk.d.mts.map +0 -1
- package/dist/types/utils/self-update.d.mts.map +0 -1
- package/dist/types/utils/semver.d.mts.map +0 -1
- package/dist/types/utils/serialize-result-json.d.mts.map +0 -1
- package/dist/types/utils/shadow-links.d.mts.map +0 -1
- package/dist/types/utils/socket-json.d.mts.map +0 -1
- package/dist/types/utils/socket-package-alert.d.mts.map +0 -1
- package/dist/types/utils/socket-url.d.mts.map +0 -1
- package/dist/types/utils/spec.d.mts.map +0 -1
- package/dist/types/utils/strings.d.mts.map +0 -1
- package/dist/types/utils/telemetry/integration.d.mts.map +0 -1
- package/dist/types/utils/telemetry/service.d.mts.map +0 -1
- package/dist/types/utils/telemetry/types.d.mts.map +0 -1
- package/dist/types/utils/terminal-link.d.mts.map +0 -1
- package/dist/types/utils/tildify.d.mts.map +0 -1
- package/dist/types/utils/translations.d.mts.map +0 -1
- package/dist/types/utils/walk-nested-map.d.mts.map +0 -1
- package/dist/types/utils/yarn-paths.d.mts.map +0 -1
- package/dist/types/utils/yarn-version.d.mts.map +0 -1
- package/dist/types/yarn-cli.d.mts.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -18,6 +18,7 @@ var arrays = require('../external/@socketsecurity/registry/lib/arrays');
|
|
|
18
18
|
var prompts = require('../external/@socketsecurity/registry/lib/prompts');
|
|
19
19
|
var require$$0 = require('node:crypto');
|
|
20
20
|
var os = require('node:os');
|
|
21
|
+
var objects = require('../external/@socketsecurity/registry/lib/objects');
|
|
21
22
|
var spawn = require('../external/@socketsecurity/registry/lib/spawn');
|
|
22
23
|
var childProcess = require('node:child_process');
|
|
23
24
|
var bin = require('../external/@socketsecurity/registry/lib/bin');
|
|
@@ -25,7 +26,7 @@ var require$$7 = require('node:timers/promises');
|
|
|
25
26
|
var fs$1 = require('../external/@socketsecurity/registry/lib/fs');
|
|
26
27
|
var strings = require('../external/@socketsecurity/registry/lib/strings');
|
|
27
28
|
var path$1 = require('../external/@socketsecurity/registry/lib/path');
|
|
28
|
-
var
|
|
29
|
+
var require$$0$2 = require('node:events');
|
|
29
30
|
var registry = require('../external/@socketsecurity/registry');
|
|
30
31
|
var packages = require('../external/@socketsecurity/registry/lib/packages');
|
|
31
32
|
var promises = require('../external/@socketsecurity/registry/lib/promises');
|
|
@@ -1452,6 +1453,58 @@ function isStricterPolicy(was, is) {
|
|
|
1452
1453
|
return false;
|
|
1453
1454
|
}
|
|
1454
1455
|
|
|
1456
|
+
function flattenReportAlerts(report) {
|
|
1457
|
+
return Array.from(utils.walkNestedMap(report.alerts)).map(({
|
|
1458
|
+
keys,
|
|
1459
|
+
value
|
|
1460
|
+
}) => {
|
|
1461
|
+
const {
|
|
1462
|
+
manifest,
|
|
1463
|
+
policy,
|
|
1464
|
+
type,
|
|
1465
|
+
url
|
|
1466
|
+
} = value;
|
|
1467
|
+
return {
|
|
1468
|
+
alertType: type,
|
|
1469
|
+
manifest: arrays.joinAnd(manifest),
|
|
1470
|
+
packageName: keys[1] || '<unknown>',
|
|
1471
|
+
// The third map key is the package version shown in report output.
|
|
1472
|
+
packageVersion: keys[2] || '<unknown>',
|
|
1473
|
+
policy,
|
|
1474
|
+
url
|
|
1475
|
+
};
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
function formatAlertTable(rows) {
|
|
1479
|
+
const headers = ['POLICY', 'ALERT TYPE', 'PACKAGE', 'VERSION', 'MANIFEST FILE'];
|
|
1480
|
+
const cells = rows.map(row => [row.policy, row.alertType, row.packageName, row.packageVersion, row.manifest]);
|
|
1481
|
+
const widths = headers.map(header => header.length);
|
|
1482
|
+
for (const cell of cells) {
|
|
1483
|
+
for (let i = 0, {
|
|
1484
|
+
length
|
|
1485
|
+
} = cell; i < length; i += 1) {
|
|
1486
|
+
widths[i] = Math.max(widths[i] ?? 0, cell[i]?.length ?? 0);
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
const toRow = values => ` ${values.map((value, i) => value.padEnd(widths[i] ?? 0)).join(' ').trimEnd()}`;
|
|
1490
|
+
const out = [toRow(headers), toRow(widths.map(width => '-'.repeat(width)))];
|
|
1491
|
+
for (let i = 0, {
|
|
1492
|
+
length
|
|
1493
|
+
} = cells; i < length; i += 1) {
|
|
1494
|
+
out.push(toRow(cells[i]));
|
|
1495
|
+
const {
|
|
1496
|
+
url
|
|
1497
|
+
} = rows[i];
|
|
1498
|
+
if (url) {
|
|
1499
|
+
out.push(` ${url}`);
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
return out;
|
|
1503
|
+
}
|
|
1504
|
+
function formatLabelledPairs(pairs) {
|
|
1505
|
+
const width = Math.max(...pairs.map(pair => pair[0].length));
|
|
1506
|
+
return pairs.map(([label, value]) => ` ${`${label}:`.padEnd(width + 1)} ${value}`);
|
|
1507
|
+
}
|
|
1455
1508
|
async function outputScanReport(result, {
|
|
1456
1509
|
filepath,
|
|
1457
1510
|
fold,
|
|
@@ -1528,9 +1581,7 @@ async function outputScanReport(result, {
|
|
|
1528
1581
|
if (short) {
|
|
1529
1582
|
logger.logger.log(scanReport.data.healthy ? 'OK' : 'ERR');
|
|
1530
1583
|
} else {
|
|
1531
|
-
logger.logger.
|
|
1532
|
-
depth: null
|
|
1533
|
-
});
|
|
1584
|
+
logger.logger.log(toPlainTextReport(scanReport.data, includeLicensePolicy));
|
|
1534
1585
|
}
|
|
1535
1586
|
}
|
|
1536
1587
|
function toJsonReport(report, includeLicensePolicy) {
|
|
@@ -1547,27 +1598,16 @@ function toJsonReport(report, includeLicensePolicy) {
|
|
|
1547
1598
|
}
|
|
1548
1599
|
function toMarkdownReport(report, includeLicensePolicy) {
|
|
1549
1600
|
const reportLevel = report.options.reportLevel;
|
|
1550
|
-
const alertFolding = report.options.fold === constants.
|
|
1551
|
-
const flatData =
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
} = value;
|
|
1561
|
-
return {
|
|
1562
|
-
'Alert Type': type,
|
|
1563
|
-
Package: keys[1] || '<unknown>',
|
|
1564
|
-
'Introduced by': keys[2] || '<unknown>',
|
|
1565
|
-
url,
|
|
1566
|
-
'Manifest file': arrays.joinAnd(manifest),
|
|
1567
|
-
Policy: policy
|
|
1568
|
-
};
|
|
1569
|
-
});
|
|
1570
|
-
const minPolicyLevel = reportLevel === constants.default.REPORT_LEVEL_DEFER ? 'everything' : reportLevel;
|
|
1601
|
+
const alertFolding = report.options.fold === constants.FOLD_SETTING_NONE ? 'none' : `up to ${report.options.fold}`;
|
|
1602
|
+
const flatData = flattenReportAlerts(report).map(row => ({
|
|
1603
|
+
'Alert Type': row.alertType,
|
|
1604
|
+
Package: row.packageName,
|
|
1605
|
+
Version: row.packageVersion,
|
|
1606
|
+
URL: row.url,
|
|
1607
|
+
'Manifest file': row.manifest,
|
|
1608
|
+
Policy: row.policy
|
|
1609
|
+
}));
|
|
1610
|
+
const minPolicyLevel = reportLevel === constants.REPORT_LEVEL_DEFER ? 'everything' : reportLevel;
|
|
1571
1611
|
const md = `
|
|
1572
1612
|
# Scan Policy Report
|
|
1573
1613
|
|
|
@@ -1592,10 +1632,30 @@ Configuration used to generate this report:
|
|
|
1592
1632
|
|
|
1593
1633
|
${report.alerts.size ? `All the alerts from the scan with a policy set to at least "${reportLevel}".` : `The scan contained no alerts with a policy set to at least "${reportLevel}".`}
|
|
1594
1634
|
|
|
1595
|
-
${!report.alerts.size ? '' : utils.mdTable(flatData, ['Policy', 'Alert Type', 'Package', '
|
|
1635
|
+
${!report.alerts.size ? '' : utils.mdTable(flatData, ['Policy', 'Alert Type', 'Package', 'Version', 'URL', 'Manifest file'])}
|
|
1596
1636
|
`.trim() + '\n';
|
|
1597
1637
|
return md;
|
|
1598
1638
|
}
|
|
1639
|
+
function toPlainTextReport(report, includeLicensePolicy) {
|
|
1640
|
+
const {
|
|
1641
|
+
reportLevel
|
|
1642
|
+
} = report.options;
|
|
1643
|
+
const policyWord = includeLicensePolicy ? 'security and license' : 'security';
|
|
1644
|
+
const alertFolding = report.options.fold === constants.FOLD_SETTING_NONE ? 'none' : `up to ${report.options.fold}`;
|
|
1645
|
+
const minPolicyLevel = reportLevel === constants.REPORT_LEVEL_DEFER ? 'everything' : reportLevel;
|
|
1646
|
+
const lines = ['Socket scan policy report', '', 'Health status', report.healthy ? ` PASSES all requirements set by your ${policyWord} policy.` : ' VIOLATES one or more policies set to the "error" level.', '', 'Settings', ...formatLabelledPairs([['Organization', report.orgSlug], ['Scan ID', report.scanId], ['Alert folding', alertFolding], ['Minimum policy level', minPolicyLevel], ['Include license alerts', includeLicensePolicy ? 'yes' : 'no']]), '', 'Alerts'];
|
|
1647
|
+
const rows = flattenReportAlerts(report);
|
|
1648
|
+
if (!rows.length) {
|
|
1649
|
+
lines.push(` No alerts with a policy set to at least "${reportLevel}".`, '');
|
|
1650
|
+
return lines.join('\n');
|
|
1651
|
+
}
|
|
1652
|
+
lines.push(` ${rows.length} ${words.pluralize('alert', rows.length)} with a policy set to at least "${reportLevel}".`, '');
|
|
1653
|
+
for (const line of formatAlertTable(rows)) {
|
|
1654
|
+
lines.push(line);
|
|
1655
|
+
}
|
|
1656
|
+
lines.push('');
|
|
1657
|
+
return lines.join('\n');
|
|
1658
|
+
}
|
|
1599
1659
|
|
|
1600
1660
|
async function handleScanReport({
|
|
1601
1661
|
filepath,
|
|
@@ -1769,8 +1829,7 @@ function sortByPurl(entries) {
|
|
|
1769
1829
|
// Emit an entry for every SBOM component AND every first-party project: a
|
|
1770
1830
|
// top-level module is a project, not a dependency component, yet its source
|
|
1771
1831
|
// roots are where reachability starts, so the sidecar must carry them.
|
|
1772
|
-
//
|
|
1773
|
-
// repeated call for the same factsFile (the same build run again) overwrites.
|
|
1832
|
+
// A run writing a facts file another run wrote replaces its entry.
|
|
1774
1833
|
function accumulateSidecar(acc, facts, artifactPaths, factsFile,
|
|
1775
1834
|
// Off when artifact paths were not resolved; entries then omit `targets` and `sources`.
|
|
1776
1835
|
withPaths = true) {
|
|
@@ -1833,7 +1892,6 @@ function serializeSidecar(acc) {
|
|
|
1833
1892
|
|
|
1834
1893
|
async function performReachabilityAnalysis(options) {
|
|
1835
1894
|
const {
|
|
1836
|
-
branchName,
|
|
1837
1895
|
cwd = process.cwd(),
|
|
1838
1896
|
factsOnlyTypes,
|
|
1839
1897
|
orgSlug,
|
|
@@ -1941,17 +1999,6 @@ async function performReachabilityAnalysis(options) {
|
|
|
1941
1999
|
// Empty reachEcosystems implies scanning all ecosystems.
|
|
1942
2000
|
...(reachabilityOptions.reachEcosystems.length ? ['--purl-types', ...reachabilityOptions.reachEcosystems] : []), ...(reachabilityOptions.reachAdvisories.length ? ['--ghsas', ...reachabilityOptions.reachAdvisories] : []), ...(reachabilityOptions.reachExcludePaths.length ? ['--exclude-dirs', ...reachabilityOptions.reachExcludePaths] : []), ...(factsOnlyTypes ? utils.useOnlySocketFactsArtifactsFlags(factsOnlyTypes) : []), ...(reachabilityOptions.reachSkipCache ? ['--skip-cache-usage'] : []), ...(reachabilityOptions.reachUseOnlyPregeneratedSboms ? ['--use-only-pregenerated-sboms'] : []), ...(sidecarPath ? ['--compute-artifacts-sidecar', sidecarPath] : [])];
|
|
1943
2001
|
|
|
1944
|
-
// Build environment variables.
|
|
1945
|
-
const coanaEnv = {};
|
|
1946
|
-
// do not pass default repo and branch name to coana to avoid mixing
|
|
1947
|
-
// buckets (cached configuration) from projects that are likely very different.
|
|
1948
|
-
if (repoName && repoName !== constants.default.SOCKET_DEFAULT_REPOSITORY) {
|
|
1949
|
-
coanaEnv['SOCKET_REPO_NAME'] = repoName;
|
|
1950
|
-
}
|
|
1951
|
-
if (branchName && branchName !== constants.default.SOCKET_DEFAULT_BRANCH) {
|
|
1952
|
-
coanaEnv['SOCKET_BRANCH_NAME'] = branchName;
|
|
1953
|
-
}
|
|
1954
|
-
|
|
1955
2002
|
// In machine-readable modes (--json/--markdown) the final payload is written
|
|
1956
2003
|
// to stdout by the output layer. Coana streams progress/logs over stdout
|
|
1957
2004
|
// under `inherit`, which would corrupt that payload, so redirect the child's
|
|
@@ -1963,7 +2010,7 @@ async function performReachabilityAnalysis(options) {
|
|
|
1963
2010
|
const coanaResult = await utils.spawnCoana(coanaArgs, orgSlug, {
|
|
1964
2011
|
coanaVersion: reachabilityOptions.reachVersion,
|
|
1965
2012
|
cwd,
|
|
1966
|
-
|
|
2013
|
+
repoName,
|
|
1967
2014
|
spinner,
|
|
1968
2015
|
stdio: coanaStdio
|
|
1969
2016
|
});
|
|
@@ -2034,6 +2081,32 @@ function buildToolLabelsFor(purlTypes) {
|
|
|
2034
2081
|
|
|
2035
2082
|
// Purl types whose packages have no namespace (NuGet ids are flat).
|
|
2036
2083
|
const NAMESPACELESS_PURL_TYPES = new Set(['nuget']);
|
|
2084
|
+
const BUILD_TOOL_PATH_ENV = {
|
|
2085
|
+
__proto__: null,
|
|
2086
|
+
gradle: 'SOCKET_CLI_GRADLE_PATH',
|
|
2087
|
+
maven: 'SOCKET_CLI_MAVEN_PATH',
|
|
2088
|
+
sbt: 'SOCKET_CLI_SBT_PATH'
|
|
2089
|
+
};
|
|
2090
|
+
function validatedEnvBuildToolPath(tool, projectDir) {
|
|
2091
|
+
const envName = BUILD_TOOL_PATH_ENV[tool];
|
|
2092
|
+
const selected = process.env[envName];
|
|
2093
|
+
if (!selected) {
|
|
2094
|
+
throw new Error(`Standalone Socket does not support ${tool} manifest execution without ${envName}: JVM runtime and toolchain assets are not bundled.`);
|
|
2095
|
+
}
|
|
2096
|
+
const executable = path.resolve(projectDir, selected);
|
|
2097
|
+
return validateExecutablePath(envName, selected, executable);
|
|
2098
|
+
}
|
|
2099
|
+
function validateExecutablePath(envName, selected, executable) {
|
|
2100
|
+
try {
|
|
2101
|
+
if (!u.statSync(executable).isFile()) {
|
|
2102
|
+
throw new Error('not a regular file');
|
|
2103
|
+
}
|
|
2104
|
+
u.accessSync(executable, u.constants.X_OK);
|
|
2105
|
+
return executable;
|
|
2106
|
+
} catch {
|
|
2107
|
+
throw new Error(`${envName} must point to a regular executable file; received '${selected}'.`);
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2037
2110
|
|
|
2038
2111
|
// PATH fallback when no `bin` and no project wrapper.
|
|
2039
2112
|
const DEFAULT_BUILD_TOOL_BIN = {
|
|
@@ -2066,23 +2139,28 @@ const BUILD_FILES = {
|
|
|
2066
2139
|
byFile: true,
|
|
2067
2140
|
nocaseGlob: '*.{sln,slnx,csproj,fsproj,vbproj}',
|
|
2068
2141
|
walkGlob: '*.{[sS][lL][nN],[sS][lL][nN][xX],[cCfFvV][sSbB][pP][rR][oO][jJ]}',
|
|
2069
|
-
// NuGet restores each project into its own project.assets.json.
|
|
2070
|
-
projectsResolveAlone: true,
|
|
2071
2142
|
// A solution covers the projects it lists.
|
|
2072
2143
|
entryRank: file => isDotnetSolution(file) ? 0 : 1
|
|
2073
2144
|
},
|
|
2074
2145
|
gradle: {
|
|
2075
2146
|
byFile: false,
|
|
2076
|
-
names: ['build.gradle', 'build.gradle.kts', 'settings.gradle', 'settings.gradle.kts']
|
|
2147
|
+
names: ['build.gradle', 'build.gradle.kts', 'settings.gradle', 'settings.gradle.kts'],
|
|
2148
|
+
rootMarkers: ['settings.gradle', 'settings.gradle.kts'],
|
|
2149
|
+
// Gradle builds `buildSrc` on its own.
|
|
2150
|
+
loadsAncestorBuild: {
|
|
2151
|
+
except: ['buildSrc']
|
|
2152
|
+
}
|
|
2077
2153
|
},
|
|
2078
2154
|
maven: {
|
|
2079
2155
|
byFile: true,
|
|
2080
2156
|
nocaseGlob: '{*-*.,}pom{.xml,}',
|
|
2081
2157
|
walkGlob: '*[pP][oO][mM]*'
|
|
2082
2158
|
},
|
|
2159
|
+
// A subproject's own `project/` is ignored by the build that includes it.
|
|
2083
2160
|
sbt: {
|
|
2084
2161
|
byFile: false,
|
|
2085
|
-
names: ['build.sbt']
|
|
2162
|
+
names: ['build.sbt'],
|
|
2163
|
+
rootMarkers: ['project']
|
|
2086
2164
|
}
|
|
2087
2165
|
};
|
|
2088
2166
|
|
|
@@ -2092,7 +2170,14 @@ const BUILD_FILES = {
|
|
|
2092
2170
|
function looksLikeSbtBuild(projectDir) {
|
|
2093
2171
|
return u.existsSync(path.resolve(projectDir, 'build.sbt')) || u.existsSync(path.resolve(projectDir, 'project'));
|
|
2094
2172
|
}
|
|
2095
|
-
function resolveBuildToolBin(tool, projectDir, bin) {
|
|
2173
|
+
function resolveBuildToolBin(tool, projectDir, bin, standalone = false) {
|
|
2174
|
+
if (standalone) {
|
|
2175
|
+
return validatedEnvBuildToolPath(tool, projectDir);
|
|
2176
|
+
}
|
|
2177
|
+
const envOverride = process.env[BUILD_TOOL_PATH_ENV[tool]];
|
|
2178
|
+
if (envOverride) {
|
|
2179
|
+
return validateExecutablePath(BUILD_TOOL_PATH_ENV[tool], envOverride, path.resolve(projectDir, envOverride));
|
|
2180
|
+
}
|
|
2096
2181
|
if (bin) {
|
|
2097
2182
|
return bin;
|
|
2098
2183
|
}
|
|
@@ -2229,6 +2314,7 @@ function buildPerRoot(parsed) {
|
|
|
2229
2314
|
out.set(rootId, {
|
|
2230
2315
|
projectKey: r.projectKey,
|
|
2231
2316
|
prod: r.prod,
|
|
2317
|
+
onClasspath: r.onClasspath,
|
|
2232
2318
|
target: r.target,
|
|
2233
2319
|
nodes
|
|
2234
2320
|
});
|
|
@@ -2314,17 +2400,22 @@ function buildSubprojectGraphs(perRoot) {
|
|
|
2314
2400
|
const graphs = new Map();
|
|
2315
2401
|
for (const {
|
|
2316
2402
|
nodes,
|
|
2403
|
+
onClasspath,
|
|
2317
2404
|
projectKey
|
|
2318
2405
|
} of perRoot.values()) {
|
|
2319
2406
|
let g = graphs.get(projectKey);
|
|
2320
2407
|
if (!g) {
|
|
2321
2408
|
g = {
|
|
2322
2409
|
children: new Map(),
|
|
2410
|
+
classpath: new Set(),
|
|
2323
2411
|
direct: new Set()
|
|
2324
2412
|
};
|
|
2325
2413
|
graphs.set(projectKey, g);
|
|
2326
2414
|
}
|
|
2327
2415
|
for (const [coordId, node] of nodes) {
|
|
2416
|
+
if (onClasspath) {
|
|
2417
|
+
g.classpath.add(coordId);
|
|
2418
|
+
}
|
|
2328
2419
|
let set = g.children.get(coordId);
|
|
2329
2420
|
if (!set) {
|
|
2330
2421
|
set = new Set();
|
|
@@ -2507,8 +2598,8 @@ function buildArtifactPaths(finalNodes, projects, excludedProjects, graphs, exis
|
|
|
2507
2598
|
}
|
|
2508
2599
|
return {
|
|
2509
2600
|
pathsById,
|
|
2510
|
-
classpathByProject: byProject(projects, graphs, g => g.
|
|
2511
|
-
directDependenciesByProject: byProject(projects, graphs, g => g.direct)
|
|
2601
|
+
classpathByProject: byProject(projects, graphs, g => g.classpath),
|
|
2602
|
+
directDependenciesByProject: byProject(projects, graphs, g => [...g.direct].filter(id => g.classpath.has(id)))
|
|
2512
2603
|
};
|
|
2513
2604
|
}
|
|
2514
2605
|
|
|
@@ -2830,6 +2921,7 @@ function serializeExcludePathPatterns(paths) {
|
|
|
2830
2921
|
// projectBuild projectKey path (build-root-relative; may be absent on disk)
|
|
2831
2922
|
// excludedProject projectKey (--with-files only; paths without a project)
|
|
2832
2923
|
// root rootId projectKey config prod(0|1) [framework runtime alias] (dotnet: NuGet short folder name, RID, TargetFrameworks entry)
|
|
2924
|
+
// noClasspath rootId (its nodes are on no classpath: in the SBOM, not on a reachability classpath)
|
|
2833
2925
|
// node rootId coordId group name version ext classifier direct(0|1) project
|
|
2834
2926
|
// edge rootId parentCoordId childCoordId
|
|
2835
2927
|
// file rootId coordId path (--with-files only)
|
|
@@ -2910,6 +3002,7 @@ function parseRecords(text) {
|
|
|
2910
3002
|
rootId: id,
|
|
2911
3003
|
projectKey: '',
|
|
2912
3004
|
prod: false,
|
|
3005
|
+
onClasspath: true,
|
|
2913
3006
|
nodes: new Map(),
|
|
2914
3007
|
edges: []
|
|
2915
3008
|
};
|
|
@@ -3072,6 +3165,11 @@ function parseRecords(text) {
|
|
|
3072
3165
|
}
|
|
3073
3166
|
break;
|
|
3074
3167
|
}
|
|
3168
|
+
case 'noClasspath':
|
|
3169
|
+
{
|
|
3170
|
+
root(f[1] ?? '').onClasspath = false;
|
|
3171
|
+
break;
|
|
3172
|
+
}
|
|
3075
3173
|
case 'unfetched':
|
|
3076
3174
|
{
|
|
3077
3175
|
const node = root(f[1] ?? '').nodes.get(f[2] ?? '');
|
|
@@ -3306,10 +3404,10 @@ function dotnetToolArgs(opts) {
|
|
|
3306
3404
|
});
|
|
3307
3405
|
}
|
|
3308
3406
|
async function invokeGradle(opts, initScriptFilename, task, tmpDirPrefix) {
|
|
3407
|
+
const bin = resolveBuildToolBin('gradle', opts.projectDir, opts.bin, utils.isStandaloneSea());
|
|
3309
3408
|
const initScript = manifestScriptsPath(initScriptFilename);
|
|
3310
3409
|
return await utils.withTmpDir(tmpDirPrefix, async tmp => {
|
|
3311
3410
|
const recordsFile = path.join(tmp, 'records.tsv');
|
|
3312
|
-
const bin = resolveBuildToolBin('gradle', opts.projectDir, opts.bin);
|
|
3313
3411
|
// Disable the configuration cache: the init script's legacy
|
|
3314
3412
|
// resolvedConfiguration API and shared accumulator aren't cache-safe.
|
|
3315
3413
|
const args = ['--init-script', initScript, '-Dorg.gradle.configuration-cache=false',
|
|
@@ -3327,6 +3425,7 @@ async function enumerateGradleWorkspaces(opts) {
|
|
|
3327
3425
|
return await invokeGradle(opts, 'socket-workspaces.init.gradle', WORKSPACES_TASK, 'socket-gradle-workspaces-');
|
|
3328
3426
|
}
|
|
3329
3427
|
async function invokeSbtIn(globalBase, opts, pluginSourceFilename, pluginDestFilename, task) {
|
|
3428
|
+
const bin = resolveBuildToolBin('sbt', opts.projectDir, opts.bin, utils.isStandaloneSea());
|
|
3330
3429
|
await writeSbtPlugin(globalBase, pluginSourceFilename, pluginDestFilename);
|
|
3331
3430
|
const recordsFile = path.join(globalBase, 'records.tsv');
|
|
3332
3431
|
// The global base is shared across sbt roots: a build that dies before
|
|
@@ -3334,7 +3433,6 @@ async function invokeSbtIn(globalBase, opts, pluginSourceFilename, pluginDestFil
|
|
|
3334
3433
|
await u.promises.rm(recordsFile, {
|
|
3335
3434
|
force: true
|
|
3336
3435
|
});
|
|
3337
|
-
const bin = resolveBuildToolBin('sbt', opts.projectDir, opts.bin);
|
|
3338
3436
|
// Fresh per-run global base (not ~/.sbt): sbt executes everything under
|
|
3339
3437
|
// plugins/, so a shared path is a code-injection surface. BSP off for this
|
|
3340
3438
|
// run. sbt also provisions the project's Scala toolchain under
|
|
@@ -3365,11 +3463,11 @@ async function enumerateSbtWorkspaces(opts) {
|
|
|
3365
3463
|
return await utils.withTmpDir('socket-sbt-workspaces-', run);
|
|
3366
3464
|
}
|
|
3367
3465
|
async function invokeMaven(opts, coanaTask, tmpDirPrefix) {
|
|
3466
|
+
const bin = resolveBuildToolBin('maven', opts.projectDir, opts.bin, utils.isStandaloneSea());
|
|
3368
3467
|
const jarPath = manifestScriptsPath('maven-extension', 'coana-maven-extension.jar');
|
|
3369
3468
|
assertBundledAssetBuilt(jarPath, 'Maven manifest extension jar', 'build:maven-extension');
|
|
3370
3469
|
return await utils.withTmpDir(tmpDirPrefix, async tmp => {
|
|
3371
3470
|
const recordsFile = path.join(tmp, 'records.tsv');
|
|
3372
|
-
const bin = resolveBuildToolBin('maven', opts.projectDir, opts.bin);
|
|
3373
3471
|
// `validate` is the cheapest phase that triggers the extension; no compile
|
|
3374
3472
|
// needed (analysis uses configured paths, not classes).
|
|
3375
3473
|
const props = [`-Dmaven.ext.class.path=${jarPath}`, `-Dcoana.task=${coanaTask}`, `-Dsocket.recordsFile=${recordsFile}`, ...commonProps(opts, '-D')];
|
|
@@ -3499,6 +3597,18 @@ const BUILD_FILE_MATCHERS = new Map(BUILD_TOOLS.map(tool => {
|
|
|
3499
3597
|
nocase: true
|
|
3500
3598
|
}) : basename => files.names.includes(basename)];
|
|
3501
3599
|
}));
|
|
3600
|
+
function pathKey(value) {
|
|
3601
|
+
return value.replaceAll('\\', '/');
|
|
3602
|
+
}
|
|
3603
|
+
function containsPath(paths, value) {
|
|
3604
|
+
const key = pathKey(value);
|
|
3605
|
+
for (const candidate of paths) {
|
|
3606
|
+
if (pathKey(candidate) === key) {
|
|
3607
|
+
return true;
|
|
3608
|
+
}
|
|
3609
|
+
}
|
|
3610
|
+
return false;
|
|
3611
|
+
}
|
|
3502
3612
|
|
|
3503
3613
|
// `entryFile` (a basename in `dir`) is set only for a tool that addresses its
|
|
3504
3614
|
// builds by file, where one directory can hold several builds.
|
|
@@ -3554,30 +3664,76 @@ async function realFilePath(file) {
|
|
|
3554
3664
|
return path.join(await utils.realpathOrResolved(path.dirname(file)), path.basename(file));
|
|
3555
3665
|
}
|
|
3556
3666
|
|
|
3557
|
-
//
|
|
3558
|
-
//
|
|
3559
|
-
//
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3667
|
+
// What a build loaded: its projects' directories and build files,
|
|
3668
|
+
// realpath-resolved. Gradle reports a project's build file even when absent,
|
|
3669
|
+
// which names nothing.
|
|
3670
|
+
|
|
3671
|
+
function emptyMembership() {
|
|
3672
|
+
return {
|
|
3673
|
+
dirs: new Set(),
|
|
3674
|
+
files: new Set()
|
|
3675
|
+
};
|
|
3676
|
+
}
|
|
3677
|
+
function addMembership(into, from) {
|
|
3678
|
+
for (const dir of from.dirs) {
|
|
3679
|
+
into.dirs.add(dir);
|
|
3680
|
+
}
|
|
3681
|
+
for (const file of from.files) {
|
|
3682
|
+
into.files.add(file);
|
|
3683
|
+
}
|
|
3684
|
+
}
|
|
3685
|
+
function unionMemberships(memberships) {
|
|
3686
|
+
const union = emptyMembership();
|
|
3687
|
+
for (const membership of memberships) {
|
|
3688
|
+
addMembership(union, membership);
|
|
3689
|
+
}
|
|
3690
|
+
return union;
|
|
3691
|
+
}
|
|
3692
|
+
function isPathInside$1(dir, file) {
|
|
3693
|
+
return file === dir || file.startsWith(`${dir}${path.sep}`);
|
|
3694
|
+
}
|
|
3695
|
+
|
|
3696
|
+
// Paths are relative to `buildRoot`. Only what lies inside `scanRoot` (when
|
|
3697
|
+
// given) counts, as only that can be a candidate.
|
|
3698
|
+
async function membershipOf(buildRoot, projects, scanRoot) {
|
|
3699
|
+
const realScanRoot = scanRoot ? await utils.realpathOrResolved(scanRoot) : undefined;
|
|
3700
|
+
const inScan = p => !realScanRoot || isPathInside$1(realScanRoot, p);
|
|
3701
|
+
const membership = emptyMembership();
|
|
3702
|
+
const [dirs, files] = await Promise.all([Promise.all(projects.map(({
|
|
3703
|
+
subprojectDir
|
|
3704
|
+
}) => utils.realpathOrResolved(path.resolve(buildRoot, subprojectDir)))), Promise.all(projects.flatMap(project => project.manifestFiles ?? []).map(({
|
|
3565
3705
|
file
|
|
3566
|
-
}) => realFilePath(path.resolve(buildRoot, file))));
|
|
3706
|
+
}) => realFilePath(path.resolve(buildRoot, file))))]);
|
|
3707
|
+
for (const dir of dirs) {
|
|
3708
|
+
if (inScan(dir)) {
|
|
3709
|
+
membership.dirs.add(dir);
|
|
3710
|
+
}
|
|
3711
|
+
}
|
|
3567
3712
|
for (const file of files) {
|
|
3568
|
-
if ((
|
|
3569
|
-
|
|
3713
|
+
if (inScan(file) && u.existsSync(file)) {
|
|
3714
|
+
membership.files.add(file);
|
|
3570
3715
|
}
|
|
3571
3716
|
}
|
|
3717
|
+
return membership;
|
|
3718
|
+
}
|
|
3719
|
+
const rootMarkerByDir = new Map();
|
|
3720
|
+
function hasRootMarker(tool, root) {
|
|
3721
|
+
const files = BUILD_FILES[tool];
|
|
3722
|
+
if (files.byFile) {
|
|
3723
|
+
return false;
|
|
3724
|
+
}
|
|
3725
|
+
return utils.getOrInsert(rootMarkerByDir, `${tool}\0${root.dir}`, () => files.rootMarkers.some(marker => u.existsSync(path.join(root.dir, marker))));
|
|
3572
3726
|
}
|
|
3573
3727
|
|
|
3574
|
-
// `root
|
|
3728
|
+
// Whether a build loaded `root`'s project; a build of its own (see
|
|
3729
|
+
// hasRootMarker) is more than that project. `root.dir` must be
|
|
3730
|
+
// realpath-resolved, as findBuildToolCandidates returns it.
|
|
3575
3731
|
function isBuildRootCovered(covered, tool, root) {
|
|
3576
3732
|
const files = BUILD_FILES[tool];
|
|
3577
3733
|
if (files.byFile) {
|
|
3578
|
-
return !!root.entryFile && covered.
|
|
3734
|
+
return !!root.entryFile && containsPath(covered.files, buildRootPath(root));
|
|
3579
3735
|
}
|
|
3580
|
-
return files.names.some(name => covered.
|
|
3736
|
+
return containsPath(covered.dirs, root.dir) || files.names.some(name => containsPath(covered.files, path.join(root.dir, name)));
|
|
3581
3737
|
}
|
|
3582
3738
|
|
|
3583
3739
|
// A dotnet solution is covered once every project it builds is, or, when the
|
|
@@ -3592,7 +3748,7 @@ async function isSolutionCovered(covered, root, opts, listMembers = listDotnetEn
|
|
|
3592
3748
|
}
|
|
3593
3749
|
const twin = entryFile.replace(/\.slnx?$/i, ext => ext.toLowerCase() === '.sln' ? '.slnx' : '.sln');
|
|
3594
3750
|
const hasTwin = u.existsSync(path.join(root.dir, twin));
|
|
3595
|
-
if (!covered.size && !hasTwin) {
|
|
3751
|
+
if (!covered.files.size && !hasTwin) {
|
|
3596
3752
|
return false;
|
|
3597
3753
|
}
|
|
3598
3754
|
const list = file => listMembers({
|
|
@@ -3609,8 +3765,19 @@ async function isSolutionCovered(covered, root, opts, listMembers = listDotnetEn
|
|
|
3609
3765
|
logger.logger.warn(`Skipping ${buildRootPath(root)}: the .NET SDK could not read it; ${twin} beside it is built instead.`);
|
|
3610
3766
|
return true;
|
|
3611
3767
|
}
|
|
3612
|
-
const members = await
|
|
3613
|
-
return !!members.length && members.every(member => covered.
|
|
3768
|
+
const members = await realMembers(listed);
|
|
3769
|
+
return !!members.length && members.every(member => containsPath(covered.files, member));
|
|
3770
|
+
}
|
|
3771
|
+
|
|
3772
|
+
// The SDK's member listings are memoized, so their resolved paths are too.
|
|
3773
|
+
const realMembersByListing = new WeakMap();
|
|
3774
|
+
function realMembers(listed) {
|
|
3775
|
+
let members = realMembersByListing.get(listed);
|
|
3776
|
+
if (!members) {
|
|
3777
|
+
members = Promise.all(listed.map(realFilePath));
|
|
3778
|
+
realMembersByListing.set(listed, members);
|
|
3779
|
+
}
|
|
3780
|
+
return members;
|
|
3614
3781
|
}
|
|
3615
3782
|
|
|
3616
3783
|
// Whether earlier builds cover `root`: its own build files, or every project
|
|
@@ -3618,6 +3785,18 @@ async function isSolutionCovered(covered, root, opts, listMembers = listDotnetEn
|
|
|
3618
3785
|
async function isRootCovered(covered, tool, root, opts, listMembers = listDotnetEntryProjects) {
|
|
3619
3786
|
return isBuildRootCovered(covered, tool, root) || tool === 'dotnet' && (await isSolutionCovered(covered, root, opts, listMembers));
|
|
3620
3787
|
}
|
|
3788
|
+
|
|
3789
|
+
// A build of its own (see hasRootMarker) is covered only by builds that load
|
|
3790
|
+
// all of `own`, what it loads itself.
|
|
3791
|
+
async function isBuildCovered(covered, tool, root, opts, own) {
|
|
3792
|
+
if (!hasRootMarker(tool, root)) {
|
|
3793
|
+
return await isRootCovered(covered, tool, root, opts);
|
|
3794
|
+
}
|
|
3795
|
+
const pick = membership => BUILD_FILES[tool].byFile ? membership.files : membership.dirs;
|
|
3796
|
+
const members = own ? pick(own) : new Set();
|
|
3797
|
+
const loaded = pick(covered);
|
|
3798
|
+
return !!members.size && [...members].every(member => loaded.has(member));
|
|
3799
|
+
}
|
|
3621
3800
|
function compareStrings(a, b) {
|
|
3622
3801
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
3623
3802
|
}
|
|
@@ -3693,57 +3872,170 @@ async function findBuildToolCandidates({
|
|
|
3693
3872
|
return result;
|
|
3694
3873
|
}
|
|
3695
3874
|
|
|
3696
|
-
//
|
|
3697
|
-
|
|
3698
|
-
//
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3875
|
+
// The setting that makes the effective `disabled` true.
|
|
3876
|
+
|
|
3877
|
+
// Gradle and sbt name a build by any build file of its directory.
|
|
3878
|
+
function namesBuildFile(key) {
|
|
3879
|
+
return BUILD_TOOLS.some(tool => {
|
|
3880
|
+
const files = BUILD_FILES[tool];
|
|
3881
|
+
return files.byFile ? isBuildFile(tool, key) : files.names.includes(key);
|
|
3882
|
+
});
|
|
3883
|
+
}
|
|
3884
|
+
|
|
3885
|
+
// The `builds` keys naming an existing build file of `tool`'s build in `dir`:
|
|
3886
|
+
// its entry file, or any of a Gradle or sbt directory's build files.
|
|
3887
|
+
function ownEntryKeys(tool, dir, builds, entryFile) {
|
|
3888
|
+
const files = BUILD_FILES[tool];
|
|
3889
|
+
if (files.byFile) {
|
|
3890
|
+
return entryFile && Object.hasOwn(builds, entryFile) ? [entryFile] : [];
|
|
3706
3891
|
}
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3892
|
+
return files.names.filter(name => Object.hasOwn(builds, name) && u.existsSync(path.join(dir, name)));
|
|
3893
|
+
}
|
|
3894
|
+
function validateBuilds({
|
|
3895
|
+
dir,
|
|
3896
|
+
sockJson
|
|
3897
|
+
}) {
|
|
3898
|
+
const builds = sockJson.defaults?.manifest?.builds;
|
|
3899
|
+
if (builds === undefined) {
|
|
3900
|
+
return;
|
|
3901
|
+
}
|
|
3902
|
+
const file = socketJsonPath(dir);
|
|
3903
|
+
if (!objects.isObjectObject(builds)) {
|
|
3904
|
+
throw new utils.InputError(`defaults.manifest.builds in ${file} must be an object keyed by build file name.`);
|
|
3905
|
+
}
|
|
3906
|
+
for (const {
|
|
3907
|
+
0: key,
|
|
3908
|
+
1: entry
|
|
3909
|
+
} of Object.entries(builds)) {
|
|
3910
|
+
if (key.includes('/') || key.includes('\\') || !namesBuildFile(key)) {
|
|
3911
|
+
throw new utils.InputError(`${buildsSetting(key)} in ${file} must be keyed by the name of a build file in that directory, such as pom.xml or build.gradle.`);
|
|
3912
|
+
}
|
|
3913
|
+
if (!objects.isObjectObject(entry)) {
|
|
3914
|
+
throw new utils.InputError(`${buildsSetting(key)} in ${file} must be an object.`);
|
|
3915
|
+
}
|
|
3916
|
+
if (entry['disabled'] !== undefined && typeof entry['disabled'] !== 'boolean') {
|
|
3917
|
+
throw new utils.InputError(`${buildsSetting(key)}.disabled in ${file} must be true or false.`);
|
|
3918
|
+
}
|
|
3919
|
+
}
|
|
3920
|
+
for (const tool of BUILD_TOOLS) {
|
|
3921
|
+
const keys = ownEntryKeys(tool, dir, builds);
|
|
3922
|
+
if (keys.length > 1) {
|
|
3923
|
+
throw new utils.InputError(`${keys.map(buildsSetting).join(' and ')} in ${file} configure the same ${tool} build. Keep one of them.`);
|
|
3924
|
+
}
|
|
3925
|
+
}
|
|
3926
|
+
}
|
|
3927
|
+
function warnMissingFiles({
|
|
3928
|
+
dir,
|
|
3929
|
+
sockJson
|
|
3930
|
+
}, warned) {
|
|
3931
|
+
for (const key of Object.keys(sockJson.defaults?.manifest?.builds ?? {})) {
|
|
3932
|
+
const file = path.join(dir, key);
|
|
3933
|
+
if (!warned.has(file) && !u.existsSync(file)) {
|
|
3934
|
+
warned.add(file);
|
|
3935
|
+
logger.logger.warn(`${buildsSetting(key)} in ${socketJsonPath(dir)} names a file that is not there, so it applies to no build.`);
|
|
3936
|
+
}
|
|
3937
|
+
}
|
|
3938
|
+
}
|
|
3939
|
+
function buildsSetting(key) {
|
|
3940
|
+
return `defaults.manifest.builds[${JSON.stringify(key)}]`;
|
|
3941
|
+
}
|
|
3942
|
+
|
|
3943
|
+
// Resolves the socket.json settings of build roots once, reading and
|
|
3944
|
+
// validating each socket.json once. `readChain` lists a directory's socket.json files,
|
|
3945
|
+
// farthest first; resolvers sharing `warned` warn about a file once.
|
|
3946
|
+
function createBuildRootSettingsResolver(readChain = utils.readSocketJsonChain, warned = new Set()) {
|
|
3947
|
+
const chains = new Map();
|
|
3948
|
+
const resolved = new Map();
|
|
3949
|
+
const validated = new Set();
|
|
3950
|
+
const chainFor = dir => {
|
|
3951
|
+
let chain = chains.get(dir);
|
|
3952
|
+
if (!chain) {
|
|
3953
|
+
chain = readChain(dir);
|
|
3954
|
+
for (const file of chain) {
|
|
3955
|
+
if (!validated.has(file.dir)) {
|
|
3956
|
+
validated.add(file.dir);
|
|
3957
|
+
validateBuilds(file);
|
|
3958
|
+
warnMissingFiles(file, warned);
|
|
3959
|
+
}
|
|
3719
3960
|
}
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3961
|
+
chains.set(dir, chain);
|
|
3962
|
+
}
|
|
3963
|
+
return chain;
|
|
3964
|
+
};
|
|
3965
|
+
const resolve = (tool, root) => {
|
|
3966
|
+
const chain = chainFor(root.dir);
|
|
3967
|
+
const merged = utils.mergeSocketJsonChain(chain);
|
|
3968
|
+
const section = {
|
|
3969
|
+
...merged.defaults?.manifest?.[tool]
|
|
3970
|
+
};
|
|
3971
|
+
let sectionDisabledBy;
|
|
3972
|
+
for (const {
|
|
3973
|
+
dir,
|
|
3974
|
+
sockJson
|
|
3975
|
+
} of chain) {
|
|
3976
|
+
if (sockJson.defaults?.manifest?.[tool]?.disabled !== undefined) {
|
|
3977
|
+
sectionDisabledBy = {
|
|
3978
|
+
dir
|
|
3979
|
+
};
|
|
3725
3980
|
}
|
|
3726
|
-
}
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3981
|
+
}
|
|
3982
|
+
const directorySkip = section['disabled'] === true;
|
|
3983
|
+
const own = chain.at(-1);
|
|
3984
|
+
const builds = own?.dir === root.dir ? own.sockJson.defaults?.manifest?.builds : undefined;
|
|
3985
|
+
// Validation leaves at most one.
|
|
3986
|
+
const entryKey = builds ? ownEntryKeys(tool, root.dir, builds, root.entryFile)[0] : undefined;
|
|
3987
|
+
let entryDisabledBy;
|
|
3988
|
+
if (entryKey) {
|
|
3989
|
+
const entry = builds[entryKey];
|
|
3990
|
+
Object.assign(section, entry);
|
|
3991
|
+
if (entry.disabled !== undefined) {
|
|
3992
|
+
entryDisabledBy = {
|
|
3993
|
+
dir: root.dir,
|
|
3994
|
+
key: entryKey
|
|
3995
|
+
};
|
|
3737
3996
|
}
|
|
3738
|
-
} else {
|
|
3739
|
-
current += ch;
|
|
3740
|
-
hasToken = true;
|
|
3741
3997
|
}
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3998
|
+
|
|
3999
|
+
// An entry can turn a build in a skipped directory back on; skipping it
|
|
4000
|
+
// there too changes nothing, as nothing in the directory is loaded.
|
|
4001
|
+
let disabledBy;
|
|
4002
|
+
if (section['disabled']) {
|
|
4003
|
+
disabledBy = directorySkip ? sectionDisabledBy : entryDisabledBy;
|
|
4004
|
+
}
|
|
4005
|
+
return {
|
|
4006
|
+
disabledBy,
|
|
4007
|
+
entryKey,
|
|
4008
|
+
sockJson: {
|
|
4009
|
+
...merged,
|
|
4010
|
+
defaults: {
|
|
4011
|
+
...merged.defaults,
|
|
4012
|
+
manifest: {
|
|
4013
|
+
...merged.defaults?.manifest,
|
|
4014
|
+
[tool]: section
|
|
4015
|
+
}
|
|
4016
|
+
}
|
|
4017
|
+
}
|
|
4018
|
+
};
|
|
4019
|
+
};
|
|
4020
|
+
return (tool, root) => utils.getOrInsert(resolved, `${tool}\0${buildRootPath(root)}`, () => resolve(tool, root));
|
|
4021
|
+
}
|
|
4022
|
+
|
|
4023
|
+
// The setting that skips builds, as `<socket.json> sets <setting>`.
|
|
4024
|
+
function describeDisabledBy(tool, {
|
|
4025
|
+
dir,
|
|
4026
|
+
key
|
|
4027
|
+
}) {
|
|
4028
|
+
const setting = key ? `${buildsSetting(key)}.disabled` : `defaults.manifest.${tool}.disabled`;
|
|
4029
|
+
return `${socketJsonPath(dir)} sets ${setting}`;
|
|
4030
|
+
}
|
|
4031
|
+
|
|
4032
|
+
// Relative to the user's shell when inside it, else absolute.
|
|
4033
|
+
function displayPath(file) {
|
|
4034
|
+
const rel = path.relative(process.cwd(), file);
|
|
4035
|
+
return rel.startsWith('..') || path.isAbsolute(rel) ? file : rel || '.';
|
|
4036
|
+
}
|
|
4037
|
+
function socketJsonPath(dir) {
|
|
4038
|
+
return displayPath(path.join(dir, constants.SOCKET_JSON));
|
|
3747
4039
|
}
|
|
3748
4040
|
|
|
3749
4041
|
const ENV_VAR_REF = /\$\$|\$\{(\w+)\}|\$(\w+)/g;
|
|
@@ -4505,198 +4797,647 @@ async function runManifestFacts({
|
|
|
4505
4797
|
};
|
|
4506
4798
|
}
|
|
4507
4799
|
|
|
4508
|
-
//
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
}
|
|
4527
|
-
|
|
4528
|
-
// one dash too, and splits `-fX` and `-f=X` into `-f X`.
|
|
4529
|
-
const MAVEN_FILE_OPTS = new Set(['f', 'file']);
|
|
4530
|
-
const MAVEN_OTHER_F_OPTS = new Set(['fae', 'fail-at-end', 'fail-fast', 'fail-never', 'ff', 'fn']);
|
|
4531
|
-
|
|
4532
|
-
// Each POM is built by its own `--file`, so a user one is dropped.
|
|
4533
|
-
function withoutMavenFileOpts(dir, opts) {
|
|
4534
|
-
const kept = [];
|
|
4535
|
-
for (let i = 0, {
|
|
4536
|
-
length
|
|
4537
|
-
} = opts; i < length; i += 1) {
|
|
4538
|
-
const opt = opts[i];
|
|
4539
|
-
const name = opt.replace(/^--?/, '');
|
|
4540
|
-
if (opt === name || MAVEN_OTHER_F_OPTS.has(name)) {
|
|
4541
|
-
kept.push(opt);
|
|
4542
|
-
} else if (MAVEN_FILE_OPTS.has(name)) {
|
|
4543
|
-
i += 1;
|
|
4544
|
-
} else if (!MAVEN_FILE_OPTS.has(name.split('=')[0]) && !(opt.startsWith('-f') && !opt.startsWith('--'))) {
|
|
4545
|
-
kept.push(opt);
|
|
4800
|
+
// Cheap subproject discovery (no dependency resolution), for builds that are
|
|
4801
|
+
// not resolved: the setup wizard's, and skipped ones. Callers decide whether
|
|
4802
|
+
// a failure fails the command.
|
|
4803
|
+
async function enumerateWorkspaces({
|
|
4804
|
+
bin,
|
|
4805
|
+
buildOpts,
|
|
4806
|
+
cwd,
|
|
4807
|
+
ecosystem,
|
|
4808
|
+
entryFile,
|
|
4809
|
+
excludeBase,
|
|
4810
|
+
excludePaths,
|
|
4811
|
+
javaHome,
|
|
4812
|
+
verbose
|
|
4813
|
+
}) {
|
|
4814
|
+
let resolvedJavaHome;
|
|
4815
|
+
if (javaHome) {
|
|
4816
|
+
const expanded = expandEnvVarRefs(javaHome);
|
|
4817
|
+
if (expanded.missing) {
|
|
4818
|
+
logger.logger.fail(`javaHome (\`${javaHome}\`) ${formatMissingEnvVarRefs(expanded.missing)}.`);
|
|
4819
|
+
return;
|
|
4546
4820
|
}
|
|
4821
|
+
resolvedJavaHome = expanded.value;
|
|
4547
4822
|
}
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4823
|
+
const scriptOpts = {
|
|
4824
|
+
bin: bin || undefined,
|
|
4825
|
+
entryFile,
|
|
4826
|
+
excludeBase,
|
|
4827
|
+
excludePaths: excludePaths?.length ? excludePaths : undefined,
|
|
4828
|
+
// `env` replaces the spawned process's whole environment, not just JAVA_HOME.
|
|
4829
|
+
env: resolvedJavaHome ? {
|
|
4830
|
+
...process.env,
|
|
4831
|
+
JAVA_HOME: resolvedJavaHome
|
|
4832
|
+
} : undefined,
|
|
4833
|
+
projectDir: cwd,
|
|
4834
|
+
stdio: verbose ? 'inherit' : 'pipe',
|
|
4835
|
+
toolOpts: buildOpts
|
|
4836
|
+
};
|
|
4837
|
+
let result;
|
|
4838
|
+
try {
|
|
4839
|
+
result = await enumerateWorkspaces$1(ecosystem, scriptOpts);
|
|
4840
|
+
} catch (e) {
|
|
4841
|
+
logger.logger.fail(`Could not run the ${ecosystem} build tool: ${utils.getErrorMessageOr(e, String(e))}`);
|
|
4842
|
+
return;
|
|
4843
|
+
}
|
|
4844
|
+
if (!result.projects.length) {
|
|
4845
|
+
logger.logger.fail(`The ${ecosystem} build produced no workspace records (exit code ${result.code}); every build reports at least its own root project, so the enumeration task did not run.`);
|
|
4846
|
+
const tail = verbose ? '' : tailBuildOutput(result.stdout, result.stderr);
|
|
4847
|
+
if (tail) {
|
|
4848
|
+
logger.logger.group('Build output:');
|
|
4849
|
+
logger.logger.error(tail);
|
|
4850
|
+
logger.logger.groupEnd();
|
|
4562
4851
|
}
|
|
4852
|
+
return;
|
|
4853
|
+
}
|
|
4854
|
+
if (!result.buildRoot) {
|
|
4855
|
+
logger.logger.fail(`The ${ecosystem} build did not report its build root, so its projects' paths cannot be located.`);
|
|
4856
|
+
return;
|
|
4563
4857
|
}
|
|
4564
|
-
return
|
|
4858
|
+
return {
|
|
4859
|
+
buildRoot: result.buildRoot,
|
|
4860
|
+
projects: result.projects
|
|
4861
|
+
};
|
|
4565
4862
|
}
|
|
4566
|
-
|
|
4567
|
-
|
|
4863
|
+
|
|
4864
|
+
// Lets the build tool load a build, resolving nothing, for what it includes.
|
|
4865
|
+
async function loadBuild({
|
|
4866
|
+
config,
|
|
4867
|
+
ecosystem,
|
|
4568
4868
|
excludePaths,
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
rootSockJson,
|
|
4573
|
-
sbtTmpDir,
|
|
4574
|
-
sidecarAcc,
|
|
4575
|
-
verbose,
|
|
4576
|
-
withFiles
|
|
4869
|
+
root,
|
|
4870
|
+
scanRoot,
|
|
4871
|
+
verbose
|
|
4577
4872
|
}) {
|
|
4578
|
-
const
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4873
|
+
const result = await enumerateWorkspaces({
|
|
4874
|
+
bin: config.bin,
|
|
4875
|
+
buildOpts: config.buildOpts,
|
|
4876
|
+
cwd: root.dir,
|
|
4877
|
+
ecosystem,
|
|
4878
|
+
entryFile: root.entryFile,
|
|
4879
|
+
excludeBase: scanRoot,
|
|
4880
|
+
excludePaths,
|
|
4881
|
+
javaHome: config.javaHome,
|
|
4882
|
+
verbose: verbose || config.verbose
|
|
4883
|
+
});
|
|
4884
|
+
if (!result) {
|
|
4885
|
+
return undefined;
|
|
4886
|
+
}
|
|
4887
|
+
return {
|
|
4888
|
+
membership: await membershipOf(result.buildRoot, result.projects, scanRoot),
|
|
4889
|
+
modules: Math.max(0, result.projects.length - 1)
|
|
4890
|
+
};
|
|
4891
|
+
}
|
|
4892
|
+
|
|
4893
|
+
// `label`, followed by how many modules it has, when any.
|
|
4894
|
+
function withModules(label, modules) {
|
|
4895
|
+
return modules ? `${label} and its ${modules} ${words.pluralize('module', modules)}` : label;
|
|
4896
|
+
}
|
|
4897
|
+
|
|
4898
|
+
// Tokenizes a build-tool options string (e.g. the value of `--gradle-opts`,
|
|
4899
|
+
// `--sbt-opts`, `--maven-opts`) into individual argv tokens. Splits on
|
|
4900
|
+
// whitespace but honors single and double quotes so a value containing spaces,
|
|
4901
|
+
// such as a settings path (`-s "my settings.xml"`), survives as one token
|
|
4902
|
+
// instead of being shredded into three. Quotes are consumed (not emitted), and
|
|
4903
|
+
// quoting is intra-token aware (`-Dkey="a b"` -> `-Dkey=a b`). For unquoted
|
|
4904
|
+
// input this is equivalent to the previous whitespace split.
|
|
4905
|
+
function parseBuildToolOpts(opts) {
|
|
4906
|
+
if (!opts) {
|
|
4907
|
+
return [];
|
|
4908
|
+
}
|
|
4909
|
+
const tokens = [];
|
|
4910
|
+
let current = '';
|
|
4911
|
+
let hasToken = false;
|
|
4912
|
+
let inSingle = false;
|
|
4913
|
+
let inDouble = false;
|
|
4914
|
+
for (let i = 0; i < opts.length; i += 1) {
|
|
4915
|
+
const ch = opts[i];
|
|
4916
|
+
if (inSingle) {
|
|
4917
|
+
if (ch === "'") {
|
|
4918
|
+
inSingle = false;
|
|
4919
|
+
} else {
|
|
4920
|
+
current += ch;
|
|
4921
|
+
}
|
|
4922
|
+
} else if (inDouble) {
|
|
4923
|
+
if (ch === '"') {
|
|
4924
|
+
inDouble = false;
|
|
4925
|
+
} else {
|
|
4926
|
+
current += ch;
|
|
4927
|
+
}
|
|
4928
|
+
} else if (ch === "'") {
|
|
4929
|
+
inSingle = true;
|
|
4930
|
+
hasToken = true;
|
|
4931
|
+
} else if (ch === '"') {
|
|
4932
|
+
inDouble = true;
|
|
4933
|
+
hasToken = true;
|
|
4934
|
+
} else if (ch === ' ' || ch === '\t') {
|
|
4935
|
+
if (hasToken) {
|
|
4936
|
+
tokens.push(current);
|
|
4937
|
+
current = '';
|
|
4938
|
+
hasToken = false;
|
|
4939
|
+
}
|
|
4940
|
+
} else {
|
|
4941
|
+
current += ch;
|
|
4942
|
+
hasToken = true;
|
|
4943
|
+
}
|
|
4944
|
+
}
|
|
4945
|
+
if (hasToken) {
|
|
4946
|
+
tokens.push(current);
|
|
4947
|
+
}
|
|
4948
|
+
return tokens;
|
|
4949
|
+
}
|
|
4950
|
+
|
|
4951
|
+
function normalizePathKey(value) {
|
|
4952
|
+
return value.replaceAll('\\', '/');
|
|
4953
|
+
}
|
|
4954
|
+
// A cascaded (not just root-level) disabled additionally skips this one build
|
|
4955
|
+
// root here, on top of its existing root-only ecosystem-wide meaning for
|
|
4956
|
+
// auto/gradle/etc. facts:false has no pom-mode equivalent here (facts-only),
|
|
4957
|
+
// so it skips too.
|
|
4958
|
+
function getSkipReason(ecosystem, disabled, facts) {
|
|
4959
|
+
if (disabled) {
|
|
4960
|
+
return `defaults.manifest.${ecosystem}.disabled is true`;
|
|
4961
|
+
}
|
|
4962
|
+
if (facts === false) {
|
|
4963
|
+
return `defaults.manifest.${ecosystem}.facts is false (pom mode)`;
|
|
4964
|
+
}
|
|
4965
|
+
return undefined;
|
|
4966
|
+
}
|
|
4967
|
+
|
|
4968
|
+
// Maven 3's options starting with `f`; its GnuParser takes a long name after
|
|
4969
|
+
// one dash too, and splits `-fX` and `-f=X` into `-f X`.
|
|
4970
|
+
const MAVEN_FILE_OPTS = new Set(['f', 'file']);
|
|
4971
|
+
const MAVEN_OTHER_F_OPTS = new Set(['fae', 'fail-at-end', 'fail-fast', 'fail-never', 'ff', 'fn']);
|
|
4972
|
+
|
|
4973
|
+
// Each POM is built by its own `--file`, so a user one is dropped.
|
|
4974
|
+
function withoutMavenFileOpts(dir, opts) {
|
|
4975
|
+
const kept = [];
|
|
4976
|
+
for (let i = 0, {
|
|
4977
|
+
length
|
|
4978
|
+
} = opts; i < length; i += 1) {
|
|
4979
|
+
const opt = opts[i];
|
|
4980
|
+
const name = opt.replace(/^--?/, '');
|
|
4981
|
+
if (opt === name || MAVEN_OTHER_F_OPTS.has(name)) {
|
|
4982
|
+
kept.push(opt);
|
|
4983
|
+
} else if (MAVEN_FILE_OPTS.has(name)) {
|
|
4984
|
+
i += 1;
|
|
4985
|
+
} else if (!MAVEN_FILE_OPTS.has(name.split('=')[0]) && !(opt.startsWith('-f') && !opt.startsWith('--'))) {
|
|
4986
|
+
kept.push(opt);
|
|
4987
|
+
}
|
|
4988
|
+
}
|
|
4989
|
+
if (kept.length !== opts.length) {
|
|
4990
|
+
logger.logger.warn(`Ignoring --file in mavenOpts for ${dir}: each POM there is built by its own file.`);
|
|
4991
|
+
}
|
|
4992
|
+
return kept;
|
|
4993
|
+
}
|
|
4994
|
+
|
|
4995
|
+
// A copy of a facts file, if there was one, and its sidecar entry.
|
|
4996
|
+
|
|
4997
|
+
// A build skipped by its own `builds` entry, loaded to skip what it loads.
|
|
4998
|
+
|
|
4999
|
+
// What loads a build another build covers, for messages.
|
|
5000
|
+
function describeLoader(loader) {
|
|
5001
|
+
return loader?.skipped ? `it is part of ${loader.path}, which is skipped` : `${loader?.path ?? 'another build'} builds it`;
|
|
5002
|
+
}
|
|
5003
|
+
function statusOf(loader) {
|
|
5004
|
+
return loader?.skipped ? 'skippedDisabled' : 'skippedCovered';
|
|
5005
|
+
}
|
|
5006
|
+
|
|
5007
|
+
// The options the build-tool scripts take besides the build itself.
|
|
5008
|
+
function buildToolScriptOptions(config, excludeBase, excludePaths) {
|
|
5009
|
+
return {
|
|
5010
|
+
bin: config.bin,
|
|
5011
|
+
excludeBase,
|
|
5012
|
+
excludePaths,
|
|
5013
|
+
toolOpts: config.buildOpts
|
|
5014
|
+
};
|
|
5015
|
+
}
|
|
5016
|
+
async function everyAsync(items, test) {
|
|
5017
|
+
for (const item of items) {
|
|
5018
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5019
|
+
if (!(await test(item))) {
|
|
5020
|
+
return false;
|
|
5021
|
+
}
|
|
5022
|
+
}
|
|
5023
|
+
return true;
|
|
5024
|
+
}
|
|
5025
|
+
|
|
5026
|
+
// Order-independent: a run that a later build turns out to load is dropped.
|
|
5027
|
+
async function walkTool(ctx, ecosystem, roots) {
|
|
5028
|
+
const buildFiles = BUILD_FILES[ecosystem];
|
|
5029
|
+
const candidates = roots.map((root, index) => ({
|
|
5030
|
+
index,
|
|
5031
|
+
marker: hasRootMarker(ecosystem, root),
|
|
5032
|
+
root
|
|
5033
|
+
}));
|
|
5034
|
+
// The tool run in a directory without a root marker loads the build of the
|
|
5035
|
+
// nearest ancestor that has one, so that build's skip applies to it.
|
|
5036
|
+
const ancestorBuild = candidates.map(candidate => {
|
|
5037
|
+
if (buildFiles.byFile || !buildFiles.loadsAncestorBuild || buildFiles.loadsAncestorBuild.except.includes(path.basename(candidate.root.dir)) || candidate.marker) {
|
|
5038
|
+
return undefined;
|
|
5039
|
+
}
|
|
5040
|
+
let nearest;
|
|
5041
|
+
for (const other of candidates) {
|
|
5042
|
+
if (other.marker && other.root.dir !== candidate.root.dir && isPathInside$1(other.root.dir, candidate.root.dir) && (!nearest || other.root.dir.length > nearest.root.dir.length)) {
|
|
5043
|
+
nearest = other;
|
|
5044
|
+
}
|
|
5045
|
+
}
|
|
5046
|
+
return nearest;
|
|
5047
|
+
});
|
|
5048
|
+
const resolvedFor = ({
|
|
5049
|
+
root
|
|
5050
|
+
}) => ctx.resolveSettings(ecosystem, root);
|
|
5051
|
+
const configs = new Map();
|
|
5052
|
+
const configFor = candidate => {
|
|
5053
|
+
const {
|
|
5054
|
+
entryKey,
|
|
5055
|
+
sockJson
|
|
5056
|
+
} = resolvedFor(candidate);
|
|
5057
|
+
const {
|
|
5058
|
+
dir
|
|
5059
|
+
} = candidate.root;
|
|
5060
|
+
// Builds sharing a directory and its settings resolve them once.
|
|
5061
|
+
return utils.getOrInsert(configs, `${dir}\0${entryKey ?? ''}`, () => resolveEcosystemConfig(ecosystem, dir, sockJson));
|
|
5062
|
+
};
|
|
5063
|
+
|
|
5064
|
+
// 'load' when the build's own entry skips it, 'skip' when a directory
|
|
5065
|
+
// setting or the build it belongs to does.
|
|
5066
|
+
const skips = new Map();
|
|
5067
|
+
const warnedSkips = new Set();
|
|
5068
|
+
const warnOnce = message => {
|
|
5069
|
+
if (!warnedSkips.has(message)) {
|
|
5070
|
+
warnedSkips.add(message);
|
|
5071
|
+
logger.logger.warn(message);
|
|
5072
|
+
}
|
|
5073
|
+
};
|
|
5074
|
+
const skipOf = candidate => utils.getOrInsert(skips, candidate.index, () => {
|
|
5075
|
+
const {
|
|
5076
|
+
disabledBy
|
|
5077
|
+
} = resolvedFor(candidate);
|
|
5078
|
+
const {
|
|
5079
|
+
skipReason
|
|
5080
|
+
} = configFor(candidate);
|
|
5081
|
+
const ancestor = ancestorBuild[candidate.index];
|
|
5082
|
+
if (disabledBy?.key) {
|
|
5083
|
+
return 'load';
|
|
5084
|
+
}
|
|
5085
|
+
if (skipReason) {
|
|
5086
|
+
// One line per setting, not per build root it skips.
|
|
5087
|
+
warnOnce(disabledBy ? `Skipping ${ecosystem} builds in and beneath ${displayPath(disabledBy.dir)}: ${describeDisabledBy(ecosystem, disabledBy)}.` : `Skipping ${buildRootPath(candidate.root)} (${ecosystem}): ${skipReason}.`);
|
|
5088
|
+
return 'skip';
|
|
5089
|
+
}
|
|
5090
|
+
return ancestor && skipOf(ancestor) ? 'skip' : undefined;
|
|
5091
|
+
});
|
|
5092
|
+
const scriptOpts = candidate => buildToolScriptOptions(configFor(candidate), ctx.realCwd, ctx.excludePaths);
|
|
5093
|
+
|
|
5094
|
+
// A solution the SDK cannot read, built through its twin instead.
|
|
5095
|
+
const superseded = new Map();
|
|
5096
|
+
const isSuperseded = candidate => utils.getOrInsert(superseded, candidate.index, async () => ecosystem === 'dotnet' ? await isRootCovered(emptyMembership(), ecosystem, candidate.root, scriptOpts(candidate)) : false);
|
|
5097
|
+
const isCovered = (covered, candidate) => isBuildCovered(covered, ecosystem, candidate.root, scriptOpts(candidate));
|
|
5098
|
+
const isRunCovered = (covered, run) => isBuildCovered(covered, ecosystem, run.root, scriptOpts(run), run.membership);
|
|
5099
|
+
// Whether a build loads `candidate`'s project, even one that is a build of
|
|
5100
|
+
// its own: what excuses its failure.
|
|
5101
|
+
const isLoadedBy = (covered, candidate) => isRootCovered(covered, ecosystem, candidate.root, scriptOpts(candidate));
|
|
5102
|
+
const isCheaplyCovered = (covered, candidate) => !candidate.marker && isBuildRootCovered(covered, ecosystem, candidate.root);
|
|
5103
|
+
const runs = new Map();
|
|
5104
|
+
const loads = new Map();
|
|
5105
|
+
const failures = [];
|
|
5106
|
+
|
|
5107
|
+
// Drops, latest first, each run the others or the skipped builds cover
|
|
5108
|
+
// while every run dropped before stays covered.
|
|
5109
|
+
const keptRuns = async () => {
|
|
5110
|
+
const ordered = [...runs.values()].sort((a, b) => a.index - b.index);
|
|
5111
|
+
const kept = new Set(ordered);
|
|
5112
|
+
const dropped = [];
|
|
5113
|
+
const skipped = [...loads.values()].map(load => load.membership);
|
|
5114
|
+
// How many kept runs and skipped builds load each path: only a run whose
|
|
5115
|
+
// own paths another loads too can be covered, so most skip the union.
|
|
5116
|
+
const loaders = new Map();
|
|
5117
|
+
const count = (membership, by) => {
|
|
5118
|
+
for (const key of [...membership.dirs, ...membership.files]) {
|
|
5119
|
+
const normalized = normalizePathKey(key);
|
|
5120
|
+
loaders.set(normalized, (loaders.get(normalized) ?? 0) + by);
|
|
5121
|
+
}
|
|
5122
|
+
};
|
|
5123
|
+
const loadedByOthers = (run, key) => (loaders.get(normalizePathKey(key)) ?? 0) - ([...run.membership.dirs, ...run.membership.files].some(candidate => normalizePathKey(candidate) === normalizePathKey(key)) ? 1 : 0) > 0;
|
|
5124
|
+
// Covering a run takes another loading its root or something it loads.
|
|
5125
|
+
const mayBeCovered = run => [buildRootPath(run.root), ...(buildFiles.byFile ? [] : buildFiles.names.map(name => path.join(run.root.dir, name))), run.root.dir, ...run.membership.dirs, ...run.membership.files].some(key => loadedByOthers(run, key));
|
|
5126
|
+
for (const membership of [...skipped, ...ordered.map(r => r.membership)]) {
|
|
5127
|
+
count(membership, 1);
|
|
5128
|
+
}
|
|
5129
|
+
const latestFirst = [...ordered].sort((a, b) => b.index - a.index);
|
|
5130
|
+
for (const run of latestFirst) {
|
|
5131
|
+
if (!mayBeCovered(run)) {
|
|
4597
5132
|
continue;
|
|
4598
5133
|
}
|
|
4599
|
-
|
|
4600
|
-
if (
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
// reactor with hundreds of nested poms would spam one warning line
|
|
4609
|
-
// per pom for what's really a single root cause. The aggregate
|
|
4610
|
-
// count still shows up in the final summary either way.
|
|
4611
|
-
if (!nearestRoot) {
|
|
4612
|
-
logger.logger.warn(`Skipping ${dir} (${ecosystem}): ${dirConfig.skipReason}.`);
|
|
4613
|
-
}
|
|
4614
|
-
disabledRoots.push({
|
|
4615
|
-
dir,
|
|
4616
|
-
sockJson
|
|
4617
|
-
});
|
|
4618
|
-
}
|
|
5134
|
+
const others = unionMemberships([...skipped, ...[...kept].filter(other => other !== run).map(other => other.membership)]);
|
|
5135
|
+
if (
|
|
5136
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5137
|
+
(await isRunCovered(others, run)) && (
|
|
5138
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5139
|
+
await everyAsync(dropped, done => isRunCovered(others, done)))) {
|
|
5140
|
+
kept.delete(run);
|
|
5141
|
+
dropped.push(run);
|
|
5142
|
+
count(run.membership, -1);
|
|
4619
5143
|
}
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
5144
|
+
}
|
|
5145
|
+
return ordered.filter(run => kept.has(run));
|
|
5146
|
+
};
|
|
5147
|
+
let kept = [];
|
|
5148
|
+
let coverage = emptyMembership();
|
|
5149
|
+
let skippedCoverage = emptyMembership();
|
|
5150
|
+
let uncoveredFailures = [];
|
|
5151
|
+
// Set when a run or load is added: only then can coverage change.
|
|
5152
|
+
let unsettled = false;
|
|
5153
|
+
const settle = async () => {
|
|
5154
|
+
if (unsettled) {
|
|
5155
|
+
unsettled = false;
|
|
5156
|
+
kept = await keptRuns();
|
|
5157
|
+
coverage = unionMemberships(kept.map(run => run.membership));
|
|
5158
|
+
skippedCoverage = unionMemberships([...loads.values()].map(load => load.membership));
|
|
5159
|
+
}
|
|
5160
|
+
const stillFailed = [];
|
|
5161
|
+
for (const failure of failures) {
|
|
5162
|
+
if (
|
|
5163
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5164
|
+
!(await isLoadedBy(coverage, failure)) &&
|
|
5165
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5166
|
+
!(await isLoadedBy(skippedCoverage, failure))) {
|
|
5167
|
+
stillFailed.push(failure);
|
|
5168
|
+
}
|
|
5169
|
+
}
|
|
5170
|
+
uncoveredFailures = stillFailed;
|
|
5171
|
+
};
|
|
5172
|
+
const isAborted = candidate => uncoveredFailures.some(failure => failure !== candidate && isPathInside$1(failure.root.dir, candidate.root.dir));
|
|
5173
|
+
for (;;) {
|
|
5174
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5175
|
+
await settle();
|
|
5176
|
+
let next;
|
|
5177
|
+
for (const candidate of candidates) {
|
|
5178
|
+
const {
|
|
5179
|
+
index
|
|
5180
|
+
} = candidate;
|
|
5181
|
+
if (runs.has(index) || loads.has(index) || failures.includes(candidate) || isAborted(candidate) || isCheaplyCovered(coverage, candidate) || isCheaplyCovered(skippedCoverage, candidate) || skipOf(candidate) === 'skip' || (
|
|
5182
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5183
|
+
await isSuperseded(candidate)) || (
|
|
5184
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5185
|
+
await isCovered(coverage, candidate)) || (
|
|
5186
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5187
|
+
await isCovered(skippedCoverage, candidate))) {
|
|
4626
5188
|
continue;
|
|
4627
5189
|
}
|
|
5190
|
+
next = candidate;
|
|
5191
|
+
break;
|
|
5192
|
+
}
|
|
5193
|
+
if (!next) {
|
|
5194
|
+
break;
|
|
5195
|
+
}
|
|
5196
|
+
if (skipOf(next) === 'load') {
|
|
4628
5197
|
// eslint-disable-next-line no-await-in-loop
|
|
4629
|
-
const
|
|
4630
|
-
config:
|
|
4631
|
-
...dirConfig,
|
|
4632
|
-
ignoreUnresolved: ignoreUnresolvedOverride ?? dirConfig.ignoreUnresolved,
|
|
4633
|
-
verbose: verbose || dirConfig.verbose
|
|
4634
|
-
},
|
|
4635
|
-
covered,
|
|
5198
|
+
const loaded = await loadBuild({
|
|
5199
|
+
config: configFor(next),
|
|
4636
5200
|
ecosystem,
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
hints: {
|
|
4642
|
-
continueOnInstallErrorsFlag: withFiles ? REACH_CONTINUE_ON_INSTALL_ERRORS_FLAG : undefined,
|
|
4643
|
-
flags: optionFlags,
|
|
4644
|
-
setupCommand: DSI_SETUP_COMMAND,
|
|
4645
|
-
socketJson: displayPath(path.join(dir, constants.SOCKET_JSON))
|
|
4646
|
-
},
|
|
4647
|
-
root,
|
|
4648
|
-
sidecarAcc,
|
|
4649
|
-
tmpDir: ecosystem === 'sbt' ? sbtTmpDir : undefined,
|
|
4650
|
-
withFiles
|
|
5201
|
+
excludePaths: ctx.excludePaths,
|
|
5202
|
+
root: next.root,
|
|
5203
|
+
scanRoot: ctx.realCwd,
|
|
5204
|
+
verbose: ctx.verbose
|
|
4651
5205
|
});
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
5206
|
+
const why = describeDisabledBy(ecosystem, resolvedFor(next).disabledBy);
|
|
5207
|
+
if (loaded) {
|
|
5208
|
+
loads.set(next.index, {
|
|
5209
|
+
...next,
|
|
5210
|
+
...loaded
|
|
4657
5211
|
});
|
|
4658
|
-
|
|
5212
|
+
unsettled = true;
|
|
5213
|
+
} else {
|
|
5214
|
+
failures.push(next);
|
|
5215
|
+
logger.logger.fail(`Could not load ${buildRootPath(next.root)} to tell which builds to skip with it (${why}). Fix its settings, or skip its whole directory instead, with \`${DSI_SETUP_COMMAND}\`.`);
|
|
4659
5216
|
}
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
5217
|
+
continue;
|
|
5218
|
+
}
|
|
5219
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5220
|
+
const run = await runCandidate(ctx, ecosystem, next, configFor(next));
|
|
5221
|
+
if (run) {
|
|
5222
|
+
runs.set(next.index, run);
|
|
5223
|
+
unsettled = true;
|
|
5224
|
+
} else {
|
|
5225
|
+
failures.push(next);
|
|
5226
|
+
}
|
|
5227
|
+
}
|
|
5228
|
+
|
|
5229
|
+
// The first kept run, or else skipped build, that loads `candidate`.
|
|
5230
|
+
const loaderOf = async candidate => {
|
|
5231
|
+
const ownRun = runs.get(candidate.index);
|
|
5232
|
+
const loaders = [...kept.filter(run => run !== ownRun).map(run => ({
|
|
5233
|
+
...run,
|
|
5234
|
+
skipped: false
|
|
5235
|
+
})), ...[...loads.values()].map(load => ({
|
|
5236
|
+
...load,
|
|
5237
|
+
skipped: true
|
|
5238
|
+
}))];
|
|
5239
|
+
for (const loader of loaders) {
|
|
5240
|
+
if (
|
|
5241
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5242
|
+
await (ownRun ? isRunCovered(loader.membership, ownRun) : isLoadedBy(loader.membership, candidate))) {
|
|
5243
|
+
return {
|
|
5244
|
+
path: buildRootPath(loader.root),
|
|
5245
|
+
skipped: loader.skipped
|
|
5246
|
+
};
|
|
4678
5247
|
}
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
5248
|
+
}
|
|
5249
|
+
return undefined;
|
|
5250
|
+
};
|
|
5251
|
+
const keptSet = new Set(kept);
|
|
5252
|
+
const keptKeys = new Set(kept.map(run => run.factsKey));
|
|
5253
|
+
const outcomes = [];
|
|
5254
|
+
for (const candidate of candidates) {
|
|
5255
|
+
const {
|
|
5256
|
+
index,
|
|
5257
|
+
root
|
|
5258
|
+
} = candidate;
|
|
5259
|
+
const run = runs.get(index);
|
|
5260
|
+
if (run && keptSet.has(run)) {
|
|
5261
|
+
if (run.result) {
|
|
5262
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5263
|
+
await putFacts(ctx, run.result.factsPath, run.factsKey, run.output);
|
|
4686
5264
|
}
|
|
4687
5265
|
outcomes.push({
|
|
4688
5266
|
...root,
|
|
4689
5267
|
ecosystem,
|
|
4690
|
-
|
|
4691
|
-
|
|
5268
|
+
...(run.result ? {
|
|
5269
|
+
factsPath: run.result.factsPath
|
|
5270
|
+
} : {}),
|
|
5271
|
+
status: run.result ? 'generated' : 'empty'
|
|
4692
5272
|
});
|
|
5273
|
+
continue;
|
|
5274
|
+
}
|
|
5275
|
+
let status;
|
|
5276
|
+
let discardedFactsPath;
|
|
5277
|
+
if (run) {
|
|
5278
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5279
|
+
const loader = await loaderOf(candidate);
|
|
5280
|
+
if (run.result) {
|
|
5281
|
+
logger.logger.info(`Dropping the Socket facts of ${buildRootPath(root)}: ${describeLoader(loader)}.`);
|
|
5282
|
+
if (!keptKeys.has(run.factsKey)) {
|
|
5283
|
+
discardedFactsPath = run.factsKey;
|
|
5284
|
+
}
|
|
5285
|
+
}
|
|
5286
|
+
status = statusOf(loader);
|
|
5287
|
+
} else if (loads.has(index)) {
|
|
5288
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5289
|
+
if (await isCovered(coverage, candidate)) {
|
|
5290
|
+
status = 'skippedCovered';
|
|
5291
|
+
} else {
|
|
5292
|
+
status = 'skippedDisabled';
|
|
5293
|
+
logger.logger.warn(`Skipping ${withModules(buildRootPath(root), loads.get(index).modules)}: ${describeDisabledBy(ecosystem, resolvedFor(candidate).disabledBy)}.`);
|
|
5294
|
+
}
|
|
5295
|
+
} else if (failures.includes(candidate)) {
|
|
5296
|
+
if (uncoveredFailures.includes(candidate)) {
|
|
5297
|
+
status = 'failed';
|
|
5298
|
+
} else {
|
|
5299
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5300
|
+
const loader = await loaderOf(candidate);
|
|
5301
|
+
if (skipOf(candidate) !== 'load') {
|
|
5302
|
+
logger.logger.info(`${buildRootPath(root)} failed to generate Socket facts on its own, but ${describeLoader(loader)}, so its failure is ignored.`);
|
|
5303
|
+
}
|
|
5304
|
+
status = statusOf(loader);
|
|
5305
|
+
}
|
|
5306
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5307
|
+
} else if (await isCovered(coverage, candidate)) {
|
|
5308
|
+
status = 'skippedCovered';
|
|
5309
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5310
|
+
} else if (await isCovered(skippedCoverage, candidate)) {
|
|
5311
|
+
status = 'skippedDisabled';
|
|
5312
|
+
} else if (isAborted(candidate)) {
|
|
5313
|
+
status = 'aborted';
|
|
5314
|
+
} else if (skipOf(candidate)) {
|
|
5315
|
+
status = 'skippedDisabled';
|
|
5316
|
+
} else {
|
|
5317
|
+
// A solution the SDK cannot read, built through its twin.
|
|
5318
|
+
status = 'skippedCovered';
|
|
5319
|
+
}
|
|
5320
|
+
if (status === 'skippedCovered') {
|
|
5321
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5322
|
+
await warnUnappliedEntry(candidate, resolvedFor(candidate).entryKey, () => loaderOf(candidate));
|
|
5323
|
+
}
|
|
5324
|
+
outcomes.push({
|
|
5325
|
+
...root,
|
|
5326
|
+
...(discardedFactsPath ? {
|
|
5327
|
+
discardedFactsPath
|
|
5328
|
+
} : {}),
|
|
5329
|
+
ecosystem,
|
|
5330
|
+
status
|
|
5331
|
+
});
|
|
5332
|
+
}
|
|
5333
|
+
for (const failure of uncoveredFailures) {
|
|
5334
|
+
const aborted = candidates.filter(candidate => isAborted(candidate) && !failures.includes(candidate) && isPathInside$1(failure.root.dir, candidate.root.dir));
|
|
5335
|
+
if (aborted.length) {
|
|
5336
|
+
logger.logger.warn(`Not building ${aborted.length} ${ecosystem} build root(s) in or under ${displayPath(failure.root.dir)}: ${buildRootPath(failure.root)} failed, and without it they cannot be told apart from its modules.`);
|
|
4693
5337
|
}
|
|
4694
5338
|
}
|
|
4695
5339
|
return outcomes;
|
|
4696
5340
|
}
|
|
4697
5341
|
|
|
4698
|
-
//
|
|
4699
|
-
//
|
|
5342
|
+
// A build root's own entry applies to nothing when another build loads it:
|
|
5343
|
+
// that build resolves it with its own settings.
|
|
5344
|
+
async function warnUnappliedEntry(candidate, entryKey, loaderOf) {
|
|
5345
|
+
if (!entryKey) {
|
|
5346
|
+
return;
|
|
5347
|
+
}
|
|
5348
|
+
const loader = await loaderOf();
|
|
5349
|
+
logger.logger.warn(`${buildsSetting(entryKey)} in ${socketJsonPath(candidate.root.dir)} does not apply: ${loader?.path ?? 'another build'} builds ${buildRootPath(candidate.root)} with its own settings.`);
|
|
5350
|
+
}
|
|
5351
|
+
async function runCandidate(ctx, ecosystem, candidate, dirConfig) {
|
|
5352
|
+
const {
|
|
5353
|
+
root
|
|
5354
|
+
} = candidate;
|
|
5355
|
+
const expectedFactsPath = path.join(root.dir, socketFactsFileName(ecosystem, root.entryFile) ?? '');
|
|
5356
|
+
const expectedKey = await utils.realpathOrResolved(expectedFactsPath);
|
|
5357
|
+
if (!ctx.originals.has(expectedKey)) {
|
|
5358
|
+
ctx.originals.set(expectedKey, await saveFacts(ctx, expectedFactsPath, expectedKey, `${ecosystem}-${candidate.index}`));
|
|
5359
|
+
}
|
|
5360
|
+
const result = await runManifestFacts({
|
|
5361
|
+
bin: dirConfig.bin,
|
|
5362
|
+
buildOpts: dirConfig.buildOpts,
|
|
5363
|
+
cwd: root.dir,
|
|
5364
|
+
ecosystem,
|
|
5365
|
+
entryFile: root.entryFile,
|
|
5366
|
+
// Relative to the scan root: a build can reach modules outside its own
|
|
5367
|
+
// directory (Maven `../x` modules, relocated Gradle projects).
|
|
5368
|
+
excludeBase: ctx.realCwd,
|
|
5369
|
+
excludeConfigs: dirConfig.excludeConfigs,
|
|
5370
|
+
excludePaths: ctx.excludePaths,
|
|
5371
|
+
hints: {
|
|
5372
|
+
continueOnInstallErrorsFlag: ctx.withFiles ? REACH_CONTINUE_ON_INSTALL_ERRORS_FLAG : undefined,
|
|
5373
|
+
flags: ctx.optionFlags,
|
|
5374
|
+
setupCommand: DSI_SETUP_COMMAND,
|
|
5375
|
+
socketJson: socketJsonPath(root.dir)
|
|
5376
|
+
},
|
|
5377
|
+
ignoreUnresolved: ctx.ignoreUnresolved ?? dirConfig.ignoreUnresolved,
|
|
5378
|
+
includeConfigs: dirConfig.includeConfigs,
|
|
5379
|
+
javaHome: dirConfig.javaHome,
|
|
5380
|
+
sidecarAcc: ctx.sidecarAcc,
|
|
5381
|
+
tmpDir: ecosystem === 'sbt' ? ctx.sbtTmpDir : undefined,
|
|
5382
|
+
verbose: ctx.verbose || dirConfig.verbose,
|
|
5383
|
+
withFiles: ctx.withFiles
|
|
5384
|
+
});
|
|
5385
|
+
if (result === null) {
|
|
5386
|
+
return undefined;
|
|
5387
|
+
}
|
|
5388
|
+
let factsKey;
|
|
5389
|
+
let output;
|
|
5390
|
+
if (result) {
|
|
5391
|
+
factsKey = await utils.realpathOrResolved(result.factsPath);
|
|
5392
|
+
output = await saveFacts(ctx, result.factsPath, factsKey, `${ecosystem}-${candidate.index}.out`);
|
|
5393
|
+
if (!ctx.originals.has(factsKey)) {
|
|
5394
|
+
ctx.originals.set(factsKey, undefined);
|
|
5395
|
+
}
|
|
5396
|
+
await putFacts(ctx, result.factsPath, factsKey, ctx.originals.get(factsKey));
|
|
5397
|
+
}
|
|
5398
|
+
return {
|
|
5399
|
+
...candidate,
|
|
5400
|
+
factsKey,
|
|
5401
|
+
// Gradle's `-p` can root the build away from `root.dir`.
|
|
5402
|
+
membership: result ? await membershipOf(path.dirname(result.factsPath), result.projects, ctx.realCwd) : emptyMembership(),
|
|
5403
|
+
output,
|
|
5404
|
+
result: result ?? undefined
|
|
5405
|
+
};
|
|
5406
|
+
}
|
|
5407
|
+
|
|
5408
|
+
// Puts `state` in place of a facts file and its sidecar entry; an unknown state
|
|
5409
|
+
// leaves the file and drops the entry.
|
|
5410
|
+
async function putFacts(ctx, file, key, state) {
|
|
5411
|
+
if (state?.sidecar) {
|
|
5412
|
+
ctx.sidecarAcc?.set(key, state.sidecar);
|
|
5413
|
+
} else {
|
|
5414
|
+
ctx.sidecarAcc?.delete(key);
|
|
5415
|
+
}
|
|
5416
|
+
if (!state) {
|
|
5417
|
+
return;
|
|
5418
|
+
}
|
|
5419
|
+
if (state.facts) {
|
|
5420
|
+
await u.promises.copyFile(state.facts, file);
|
|
5421
|
+
} else {
|
|
5422
|
+
await u.promises.rm(file, {
|
|
5423
|
+
force: true
|
|
5424
|
+
});
|
|
5425
|
+
}
|
|
5426
|
+
}
|
|
5427
|
+
async function saveFacts(ctx, file, key, name) {
|
|
5428
|
+
let facts;
|
|
5429
|
+
if (u.existsSync(file)) {
|
|
5430
|
+
facts = path.join(await ctx.backupDir(), name);
|
|
5431
|
+
await u.promises.copyFile(file, facts);
|
|
5432
|
+
}
|
|
5433
|
+
return {
|
|
5434
|
+
facts,
|
|
5435
|
+
sidecar: ctx.sidecarAcc?.get(key)
|
|
5436
|
+
};
|
|
5437
|
+
}
|
|
5438
|
+
|
|
5439
|
+
// Builds `root` unless earlier builds cover it, then adds what it loaded to
|
|
5440
|
+
// `covered`.
|
|
4700
5441
|
async function buildUncoveredRoot({
|
|
4701
5442
|
config,
|
|
4702
5443
|
covered,
|
|
@@ -4714,12 +5455,7 @@ async function buildUncoveredRoot({
|
|
|
4714
5455
|
bin,
|
|
4715
5456
|
buildOpts
|
|
4716
5457
|
} = config;
|
|
4717
|
-
if (await isRootCovered(covered, ecosystem, root, {
|
|
4718
|
-
bin,
|
|
4719
|
-
excludeBase,
|
|
4720
|
-
excludePaths,
|
|
4721
|
-
toolOpts: buildOpts
|
|
4722
|
-
})) {
|
|
5458
|
+
if (await isRootCovered(covered, ecosystem, root, buildToolScriptOptions(config, excludeBase, excludePaths))) {
|
|
4723
5459
|
return 'covered';
|
|
4724
5460
|
}
|
|
4725
5461
|
const result = await runManifestFacts({
|
|
@@ -4741,14 +5477,12 @@ async function buildUncoveredRoot({
|
|
|
4741
5477
|
withFiles
|
|
4742
5478
|
});
|
|
4743
5479
|
if (result) {
|
|
4744
|
-
|
|
4745
|
-
await addCoveredBuildFiles(covered, ecosystem, path.dirname(result.factsPath), result.projects);
|
|
5480
|
+
addMembership(covered, await membershipOf(path.dirname(result.factsPath), result.projects));
|
|
4746
5481
|
}
|
|
4747
5482
|
return result;
|
|
4748
5483
|
}
|
|
4749
5484
|
|
|
4750
|
-
// A
|
|
4751
|
-
// files it would have covered are all its own tool's.
|
|
5485
|
+
// A failure fails the walk only when no kept or skipped build loads it.
|
|
4752
5486
|
async function generateRecursiveManifests({
|
|
4753
5487
|
cwd,
|
|
4754
5488
|
excludePaths,
|
|
@@ -4765,9 +5499,8 @@ async function generateRecursiveManifests({
|
|
|
4765
5499
|
// must match or every boundary/relative-path comparison below breaks as
|
|
4766
5500
|
// soon as cwd contains a symlink (macOS /tmp -> /private/tmp, etc.).
|
|
4767
5501
|
const realCwd = await utils.realpathOrResolved(cwd);
|
|
4768
|
-
// A
|
|
4769
|
-
//
|
|
4770
|
-
// what actually decides skip vs. include.
|
|
5502
|
+
// A nested socket.json may re-enable an ecosystem the root disables, so the
|
|
5503
|
+
// per-root settings below decide skips, not this scan.
|
|
4771
5504
|
const candidatesByTool = await findBuildToolCandidates({
|
|
4772
5505
|
cwd,
|
|
4773
5506
|
excludePaths,
|
|
@@ -4775,18 +5508,46 @@ async function generateRecursiveManifests({
|
|
|
4775
5508
|
socketConfig: utils.loadSocketConfig(cwd),
|
|
4776
5509
|
sockJson: withoutDisabledFlags(rootSockJson)
|
|
4777
5510
|
});
|
|
4778
|
-
const
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
5511
|
+
const resolveSettings = createBuildRootSettingsResolver();
|
|
5512
|
+
// Invalid settings fail the scan before any build runs.
|
|
5513
|
+
for (const {
|
|
5514
|
+
0: tool,
|
|
5515
|
+
1: roots
|
|
5516
|
+
} of candidatesByTool) {
|
|
5517
|
+
for (const root of roots) {
|
|
5518
|
+
resolveSettings(tool, root);
|
|
5519
|
+
}
|
|
5520
|
+
}
|
|
5521
|
+
// A failure another build excuses leaves the exit code it set.
|
|
5522
|
+
const exitCodeBefore = process.exitCode;
|
|
5523
|
+
let backupDir;
|
|
5524
|
+
const runAll = async resolvedSbtTmpDir => {
|
|
5525
|
+
const ctx = {
|
|
5526
|
+
backupDir: async () => {
|
|
5527
|
+
backupDir ??= await u.promises.mkdtemp(path.join(os.tmpdir(), 'socket-facts-backup-'));
|
|
5528
|
+
return backupDir;
|
|
5529
|
+
},
|
|
5530
|
+
excludePaths,
|
|
5531
|
+
ignoreUnresolved,
|
|
5532
|
+
optionFlags,
|
|
5533
|
+
originals: new Map(),
|
|
5534
|
+
realCwd,
|
|
5535
|
+
resolveSettings,
|
|
5536
|
+
sbtTmpDir: resolvedSbtTmpDir,
|
|
5537
|
+
sidecarAcc,
|
|
5538
|
+
verbose,
|
|
5539
|
+
withFiles
|
|
5540
|
+
};
|
|
5541
|
+
const outcomes = [];
|
|
5542
|
+
for (const {
|
|
5543
|
+
0: ecosystem,
|
|
5544
|
+
1: roots
|
|
5545
|
+
} of candidatesByTool) {
|
|
5546
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5547
|
+
outcomes.push(...(await walkTool(ctx, ecosystem, roots)));
|
|
5548
|
+
}
|
|
5549
|
+
return outcomes;
|
|
5550
|
+
};
|
|
4790
5551
|
|
|
4791
5552
|
// A shared global base across every sbt root in this run lets sbt's own
|
|
4792
5553
|
// Scala-toolchain cache under <base>/boot survive between invocations
|
|
@@ -4795,7 +5556,20 @@ async function generateRecursiveManifests({
|
|
|
4795
5556
|
// caller-supplied sbtTmpDir is reused as-is (the caller owns its lifetime);
|
|
4796
5557
|
// otherwise one is allocated and cleaned up here, but only when there's an
|
|
4797
5558
|
// sbt root to benefit from sharing it at all.
|
|
4798
|
-
|
|
5559
|
+
let outcomes;
|
|
5560
|
+
try {
|
|
5561
|
+
outcomes = sbtTmpDir ? await runAll(sbtTmpDir) : candidatesByTool.get('sbt')?.length ? await utils.withTmpDir('socket-sbt-facts-shared-', runAll) : await runAll(undefined);
|
|
5562
|
+
} finally {
|
|
5563
|
+
if (backupDir) {
|
|
5564
|
+
await u.promises.rm(backupDir, {
|
|
5565
|
+
recursive: true,
|
|
5566
|
+
force: true
|
|
5567
|
+
});
|
|
5568
|
+
}
|
|
5569
|
+
}
|
|
5570
|
+
if (!outcomes.some(o => o.status === 'failed')) {
|
|
5571
|
+
process.exitCode = exitCodeBefore;
|
|
5572
|
+
}
|
|
4799
5573
|
if (verbose) {
|
|
4800
5574
|
logger.logger.info(`Discovered ${outcomes.length} build-tool candidate(s).`);
|
|
4801
5575
|
}
|
|
@@ -4861,6 +5635,8 @@ function resolveEcosystemConfig(ecosystem, dir, sockJson) {
|
|
|
4861
5635
|
};
|
|
4862
5636
|
}
|
|
4863
5637
|
|
|
5638
|
+
const DSI_SETTINGS_DOCS_URL = 'https://github.com/SocketDev/socket-cli/blob/v1.x/docs/dynamic-sbom-inference-settings.md';
|
|
5639
|
+
|
|
4864
5640
|
// Who consumes the facts: Coana for `fix` and `reach` (which also resolves
|
|
4865
5641
|
// artifact paths), or only the scan upload.
|
|
4866
5642
|
|
|
@@ -4910,19 +5686,32 @@ async function runDynamicSbomInference({
|
|
|
4910
5686
|
// Fail loud rather than silently proceed with a partial multi-root result:
|
|
4911
5687
|
// matches handleManifestDynamicSbomInference's own check.
|
|
4912
5688
|
if (outcomes.some(o => o.status === 'failed')) {
|
|
4913
|
-
throw new utils.InputError('One or more independent build roots failed to generate Socket facts; aborting (see the errors above).');
|
|
5689
|
+
throw new utils.InputError(['One or more independent build roots failed to generate Socket facts; aborting (see the errors above).', '', `- To fix a build's settings or skip it, run \`${DSI_SETUP_COMMAND}\`.`, `- The settings are documented at ${DSI_SETTINGS_DOCS_URL}.`].join('\n'));
|
|
4914
5690
|
}
|
|
4915
5691
|
const factsPaths = outcomes.filter(o => o.status === 'generated').map(o => o.factsPath);
|
|
4916
5692
|
if (coanaReadsFacts) {
|
|
4917
5693
|
checkFactsForCoana(outcomes, consumer, !!factsPaths.length);
|
|
4918
5694
|
}
|
|
4919
5695
|
return {
|
|
5696
|
+
discardedFactsPaths: outcomes.flatMap(o => o.discardedFactsPath ? [o.discardedFactsPath] : []),
|
|
4920
5697
|
factsOnlyTypes,
|
|
4921
5698
|
factsPaths,
|
|
4922
5699
|
resolvedPathsSidecar: sidecarAcc && hasSidecarEntries(sidecarAcc) ? serializeSidecar(sidecarAcc) : undefined
|
|
4923
5700
|
};
|
|
4924
5701
|
}
|
|
4925
5702
|
|
|
5703
|
+
// `paths` without the facts files discovery discarded: each holds what was
|
|
5704
|
+
// there before the scan, or a dropped run's facts, not a kept build's.
|
|
5705
|
+
async function withoutDiscardedFacts(paths, discarded) {
|
|
5706
|
+
if (!discarded?.length) {
|
|
5707
|
+
return paths;
|
|
5708
|
+
}
|
|
5709
|
+
const names = new Set(discarded.map(p => path.basename(p)));
|
|
5710
|
+
const keys = new Set(discarded);
|
|
5711
|
+
const isDiscarded = await Promise.all(paths.map(async p => names.has(path.basename(p)) && keys.has(await utils.realpathOrResolved(p))));
|
|
5712
|
+
return paths.filter((_, index) => !isDiscarded[index]);
|
|
5713
|
+
}
|
|
5714
|
+
|
|
4926
5715
|
// The point here is to attempt to detect the various supported manifest files
|
|
4927
5716
|
// the CLI can generate. This would be environments that we can't do server side
|
|
4928
5717
|
|
|
@@ -5074,7 +5863,7 @@ function isNodeScript(bin) {
|
|
|
5074
5863
|
if (/\.[cm]?js$/i.test(bin)) {
|
|
5075
5864
|
return true;
|
|
5076
5865
|
}
|
|
5077
|
-
if (path.extname(bin) ||
|
|
5866
|
+
if (path.extname(bin) || !u.existsSync(bin)) {
|
|
5078
5867
|
return false;
|
|
5079
5868
|
}
|
|
5080
5869
|
const fd = u.openSync(bin, 'r');
|
|
@@ -5255,6 +6044,31 @@ function buildBazelStartupFlags(opts) {
|
|
|
5255
6044
|
* 4. If neither is found, throw InputError with install instructions.
|
|
5256
6045
|
*/
|
|
5257
6046
|
async function resolveBazelBinary(explicit, env, cwd) {
|
|
6047
|
+
if (utils.isStandaloneSea()) {
|
|
6048
|
+
const override = explicit ?? env['SOCKET_CLI_BAZEL_PATH'];
|
|
6049
|
+
if (!override) {
|
|
6050
|
+
throw new utils.InputError('Bazel is not bundled with this standalone Socket CLI. Set SOCKET_CLI_BAZEL_PATH or pass --bazel with an installed native Bazel executable.');
|
|
6051
|
+
}
|
|
6052
|
+
const resolved = path.resolve(cwd, override);
|
|
6053
|
+
try {
|
|
6054
|
+
if (!u.existsSync(resolved) || !u.statSync(resolved).isFile()) {
|
|
6055
|
+
throw new Error('not a file');
|
|
6056
|
+
}
|
|
6057
|
+
if (process.platform !== 'win32') {
|
|
6058
|
+
u.accessSync(resolved, u.constants.X_OK);
|
|
6059
|
+
}
|
|
6060
|
+
} catch {
|
|
6061
|
+
throw new utils.InputError(`The standalone Bazel path '${resolved}' is missing or not executable.`);
|
|
6062
|
+
}
|
|
6063
|
+
const bin = resolveBazelExecutable(resolved);
|
|
6064
|
+
if (/^bazelisk(?:\.exe)?$/i.test(path.basename(bin))) {
|
|
6065
|
+
throw new utils.InputError('Standalone Socket requires an installed Bazel binary and will not use Bazelisk to download a Bazel version.');
|
|
6066
|
+
}
|
|
6067
|
+
if (bin === process.execPath || isNodeScript(bin)) {
|
|
6068
|
+
throw new utils.InputError('Standalone Socket cannot launch Bazel through a JavaScript launcher because process.execPath is the SEA executable. Set SOCKET_CLI_BAZEL_PATH to a native Bazel executable.');
|
|
6069
|
+
}
|
|
6070
|
+
return bin;
|
|
6071
|
+
}
|
|
5258
6072
|
if (explicit) {
|
|
5259
6073
|
const resolved = path.resolve(cwd, explicit);
|
|
5260
6074
|
if (!u.existsSync(resolved)) {
|
|
@@ -5564,7 +6378,7 @@ function buildBazelArgv(queryStr, opts, output = 'build') {
|
|
|
5564
6378
|
// `--keep_going --output=label` keeps it fast even on partial-analysis
|
|
5565
6379
|
// repos and avoids paying for `--output=jsonproto` plus
|
|
5566
6380
|
// `--proto:output_rule_attrs` (which the heavier metadata extraction in
|
|
5567
|
-
// `
|
|
6381
|
+
// `cquery.mts` needs but the probe does not).
|
|
5568
6382
|
function buildBazelProbeCqueryArgv(repoName, opts) {
|
|
5569
6383
|
const userFlags = splitBazelFlags(opts.bazelFlags);
|
|
5570
6384
|
return [...buildBazelStartupFlags(opts), 'cquery', '--lockfile_mode=off', '--noshow_progress', ...opts.invocationFlags, `@${repoName}//...`, '--output=label', '--keep_going', ...userFlags];
|
|
@@ -5731,7 +6545,7 @@ async function runBazelModShowVisibleRepos(opts) {
|
|
|
5731
6545
|
/**
|
|
5732
6546
|
* Bzlmod-native Maven hub enumeration via the rules_jvm_external maven
|
|
5733
6547
|
* extension. The text-format report lists every repo the extension
|
|
5734
|
-
* generated; `parseShowExtensionOutput` (
|
|
6548
|
+
* generated; `parseShowExtensionOutput` (repo-discovery.mts)
|
|
5735
6549
|
* extracts the hubs from the `Fetched repositories:` section.
|
|
5736
6550
|
*/
|
|
5737
6551
|
async function runBazelModShowMavenExtension(opts) {
|
|
@@ -5748,7 +6562,7 @@ async function runBazelModShowPipExtension(opts) {
|
|
|
5748
6562
|
}
|
|
5749
6563
|
|
|
5750
6564
|
/**
|
|
5751
|
-
* Build a `RepoProbe` (compatible with
|
|
6565
|
+
* Build a `RepoProbe` (compatible with repo-discovery's tri-state
|
|
5752
6566
|
* classifier) bound to opts. Runs the lightweight presence-check cquery
|
|
5753
6567
|
* `@<name>//... --output=label --keep_going` — cheap enough to attempt
|
|
5754
6568
|
* every conventional Maven hub name without triggering `repository_rule`
|
|
@@ -6298,6 +7112,18 @@ function validateOutputBase(outputBase, cwd) {
|
|
|
6298
7112
|
}
|
|
6299
7113
|
}
|
|
6300
7114
|
|
|
7115
|
+
const BAZEL_AUTO_MANIFEST_DIR_NAME = '.socket-auto-manifest';
|
|
7116
|
+
const BAZEL_MANIFESTS_DIR_NAME = 'bazel-manifests';
|
|
7117
|
+
const BAZEL_SYNTHETIC_OUTPUT_DIR_NAMES = new Set([BAZEL_AUTO_MANIFEST_DIR_NAME, BAZEL_MANIFESTS_DIR_NAME]);
|
|
7118
|
+
const SOCKET_WORKSPACE_DIR_NAME = '.socket';
|
|
7119
|
+
const DEFAULT_BAZEL_MANIFEST_OUTPUT_DISPLAY_PATH = `./${SOCKET_WORKSPACE_DIR_NAME}/${BAZEL_MANIFESTS_DIR_NAME}/`;
|
|
7120
|
+
function getBazelAutoManifestDirectory(out) {
|
|
7121
|
+
return path.join(out, BAZEL_AUTO_MANIFEST_DIR_NAME);
|
|
7122
|
+
}
|
|
7123
|
+
function getDefaultBazelManifestDirectory(repo) {
|
|
7124
|
+
return path.join(repo, SOCKET_WORKSPACE_DIR_NAME, BAZEL_MANIFESTS_DIR_NAME);
|
|
7125
|
+
}
|
|
7126
|
+
|
|
6301
7127
|
function isPython3(executable, env, cwd) {
|
|
6302
7128
|
try {
|
|
6303
7129
|
const version = childProcess.execFileSync(executable, ['-c', 'import sys\nprint(sys.version_info.major)'], {
|
|
@@ -6312,11 +7138,58 @@ function isPython3(executable, env, cwd) {
|
|
|
6312
7138
|
// Windows application aliases can resolve without a working interpreter.
|
|
6313
7139
|
return false;
|
|
6314
7140
|
}
|
|
6315
|
-
}
|
|
6316
|
-
function notPython3Error(executable) {
|
|
6317
|
-
return new utils.InputError(`Python 3 is required for Bazel manifest extraction. ${executable} did not run as Python 3. Install Python 3 and ensure python${process.platform === 'win32' ? '.exe' : ''} is on PATH.`);
|
|
6318
|
-
}
|
|
6319
|
-
async function provisionPythonShim(env, cwd) {
|
|
7141
|
+
}
|
|
7142
|
+
function notPython3Error(executable) {
|
|
7143
|
+
return new utils.InputError(`Python 3 is required for Bazel manifest extraction. ${executable} did not run as Python 3. Install Python 3 and ensure python${process.platform === 'win32' ? '.exe' : ''} is on PATH or set SOCKET_CLI_PYTHON_PATH in a standalone build.`);
|
|
7144
|
+
}
|
|
7145
|
+
async function provisionPythonShim(env, cwd) {
|
|
7146
|
+
if (utils.isStandaloneSea()) {
|
|
7147
|
+
const override = env['SOCKET_CLI_PYTHON_PATH'];
|
|
7148
|
+
if (!override) {
|
|
7149
|
+
throw new utils.InputError('Python is not bundled with this standalone Socket CLI. Set SOCKET_CLI_PYTHON_PATH to an installed Python 3 executable for Bazel manifest extraction.');
|
|
7150
|
+
}
|
|
7151
|
+
const executable = path.resolve(cwd, override);
|
|
7152
|
+
try {
|
|
7153
|
+
u.accessSync(executable, process.platform === 'win32' ? u.constants.F_OK : u.constants.X_OK);
|
|
7154
|
+
if (!u.statSync(executable).isFile()) {
|
|
7155
|
+
throw new Error('not a file');
|
|
7156
|
+
}
|
|
7157
|
+
} catch {
|
|
7158
|
+
throw new utils.InputError(`SOCKET_CLI_PYTHON_PATH must point to an executable Python 3 binary, but '${executable}' is missing or not executable.`);
|
|
7159
|
+
}
|
|
7160
|
+
if (process.platform === 'win32' && path.extname(executable).toLowerCase() !== '.exe') {
|
|
7161
|
+
throw new utils.InputError('Bazel on Windows requires SOCKET_CLI_PYTHON_PATH to point to a native Python 3 python.exe.');
|
|
7162
|
+
}
|
|
7163
|
+
if (!isPython3(executable, env, cwd)) {
|
|
7164
|
+
throw notPython3Error(executable);
|
|
7165
|
+
}
|
|
7166
|
+
if (process.platform === 'win32') {
|
|
7167
|
+
if (path.basename(executable).toLowerCase() !== 'python.exe') {
|
|
7168
|
+
throw new utils.InputError("SOCKET_CLI_PYTHON_PATH must name python.exe on Windows so its adjacent DLLs and standard library remain available. Point it to the Python installation's python.exe.");
|
|
7169
|
+
}
|
|
7170
|
+
return {
|
|
7171
|
+
env: prependBazelPath(env, path.dirname(executable)),
|
|
7172
|
+
shimDir: undefined
|
|
7173
|
+
};
|
|
7174
|
+
}
|
|
7175
|
+
const shimDir = u.mkdtempSync(path.join(os.tmpdir(), 'socket-bazel-python-'));
|
|
7176
|
+
try {
|
|
7177
|
+
for (const name of ['python', 'python3']) {
|
|
7178
|
+
const alias = path.join(shimDir, name);
|
|
7179
|
+
u.symlinkSync(executable, alias);
|
|
7180
|
+
}
|
|
7181
|
+
} catch (error) {
|
|
7182
|
+
u.rmSync(shimDir, {
|
|
7183
|
+
recursive: true,
|
|
7184
|
+
force: true
|
|
7185
|
+
});
|
|
7186
|
+
throw error;
|
|
7187
|
+
}
|
|
7188
|
+
return {
|
|
7189
|
+
env: prependBazelPath(env, shimDir),
|
|
7190
|
+
shimDir
|
|
7191
|
+
};
|
|
7192
|
+
}
|
|
6320
7193
|
const python = await findBazelExecutable('python', env, cwd);
|
|
6321
7194
|
if (python) {
|
|
6322
7195
|
if (process.platform === 'win32' && path.extname(python).toLowerCase() !== '.exe') {
|
|
@@ -6819,7 +7692,7 @@ const COMPLETENESS_SUMMARY_FILE_NAME = 'socket-bazel-manifest-summary.json';
|
|
|
6819
7692
|
// `socket manifest bazel` command nor `--auto-manifest`) can omit it and let
|
|
6820
7693
|
// the walk descend `node_modules`/VCS/vendored trees. Callers may
|
|
6821
7694
|
// pass extra names/prefixes to EXTEND, not replace, this set.
|
|
6822
|
-
const DEFAULT_BAZEL_WALKER_IGNORE_DIR_NAMES = new Set([...utils.IGNORED_DIRS, '.hg', '.idea', '.pnpm-store',
|
|
7695
|
+
const DEFAULT_BAZEL_WALKER_IGNORE_DIR_NAMES = new Set([...utils.IGNORED_DIRS, '.hg', '.idea', '.pnpm-store', BAZEL_AUTO_MANIFEST_DIR_NAME, '.svn', '.vscode']);
|
|
6823
7696
|
// Bazel's `bazel-*` output_base symlinks.
|
|
6824
7697
|
const DEFAULT_BAZEL_WALKER_IGNORE_DIR_PREFIXES = ['bazel-'];
|
|
6825
7698
|
// Splits "g:a:v" -> { groupArtifact: "g:a", version: "v" }.
|
|
@@ -6974,8 +7847,6 @@ function hubManifestFileName(repoName) {
|
|
|
6974
7847
|
// the explicit-command default output dir. The gate must never read a file in
|
|
6975
7848
|
// one of these as evidence of committed coverage, or a stale prior-run
|
|
6976
7849
|
// synthetic file would let a later run wrongly skip a hub.
|
|
6977
|
-
const CLI_SYNTHETIC_OUTPUT_DIR_NAMES = new Set(['.socket-auto-manifest', 'bazel-manifests']);
|
|
6978
|
-
|
|
6979
7850
|
// Does a committed lockfile already cover THIS hub at THIS hub's own workspace
|
|
6980
7851
|
// root? Each workspace is processed independently by the caller, and a
|
|
6981
7852
|
// committed lockfile covers the workspace it lives IN — a nested workspace's
|
|
@@ -7000,7 +7871,7 @@ function committedLockfileCovers(args) {
|
|
|
7000
7871
|
const workspaceRootResolved = path.resolve(workspaceRoot);
|
|
7001
7872
|
// The committed lockfile, if any, lives directly in the hub's own workspace
|
|
7002
7873
|
// root — not in a nested workspace and not in the CLI's output dir.
|
|
7003
|
-
if (workspaceRootResolved === manifestDirResolved ||
|
|
7874
|
+
if (workspaceRootResolved === manifestDirResolved || BAZEL_SYNTHETIC_OUTPUT_DIR_NAMES.has(path.basename(workspaceRootResolved))) {
|
|
7004
7875
|
// The workspace root IS an output location; nothing here is committed.
|
|
7005
7876
|
return undefined;
|
|
7006
7877
|
}
|
|
@@ -7289,7 +8160,7 @@ async function extractBazelToMaven(opts) {
|
|
|
7289
8160
|
logger.logger.log(`[VERBOSE] initial --output_user_root=${outputUserRoot} (will be reaped on completion)`);
|
|
7290
8161
|
}
|
|
7291
8162
|
const layout = opts.outLayout ?? 'standalone';
|
|
7292
|
-
const manifestDir = layout === 'flat' ?
|
|
8163
|
+
const manifestDir = layout === 'flat' ? getBazelAutoManifestDirectory(out) : out;
|
|
7293
8164
|
// One manifest per (workspace, hub), written best-effort: a single wedged
|
|
7294
8165
|
// hub must not discard the manifests every other hub produced.
|
|
7295
8166
|
const manifestPaths = [];
|
|
@@ -7709,7 +8580,7 @@ async function convertDotnetToFacts({
|
|
|
7709
8580
|
return null;
|
|
7710
8581
|
}
|
|
7711
8582
|
const dir = await utils.realpathOrResolved(cwd);
|
|
7712
|
-
const covered =
|
|
8583
|
+
const covered = emptyMembership();
|
|
7713
8584
|
let last;
|
|
7714
8585
|
for (const entry of entries) {
|
|
7715
8586
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -7852,9 +8723,18 @@ async function convertGradleToMaven({
|
|
|
7852
8723
|
}) {
|
|
7853
8724
|
// TODO: Implement json/md.
|
|
7854
8725
|
|
|
8726
|
+
let selectedBin;
|
|
8727
|
+
try {
|
|
8728
|
+
selectedBin = resolveBuildToolBin('gradle', cwd, bin, utils.isStandaloneSea());
|
|
8729
|
+
} catch (error) {
|
|
8730
|
+
process.exitCode = 1;
|
|
8731
|
+
logger.logger.fail(error instanceof Error ? error.message : String(error));
|
|
8732
|
+
return;
|
|
8733
|
+
}
|
|
8734
|
+
|
|
7855
8735
|
// Note: use resolve because the bin could be an absolute path, away from cwd
|
|
7856
8736
|
// TODO: what about $PATH resolved commands? (`gradlew` without dir prefix)
|
|
7857
|
-
const rBin = path.resolve(cwd,
|
|
8737
|
+
const rBin = path.resolve(cwd, selectedBin);
|
|
7858
8738
|
const binExists = u.existsSync(rBin);
|
|
7859
8739
|
const cwdExists = u.existsSync(cwd);
|
|
7860
8740
|
logger.logger.group('gradle2maven:');
|
|
@@ -7881,9 +8761,9 @@ async function convertGradleToMaven({
|
|
|
7881
8761
|
const excludeProps = excludePaths?.length ? [`-Psocket.excludePaths=${excludePaths.join(',')}`] : [];
|
|
7882
8762
|
const commandArgs = ['--init-script', initLocation, ...excludeProps, ...gradleOpts, 'pom'];
|
|
7883
8763
|
if (verbose) {
|
|
7884
|
-
logger.logger.log('[VERBOSE] Executing:', [
|
|
8764
|
+
logger.logger.log('[VERBOSE] Executing:', [selectedBin], ', args:', commandArgs);
|
|
7885
8765
|
}
|
|
7886
|
-
logger.logger.log(`Converting gradle to maven from \`${
|
|
8766
|
+
logger.logger.log(`Converting gradle to maven from \`${selectedBin}\` on \`${cwd}\` ...`);
|
|
7887
8767
|
const output = await execGradle(rBin, commandArgs, cwd, verbose);
|
|
7888
8768
|
if (output.code) {
|
|
7889
8769
|
process.exitCode = 1;
|
|
@@ -7994,22 +8874,30 @@ async function convertSbtToMaven({
|
|
|
7994
8874
|
}) {
|
|
7995
8875
|
// TODO: Implement json/md.
|
|
7996
8876
|
|
|
8877
|
+
let selectedBin;
|
|
8878
|
+
try {
|
|
8879
|
+
selectedBin = resolveBuildToolBin('sbt', cwd, bin, utils.isStandaloneSea());
|
|
8880
|
+
} catch (error) {
|
|
8881
|
+
process.exitCode = 1;
|
|
8882
|
+
logger.logger.fail(error instanceof Error ? error.message : String(error));
|
|
8883
|
+
return;
|
|
8884
|
+
}
|
|
7997
8885
|
const {
|
|
7998
8886
|
spinner
|
|
7999
8887
|
} = constants.default;
|
|
8000
8888
|
logger.logger.group('sbt2maven:');
|
|
8001
|
-
logger.logger.info(`- executing: \`${
|
|
8889
|
+
logger.logger.info(`- executing: \`${selectedBin}\``);
|
|
8002
8890
|
logger.logger.info(`- src dir: \`${cwd}\``);
|
|
8003
8891
|
logger.logger.groupEnd();
|
|
8004
8892
|
try {
|
|
8005
|
-
spinner.start(`Converting sbt to maven from \`${
|
|
8893
|
+
spinner.start(`Converting sbt to maven from \`${selectedBin}\` on \`${cwd}\`...`);
|
|
8006
8894
|
|
|
8007
8895
|
// Run sbt with the init script we provide which should yield zero or more
|
|
8008
8896
|
// pom files. We have to figure out where to store those pom files such that
|
|
8009
8897
|
// we can upload them and predict them through the GitHub API. We could do a
|
|
8010
8898
|
// .socket folder. We could do a socket.pom.gz with all the poms, although
|
|
8011
8899
|
// I'd prefer something plain-text if it is to be committed.
|
|
8012
|
-
const output = await spawn.spawn(
|
|
8900
|
+
const output = await spawn.spawn(selectedBin, ['makePom', ...sbtOpts], {
|
|
8013
8901
|
cwd
|
|
8014
8902
|
});
|
|
8015
8903
|
spinner.stop();
|
|
@@ -8560,6 +9448,7 @@ async function createNewScan({
|
|
|
8560
9448
|
// Sidecar forwarded to reachability; populated only when reach runs.
|
|
8561
9449
|
let resolvedPathsSidecar;
|
|
8562
9450
|
let factsOnlyTypes;
|
|
9451
|
+
let discardedFactsPaths;
|
|
8563
9452
|
|
|
8564
9453
|
// sbt provisions its Scala toolchain under the directory passed as its
|
|
8565
9454
|
// isolated global base; reach's artifactPaths point into it, so it must
|
|
@@ -8590,6 +9479,7 @@ async function createNewScan({
|
|
|
8590
9479
|
scanTargets = Array.from(new Set([...scanTargets, ...dynamicResult.factsPaths]));
|
|
8591
9480
|
resolvedPathsSidecar = dynamicResult.resolvedPathsSidecar;
|
|
8592
9481
|
factsOnlyTypes = dynamicResult.factsOnlyTypes;
|
|
9482
|
+
discardedFactsPaths = dynamicResult.discardedFactsPaths;
|
|
8593
9483
|
}
|
|
8594
9484
|
if (autoManifest) {
|
|
8595
9485
|
const sockJson = utils.readOrDefaultSocketJson(cwd);
|
|
@@ -8655,11 +9545,11 @@ async function createNewScan({
|
|
|
8655
9545
|
reachabilityOptions: reach,
|
|
8656
9546
|
target: targets[0]
|
|
8657
9547
|
});
|
|
8658
|
-
const packagePaths = scanFiles ?? (await utils.getPackageFilesForScan(scanTargets, supportedFiles, {
|
|
9548
|
+
const packagePaths = scanFiles ?? (await withoutDiscardedFacts(await utils.getPackageFilesForScan(scanTargets, supportedFiles, {
|
|
8659
9549
|
additionalIgnores: additionalScaIgnores,
|
|
8660
9550
|
config: socketConfig,
|
|
8661
9551
|
cwd
|
|
8662
|
-
}));
|
|
9552
|
+
}), discardedFactsPaths));
|
|
8663
9553
|
spinner.successAndStop(`Found ${packagePaths.length} ${words.pluralize('file', packagePaths.length)} to include in scan.`);
|
|
8664
9554
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
8665
9555
|
nook: true,
|
|
@@ -8700,7 +9590,6 @@ async function createNewScan({
|
|
|
8700
9590
|
});
|
|
8701
9591
|
spinner.start();
|
|
8702
9592
|
const reachResult = await performReachabilityAnalysis({
|
|
8703
|
-
branchName,
|
|
8704
9593
|
cwd,
|
|
8705
9594
|
factsOnlyTypes,
|
|
8706
9595
|
orgSlug,
|
|
@@ -10269,10 +11158,12 @@ async function generateSocketFactsForFix({
|
|
|
10269
11158
|
await restoreAll(originals);
|
|
10270
11159
|
};
|
|
10271
11160
|
let artifactsFlags;
|
|
11161
|
+
let discardedPaths;
|
|
10272
11162
|
let paths;
|
|
10273
11163
|
const sidecarFile = path.join(tmpDir, 'sidecar.json');
|
|
10274
11164
|
try {
|
|
10275
11165
|
const {
|
|
11166
|
+
discardedFactsPaths,
|
|
10276
11167
|
factsOnlyTypes,
|
|
10277
11168
|
factsPaths,
|
|
10278
11169
|
resolvedPathsSidecar
|
|
@@ -10284,6 +11175,7 @@ async function generateSocketFactsForFix({
|
|
|
10284
11175
|
sbtTmpDir: undefined
|
|
10285
11176
|
});
|
|
10286
11177
|
artifactsFlags = utils.useOnlySocketFactsArtifactsFlags(factsOnlyTypes);
|
|
11178
|
+
discardedPaths = discardedFactsPaths;
|
|
10287
11179
|
paths = factsPaths.map(p => path.resolve(cwd, p));
|
|
10288
11180
|
// Written even when empty, as for reach; applying fixes looks each facts
|
|
10289
11181
|
// file up in it, so an empty one is the same as none.
|
|
@@ -10299,9 +11191,11 @@ async function generateSocketFactsForFix({
|
|
|
10299
11191
|
}) => !generated.has(source)), ...(await backUp(paths, path.join(tmpDir, 'generated')))];
|
|
10300
11192
|
return {
|
|
10301
11193
|
artifactsFlags,
|
|
11194
|
+
discardedPaths,
|
|
10302
11195
|
paths,
|
|
10303
11196
|
sidecarFile,
|
|
10304
|
-
|
|
11197
|
+
// A discarded file a run left as written is removed too.
|
|
11198
|
+
remove: () => reset([...paths, ...discardedPaths]),
|
|
10305
11199
|
restore: () => restoreAll(backups)
|
|
10306
11200
|
};
|
|
10307
11201
|
}
|
|
@@ -10523,7 +11417,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
|
|
|
10523
11417
|
cwd,
|
|
10524
11418
|
outputPath: constants.DOT_SOCKET_DOT_FACTS_JSON
|
|
10525
11419
|
}));
|
|
10526
|
-
|
|
11420
|
+
let scanFilepaths = await findScanFilepaths();
|
|
10527
11421
|
if (factsSlot) {
|
|
10528
11422
|
if (!silence) {
|
|
10529
11423
|
spinner?.stop();
|
|
@@ -10536,6 +11430,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
|
|
|
10536
11430
|
findFactsPaths: async () => (await findScanFilepaths()).filter(utils.isSocketFactsFile),
|
|
10537
11431
|
tmpDir: factsSlot.tmpDir
|
|
10538
11432
|
});
|
|
11433
|
+
scanFilepaths = await withoutDiscardedFacts(scanFilepaths, factsSlot.generated.discardedPaths);
|
|
10539
11434
|
const known = new Set(scanFilepaths);
|
|
10540
11435
|
scanFilepaths.push(...factsSlot.generated.paths.filter(p => !known.has(p)));
|
|
10541
11436
|
if (!silence) {
|
|
@@ -12367,6 +13262,161 @@ async function run$K(argv, importMeta, {
|
|
|
12367
13262
|
await attemptLogout();
|
|
12368
13263
|
}
|
|
12369
13264
|
|
|
13265
|
+
async function runCdxgen$1(projectPath, outputPath, options, beforeExit) {
|
|
13266
|
+
const isolatedRoot = await u.promises.mkdtemp(path.join(os.tmpdir(), 'socket-cdxgen-api-'));
|
|
13267
|
+
try {
|
|
13268
|
+
const packageJson = JSON.parse(await u.promises.readFile(path.join(projectPath, 'package.json'), 'utf8'));
|
|
13269
|
+
if (typeof packageJson['name'] !== 'string' || !packageJson['name']) {
|
|
13270
|
+
// cdxgen otherwise uses the directory basename as its fallback project
|
|
13271
|
+
// name; retain the user's project identity while scanning the temp root.
|
|
13272
|
+
packageJson['name'] = path.basename(path.resolve(projectPath));
|
|
13273
|
+
}
|
|
13274
|
+
await Promise.all([u.promises.writeFile(path.join(isolatedRoot, 'package.json'), `${JSON.stringify(packageJson)}\n`), u.promises.copyFile(path.join(projectPath, 'package-lock.json'), path.join(isolatedRoot, 'package-lock.json'))]);
|
|
13275
|
+
} catch (error) {
|
|
13276
|
+
await u.promises.rm(isolatedRoot, {
|
|
13277
|
+
recursive: true,
|
|
13278
|
+
force: true
|
|
13279
|
+
});
|
|
13280
|
+
throw error;
|
|
13281
|
+
}
|
|
13282
|
+
const process = new require$$0$2.EventEmitter();
|
|
13283
|
+
const cleanTemp = async () => await u.promises.rm(isolatedRoot, {
|
|
13284
|
+
recursive: true,
|
|
13285
|
+
force: true
|
|
13286
|
+
});
|
|
13287
|
+
const embeddedPromise = utils.runEmbeddedJsTool('cdxgen', [], {
|
|
13288
|
+
cwd: options?.cwd,
|
|
13289
|
+
env: {
|
|
13290
|
+
CDXGEN_PLUGINS_DIR: 'plugins-empty'
|
|
13291
|
+
},
|
|
13292
|
+
inheritEnv: false,
|
|
13293
|
+
signal: options?.signal,
|
|
13294
|
+
stdio: options?.stdio,
|
|
13295
|
+
ipc: {
|
|
13296
|
+
projectPath: isolatedRoot,
|
|
13297
|
+
sourceRoot: path.resolve(projectPath),
|
|
13298
|
+
outputPath
|
|
13299
|
+
}
|
|
13300
|
+
});
|
|
13301
|
+
const finalize = async (code, signal) => {
|
|
13302
|
+
const cleanupResults = await Promise.allSettled([cleanTemp(), Promise.resolve().then(async () => await beforeExit?.())]);
|
|
13303
|
+
const cleanupErrors = cleanupResults.flatMap(result => result.status === 'rejected' ? [result.reason] : []);
|
|
13304
|
+
const failure = cleanupErrors.length === 0 ? undefined : cleanupErrors.length === 1 ? cleanupErrors[0] : new AggregateError(cleanupErrors, 'cdxgen cleanup failed');
|
|
13305
|
+
process.emit('exit', failure ? 1 : code, failure ? null : signal);
|
|
13306
|
+
if (failure) {
|
|
13307
|
+
throw failure;
|
|
13308
|
+
}
|
|
13309
|
+
};
|
|
13310
|
+
const spawnPromise = embeddedPromise.then(async result => {
|
|
13311
|
+
await finalize(result.code, result.signal);
|
|
13312
|
+
return result;
|
|
13313
|
+
}, async error => {
|
|
13314
|
+
await finalize(1, null);
|
|
13315
|
+
throw error;
|
|
13316
|
+
});
|
|
13317
|
+
Object.defineProperty(spawnPromise, 'process', {
|
|
13318
|
+
value: process
|
|
13319
|
+
});
|
|
13320
|
+
return {
|
|
13321
|
+
spawnPromise
|
|
13322
|
+
};
|
|
13323
|
+
}
|
|
13324
|
+
|
|
13325
|
+
async function removeIfOwned(filename, identity) {
|
|
13326
|
+
try {
|
|
13327
|
+
const stat = await u.promises.lstat(filename);
|
|
13328
|
+
if (String(stat.dev) === identity.dev && String(stat.ino) === identity.ino) {
|
|
13329
|
+
await u.promises.unlink(filename);
|
|
13330
|
+
}
|
|
13331
|
+
} catch (error) {
|
|
13332
|
+
if (!(error instanceof Error && 'code' in error && error.code === 'ENOENT')) {
|
|
13333
|
+
throw error;
|
|
13334
|
+
}
|
|
13335
|
+
}
|
|
13336
|
+
}
|
|
13337
|
+
async function removeOwnedPackageLock(owner) {
|
|
13338
|
+
if (!owner) {
|
|
13339
|
+
return;
|
|
13340
|
+
}
|
|
13341
|
+
try {
|
|
13342
|
+
const [stat, contents] = await Promise.all([u.promises.lstat(owner.path), u.promises.readFile(owner.path)]);
|
|
13343
|
+
const digest = require$$0.createHash('sha256').update(contents).digest('hex');
|
|
13344
|
+
if (String(stat.dev) === owner.dev && String(stat.ino) === owner.ino && stat.size === owner.size && digest === owner.sha256) {
|
|
13345
|
+
await u.promises.unlink(owner.path);
|
|
13346
|
+
}
|
|
13347
|
+
} catch (error) {
|
|
13348
|
+
if (!(error instanceof Error && 'code' in error && error.code === 'ENOENT')) {
|
|
13349
|
+
throw error;
|
|
13350
|
+
}
|
|
13351
|
+
}
|
|
13352
|
+
}
|
|
13353
|
+
async function convertYarnClassicToNpmLock(projectPath, signal) {
|
|
13354
|
+
utils.assertEmbeddedToolAvailable('synp');
|
|
13355
|
+
const root = path.resolve(projectPath);
|
|
13356
|
+
const packageLockPath = path.join(root, 'package-lock.json');
|
|
13357
|
+
const temporaryPath = path.join(root, `.socket-cdxgen-lock-${require$$0.randomUUID()}.tmp`);
|
|
13358
|
+
const placeholder = await u.promises.open(temporaryPath, 'wx', 0o600);
|
|
13359
|
+
const placeholderStat = await placeholder.stat();
|
|
13360
|
+
await placeholder.close();
|
|
13361
|
+
const placeholderIdentity = {
|
|
13362
|
+
dev: String(placeholderStat.dev),
|
|
13363
|
+
ino: String(placeholderStat.ino)
|
|
13364
|
+
};
|
|
13365
|
+
let packageLockOwner;
|
|
13366
|
+
try {
|
|
13367
|
+
const result = await utils.runEmbeddedJsTool('synp', [], {
|
|
13368
|
+
cwd: root,
|
|
13369
|
+
inheritEnv: false,
|
|
13370
|
+
env: {},
|
|
13371
|
+
signal,
|
|
13372
|
+
stdio: 'pipe',
|
|
13373
|
+
ipc: {
|
|
13374
|
+
projectPath: root,
|
|
13375
|
+
outputPath: temporaryPath,
|
|
13376
|
+
tempDev: placeholderIdentity.dev,
|
|
13377
|
+
tempIno: placeholderIdentity.ino
|
|
13378
|
+
}
|
|
13379
|
+
});
|
|
13380
|
+
if (result.code !== 0 || result.cancelled) {
|
|
13381
|
+
throw Object.assign(new Error(result.stderr?.trim() || 'Embedded Synp failed to convert yarn.lock.'), {
|
|
13382
|
+
code: result.signal ?? undefined
|
|
13383
|
+
});
|
|
13384
|
+
}
|
|
13385
|
+
let converted;
|
|
13386
|
+
try {
|
|
13387
|
+
converted = JSON.parse(result.stdout ?? '');
|
|
13388
|
+
} catch {
|
|
13389
|
+
throw new Error('Embedded Synp returned invalid ownership metadata.');
|
|
13390
|
+
}
|
|
13391
|
+
if (converted.dev !== placeholderIdentity.dev || converted.ino !== placeholderIdentity.ino || !Number.isSafeInteger(converted.size) || converted.size <= 0 || !/^[a-f0-9]{64}$/.test(converted.sha256)) {
|
|
13392
|
+
throw new Error('Embedded Synp returned invalid ownership metadata.');
|
|
13393
|
+
}
|
|
13394
|
+
const [tempStat, tempContents] = await Promise.all([u.promises.lstat(temporaryPath), u.promises.readFile(temporaryPath)]);
|
|
13395
|
+
const tempDigest = require$$0.createHash('sha256').update(tempContents).digest('hex');
|
|
13396
|
+
if (String(tempStat.dev) !== converted.dev || String(tempStat.ino) !== converted.ino || tempStat.size !== converted.size || tempDigest !== converted.sha256 || JSON.parse(tempContents.toString('utf8')).lockfileVersion !== 1) {
|
|
13397
|
+
throw new Error('Embedded Synp output failed ownership or format verification.');
|
|
13398
|
+
}
|
|
13399
|
+
|
|
13400
|
+
// link() creates the destination atomically and fails if another process
|
|
13401
|
+
// created package-lock.json after our initial absence check.
|
|
13402
|
+
await u.promises.link(temporaryPath, packageLockPath);
|
|
13403
|
+
packageLockOwner = {
|
|
13404
|
+
path: packageLockPath,
|
|
13405
|
+
dev: converted.dev,
|
|
13406
|
+
ino: converted.ino,
|
|
13407
|
+
size: converted.size,
|
|
13408
|
+
sha256: converted.sha256
|
|
13409
|
+
};
|
|
13410
|
+
await u.promises.unlink(temporaryPath);
|
|
13411
|
+
return packageLockOwner;
|
|
13412
|
+
} catch (error) {
|
|
13413
|
+
await removeOwnedPackageLock(packageLockOwner);
|
|
13414
|
+
throw error;
|
|
13415
|
+
} finally {
|
|
13416
|
+
await removeIfOwned(temporaryPath, placeholderIdentity);
|
|
13417
|
+
}
|
|
13418
|
+
}
|
|
13419
|
+
|
|
12370
13420
|
const {
|
|
12371
13421
|
PACKAGE_LOCK_JSON,
|
|
12372
13422
|
PNPM_LOCK_YAML,
|
|
@@ -12408,6 +13458,167 @@ function argvObjectToArray(argvObj) {
|
|
|
12408
13458
|
return result;
|
|
12409
13459
|
}
|
|
12410
13460
|
async function runCdxgen(argvObj) {
|
|
13461
|
+
if (utils.isStandaloneSea()) {
|
|
13462
|
+
const unsupported = new Set(['deep', 'evidence', 'include-formulation', 'include-crypto', 'install-deps', 'multi-project', 'recurse', 'server', 'export-proto', 'proto-bin-file', 'profile', 'feature-flags', 'filter', 'only', 'technique', 'standard', 'exclude-type', 'babel', 'validate']);
|
|
13463
|
+
for (const key of Object.keys(argvObj)) {
|
|
13464
|
+
if (unsupported.has(key)) {
|
|
13465
|
+
const value = argvObj[key];
|
|
13466
|
+
if (value !== false && value !== undefined && value !== null) {
|
|
13467
|
+
throw new Error(`The standalone cdxgen build does not support --${key}.`);
|
|
13468
|
+
}
|
|
13469
|
+
} else if (!['_', '--', 'output', 'type', 'lifecycle', 'help'].includes(key)) {
|
|
13470
|
+
throw new Error(`The standalone cdxgen build does not support --${key}.`);
|
|
13471
|
+
}
|
|
13472
|
+
}
|
|
13473
|
+
if (argvObj['help']) {
|
|
13474
|
+
throw new Error('Help output is handled before cdxgen execution.');
|
|
13475
|
+
}
|
|
13476
|
+
if (argvObj['lifecycle'] && argvObj['lifecycle'] !== 'pre-build') {
|
|
13477
|
+
throw new Error('The standalone cdxgen build supports only the pre-build lifecycle.');
|
|
13478
|
+
}
|
|
13479
|
+
if (argvObj['type'] && !['npm', 'nodejs', 'javascript', 'js', 'typescript', 'ts', 'tsx'].includes(String(argvObj['type']).toLowerCase())) {
|
|
13480
|
+
throw new Error('The standalone cdxgen build supports only npm projects.');
|
|
13481
|
+
}
|
|
13482
|
+
const positional = Array.isArray(argvObj['_']) ? argvObj['_'] : [];
|
|
13483
|
+
if (positional.length > 1 || positional[0] && path.resolve(String(positional[0])) !== process.cwd()) {
|
|
13484
|
+
throw new Error('The standalone cdxgen build supports one project at the current working directory.');
|
|
13485
|
+
}
|
|
13486
|
+
if (Array.isArray(argvObj['--']) && argvObj['--'].length) {
|
|
13487
|
+
throw new Error('The standalone cdxgen build does not support arguments after --.');
|
|
13488
|
+
}
|
|
13489
|
+
const root = process.cwd();
|
|
13490
|
+
const packageLockPath = path.join(root, PACKAGE_LOCK_JSON);
|
|
13491
|
+
const yarnLockPath = path.join(root, YARN_LOCK);
|
|
13492
|
+
if (u.existsSync(path.join(root, 'npm-shrinkwrap.json')) || u.existsSync(path.join(root, 'rush.json')) || u.existsSync(path.join(root, PNPM_LOCK_YAML))) {
|
|
13493
|
+
throw new Error('The standalone cdxgen build supports one npm or Yarn Classic project without shrinkwrap, pnpm, or Rush configuration.');
|
|
13494
|
+
}
|
|
13495
|
+
let packageJson;
|
|
13496
|
+
try {
|
|
13497
|
+
packageJson = JSON.parse(await u.promises.readFile(path.join(root, 'package.json'), 'utf8'));
|
|
13498
|
+
} catch {
|
|
13499
|
+
throw new Error('The standalone cdxgen build requires a valid root package.json.');
|
|
13500
|
+
}
|
|
13501
|
+
if (!packageJson || typeof packageJson !== 'object' || Array.isArray(packageJson)) {
|
|
13502
|
+
throw new Error('The standalone cdxgen build requires a valid root package.json object.');
|
|
13503
|
+
}
|
|
13504
|
+
if (packageJson.workspaces || packageJson.workspace) {
|
|
13505
|
+
throw new Error('The standalone cdxgen build does not support workspaces.');
|
|
13506
|
+
}
|
|
13507
|
+
const localDependency = value => typeof value === 'string' && /^(?:file:|link:|workspace:)/i.test(value);
|
|
13508
|
+
for (const group of [packageJson.dependencies, packageJson.devDependencies, packageJson.optionalDependencies, packageJson.peerDependencies]) {
|
|
13509
|
+
if (Object.values(group ?? {}).some(localDependency)) {
|
|
13510
|
+
throw new Error('The standalone cdxgen build does not support local or workspace dependencies.');
|
|
13511
|
+
}
|
|
13512
|
+
}
|
|
13513
|
+
const hasPackageLock = u.existsSync(packageLockPath);
|
|
13514
|
+
const hasYarnLock = u.existsSync(yarnLockPath);
|
|
13515
|
+
if (hasPackageLock && hasYarnLock) {
|
|
13516
|
+
throw new Error('The standalone cdxgen build does not support projects with both npm and Yarn lockfiles.');
|
|
13517
|
+
}
|
|
13518
|
+
let generatedLock;
|
|
13519
|
+
const abortController = new AbortController();
|
|
13520
|
+
const onSigint = () => abortController.abort(Object.assign(new Error('Interrupted'), {
|
|
13521
|
+
code: 'SIGINT'
|
|
13522
|
+
}));
|
|
13523
|
+
const onSigterm = () => abortController.abort(Object.assign(new Error('Terminated'), {
|
|
13524
|
+
code: 'SIGTERM'
|
|
13525
|
+
}));
|
|
13526
|
+
const onSighup = () => abortController.abort(Object.assign(new Error('Hangup'), {
|
|
13527
|
+
code: 'SIGHUP'
|
|
13528
|
+
}));
|
|
13529
|
+
let signalHandlersInstalled = false;
|
|
13530
|
+
const installSignalHandlers = () => {
|
|
13531
|
+
if (signalHandlersInstalled) {
|
|
13532
|
+
return;
|
|
13533
|
+
}
|
|
13534
|
+
signalHandlersInstalled = true;
|
|
13535
|
+
process.once('SIGINT', onSigint);
|
|
13536
|
+
process.once('SIGTERM', onSigterm);
|
|
13537
|
+
process.once('SIGHUP', onSighup);
|
|
13538
|
+
};
|
|
13539
|
+
const removeSignalHandlers = () => {
|
|
13540
|
+
if (!signalHandlersInstalled) {
|
|
13541
|
+
return;
|
|
13542
|
+
}
|
|
13543
|
+
signalHandlersInstalled = false;
|
|
13544
|
+
process.removeListener('SIGINT', onSigint);
|
|
13545
|
+
process.removeListener('SIGTERM', onSigterm);
|
|
13546
|
+
process.removeListener('SIGHUP', onSighup);
|
|
13547
|
+
};
|
|
13548
|
+
if (hasPackageLock) {
|
|
13549
|
+
let lock;
|
|
13550
|
+
try {
|
|
13551
|
+
lock = JSON.parse(await u.promises.readFile(packageLockPath, 'utf8'));
|
|
13552
|
+
} catch {
|
|
13553
|
+
throw new Error('The standalone cdxgen build requires a valid npm package-lock.json.');
|
|
13554
|
+
}
|
|
13555
|
+
if (lock.lockfileVersion !== 3) {
|
|
13556
|
+
throw new Error('The standalone cdxgen build requires npm package-lock v3; only Yarn Classic conversion uses v1.');
|
|
13557
|
+
}
|
|
13558
|
+
utils.assertEmbeddedToolAvailable('cdxgen', 'manifest-cdxgen-npm-lock-v3');
|
|
13559
|
+
} else if (hasYarnLock) {
|
|
13560
|
+
const yarnText = await u.promises.readFile(yarnLockPath, 'utf8');
|
|
13561
|
+
if (!/^# yarn lockfile v1(?:\r?\n|$)/m.test(yarnText) || /^__metadata:\s*$/m.test(yarnText) || u.existsSync(path.join(root, '.yarnrc.yml'))) {
|
|
13562
|
+
throw new Error('The standalone cdxgen build supports Yarn Classic lockfile v1 only; Yarn Berry is unavailable.');
|
|
13563
|
+
}
|
|
13564
|
+
if (!u.existsSync(path.join(root, 'node_modules'))) {
|
|
13565
|
+
throw new Error('Yarn Classic conversion requires an existing node_modules directory.');
|
|
13566
|
+
}
|
|
13567
|
+
utils.assertEmbeddedToolAvailable('cdxgen', 'manifest-cdxgen-yarn-classic');
|
|
13568
|
+
utils.assertEmbeddedToolAvailable('synp');
|
|
13569
|
+
installSignalHandlers();
|
|
13570
|
+
try {
|
|
13571
|
+
generatedLock = await convertYarnClassicToNpmLock(root, abortController.signal);
|
|
13572
|
+
} catch (error) {
|
|
13573
|
+
removeSignalHandlers();
|
|
13574
|
+
if (abortController.signal.aborted) {
|
|
13575
|
+
const reason = abortController.signal.reason;
|
|
13576
|
+
if (typeof reason?.code === 'string') {
|
|
13577
|
+
if (utils.isStandaloneSea()) {
|
|
13578
|
+
await removeOwnedPackageLock(generatedLock);
|
|
13579
|
+
const canceled = Promise.resolve({
|
|
13580
|
+
code: null,
|
|
13581
|
+
signal: reason.code,
|
|
13582
|
+
cancelled: true
|
|
13583
|
+
});
|
|
13584
|
+
Object.defineProperty(canceled, 'process', {
|
|
13585
|
+
value: new require$$0$2.EventEmitter()
|
|
13586
|
+
});
|
|
13587
|
+
return {
|
|
13588
|
+
spawnPromise: canceled
|
|
13589
|
+
};
|
|
13590
|
+
}
|
|
13591
|
+
process.kill(process.pid, reason.code);
|
|
13592
|
+
}
|
|
13593
|
+
}
|
|
13594
|
+
throw error;
|
|
13595
|
+
}
|
|
13596
|
+
} else {
|
|
13597
|
+
throw new Error('The standalone cdxgen build requires npm package-lock v3 or Yarn Classic lockfile v1 with node_modules.');
|
|
13598
|
+
}
|
|
13599
|
+
const output = typeof argvObj['output'] === 'string' ? argvObj['output'] : 'socket-cdx.json';
|
|
13600
|
+
const outputPath = output === '-' ? '-' : path.resolve(root, output);
|
|
13601
|
+
if (generatedLock && outputPath === packageLockPath) {
|
|
13602
|
+
await removeOwnedPackageLock(generatedLock);
|
|
13603
|
+
removeSignalHandlers();
|
|
13604
|
+
throw new Error('The standalone cdxgen build cannot use package-lock.json as the SBOM output path.');
|
|
13605
|
+
}
|
|
13606
|
+
installSignalHandlers();
|
|
13607
|
+
try {
|
|
13608
|
+
const embedded = await runCdxgen$1(root, outputPath, {
|
|
13609
|
+
stdio: 'inherit',
|
|
13610
|
+
signal: abortController.signal
|
|
13611
|
+
}, async () => {
|
|
13612
|
+
removeSignalHandlers();
|
|
13613
|
+
await removeOwnedPackageLock(generatedLock);
|
|
13614
|
+
});
|
|
13615
|
+
return embedded;
|
|
13616
|
+
} catch (error) {
|
|
13617
|
+
removeSignalHandlers();
|
|
13618
|
+
await removeOwnedPackageLock(generatedLock);
|
|
13619
|
+
throw error;
|
|
13620
|
+
}
|
|
13621
|
+
}
|
|
12411
13622
|
const argvMutable = {
|
|
12412
13623
|
__proto__: null,
|
|
12413
13624
|
...argvObj
|
|
@@ -12734,6 +13945,25 @@ async function run$J(argv, importMeta, context) {
|
|
|
12734
13945
|
return;
|
|
12735
13946
|
}
|
|
12736
13947
|
|
|
13948
|
+
// The standalone build must not start cdxgen just to display its help:
|
|
13949
|
+
// cdxgen is an optional payload and can be unavailable for this target.
|
|
13950
|
+
// Keep this local help useful without resolving or installing that payload.
|
|
13951
|
+
if (yargv.help && utils.isStandaloneSea()) {
|
|
13952
|
+
logger.logger.log(`
|
|
13953
|
+
Usage
|
|
13954
|
+
socket manifest cdxgen [options] [path]
|
|
13955
|
+
|
|
13956
|
+
Options
|
|
13957
|
+
-h, --help Show this help
|
|
13958
|
+
-o, --output <file> Output file (default: socket-cdx.json)
|
|
13959
|
+
-t, --type <type> npm, nodejs, javascript, js, typescript, ts, or tsx
|
|
13960
|
+
--lifecycle pre-build Read dependency metadata without running project installs
|
|
13961
|
+
|
|
13962
|
+
Generates a CycloneDX SBOM from a root npm package-lock.json v3.
|
|
13963
|
+
Only one npm project is supported in this standalone build. Other cdxgen modes are unavailable.`);
|
|
13964
|
+
return;
|
|
13965
|
+
}
|
|
13966
|
+
|
|
12737
13967
|
// Change defaults when not passing the --help flag.
|
|
12738
13968
|
if (!yargv.help) {
|
|
12739
13969
|
// Make 'lifecycle' default to 'pre-build', which also sets 'install-deps' to `false`,
|
|
@@ -12752,6 +13982,21 @@ async function run$J(argv, importMeta, context) {
|
|
|
12752
13982
|
const {
|
|
12753
13983
|
spawnPromise
|
|
12754
13984
|
} = await runCdxgen(yargv);
|
|
13985
|
+
if (utils.isStandaloneSea()) {
|
|
13986
|
+
// The embedded Worker exposes an awaited result. Avoid translating its
|
|
13987
|
+
// synthetic exit event into process.exit(), which can bypass CLI error
|
|
13988
|
+
// formatting and telemetry drain on rejection or cancellation.
|
|
13989
|
+
const result = await spawnPromise;
|
|
13990
|
+
if (result.signal) {
|
|
13991
|
+
process.exitCode = 128 + (os.constants.signals[result.signal] ?? 1);
|
|
13992
|
+
} else {
|
|
13993
|
+
process.exitCode = typeof result.code === 'number' ? result.code : 1;
|
|
13994
|
+
if (result.code === 0 && typeof yargv.output === 'string' && yargv.output !== '-' && u.existsSync(path.resolve(process.cwd(), yargv.output))) {
|
|
13995
|
+
logger.logger.log(vendor.yoctocolorsCjsExports.cyanBright(`${yargv.output} created!`));
|
|
13996
|
+
}
|
|
13997
|
+
}
|
|
13998
|
+
return;
|
|
13999
|
+
}
|
|
12755
14000
|
|
|
12756
14001
|
// See https://nodejs.org/api/child_process.html#event-exit.
|
|
12757
14002
|
spawnPromise.process.on('exit', (code, signalName) => {
|
|
@@ -12819,7 +14064,7 @@ function resolveBazelManifestSettings({
|
|
|
12819
14064
|
const socketJsonOut = config.out;
|
|
12820
14065
|
const outFromSocketJson = !cliOut && typeof socketJsonOut === 'string';
|
|
12821
14066
|
const outValue = cliOut ?? socketJsonOut;
|
|
12822
|
-
const resolvedOut = outValue ? path.resolve(cwd, outValue) :
|
|
14067
|
+
const resolvedOut = outValue ? path.resolve(cwd, outValue) : getDefaultBazelManifestDirectory(cwd);
|
|
12823
14068
|
const canonicalCwd = canonicalizeForContainment(cwd);
|
|
12824
14069
|
const canonicalOut = canonicalizeForContainment(resolvedOut);
|
|
12825
14070
|
const relativeOut = path.relative(canonicalCwd, canonicalOut);
|
|
@@ -13561,7 +14806,7 @@ async function extractBazelToPypi(opts) {
|
|
|
13561
14806
|
logger.logger.groupEnd();
|
|
13562
14807
|
let pythonShimDir;
|
|
13563
14808
|
try {
|
|
13564
|
-
if (process.platform === 'win32') {
|
|
14809
|
+
if ((opts.platform ?? process.platform) === 'win32') {
|
|
13565
14810
|
throw new utils.InputError('Bazel PyPI extraction on Windows is not supported yet. Platform-specific dependency selection still needs verification. Use --ecosystem maven for Windows SCA scans.');
|
|
13566
14811
|
}
|
|
13567
14812
|
// Validate caller-provided Bazel filesystem settings before invoking Bazel.
|
|
@@ -13696,7 +14941,7 @@ async function extractBazelToPypi(opts) {
|
|
|
13696
14941
|
const sorted = sortPackageLines(allLines);
|
|
13697
14942
|
const lines = sorted.map(p => `${p.name}==${p.version}\n`);
|
|
13698
14943
|
const layout = opts.outLayout ?? 'standalone';
|
|
13699
|
-
const manifestDir = layout === 'flat' ?
|
|
14944
|
+
const manifestDir = layout === 'flat' ? getBazelAutoManifestDirectory(out) : out;
|
|
13700
14945
|
u.mkdirSync(manifestDir, {
|
|
13701
14946
|
recursive: true
|
|
13702
14947
|
});
|
|
@@ -13852,7 +15097,7 @@ const config$h = {
|
|
|
13852
15097
|
},
|
|
13853
15098
|
out: {
|
|
13854
15099
|
type: 'string',
|
|
13855
|
-
description:
|
|
15100
|
+
description: `Output directory for generated manifests; default: ${DEFAULT_BAZEL_MANIFEST_OUTPUT_DISPLAY_PATH}`
|
|
13856
15101
|
},
|
|
13857
15102
|
perRepoTimeout: {
|
|
13858
15103
|
type: 'number',
|
|
@@ -16341,71 +17586,7 @@ function notCanceled$2() {
|
|
|
16341
17586
|
};
|
|
16342
17587
|
}
|
|
16343
17588
|
|
|
16344
|
-
//
|
|
16345
|
-
// `socket manifest setup --dynamic-sbom-inference`; dynamic-sbom-inference
|
|
16346
|
-
// itself instead gets this list for free as a side effect of its own full
|
|
16347
|
-
// facts run.
|
|
16348
|
-
async function enumerateWorkspaces({
|
|
16349
|
-
bin,
|
|
16350
|
-
buildOpts,
|
|
16351
|
-
cwd,
|
|
16352
|
-
ecosystem,
|
|
16353
|
-
entryFile,
|
|
16354
|
-
excludeBase,
|
|
16355
|
-
excludePaths,
|
|
16356
|
-
javaHome,
|
|
16357
|
-
verbose
|
|
16358
|
-
}) {
|
|
16359
|
-
let resolvedJavaHome;
|
|
16360
|
-
if (javaHome) {
|
|
16361
|
-
const expanded = expandEnvVarRefs(javaHome);
|
|
16362
|
-
if (expanded.missing) {
|
|
16363
|
-
process.exitCode = 1;
|
|
16364
|
-
logger.logger.fail(`javaHome (\`${javaHome}\`) ${formatMissingEnvVarRefs(expanded.missing)}.`);
|
|
16365
|
-
return;
|
|
16366
|
-
}
|
|
16367
|
-
resolvedJavaHome = expanded.value;
|
|
16368
|
-
}
|
|
16369
|
-
const scriptOpts = {
|
|
16370
|
-
bin: bin || undefined,
|
|
16371
|
-
entryFile,
|
|
16372
|
-
excludeBase,
|
|
16373
|
-
excludePaths: excludePaths?.length ? excludePaths : undefined,
|
|
16374
|
-
// `env` replaces the spawned process's whole environment, not just JAVA_HOME.
|
|
16375
|
-
env: resolvedJavaHome ? {
|
|
16376
|
-
...process.env,
|
|
16377
|
-
JAVA_HOME: resolvedJavaHome
|
|
16378
|
-
} : undefined,
|
|
16379
|
-
projectDir: cwd,
|
|
16380
|
-
stdio: 'pipe',
|
|
16381
|
-
toolOpts: buildOpts
|
|
16382
|
-
};
|
|
16383
|
-
let result;
|
|
16384
|
-
try {
|
|
16385
|
-
result = await enumerateWorkspaces$1(ecosystem, scriptOpts);
|
|
16386
|
-
} catch (e) {
|
|
16387
|
-
process.exitCode = 1;
|
|
16388
|
-
logger.logger.fail(`Could not run the ${ecosystem} build tool: ${utils.getErrorMessageOr(e, String(e))}`);
|
|
16389
|
-
return;
|
|
16390
|
-
}
|
|
16391
|
-
if (!result.projects.length) {
|
|
16392
|
-
process.exitCode = 1;
|
|
16393
|
-
logger.logger.fail(`The ${ecosystem} build produced no workspace records (exit code ${result.code}); every build reports at least its own root project, so the enumeration task did not run.`);
|
|
16394
|
-
return;
|
|
16395
|
-
}
|
|
16396
|
-
if (!result.buildRoot) {
|
|
16397
|
-
process.exitCode = 1;
|
|
16398
|
-
logger.logger.fail(`The ${ecosystem} build did not report its build root, so its projects' paths cannot be located.`);
|
|
16399
|
-
return;
|
|
16400
|
-
}
|
|
16401
|
-
return {
|
|
16402
|
-
buildRoot: result.buildRoot,
|
|
16403
|
-
projects: result.projects
|
|
16404
|
-
};
|
|
16405
|
-
}
|
|
16406
|
-
|
|
16407
|
-
// One prompt per directory, as settings are per directory; Maven may have
|
|
16408
|
-
// several POMs, so several roots, there.
|
|
17589
|
+
// The builds of one tool in one directory.
|
|
16409
17590
|
|
|
16410
17591
|
const ROOT_ECOSYSTEMS = ['maven', 'gradle', 'sbt', 'dotnet'];
|
|
16411
17592
|
|
|
@@ -16490,6 +17671,7 @@ async function discoverBuildRoots({
|
|
|
16490
17671
|
}) {
|
|
16491
17672
|
const realCwd = await utils.realpathOrResolved(cwd);
|
|
16492
17673
|
const included = [];
|
|
17674
|
+
const excludedBuilds = [];
|
|
16493
17675
|
const ignorePatterns = (excludePaths ?? []).flatMap(excludePathToScanIgnores);
|
|
16494
17676
|
const ecosystemsByRoot = new Map();
|
|
16495
17677
|
for (const [ecosystem, fullRoots] of fullByTool) {
|
|
@@ -16526,10 +17708,12 @@ async function discoverBuildRoots({
|
|
|
16526
17708
|
ecosystem,
|
|
16527
17709
|
roots: includedRoots
|
|
16528
17710
|
});
|
|
16529
|
-
// `disabled`
|
|
16530
|
-
// without its included siblings.
|
|
17711
|
+
// A section's `disabled` would also skip the included siblings.
|
|
16531
17712
|
for (const root of excludedRoots) {
|
|
16532
|
-
|
|
17713
|
+
excludedBuilds.push({
|
|
17714
|
+
ecosystem,
|
|
17715
|
+
root
|
|
17716
|
+
});
|
|
16533
17717
|
}
|
|
16534
17718
|
continue;
|
|
16535
17719
|
}
|
|
@@ -16545,438 +17729,552 @@ async function discoverBuildRoots({
|
|
|
16545
17729
|
dir,
|
|
16546
17730
|
ecosystems: [...ecosystems].sort()
|
|
16547
17731
|
})),
|
|
17732
|
+
excludedBuilds,
|
|
16548
17733
|
included
|
|
16549
17734
|
};
|
|
16550
17735
|
}
|
|
16551
17736
|
|
|
16552
|
-
//
|
|
16553
|
-
|
|
16554
|
-
|
|
16555
|
-
async function markWorkspaceCoverage({
|
|
16556
|
-
covered,
|
|
16557
|
-
cwd,
|
|
16558
|
-
dir,
|
|
16559
|
-
ecosystem,
|
|
16560
|
-
excludePaths,
|
|
16561
|
-
rootSockJson,
|
|
16562
|
-
roots
|
|
16563
|
-
}) {
|
|
16564
|
-
if (roots.every(root => isBuildRootCovered(covered, ecosystem, root))) {
|
|
16565
|
-
return {
|
|
16566
|
-
ok: true,
|
|
16567
|
-
data: undefined
|
|
16568
|
-
};
|
|
16569
|
-
}
|
|
16570
|
-
const cascade = utils.readSocketJsonCascade(dir, cwd, rootSockJson);
|
|
16571
|
-
const {
|
|
16572
|
-
bin,
|
|
16573
|
-
buildOpts,
|
|
16574
|
-
javaHome,
|
|
16575
|
-
skipReason
|
|
16576
|
-
} = resolveEcosystemConfig(ecosystem, dir, cascade);
|
|
16577
|
-
if (skipReason) {
|
|
16578
|
-
return {
|
|
16579
|
-
ok: true,
|
|
16580
|
-
data: undefined
|
|
16581
|
-
};
|
|
16582
|
-
}
|
|
16583
|
-
for (const root of roots) {
|
|
16584
|
-
if (
|
|
16585
|
-
// eslint-disable-next-line no-await-in-loop
|
|
16586
|
-
await isRootCovered(covered, ecosystem, root, {
|
|
16587
|
-
bin,
|
|
16588
|
-
excludeBase: cwd,
|
|
16589
|
-
excludePaths,
|
|
16590
|
-
toolOpts: buildOpts
|
|
16591
|
-
})) {
|
|
16592
|
-
continue;
|
|
16593
|
-
}
|
|
16594
|
-
// eslint-disable-next-line no-await-in-loop
|
|
16595
|
-
const enumResult = await enumerateWorkspaces({
|
|
16596
|
-
bin,
|
|
16597
|
-
buildOpts,
|
|
16598
|
-
cwd: dir,
|
|
16599
|
-
ecosystem,
|
|
16600
|
-
entryFile: root.entryFile,
|
|
16601
|
-
excludeBase: cwd,
|
|
16602
|
-
excludePaths,
|
|
16603
|
-
javaHome,
|
|
16604
|
-
verbose: false
|
|
16605
|
-
});
|
|
16606
|
-
if (!enumResult) {
|
|
16607
|
-
const relRoot = path.relative(cwd, buildRootPath(root)) || '.';
|
|
16608
|
-
return {
|
|
16609
|
-
ok: false,
|
|
16610
|
-
message: `Could not determine ${ecosystem} workspace layout for ${relRoot}; aborting rather than risk misclassifying its members.`
|
|
16611
|
-
};
|
|
16612
|
-
}
|
|
16613
|
-
// eslint-disable-next-line no-await-in-loop
|
|
16614
|
-
await addCoveredBuildFiles(covered, ecosystem, enumResult.buildRoot, enumResult.projects);
|
|
16615
|
-
}
|
|
17737
|
+
// Changes to socket.json files, kept until the user confirms them.
|
|
17738
|
+
|
|
17739
|
+
function createSettingsDraft() {
|
|
16616
17740
|
return {
|
|
16617
|
-
|
|
16618
|
-
|
|
17741
|
+
files: new Map(),
|
|
17742
|
+
notes: new Map(),
|
|
17743
|
+
resolver: undefined,
|
|
17744
|
+
warned: new Set()
|
|
16619
17745
|
};
|
|
16620
17746
|
}
|
|
16621
|
-
|
|
16622
|
-
|
|
16623
|
-
|
|
16624
|
-
|
|
16625
|
-
|
|
16626
|
-
|
|
16627
|
-
cwd,
|
|
16628
|
-
dir,
|
|
16629
|
-
ecosystems,
|
|
16630
|
-
rootSockJson
|
|
16631
|
-
}) {
|
|
16632
|
-
const relDir = path.relative(cwd, dir) || '.';
|
|
16633
|
-
const cascade = utils.readSocketJsonCascade(dir, cwd, rootSockJson);
|
|
16634
|
-
const needsWrite = ecosystems.filter(ecosystem => getEcosystemSection(cascade, ecosystem)['disabled'] !== true);
|
|
16635
|
-
if (!needsWrite.length) {
|
|
16636
|
-
return notCanceled$1();
|
|
16637
|
-
}
|
|
16638
|
-
const ownSockJson = utils.readOrDefaultSocketJson(dir);
|
|
16639
|
-
if (!ownSockJson.defaults) {
|
|
16640
|
-
ownSockJson.defaults = {};
|
|
16641
|
-
}
|
|
16642
|
-
if (!ownSockJson.defaults.manifest) {
|
|
16643
|
-
ownSockJson.defaults.manifest = {};
|
|
16644
|
-
}
|
|
16645
|
-
const manifest = ownSockJson.defaults.manifest;
|
|
16646
|
-
for (const ecosystem of needsWrite) {
|
|
16647
|
-
manifest[ecosystem] = {
|
|
16648
|
-
...getEcosystemSection(ownSockJson, ecosystem),
|
|
16649
|
-
disabled: true
|
|
16650
|
-
};
|
|
16651
|
-
}
|
|
16652
|
-
const writeResult = await utils.writeSocketJson(dir, ownSockJson);
|
|
16653
|
-
if (!writeResult.ok) {
|
|
16654
|
-
return writeResult;
|
|
16655
|
-
}
|
|
16656
|
-
logger.logger.success(`Disabled ${relDir} (${needsWrite.join(', ')})`);
|
|
16657
|
-
return notCanceled$1();
|
|
17747
|
+
function setDraftFile(draft, dir, sockJson) {
|
|
17748
|
+
draft.files.set(dir, sockJson);
|
|
17749
|
+
draft.resolver = undefined;
|
|
17750
|
+
}
|
|
17751
|
+
function cloneSocketJson(sockJson) {
|
|
17752
|
+
return JSON.parse(JSON.stringify(sockJson));
|
|
16658
17753
|
}
|
|
16659
17754
|
|
|
16660
|
-
//
|
|
16661
|
-
|
|
16662
|
-
|
|
16663
|
-
|
|
16664
|
-
|
|
16665
|
-
|
|
16666
|
-
|
|
16667
|
-
|
|
17755
|
+
// `dir`'s own socket.json as it will be written.
|
|
17756
|
+
function draftSettings(draft, dir) {
|
|
17757
|
+
return cloneSocketJson(draft.files.get(dir) ?? utils.readOrDefaultSocketJson(dir));
|
|
17758
|
+
}
|
|
17759
|
+
function stageSettings(draft, dir, sockJson, note) {
|
|
17760
|
+
setDraftFile(draft, dir, sockJson);
|
|
17761
|
+
const notes = utils.getOrInsert(draft.notes, dir, () => []);
|
|
17762
|
+
if (!notes.includes(note)) {
|
|
17763
|
+
notes.push(note);
|
|
17764
|
+
}
|
|
17765
|
+
}
|
|
17766
|
+
function manifestOf(sockJson) {
|
|
17767
|
+
if (!sockJson.defaults) {
|
|
17768
|
+
sockJson.defaults = {};
|
|
16668
17769
|
}
|
|
16669
|
-
if (
|
|
16670
|
-
|
|
16671
|
-
factsOnly: true
|
|
16672
|
-
});
|
|
17770
|
+
if (!sockJson.defaults.manifest) {
|
|
17771
|
+
sockJson.defaults.manifest = {};
|
|
16673
17772
|
}
|
|
16674
|
-
|
|
16675
|
-
|
|
17773
|
+
return sockJson.defaults.manifest;
|
|
17774
|
+
}
|
|
17775
|
+
|
|
17776
|
+
// The socket.json files from the filesystem root down to `dir`, as they will
|
|
17777
|
+
// be written.
|
|
17778
|
+
function draftChain(draft, dir) {
|
|
17779
|
+
const byDir = new Map(utils.readSocketJsonChain(dir).map(file => [file.dir, file.sockJson]));
|
|
17780
|
+
for (const {
|
|
17781
|
+
0: fileDir,
|
|
17782
|
+
1: sockJson
|
|
17783
|
+
} of draft.files) {
|
|
17784
|
+
if (isPathInside$1(fileDir, dir)) {
|
|
17785
|
+
byDir.set(fileDir, sockJson);
|
|
17786
|
+
}
|
|
16676
17787
|
}
|
|
16677
|
-
return
|
|
16678
|
-
|
|
16679
|
-
|
|
17788
|
+
return [...byDir].sort((a, b) => a[0].length - b[0].length).map(({
|
|
17789
|
+
0: fileDir,
|
|
17790
|
+
1: sockJson
|
|
17791
|
+
}) => ({
|
|
17792
|
+
dir: fileDir,
|
|
17793
|
+
sockJson
|
|
17794
|
+
}));
|
|
17795
|
+
}
|
|
17796
|
+
function draftCascade(draft, dir) {
|
|
17797
|
+
return utils.mergeSocketJsonChain(draftChain(draft, dir));
|
|
17798
|
+
}
|
|
17799
|
+
function resolveDraftSettings(draft, ecosystem, root) {
|
|
17800
|
+
draft.resolver ??= createBuildRootSettingsResolver(dir => draftChain(draft, dir), draft.warned);
|
|
17801
|
+
return draft.resolver(ecosystem, root);
|
|
16680
17802
|
}
|
|
16681
17803
|
|
|
16682
|
-
//
|
|
16683
|
-
|
|
16684
|
-
|
|
16685
|
-
|
|
16686
|
-
|
|
16687
|
-
cwd,
|
|
16688
|
-
|
|
17804
|
+
// "other build", or "3 other builds".
|
|
17805
|
+
function otherBuilds(count) {
|
|
17806
|
+
return count === 1 ? 'other build' : `${count} other builds`;
|
|
17807
|
+
}
|
|
17808
|
+
function relPath(cwd, file) {
|
|
17809
|
+
return (path.relative(cwd, file) || '.').split(path.sep).join('/');
|
|
17810
|
+
}
|
|
17811
|
+
|
|
17812
|
+
// One build of the walk; a directory holding several builds of one tool has
|
|
17813
|
+
// a prompt, and settings, per build file.
|
|
17814
|
+
|
|
17815
|
+
function buildKey({
|
|
16689
17816
|
ecosystem,
|
|
16690
|
-
|
|
17817
|
+
root
|
|
16691
17818
|
}) {
|
|
16692
|
-
|
|
16693
|
-
|
|
16694
|
-
|
|
16695
|
-
|
|
16696
|
-
|
|
16697
|
-
|
|
16698
|
-
|
|
17819
|
+
return `${ecosystem}\0${buildRootPath(root)}`;
|
|
17820
|
+
}
|
|
17821
|
+
function buildLabel(cwd, {
|
|
17822
|
+
ecosystem,
|
|
17823
|
+
root,
|
|
17824
|
+
sharesDir
|
|
17825
|
+
}) {
|
|
17826
|
+
const where = sharesDir ? relPath(cwd, buildRootPath(root)) : root.dir === cwd ? 'This project' : relPath(cwd, root.dir);
|
|
17827
|
+
return `${where} (${ecosystem})`;
|
|
17828
|
+
}
|
|
17829
|
+
|
|
17830
|
+
// The build file a build's own `builds` entry is keyed by: the one its entry
|
|
17831
|
+
// names, else the first one in its directory.
|
|
17832
|
+
function buildsKeyOf(draft, {
|
|
17833
|
+
ecosystem,
|
|
17834
|
+
root
|
|
17835
|
+
}) {
|
|
17836
|
+
const files = BUILD_FILES[ecosystem];
|
|
17837
|
+
if (files.byFile) {
|
|
17838
|
+
return root.entryFile ?? '';
|
|
16699
17839
|
}
|
|
17840
|
+
return resolveDraftSettings(draft, ecosystem, root).entryKey ?? files.names.find(name => u.existsSync(path.join(root.dir, name))) ?? files.names[0];
|
|
17841
|
+
}
|
|
17842
|
+
// Whether a build's settings go in its own entry, rather than in its
|
|
17843
|
+
// directory's section, which the builds beneath inherit.
|
|
17844
|
+
function writesOwnEntry(draft, build) {
|
|
17845
|
+
return build.sharesDir || !!resolveDraftSettings(draft, build.ecosystem, build.root).entryKey;
|
|
17846
|
+
}
|
|
17847
|
+
function membershipFor(map, ecosystem) {
|
|
17848
|
+
return utils.getOrInsert(map, ecosystem, emptyMembership);
|
|
17849
|
+
}
|
|
17850
|
+
function buildConfig(walk, {
|
|
17851
|
+
ecosystem,
|
|
17852
|
+
root
|
|
17853
|
+
}) {
|
|
17854
|
+
return resolveEcosystemConfig(ecosystem, root.dir, resolveDraftSettings(walk.draft, ecosystem, root).sockJson);
|
|
17855
|
+
}
|
|
17856
|
+
|
|
17857
|
+
// Whether a build `covered` stands for already loads `build`.
|
|
17858
|
+
async function isLoadedBy(walk, covered, build) {
|
|
17859
|
+
return await isBuildCovered(covered, build.ecosystem, build.root, buildToolScriptOptions(buildConfig(walk, build), walk.cwd, walk.excludePaths));
|
|
17860
|
+
}
|
|
16700
17861
|
|
|
16701
|
-
|
|
16702
|
-
|
|
16703
|
-
|
|
16704
|
-
|
|
16705
|
-
|
|
16706
|
-
|
|
17862
|
+
// Keeps only answers that differ from what the build would inherit; a
|
|
17863
|
+
// directory section also sets defaults for the builds beneath it.
|
|
17864
|
+
async function configureBuild(draft, cwd, build) {
|
|
17865
|
+
const {
|
|
17866
|
+
ecosystem,
|
|
17867
|
+
root
|
|
17868
|
+
} = build;
|
|
17869
|
+
const key = buildsKeyOf(draft, build);
|
|
17870
|
+
const own = draftSettings(draft, root.dir);
|
|
17871
|
+
const manifest = manifestOf(own);
|
|
17872
|
+
const builds = {
|
|
17873
|
+
...manifest['builds']
|
|
17874
|
+
};
|
|
17875
|
+
const intoEntry = writesOwnEntry(draft, build);
|
|
17876
|
+
const target = intoEntry ? {
|
|
17877
|
+
...builds[key]
|
|
17878
|
+
} : {
|
|
17879
|
+
...getEcosystemSection(own, ecosystem)
|
|
17880
|
+
};
|
|
17881
|
+
const inherited = getEcosystemSection(draftCascade(draft, intoEntry ? root.dir : path.dirname(root.dir)), ecosystem);
|
|
16707
17882
|
const seed = {
|
|
16708
|
-
...getEcosystemSection(
|
|
16709
|
-
...getEcosystemSection(ownSockJson, ecosystem)
|
|
17883
|
+
...getEcosystemSection(resolveDraftSettings(draft, ecosystem, root).sockJson, ecosystem)
|
|
16710
17884
|
};
|
|
17885
|
+
const seeded = Object.keys(seed);
|
|
16711
17886
|
const result = await runEcosystemWizard(ecosystem, seed);
|
|
16712
17887
|
if (!result.ok || result.data.canceled) {
|
|
16713
17888
|
return result;
|
|
16714
17889
|
}
|
|
16715
|
-
const
|
|
16716
|
-
|
|
16717
|
-
|
|
16718
|
-
|
|
17890
|
+
const before = JSON.stringify(target);
|
|
17891
|
+
// An answer the wizard removed leaves the field to inheritance.
|
|
17892
|
+
for (const field of new Set([...seeded, ...Object.keys(seed)])) {
|
|
17893
|
+
if (!Object.hasOwn(seed, field) || seed[field] === inherited[field]) {
|
|
17894
|
+
delete target[field];
|
|
17895
|
+
} else {
|
|
17896
|
+
target[field] = seed[field];
|
|
16719
17897
|
}
|
|
16720
17898
|
}
|
|
16721
|
-
|
|
16722
|
-
|
|
16723
|
-
|
|
16724
|
-
logger.logger.log(`No changes for ${relDir} (${ecosystem}); nothing written.`);
|
|
17899
|
+
const label = buildLabel(cwd, build);
|
|
17900
|
+
if (JSON.stringify(target) === before) {
|
|
17901
|
+
logger.logger.log(`No changes for ${label}.`);
|
|
16725
17902
|
return notCanceled$1();
|
|
16726
17903
|
}
|
|
16727
|
-
|
|
16728
|
-
|
|
16729
|
-
|
|
16730
|
-
|
|
16731
|
-
|
|
17904
|
+
if (intoEntry) {
|
|
17905
|
+
manifest['builds'] = {
|
|
17906
|
+
...builds,
|
|
17907
|
+
[key]: target
|
|
17908
|
+
};
|
|
17909
|
+
stageSettings(draft, root.dir, own, `configure ${key}`);
|
|
17910
|
+
} else {
|
|
17911
|
+
manifest[ecosystem] = target;
|
|
17912
|
+
stageSettings(draft, root.dir, own, `configure ${ecosystem} builds`);
|
|
16732
17913
|
}
|
|
16733
|
-
logger.logger.success(`Configured ${
|
|
17914
|
+
logger.logger.success(`Configured ${label}`);
|
|
16734
17915
|
return notCanceled$1();
|
|
16735
17916
|
}
|
|
16736
|
-
|
|
16737
|
-
//
|
|
16738
|
-
//
|
|
16739
|
-
|
|
17917
|
+
|
|
17918
|
+
// Sets `disabled` for every `ecosystems` in `dir`'s section, so their builds
|
|
17919
|
+
// in and beneath it are skipped, unless the settings above already do.
|
|
17920
|
+
function disableDirectory(draft, dir, ecosystems) {
|
|
17921
|
+
const cascade = draftCascade(draft, dir);
|
|
17922
|
+
const needed = ecosystems.filter(ecosystem => getEcosystemSection(cascade, ecosystem)['disabled'] !== true);
|
|
17923
|
+
if (needed.length) {
|
|
17924
|
+
const own = draftSettings(draft, dir);
|
|
17925
|
+
const manifest = manifestOf(own);
|
|
17926
|
+
for (const ecosystem of needed) {
|
|
17927
|
+
manifest[ecosystem] = {
|
|
17928
|
+
...getEcosystemSection(own, ecosystem),
|
|
17929
|
+
disabled: true
|
|
17930
|
+
};
|
|
17931
|
+
}
|
|
17932
|
+
stageSettings(draft, dir, own, `skip ${needed.join(', ')} builds in and beneath it`);
|
|
17933
|
+
}
|
|
17934
|
+
return needed;
|
|
17935
|
+
}
|
|
17936
|
+
|
|
17937
|
+
// Skips just this build and what it loads, under its own build file.
|
|
17938
|
+
function disableBuild(draft, build) {
|
|
17939
|
+
const {
|
|
17940
|
+
root
|
|
17941
|
+
} = build;
|
|
17942
|
+
const key = buildsKeyOf(draft, build);
|
|
17943
|
+
const own = draftSettings(draft, root.dir);
|
|
17944
|
+
const manifest = manifestOf(own);
|
|
17945
|
+
const builds = manifest['builds'] ?? {};
|
|
17946
|
+
if (builds[key]?.['disabled'] === true) {
|
|
17947
|
+
return;
|
|
17948
|
+
}
|
|
17949
|
+
manifest['builds'] = {
|
|
17950
|
+
...builds,
|
|
17951
|
+
[key]: {
|
|
17952
|
+
...builds[key],
|
|
17953
|
+
disabled: true
|
|
17954
|
+
}
|
|
17955
|
+
};
|
|
17956
|
+
stageSettings(draft, root.dir, own, `skip ${key}`);
|
|
17957
|
+
}
|
|
17958
|
+
|
|
17959
|
+
// Turns a skipped build back on at the setting that skipped it: dropping that
|
|
17960
|
+
// setting where nothing above skips the build too, else overriding it.
|
|
17961
|
+
function enableBuild(draft, build, disabledBy) {
|
|
17962
|
+
const {
|
|
17963
|
+
ecosystem,
|
|
17964
|
+
root
|
|
17965
|
+
} = build;
|
|
17966
|
+
const own = draftSettings(draft, disabledBy.dir);
|
|
17967
|
+
const manifest = manifestOf(own);
|
|
17968
|
+
const target = disabledBy.key ? {
|
|
17969
|
+
...manifest['builds']?.[disabledBy.key]
|
|
17970
|
+
} : getEcosystemSection(own, ecosystem);
|
|
17971
|
+
delete target['disabled'];
|
|
17972
|
+
const place = value => {
|
|
17973
|
+
if (disabledBy.key) {
|
|
17974
|
+
manifest['builds'] = {
|
|
17975
|
+
...manifest['builds'],
|
|
17976
|
+
[disabledBy.key]: value
|
|
17977
|
+
};
|
|
17978
|
+
} else {
|
|
17979
|
+
manifest[ecosystem] = value;
|
|
17980
|
+
}
|
|
17981
|
+
};
|
|
17982
|
+
place(target);
|
|
17983
|
+
setDraftFile(draft, disabledBy.dir, own);
|
|
17984
|
+
if (resolveDraftSettings(draft, ecosystem, root).disabledBy) {
|
|
17985
|
+
place({
|
|
17986
|
+
...target,
|
|
17987
|
+
disabled: false
|
|
17988
|
+
});
|
|
17989
|
+
}
|
|
17990
|
+
stageSettings(draft, disabledBy.dir, own, disabledBy.key ? `build ${disabledBy.key} again` : `build ${ecosystem} builds here again`);
|
|
17991
|
+
}
|
|
17992
|
+
// The build tool could not load `build`. Fixing its settings comes first: a
|
|
17993
|
+
// build Socket can load is built once with its modules, and skips exactly.
|
|
17994
|
+
async function askCantLoad(walk, build, allowDirectory) {
|
|
17995
|
+
const label = buildLabel(walk.cwd, build);
|
|
17996
|
+
const relDir = relPath(walk.cwd, build.root.dir);
|
|
17997
|
+
const beneath = walk.builds.filter(other => other !== build && isPathInside$1(build.root.dir, other.root.dir) && !walk.decided.has(buildKey(other))).length;
|
|
17998
|
+
const skipNotes = [...(beneath ? [`Also skips the ${otherBuilds(beneath)} in and beneath ${relDir}/. To build one of them, run \`${DSI_SETUP_COMMAND}\` in its directory.`] : []), `Modules of ${relPath(walk.cwd, buildRootPath(build.root))} outside ${relDir}/ can't be found without loading it, so they are asked about separately.`];
|
|
16740
17999
|
return await prompts.select({
|
|
16741
|
-
message:
|
|
18000
|
+
message: `Socket could not load ${label} (see above). Builds Socket can load are built once with all their modules, and can be skipped without skipping the builds next to them. What should happen with it?`,
|
|
16742
18001
|
choices: [{
|
|
16743
|
-
name: '
|
|
16744
|
-
value: 'inherit',
|
|
16745
|
-
description: "Make no change - keep this project's current effective configuration"
|
|
16746
|
-
}, {
|
|
16747
|
-
name: 'Configure',
|
|
18002
|
+
name: 'Configure it and try again',
|
|
16748
18003
|
value: 'configure',
|
|
16749
|
-
description: 'Set
|
|
18004
|
+
description: 'Set the JDK, build tool or options, then load it again'
|
|
18005
|
+
}, allowDirectory ? {
|
|
18006
|
+
name: `Skip ${relDir}/ and everything beneath it, without loading it`,
|
|
18007
|
+
value: 'directory',
|
|
18008
|
+
description: skipNotes.join(' ')
|
|
18009
|
+
} : {
|
|
18010
|
+
name: 'Go on without loading it',
|
|
18011
|
+
value: 'directory',
|
|
18012
|
+
description: 'The builds it would include are asked about separately'
|
|
18013
|
+
}, {
|
|
18014
|
+
name: 'Stop',
|
|
18015
|
+
value: 'stop'
|
|
16750
18016
|
}],
|
|
16751
|
-
default: '
|
|
18017
|
+
default: 'configure'
|
|
16752
18018
|
});
|
|
16753
18019
|
}
|
|
16754
|
-
//
|
|
16755
|
-
|
|
16756
|
-
|
|
16757
|
-
//
|
|
16758
|
-
|
|
16759
|
-
|
|
16760
|
-
|
|
16761
|
-
|
|
16762
|
-
|
|
16763
|
-
|
|
16764
|
-
|
|
16765
|
-
const action = await askCandidateAction(relDir, ecosystem);
|
|
16766
|
-
if (action === undefined || action === null) {
|
|
16767
|
-
canceledByUser$1();
|
|
16768
|
-
return {
|
|
16769
|
-
ok: true,
|
|
16770
|
-
data: {
|
|
16771
|
-
canceled: true,
|
|
16772
|
-
outcome: 'inherited'
|
|
16773
|
-
}
|
|
16774
|
-
};
|
|
16775
|
-
}
|
|
16776
|
-
if (action === 'configure') {
|
|
16777
|
-
const result = await configureCandidate({
|
|
16778
|
-
cwd,
|
|
16779
|
-
dir,
|
|
16780
|
-
ecosystem,
|
|
16781
|
-
rootSockJson
|
|
18020
|
+
// Loads `build`, and while that fails, asks how to go on.
|
|
18021
|
+
async function loadOrAsk(walk, build, allowDirectory = true) {
|
|
18022
|
+
for (;;) {
|
|
18023
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18024
|
+
const loaded = await loadBuild({
|
|
18025
|
+
config: buildConfig(walk, build),
|
|
18026
|
+
ecosystem: build.ecosystem,
|
|
18027
|
+
excludePaths: walk.excludePaths,
|
|
18028
|
+
root: build.root,
|
|
18029
|
+
scanRoot: walk.cwd,
|
|
18030
|
+
verbose: false
|
|
16782
18031
|
});
|
|
16783
|
-
if (
|
|
16784
|
-
return result;
|
|
16785
|
-
}
|
|
16786
|
-
return {
|
|
16787
|
-
ok: true,
|
|
16788
|
-
data: {
|
|
16789
|
-
...result.data,
|
|
16790
|
-
outcome: 'configured'
|
|
16791
|
-
}
|
|
16792
|
-
};
|
|
16793
|
-
}
|
|
16794
|
-
// 'inherit', or any unexpected value - the safe no-op default.
|
|
16795
|
-
return {
|
|
16796
|
-
ok: true,
|
|
16797
|
-
data: {
|
|
16798
|
-
canceled: false,
|
|
16799
|
-
outcome: 'inherited'
|
|
16800
|
-
}
|
|
16801
|
-
};
|
|
16802
|
-
}
|
|
16803
|
-
|
|
16804
|
-
// Prompts for configure/inherit, unless the cascade shows the candidate
|
|
16805
|
-
// disabled: offer to re-enable if that's its own file, then continue into
|
|
16806
|
-
// the normal prompt; stay silent if it's only inherited from an ancestor's
|
|
16807
|
-
// bulk write (that's noise for a large excluded subtree).
|
|
16808
|
-
async function processCandidate({
|
|
16809
|
-
cwd,
|
|
16810
|
-
dir,
|
|
16811
|
-
ecosystem,
|
|
16812
|
-
rootSockJson
|
|
16813
|
-
}) {
|
|
16814
|
-
const relDir = path.relative(cwd, dir) || '.';
|
|
16815
|
-
const cascade = utils.readSocketJsonCascade(dir, cwd, rootSockJson);
|
|
16816
|
-
if (getEcosystemSection(cascade, ecosystem)['disabled'] === true) {
|
|
16817
|
-
const ownSockJson = utils.readOrDefaultSocketJson(dir);
|
|
16818
|
-
if (getEcosystemSection(ownSockJson, ecosystem)['disabled'] !== true) {
|
|
16819
|
-
// Inherited from an ancestor, not this candidate's own file - stay silent.
|
|
18032
|
+
if (loaded) {
|
|
16820
18033
|
return {
|
|
16821
18034
|
ok: true,
|
|
16822
18035
|
data: {
|
|
16823
18036
|
canceled: false,
|
|
16824
|
-
|
|
16825
|
-
reenabled: false
|
|
18037
|
+
loaded
|
|
16826
18038
|
}
|
|
16827
18039
|
};
|
|
16828
18040
|
}
|
|
16829
|
-
|
|
16830
|
-
|
|
16831
|
-
|
|
18041
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18042
|
+
const action = await askCantLoad(walk, build, allowDirectory);
|
|
18043
|
+
if (action === null || action === undefined) {
|
|
18044
|
+
return canceledByUser$1();
|
|
18045
|
+
}
|
|
18046
|
+
if (action === 'stop') {
|
|
16832
18047
|
return {
|
|
16833
|
-
ok:
|
|
16834
|
-
|
|
16835
|
-
canceled: true,
|
|
16836
|
-
outcome: 'skipped',
|
|
16837
|
-
reenabled: false
|
|
16838
|
-
}
|
|
18048
|
+
ok: false,
|
|
18049
|
+
message: `Stopped: Socket could not load ${buildLabel(walk.cwd, build)}.`
|
|
16839
18050
|
};
|
|
16840
18051
|
}
|
|
16841
|
-
if (
|
|
18052
|
+
if (action === 'directory') {
|
|
16842
18053
|
return {
|
|
16843
18054
|
ok: true,
|
|
16844
18055
|
data: {
|
|
16845
18056
|
canceled: false,
|
|
16846
|
-
|
|
16847
|
-
reenabled: false
|
|
18057
|
+
loaded: 'directory'
|
|
16848
18058
|
}
|
|
16849
18059
|
};
|
|
16850
18060
|
}
|
|
16851
|
-
|
|
16852
|
-
|
|
16853
|
-
|
|
16854
|
-
|
|
16855
|
-
ownSockJson.defaults.manifest = {};
|
|
18061
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18062
|
+
const configured = await configureBuild(walk.draft, walk.cwd, build);
|
|
18063
|
+
if (!configured.ok || configured.data.canceled) {
|
|
18064
|
+
return configured;
|
|
16856
18065
|
}
|
|
16857
|
-
|
|
16858
|
-
|
|
16859
|
-
|
|
16860
|
-
|
|
16861
|
-
|
|
16862
|
-
|
|
16863
|
-
|
|
16864
|
-
|
|
18066
|
+
}
|
|
18067
|
+
}
|
|
18068
|
+
|
|
18069
|
+
// Skips `build`'s directory and everything beneath it, unasked.
|
|
18070
|
+
function skipDirectory(walk, build) {
|
|
18071
|
+
const beneath = walk.builds.filter(other => other !== build && isPathInside$1(build.root.dir, other.root.dir));
|
|
18072
|
+
disableDirectory(walk.draft, build.root.dir, [...new Set([build.ecosystem, ...beneath.map(other => other.ecosystem)])]);
|
|
18073
|
+
for (const other of [build, ...beneath]) {
|
|
18074
|
+
if (!walk.decided.has(buildKey(other))) {
|
|
18075
|
+
walk.decided.add(buildKey(other));
|
|
18076
|
+
walk.counts.skipped += 1;
|
|
16865
18077
|
}
|
|
16866
|
-
|
|
16867
|
-
|
|
16868
|
-
|
|
16869
|
-
|
|
16870
|
-
|
|
16871
|
-
|
|
16872
|
-
|
|
16873
|
-
|
|
16874
|
-
|
|
16875
|
-
|
|
18078
|
+
}
|
|
18079
|
+
logger.logger.success(`Skipped ${relPath(walk.cwd, build.root.dir)}/ and everything beneath it.`);
|
|
18080
|
+
}
|
|
18081
|
+
|
|
18082
|
+
// A scan skips the modules of a build skipped under its own name, so the
|
|
18083
|
+
// wizard doesn't ask about them either.
|
|
18084
|
+
async function loadInto(walk, build, into, {
|
|
18085
|
+
allowDirectory = true,
|
|
18086
|
+
announce = true
|
|
18087
|
+
} = {}) {
|
|
18088
|
+
const result = await loadOrAsk(walk, build, allowDirectory);
|
|
18089
|
+
if (!result.ok || result.data.canceled) {
|
|
18090
|
+
return result;
|
|
18091
|
+
}
|
|
18092
|
+
const {
|
|
18093
|
+
loaded
|
|
18094
|
+
} = result.data;
|
|
18095
|
+
if (loaded === 'directory') {
|
|
18096
|
+
if (allowDirectory) {
|
|
18097
|
+
skipDirectory(walk, build);
|
|
16876
18098
|
}
|
|
16877
|
-
|
|
16878
|
-
|
|
16879
|
-
|
|
16880
|
-
|
|
16881
|
-
|
|
18099
|
+
} else if (loaded) {
|
|
18100
|
+
addMembership(membershipFor(walk[into], build.ecosystem), loaded.membership);
|
|
18101
|
+
if (into === 'skipped') {
|
|
18102
|
+
disableBuild(walk.draft, build);
|
|
18103
|
+
walk.counts.skipped += 1;
|
|
18104
|
+
if (announce) {
|
|
18105
|
+
logger.logger.success(`Skipped ${withModules(relPath(walk.cwd, buildRootPath(build.root)), loaded.modules)}.`);
|
|
16882
18106
|
}
|
|
16883
|
-
}
|
|
18107
|
+
}
|
|
16884
18108
|
}
|
|
16885
|
-
|
|
16886
|
-
|
|
16887
|
-
|
|
16888
|
-
|
|
16889
|
-
|
|
16890
|
-
|
|
18109
|
+
return notCanceled$1();
|
|
18110
|
+
}
|
|
18111
|
+
async function askBuildAction(label) {
|
|
18112
|
+
return await prompts.select({
|
|
18113
|
+
message: label,
|
|
18114
|
+
choices: [{
|
|
18115
|
+
name: 'Leave as-is',
|
|
18116
|
+
value: 'inherit',
|
|
18117
|
+
description: 'Build it with its current settings'
|
|
18118
|
+
}, {
|
|
18119
|
+
name: 'Configure',
|
|
18120
|
+
value: 'configure',
|
|
18121
|
+
description: 'Set the JDK, build tool or options for it'
|
|
18122
|
+
}, {
|
|
18123
|
+
name: 'Skip',
|
|
18124
|
+
value: 'skip',
|
|
18125
|
+
description: "Don't build it or its modules"
|
|
18126
|
+
}],
|
|
18127
|
+
default: 'inherit'
|
|
16891
18128
|
});
|
|
16892
|
-
|
|
16893
|
-
|
|
16894
|
-
}
|
|
18129
|
+
}
|
|
18130
|
+
function decided(load) {
|
|
16895
18131
|
return {
|
|
16896
18132
|
ok: true,
|
|
16897
18133
|
data: {
|
|
16898
|
-
|
|
16899
|
-
|
|
18134
|
+
canceled: false,
|
|
18135
|
+
load
|
|
16900
18136
|
}
|
|
16901
18137
|
};
|
|
16902
18138
|
}
|
|
16903
18139
|
|
|
16904
|
-
//
|
|
16905
|
-
|
|
16906
|
-
|
|
16907
|
-
|
|
16908
|
-
|
|
16909
|
-
|
|
16910
|
-
|
|
16911
|
-
|
|
18140
|
+
// What to load `build` into, as decided; none for a build skipped unloaded.
|
|
18141
|
+
async function reviewBuild(walk, build) {
|
|
18142
|
+
walk.decided.add(buildKey(build));
|
|
18143
|
+
const label = buildLabel(walk.cwd, build);
|
|
18144
|
+
const {
|
|
18145
|
+
disabledBy
|
|
18146
|
+
} = resolveDraftSettings(walk.draft, build.ecosystem, build.root);
|
|
18147
|
+
if (disabledBy) {
|
|
18148
|
+
// A directory skip from above covers this build silently; the setting
|
|
18149
|
+
// that names this build or its directory is offered back.
|
|
18150
|
+
if (!disabledBy.key && disabledBy.dir !== build.root.dir) {
|
|
18151
|
+
walk.counts.skipped += 1;
|
|
18152
|
+
return notCanceled$1();
|
|
18153
|
+
}
|
|
18154
|
+
const again = await askYesNo(`${label} is skipped. Build it again?`);
|
|
18155
|
+
if (again === null || again === undefined) {
|
|
18156
|
+
return canceledByUser$1();
|
|
18157
|
+
}
|
|
18158
|
+
if (!again) {
|
|
18159
|
+
if (!disabledBy.key) {
|
|
18160
|
+
walk.counts.skipped += 1;
|
|
18161
|
+
return notCanceled$1();
|
|
18162
|
+
}
|
|
18163
|
+
return decided({
|
|
18164
|
+
announce: false,
|
|
18165
|
+
into: 'skipped'
|
|
18166
|
+
});
|
|
18167
|
+
}
|
|
18168
|
+
enableBuild(walk.draft, build, disabledBy);
|
|
16912
18169
|
}
|
|
16913
|
-
|
|
16914
|
-
|
|
16915
|
-
|
|
16916
|
-
|
|
16917
|
-
|
|
16918
|
-
|
|
16919
|
-
|
|
16920
|
-
|
|
16921
|
-
|
|
16922
|
-
|
|
16923
|
-
|
|
16924
|
-
|
|
16925
|
-
|
|
18170
|
+
const action = await askBuildAction(label);
|
|
18171
|
+
if (action === null || action === undefined) {
|
|
18172
|
+
return canceledByUser$1();
|
|
18173
|
+
}
|
|
18174
|
+
if (action === 'skip') {
|
|
18175
|
+
return decided({
|
|
18176
|
+
announce: true,
|
|
18177
|
+
into: 'skipped'
|
|
18178
|
+
});
|
|
18179
|
+
}
|
|
18180
|
+
if (action === 'configure') {
|
|
18181
|
+
const configured = await configureBuild(walk.draft, walk.cwd, build);
|
|
18182
|
+
if (!configured.ok || configured.data.canceled) {
|
|
18183
|
+
return configured;
|
|
18184
|
+
}
|
|
18185
|
+
walk.counts.configured += 1;
|
|
18186
|
+
} else {
|
|
18187
|
+
walk.counts.inherited += 1;
|
|
18188
|
+
}
|
|
18189
|
+
return decided({
|
|
18190
|
+
announce: true,
|
|
18191
|
+
into: 'covered'
|
|
16926
18192
|
});
|
|
16927
18193
|
}
|
|
16928
18194
|
|
|
16929
|
-
//
|
|
16930
|
-
//
|
|
16931
|
-
//
|
|
16932
|
-
//
|
|
16933
|
-
//
|
|
16934
|
-
|
|
16935
|
-
|
|
16936
|
-
|
|
16937
|
-
const jsonPath = path.join(cwd, constants.SOCKET_JSON);
|
|
16938
|
-
if (u.existsSync(jsonPath)) {
|
|
16939
|
-
logger.logger.info(`Found ${constants.SOCKET_JSON} at ${jsonPath}`);
|
|
16940
|
-
} else {
|
|
16941
|
-
logger.logger.info(`No ${constants.SOCKET_JSON} found at ${cwd}, will generate a new one`);
|
|
18195
|
+
// Dispatches to the right ecosystem-specific wizard. `factsOnly` skips the
|
|
18196
|
+
// facts/pom question - dynamic-sbom-inference never generates a pom.xml, it
|
|
18197
|
+
// just skips a project resolved to `facts: false` (see
|
|
18198
|
+
// generateRecursiveManifests' skipReason), so offering that choice here
|
|
18199
|
+
// would be misleading.
|
|
18200
|
+
async function runEcosystemWizard(ecosystem, config) {
|
|
18201
|
+
if (ecosystem === 'dotnet') {
|
|
18202
|
+
return await setupDotnet(config);
|
|
16942
18203
|
}
|
|
16943
|
-
|
|
16944
|
-
|
|
16945
|
-
|
|
16946
|
-
|
|
16947
|
-
logger.logger.log('');
|
|
16948
|
-
logger.logger.log(`This command will generate a ${constants.SOCKET_JSON} file in ${cwd}.`);
|
|
16949
|
-
logger.logger.log('socket.json properties are inherited by nested paths.');
|
|
16950
|
-
logger.logger.log('');
|
|
16951
|
-
const sockJsonCResult = utils.readSocketJsonSync(cwd, defaultOnReadError);
|
|
16952
|
-
if (!sockJsonCResult.ok) {
|
|
16953
|
-
return sockJsonCResult;
|
|
18204
|
+
if (ecosystem === 'gradle') {
|
|
18205
|
+
return await setupGradle(config, {
|
|
18206
|
+
factsOnly: true
|
|
18207
|
+
});
|
|
16954
18208
|
}
|
|
16955
|
-
|
|
16956
|
-
|
|
16957
|
-
sockJson.defaults = {};
|
|
18209
|
+
if (ecosystem === 'maven') {
|
|
18210
|
+
return await setupMaven(config);
|
|
16958
18211
|
}
|
|
16959
|
-
|
|
16960
|
-
|
|
18212
|
+
return await setupSbt(config, {
|
|
18213
|
+
factsOnly: true
|
|
18214
|
+
});
|
|
18215
|
+
}
|
|
18216
|
+
|
|
18217
|
+
// Accepting every prompt's default leaves an ecosystem's section empty (see
|
|
18218
|
+
// askForBin in setup-manifest-config.mts); an empty one changes nothing.
|
|
18219
|
+
function dropIfEmpty(manifest, ecosystem) {
|
|
18220
|
+
const section = manifest[ecosystem];
|
|
18221
|
+
if (section && Object.keys(section).length) {
|
|
18222
|
+
return true;
|
|
16961
18223
|
}
|
|
16962
|
-
|
|
16963
|
-
|
|
18224
|
+
delete manifest[ecosystem];
|
|
18225
|
+
return false;
|
|
18226
|
+
}
|
|
18227
|
+
async function askYesNo(message) {
|
|
18228
|
+
return await prompts.select({
|
|
18229
|
+
message,
|
|
18230
|
+
choices: [{
|
|
18231
|
+
name: 'Yes',
|
|
18232
|
+
value: true
|
|
18233
|
+
}, {
|
|
18234
|
+
name: 'No',
|
|
18235
|
+
value: false
|
|
18236
|
+
}]
|
|
18237
|
+
});
|
|
18238
|
+
}
|
|
18239
|
+
|
|
18240
|
+
// Defaults for the builds in and beneath cwd. A skip that applies here, from
|
|
18241
|
+
// this directory's socket.json or one above it, is offered back first. A tool's
|
|
18242
|
+
// only build at cwd, without an entry of its own, sets them from its prompt.
|
|
18243
|
+
async function setupRootDefaults(draft, cwd, ecosystems, buildsAtCwd) {
|
|
16964
18244
|
for (const ecosystem of ecosystems) {
|
|
16965
18245
|
const label = ECOSYSTEM_LABELS[ecosystem];
|
|
16966
|
-
const
|
|
16967
|
-
|
|
18246
|
+
const {
|
|
18247
|
+
disabledBy
|
|
18248
|
+
} = resolveDraftSettings(draft, ecosystem, {
|
|
18249
|
+
dir: cwd
|
|
18250
|
+
});
|
|
18251
|
+
if (disabledBy && !disabledBy.key) {
|
|
18252
|
+
const where = disabledBy.dir === cwd ? `${label} builds here are skipped.` : `${socketJsonPath(disabledBy.dir)} skips ${label} builds in and beneath ${displayPath(disabledBy.dir)}, including this directory.`;
|
|
16968
18253
|
// eslint-disable-next-line no-await-in-loop
|
|
16969
|
-
const
|
|
16970
|
-
if (
|
|
18254
|
+
const again = await askYesNo(`${where} Build the ${label} projects here?`);
|
|
18255
|
+
if (again === null || again === undefined) {
|
|
16971
18256
|
return canceledByUser$1();
|
|
16972
18257
|
}
|
|
16973
|
-
if (!
|
|
18258
|
+
if (!again) {
|
|
16974
18259
|
continue;
|
|
16975
18260
|
}
|
|
16976
|
-
|
|
16977
|
-
|
|
18261
|
+
const own = draftSettings(draft, cwd);
|
|
18262
|
+
const manifest = manifestOf(own);
|
|
18263
|
+
manifest[ecosystem] = {
|
|
18264
|
+
...getEcosystemSection(own, ecosystem),
|
|
18265
|
+
disabled: false
|
|
18266
|
+
};
|
|
18267
|
+
stageSettings(draft, cwd, own, `build ${label} projects here again`);
|
|
18268
|
+
}
|
|
18269
|
+
const atCwd = buildsAtCwd(ecosystem);
|
|
18270
|
+
if (atCwd.length === 1 && !writesOwnEntry(draft, {
|
|
18271
|
+
ecosystem,
|
|
18272
|
+
root: atCwd[0],
|
|
18273
|
+
sharesDir: false
|
|
18274
|
+
})) {
|
|
18275
|
+
continue;
|
|
16978
18276
|
}
|
|
16979
|
-
const message =
|
|
18277
|
+
const message = atCwd.length ? `Configure ${label} defaults for the projects here and beneath?` : `Configure ${label} defaults for any nested projects?`;
|
|
16980
18278
|
// eslint-disable-next-line no-await-in-loop
|
|
16981
18279
|
const wants = await askYesNo(message);
|
|
16982
18280
|
if (wants === undefined || wants === null) {
|
|
@@ -16985,49 +18283,66 @@ async function setupRecursiveRootDefaults(cwd, defaultOnReadError, ecosystems, e
|
|
|
16985
18283
|
if (!wants) {
|
|
16986
18284
|
continue;
|
|
16987
18285
|
}
|
|
16988
|
-
|
|
16989
|
-
|
|
16990
|
-
|
|
18286
|
+
const own = draftSettings(draft, cwd);
|
|
18287
|
+
const manifest = manifestOf(own);
|
|
18288
|
+
const section = {
|
|
18289
|
+
...getEcosystemSection(own, ecosystem)
|
|
18290
|
+
};
|
|
18291
|
+
manifest[ecosystem] = section;
|
|
16991
18292
|
// eslint-disable-next-line no-await-in-loop
|
|
16992
|
-
const result = await runEcosystemWizard(ecosystem,
|
|
18293
|
+
const result = await runEcosystemWizard(ecosystem, section);
|
|
16993
18294
|
if (!result.ok || result.data.canceled) {
|
|
16994
18295
|
return result;
|
|
16995
18296
|
}
|
|
16996
18297
|
if (dropIfEmpty(manifest, ecosystem)) {
|
|
16997
|
-
|
|
18298
|
+
stageSettings(draft, cwd, own, `configure ${label} defaults`);
|
|
16998
18299
|
}
|
|
16999
18300
|
}
|
|
17000
|
-
|
|
17001
|
-
|
|
17002
|
-
|
|
18301
|
+
return notCanceled$1();
|
|
18302
|
+
}
|
|
18303
|
+
async function confirmAndWrite(draft, cwd) {
|
|
18304
|
+
if (!draft.files.size) {
|
|
18305
|
+
logger.logger.log('Nothing to write: no settings changed.');
|
|
17003
18306
|
return notCanceled$1();
|
|
17004
18307
|
}
|
|
17005
|
-
|
|
17006
|
-
|
|
17007
|
-
|
|
17008
|
-
|
|
17009
|
-
|
|
17010
|
-
|
|
18308
|
+
const dirs = [...draft.files.keys()].sort();
|
|
18309
|
+
const files = dirs.map(dir => relPath(cwd, path.join(dir, constants.SOCKET_JSON)));
|
|
18310
|
+
const width = Math.max(...files.map(file => file.length));
|
|
18311
|
+
logger.logger.log(`Ready to write ${dirs.length} ${words.pluralize('file', dirs.length)}:`);
|
|
18312
|
+
for (const {
|
|
18313
|
+
0: index,
|
|
18314
|
+
1: dir
|
|
18315
|
+
} of dirs.entries()) {
|
|
18316
|
+
logger.logger.log(` ${files[index].padEnd(width)} ${(draft.notes.get(dir) ?? []).join('; ')}`);
|
|
18317
|
+
}
|
|
18318
|
+
const write = await askYesNo(dirs.length === 1 ? 'Write it?' : 'Write them?');
|
|
18319
|
+
if (write === null || write === undefined) {
|
|
18320
|
+
return canceledByUser$1();
|
|
18321
|
+
}
|
|
18322
|
+
if (!write) {
|
|
18323
|
+
logger.logger.log('Nothing written.');
|
|
18324
|
+
return notCanceled$1();
|
|
18325
|
+
}
|
|
18326
|
+
for (const dir of dirs) {
|
|
18327
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18328
|
+
const result = await utils.writeSocketJson(dir, draft.files.get(dir));
|
|
18329
|
+
if (!result.ok) {
|
|
18330
|
+
return result;
|
|
18331
|
+
}
|
|
17011
18332
|
}
|
|
18333
|
+
logger.logger.success(`Wrote ${arrays.joinAnd(files)}`);
|
|
17012
18334
|
return notCanceled$1();
|
|
17013
18335
|
}
|
|
17014
18336
|
|
|
17015
|
-
//
|
|
17016
|
-
// scanBuildRoots) only ever answers "which build tools exist", never "which
|
|
17017
|
-
// projects to configure". `--exclude-paths` matches are bulk-disabled
|
|
17018
|
-
// unconditionally, independent of the interactive walk below, so re-running
|
|
17019
|
-
// later with one more entry (or none) never re-answers settled decisions.
|
|
17020
|
-
// Everything else gets a configure-or-inherit prompt (see processCandidate),
|
|
17021
|
-
// except a workspace member a parent build already declares - learned via
|
|
17022
|
-
// markWorkspaceCoverage right after the parent's own prompt, not a separate
|
|
17023
|
-
// bulk pass, so a reactor member is silently skipped instead of prompted.
|
|
18337
|
+
// Nothing is written until the user confirms the draft.
|
|
17024
18338
|
async function setupRecursiveManifestConfig(cwd, defaultOnReadError, excludePaths) {
|
|
17025
18339
|
logger.logger.log('');
|
|
17026
18340
|
logger.logger.log(`Configuring ${cwd} ...`);
|
|
17027
|
-
const
|
|
17028
|
-
|
|
17029
|
-
|
|
17030
|
-
|
|
18341
|
+
const ownRead = utils.readSocketJsonSync(cwd, defaultOnReadError);
|
|
18342
|
+
if (!ownRead.ok) {
|
|
18343
|
+
return ownRead;
|
|
18344
|
+
}
|
|
18345
|
+
// Candidate dirs come back realpath-resolved; cwd must match.
|
|
17031
18346
|
const realCwd = await utils.realpathOrResolved(cwd);
|
|
17032
18347
|
logger.logger.log('');
|
|
17033
18348
|
logger.logger.log('Scanning for build roots ...');
|
|
@@ -17037,20 +18352,16 @@ async function setupRecursiveManifestConfig(cwd, defaultOnReadError, excludePath
|
|
|
17037
18352
|
} = await scanBuildRoots({
|
|
17038
18353
|
cwd,
|
|
17039
18354
|
excludePaths,
|
|
17040
|
-
sockJson: withoutDisabledFlags(
|
|
18355
|
+
sockJson: withoutDisabledFlags(ownRead.data)
|
|
17041
18356
|
});
|
|
17042
|
-
// includedByTool
|
|
17043
|
-
//
|
|
17044
|
-
// either - there'd be nothing left for its root defaults to apply to.
|
|
18357
|
+
// includedByTool, so an ecosystem whose only builds --exclude-paths
|
|
18358
|
+
// excludes isn't offered.
|
|
17045
18359
|
const detectedEcosystems = ROOT_ECOSYSTEMS.filter(ecosystem => (includedByTool.get(ecosystem)?.length ?? 0) > 0);
|
|
17046
18360
|
if (detectedEcosystems.length) {
|
|
17047
18361
|
logger.logger.log(`Detected: ${detectedEcosystems.map(ecosystem => ECOSYSTEM_LABELS[ecosystem]).join(', ')}.`);
|
|
17048
18362
|
} else {
|
|
17049
18363
|
logger.logger.log(`No Gradle, Maven, sbt or .NET build roots found beneath ${cwd}.`);
|
|
17050
|
-
//
|
|
17051
|
-
// that's a deliberate choice and setup still proceeds normally below.
|
|
17052
|
-
// Zero build roots anywhere means --dynamic-sbom-inference doesn't apply
|
|
17053
|
-
// to this target at all, so fail rather than silently do nothing.
|
|
18364
|
+
// Builds that --exclude-paths excludes are a choice, not an absence.
|
|
17054
18365
|
const hasAnyBuildRoot = ROOT_ECOSYSTEMS.some(ecosystem => (fullByTool.get(ecosystem)?.length ?? 0) > 0);
|
|
17055
18366
|
if (!hasAnyBuildRoot) {
|
|
17056
18367
|
return {
|
|
@@ -17061,22 +18372,15 @@ async function setupRecursiveManifestConfig(cwd, defaultOnReadError, excludePath
|
|
|
17061
18372
|
}
|
|
17062
18373
|
}
|
|
17063
18374
|
logger.logger.log('');
|
|
17064
|
-
|
|
17065
|
-
|
|
17066
|
-
|
|
17067
|
-
|
|
17068
|
-
const rootResult = await setupRecursiveRootDefaults(cwd, defaultOnReadError, detectedEcosystems, ecosystemsAtCwd);
|
|
17069
|
-
if (!rootResult.ok) {
|
|
18375
|
+
const draft = createSettingsDraft();
|
|
18376
|
+
const atCwd = ecosystem => (includedByTool.get(ecosystem) ?? []).filter(root => root.dir === realCwd);
|
|
18377
|
+
const rootResult = await setupRootDefaults(draft, realCwd, detectedEcosystems, atCwd);
|
|
18378
|
+
if (!rootResult.ok || rootResult.data.canceled) {
|
|
17070
18379
|
return rootResult;
|
|
17071
18380
|
}
|
|
17072
|
-
if (rootResult.data.canceled) {
|
|
17073
|
-
return canceledByUser$1();
|
|
17074
|
-
}
|
|
17075
|
-
|
|
17076
|
-
// Re-read: the root wizard may have just written a new socket.json.
|
|
17077
|
-
const rootSockJson = utils.readOrDefaultSocketJson(cwd);
|
|
17078
18381
|
const {
|
|
17079
18382
|
excluded,
|
|
18383
|
+
excludedBuilds,
|
|
17080
18384
|
included
|
|
17081
18385
|
} = await discoverBuildRoots({
|
|
17082
18386
|
cwd,
|
|
@@ -17084,133 +18388,152 @@ async function setupRecursiveManifestConfig(cwd, defaultOnReadError, excludePath
|
|
|
17084
18388
|
fullByTool,
|
|
17085
18389
|
includedByTool
|
|
17086
18390
|
});
|
|
17087
|
-
|
|
17088
|
-
|
|
17089
|
-
|
|
17090
|
-
|
|
17091
|
-
|
|
17092
|
-
|
|
17093
|
-
|
|
17094
|
-
const orderedExcluded = sortByDepthThenPath(excluded, realCwd);
|
|
17095
|
-
for (const candidate of orderedExcluded) {
|
|
17096
|
-
// eslint-disable-next-line no-await-in-loop
|
|
17097
|
-
const result = await disableExclusionRoot({
|
|
17098
|
-
cwd: realCwd,
|
|
17099
|
-
dir: candidate.dir,
|
|
17100
|
-
ecosystems: candidate.ecosystems,
|
|
17101
|
-
rootSockJson
|
|
17102
|
-
});
|
|
17103
|
-
if (!result.ok) {
|
|
17104
|
-
return result;
|
|
17105
|
-
}
|
|
17106
|
-
}
|
|
17107
|
-
}
|
|
17108
|
-
}
|
|
17109
|
-
if (!included.length) {
|
|
17110
|
-
logger.logger.log('');
|
|
17111
|
-
logger.logger.success('Recursive setup complete.');
|
|
17112
|
-
return notCanceled$1();
|
|
18391
|
+
for (const {
|
|
18392
|
+
ecosystem,
|
|
18393
|
+
root
|
|
18394
|
+
} of excludedBuilds) {
|
|
18395
|
+
disableBuild(draft, {
|
|
18396
|
+
ecosystem,
|
|
18397
|
+
root});
|
|
17113
18398
|
}
|
|
17114
|
-
|
|
17115
|
-
|
|
17116
|
-
|
|
17117
|
-
|
|
18399
|
+
for (const {
|
|
18400
|
+
dir,
|
|
18401
|
+
ecosystems
|
|
18402
|
+
} of sortByDepthThenPath(excluded, realCwd)) {
|
|
18403
|
+
disableDirectory(draft, dir, ecosystems);
|
|
17118
18404
|
}
|
|
17119
|
-
if (!
|
|
17120
|
-
logger.logger.log('');
|
|
17121
|
-
logger.logger.success('Recursive setup complete.');
|
|
17122
|
-
return notCanceled$1();
|
|
18405
|
+
if (excludePaths?.length && !excluded.length && !excludedBuilds.length) {
|
|
18406
|
+
logger.logger.log('None matched --exclude-paths; nothing skipped.');
|
|
17123
18407
|
}
|
|
17124
|
-
|
|
17125
|
-
|
|
17126
|
-
|
|
17127
|
-
|
|
18408
|
+
const builds = sortByDepthThenPath(included, realCwd).flatMap(({
|
|
18409
|
+
ecosystem,
|
|
18410
|
+
roots
|
|
18411
|
+
}) => sortByDepthThenPath(roots, realCwd, ecosystem).map(root => ({
|
|
18412
|
+
ecosystem,
|
|
18413
|
+
root,
|
|
18414
|
+
sharesDir: roots.length > 1
|
|
18415
|
+
})));
|
|
18416
|
+
const walk = {
|
|
18417
|
+
builds,
|
|
18418
|
+
counts: {
|
|
18419
|
+
configured: 0,
|
|
18420
|
+
covered: 0,
|
|
18421
|
+
inherited: 0,
|
|
18422
|
+
skipped: 0
|
|
18423
|
+
},
|
|
18424
|
+
covered: new Map(),
|
|
18425
|
+
cwd: realCwd,
|
|
18426
|
+
decided: new Set(),
|
|
18427
|
+
draft,
|
|
18428
|
+
excludePaths,
|
|
18429
|
+
skipped: new Map()
|
|
18430
|
+
};
|
|
17128
18431
|
|
|
17129
|
-
//
|
|
17130
|
-
|
|
17131
|
-
const
|
|
17132
|
-
|
|
17133
|
-
|
|
17134
|
-
// recognized.
|
|
17135
|
-
for (const ecosystem of ROOT_ECOSYSTEMS) {
|
|
17136
|
-
// eslint-disable-next-line no-await-in-loop
|
|
17137
|
-
const coverageResult = await markWorkspaceCoverage({
|
|
17138
|
-
covered: coveredFor(ecosystem),
|
|
17139
|
-
cwd: realCwd,
|
|
17140
|
-
dir: realCwd,
|
|
18432
|
+
// The builds at cwd are decided first, and loaded only for the review below:
|
|
18433
|
+
// what they include isn't asked about.
|
|
18434
|
+
const cwdBuilds = ROOT_ECOSYSTEMS.flatMap(ecosystem => {
|
|
18435
|
+
const roots = atCwd(ecosystem);
|
|
18436
|
+
return roots.map(root => ({
|
|
17141
18437
|
ecosystem,
|
|
17142
|
-
|
|
17143
|
-
|
|
17144
|
-
|
|
17145
|
-
|
|
17146
|
-
if (!coverageResult.ok) {
|
|
17147
|
-
return coverageResult;
|
|
17148
|
-
}
|
|
17149
|
-
}
|
|
17150
|
-
const counts = {
|
|
17151
|
-
configured: 0,
|
|
17152
|
-
covered: 0,
|
|
17153
|
-
inherited: 0,
|
|
17154
|
-
reenabled: 0,
|
|
17155
|
-
skipped: 0
|
|
17156
|
-
};
|
|
17157
|
-
// A parent is prompted before its children, so a child's shown default
|
|
17158
|
-
// reflects the parent's just-written cascade.
|
|
17159
|
-
const orderedIncluded = sortByDepthThenPath(included, realCwd);
|
|
17160
|
-
for (const candidate of orderedIncluded) {
|
|
18438
|
+
root,
|
|
18439
|
+
sharesDir: roots.length > 1
|
|
18440
|
+
}));
|
|
18441
|
+
}).filter(build => {
|
|
17161
18442
|
const {
|
|
17162
|
-
|
|
17163
|
-
} =
|
|
17164
|
-
|
|
17165
|
-
|
|
17166
|
-
|
|
17167
|
-
|
|
17168
|
-
|
|
18443
|
+
disabledBy
|
|
18444
|
+
} = resolveDraftSettings(draft, build.ecosystem, build.root);
|
|
18445
|
+
return !disabledBy || !!disabledBy.key;
|
|
18446
|
+
});
|
|
18447
|
+
const cwdLoads = [];
|
|
18448
|
+
for (const build of cwdBuilds) {
|
|
17169
18449
|
// eslint-disable-next-line no-await-in-loop
|
|
17170
|
-
const result = await
|
|
17171
|
-
|
|
17172
|
-
dir: candidate.dir,
|
|
17173
|
-
ecosystem,
|
|
17174
|
-
rootSockJson
|
|
17175
|
-
});
|
|
17176
|
-
if (!result.ok) {
|
|
18450
|
+
const result = await reviewBuild(walk, build);
|
|
18451
|
+
if (!result.ok || result.data.canceled) {
|
|
17177
18452
|
return result;
|
|
17178
18453
|
}
|
|
17179
|
-
|
|
17180
|
-
|
|
17181
|
-
|
|
17182
|
-
|
|
17183
|
-
|
|
17184
|
-
|
|
17185
|
-
|
|
17186
|
-
|
|
17187
|
-
|
|
18454
|
+
const {
|
|
18455
|
+
load
|
|
18456
|
+
} = result.data;
|
|
18457
|
+
if (load) {
|
|
18458
|
+
if (load.into === 'skipped') {
|
|
18459
|
+
disableBuild(draft, build);
|
|
18460
|
+
}
|
|
18461
|
+
cwdLoads.push({
|
|
18462
|
+
build,
|
|
18463
|
+
into: load.into
|
|
18464
|
+
});
|
|
17188
18465
|
}
|
|
17189
|
-
|
|
17190
|
-
|
|
17191
|
-
|
|
17192
|
-
|
|
17193
|
-
|
|
18466
|
+
}
|
|
18467
|
+
if (builds.length) {
|
|
18468
|
+
logger.logger.log('');
|
|
18469
|
+
const review = await askYesNo(`Review the ${otherBuilds(builds.length)} found beneath this one?`);
|
|
18470
|
+
if (review === null || review === undefined) {
|
|
18471
|
+
return canceledByUser$1();
|
|
17194
18472
|
}
|
|
17195
|
-
|
|
17196
|
-
|
|
17197
|
-
|
|
17198
|
-
|
|
17199
|
-
|
|
17200
|
-
|
|
17201
|
-
|
|
17202
|
-
|
|
17203
|
-
|
|
17204
|
-
|
|
17205
|
-
|
|
17206
|
-
|
|
17207
|
-
|
|
17208
|
-
|
|
17209
|
-
|
|
18473
|
+
if (review) {
|
|
18474
|
+
for (const {
|
|
18475
|
+
build,
|
|
18476
|
+
into
|
|
18477
|
+
} of cwdLoads) {
|
|
18478
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18479
|
+
const result = await loadInto(walk, build, into, {
|
|
18480
|
+
allowDirectory: false,
|
|
18481
|
+
announce: false
|
|
18482
|
+
});
|
|
18483
|
+
if (!result.ok || result.data.canceled) {
|
|
18484
|
+
return result;
|
|
18485
|
+
}
|
|
18486
|
+
}
|
|
18487
|
+
for (const build of builds) {
|
|
18488
|
+
if (walk.decided.has(buildKey(build))) {
|
|
18489
|
+
continue;
|
|
18490
|
+
}
|
|
18491
|
+
let loaded = false;
|
|
18492
|
+
for (const into of ['covered', 'skipped']) {
|
|
18493
|
+
if (!loaded && (
|
|
18494
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18495
|
+
await isLoadedBy(walk, membershipFor(walk[into], build.ecosystem), build))) {
|
|
18496
|
+
loaded = true;
|
|
18497
|
+
walk.decided.add(buildKey(build));
|
|
18498
|
+
walk.counts[into] += 1;
|
|
18499
|
+
}
|
|
18500
|
+
}
|
|
18501
|
+
if (loaded) {
|
|
18502
|
+
continue;
|
|
18503
|
+
}
|
|
18504
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18505
|
+
const result = await reviewBuild(walk, build);
|
|
18506
|
+
if (!result.ok || result.data.canceled) {
|
|
18507
|
+
return result;
|
|
18508
|
+
}
|
|
18509
|
+
const {
|
|
18510
|
+
load
|
|
18511
|
+
} = result.data;
|
|
18512
|
+
if (load) {
|
|
18513
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18514
|
+
const loaded = await loadInto(walk, build, load.into, {
|
|
18515
|
+
announce: load.announce
|
|
18516
|
+
});
|
|
18517
|
+
if (!loaded.ok || loaded.data.canceled) {
|
|
18518
|
+
return loaded;
|
|
18519
|
+
}
|
|
18520
|
+
}
|
|
18521
|
+
}
|
|
18522
|
+
const {
|
|
18523
|
+
configured,
|
|
18524
|
+
covered,
|
|
18525
|
+
inherited,
|
|
18526
|
+
skipped
|
|
18527
|
+
} = walk.counts;
|
|
18528
|
+
logger.logger.log('');
|
|
18529
|
+
logger.logger.log(`${configured} configured, ${inherited} left as-is, ${skipped} skipped, ${covered} part of another build.`);
|
|
17210
18530
|
}
|
|
17211
18531
|
}
|
|
17212
18532
|
logger.logger.log('');
|
|
17213
|
-
|
|
18533
|
+
const written = await confirmAndWrite(draft, realCwd);
|
|
18534
|
+
if (!written.ok || written.data.canceled) {
|
|
18535
|
+
return written;
|
|
18536
|
+
}
|
|
17214
18537
|
logger.logger.log('');
|
|
17215
18538
|
logger.logger.success('Recursive setup complete.');
|
|
17216
18539
|
return notCanceled$1();
|
|
@@ -17870,7 +19193,7 @@ async function lsPnpm(pkgEnvDetails, options) {
|
|
|
17870
19193
|
__proto__: null,
|
|
17871
19194
|
...options
|
|
17872
19195
|
};
|
|
17873
|
-
if (npmExecPath && npmExecPath !== NPM$1) {
|
|
19196
|
+
if (!constants.default.WIN32 && npmExecPath && npmExecPath !== NPM$1) {
|
|
17874
19197
|
const result = await npmQuery(npmExecPath, cwd);
|
|
17875
19198
|
if (result) {
|
|
17876
19199
|
return result;
|
|
@@ -18565,6 +19888,90 @@ async function run$u(argv, importMeta, {
|
|
|
18565
19888
|
});
|
|
18566
19889
|
}
|
|
18567
19890
|
|
|
19891
|
+
function parsePurlsOption(argv, suppliedPurls) {
|
|
19892
|
+
const hasPurlsOption = argv.some(argument => argument === '--purls' || argument.startsWith('--purls='));
|
|
19893
|
+
if (suppliedPurls === undefined) {
|
|
19894
|
+
return hasPurlsOption ? parseDependenciesPurls([]) : {
|
|
19895
|
+
ok: true,
|
|
19896
|
+
purls: undefined
|
|
19897
|
+
};
|
|
19898
|
+
}
|
|
19899
|
+
if (!hasPurlsOption && Array.isArray(suppliedPurls) && suppliedPurls.length === 0) {
|
|
19900
|
+
return {
|
|
19901
|
+
ok: true,
|
|
19902
|
+
purls: undefined
|
|
19903
|
+
};
|
|
19904
|
+
}
|
|
19905
|
+
if (!Array.isArray(suppliedPurls) || !suppliedPurls.every(value => typeof value === 'string')) {
|
|
19906
|
+
return {
|
|
19907
|
+
ok: false,
|
|
19908
|
+
message: 'Provide at least one non-empty PURL with --purls.'
|
|
19909
|
+
};
|
|
19910
|
+
}
|
|
19911
|
+
return parseDependenciesPurls(suppliedPurls);
|
|
19912
|
+
}
|
|
19913
|
+
function parseDependenciesPurls(values) {
|
|
19914
|
+
if (values === undefined) {
|
|
19915
|
+
return {
|
|
19916
|
+
ok: true,
|
|
19917
|
+
purls: undefined
|
|
19918
|
+
};
|
|
19919
|
+
}
|
|
19920
|
+
const purls = [];
|
|
19921
|
+
const seen = new Set();
|
|
19922
|
+
const purlValues = values.flatMap(value => value.split(','));
|
|
19923
|
+
for (const value of purlValues) {
|
|
19924
|
+
const purl = utils.normalizePurl(value.trim());
|
|
19925
|
+
const parsed = utils.getPurlObject(purl, {
|
|
19926
|
+
throws: false
|
|
19927
|
+
});
|
|
19928
|
+
if (!parsed) {
|
|
19929
|
+
return {
|
|
19930
|
+
ok: false,
|
|
19931
|
+
message: `Invalid PURL "${value}". Use a full PURL such as pkg:npm/minimist@1.2.3.`
|
|
19932
|
+
};
|
|
19933
|
+
}
|
|
19934
|
+
if (Object.keys(parsed.qualifiers ?? {}).length > 0 || parsed.subpath) {
|
|
19935
|
+
return {
|
|
19936
|
+
ok: false,
|
|
19937
|
+
message: `PURL "${value}" includes qualifiers or a subpath, which this search does not support. Search by package identity and version only.`
|
|
19938
|
+
};
|
|
19939
|
+
}
|
|
19940
|
+
if (!seen.has(purl)) {
|
|
19941
|
+
seen.add(purl);
|
|
19942
|
+
purls.push(purl);
|
|
19943
|
+
}
|
|
19944
|
+
}
|
|
19945
|
+
if (purls.length === 0) {
|
|
19946
|
+
return {
|
|
19947
|
+
ok: false,
|
|
19948
|
+
message: 'Provide at least one non-empty PURL with --purls.'
|
|
19949
|
+
};
|
|
19950
|
+
}
|
|
19951
|
+
return {
|
|
19952
|
+
ok: true,
|
|
19953
|
+
purls
|
|
19954
|
+
};
|
|
19955
|
+
}
|
|
19956
|
+
function matchesConfirmedPurls(requested, filters) {
|
|
19957
|
+
if (typeof filters !== 'object' || filters === null) {
|
|
19958
|
+
return false;
|
|
19959
|
+
}
|
|
19960
|
+
if (!('valid' in filters) || !('invalid' in filters)) {
|
|
19961
|
+
return false;
|
|
19962
|
+
}
|
|
19963
|
+
const {
|
|
19964
|
+
invalid,
|
|
19965
|
+
valid
|
|
19966
|
+
} = filters;
|
|
19967
|
+
if (!Array.isArray(valid) || !valid.every(value => typeof value === 'string') || !Array.isArray(invalid) || !invalid.every(value => typeof value === 'string') || invalid.length > 0) {
|
|
19968
|
+
return false;
|
|
19969
|
+
}
|
|
19970
|
+
const expected = new Set(requested);
|
|
19971
|
+
const actual = new Set(valid);
|
|
19972
|
+
return expected.size === requested.length && actual.size === valid.length && expected.size === actual.size && [...expected].every(value => actual.has(value));
|
|
19973
|
+
}
|
|
19974
|
+
|
|
18568
19975
|
async function fetchDependencies(config, options) {
|
|
18569
19976
|
const {
|
|
18570
19977
|
sdkOpts
|
|
@@ -18579,17 +19986,26 @@ async function fetchDependencies(config, options) {
|
|
|
18579
19986
|
const sockSdk = sockSdkCResult.data;
|
|
18580
19987
|
const {
|
|
18581
19988
|
limit,
|
|
18582
|
-
offset
|
|
18583
|
-
|
|
18584
|
-
|
|
18585
|
-
|
|
18586
|
-
};
|
|
18587
|
-
return await utils.handleApiCall(sockSdk.searchDependencies({
|
|
19989
|
+
offset,
|
|
19990
|
+
purls
|
|
19991
|
+
} = config;
|
|
19992
|
+
const result = await utils.handleApiCall(sockSdk.searchDependencies({
|
|
18588
19993
|
limit,
|
|
18589
|
-
offset
|
|
19994
|
+
offset,
|
|
19995
|
+
...(purls === undefined ? {} : {
|
|
19996
|
+
purls
|
|
19997
|
+
})
|
|
18590
19998
|
}), {
|
|
18591
19999
|
description: 'organization dependencies'
|
|
18592
20000
|
});
|
|
20001
|
+
if (result.ok && purls !== undefined && !matchesConfirmedPurls(purls, result.data.purlFilters)) {
|
|
20002
|
+
return {
|
|
20003
|
+
ok: false,
|
|
20004
|
+
message: 'The server did not confirm every requested PURL filter.',
|
|
20005
|
+
cause: 'Review the PURLs and try again. No dependency results were displayed because the filters may not have been applied.'
|
|
20006
|
+
};
|
|
20007
|
+
}
|
|
20008
|
+
return result;
|
|
18593
20009
|
}
|
|
18594
20010
|
|
|
18595
20011
|
// @ts-ignore
|
|
@@ -18655,17 +20071,20 @@ function outputMarkdown(result, {
|
|
|
18655
20071
|
async function handleDependencies({
|
|
18656
20072
|
limit,
|
|
18657
20073
|
offset,
|
|
18658
|
-
outputKind
|
|
20074
|
+
outputKind,
|
|
20075
|
+
purls
|
|
18659
20076
|
}) {
|
|
18660
20077
|
debug.debugFn('notice', `Fetching dependencies with limit=${limit}, offset=${offset}`);
|
|
18661
20078
|
debug.debugDir('inspect', {
|
|
18662
20079
|
limit,
|
|
18663
20080
|
offset,
|
|
18664
|
-
outputKind
|
|
20081
|
+
outputKind,
|
|
20082
|
+
purls
|
|
18665
20083
|
});
|
|
18666
20084
|
const result = await fetchDependencies({
|
|
18667
20085
|
limit,
|
|
18668
|
-
offset
|
|
20086
|
+
offset,
|
|
20087
|
+
purls
|
|
18669
20088
|
});
|
|
18670
20089
|
debug.debugFn('notice', `Dependencies ${result.ok ? 'fetched successfully' : 'fetch failed'}`);
|
|
18671
20090
|
debug.debugDir('inspect', {
|
|
@@ -18703,7 +20122,12 @@ async function run$t(argv, importMeta, {
|
|
|
18703
20122
|
offset: {
|
|
18704
20123
|
type: 'number',
|
|
18705
20124
|
default: 0,
|
|
18706
|
-
description: '
|
|
20125
|
+
description: 'Number of dependencies to skip'
|
|
20126
|
+
},
|
|
20127
|
+
purls: {
|
|
20128
|
+
type: 'string',
|
|
20129
|
+
isMultiple: true,
|
|
20130
|
+
description: 'Search by PURL; pkg: is optional. Comma-separate values or repeat this flag'
|
|
18707
20131
|
},
|
|
18708
20132
|
...flags.outputFlags
|
|
18709
20133
|
},
|
|
@@ -18720,6 +20144,7 @@ async function run$t(argv, importMeta, {
|
|
|
18720
20144
|
Examples
|
|
18721
20145
|
${command}
|
|
18722
20146
|
${command} --limit 20 --offset 10
|
|
20147
|
+
${command} --purls 'npm/minimist@0.0.4,pkg:pypi/requests'
|
|
18723
20148
|
`
|
|
18724
20149
|
};
|
|
18725
20150
|
const cli = utils.meowOrExit({
|
|
@@ -18732,8 +20157,16 @@ async function run$t(argv, importMeta, {
|
|
|
18732
20157
|
json,
|
|
18733
20158
|
limit,
|
|
18734
20159
|
markdown,
|
|
18735
|
-
offset
|
|
20160
|
+
offset,
|
|
20161
|
+
purls: suppliedPurls
|
|
18736
20162
|
} = cli.flags;
|
|
20163
|
+
const parsedPurls = parsePurlsOption(argv, suppliedPurls);
|
|
20164
|
+
if (!parsedPurls.ok) {
|
|
20165
|
+
throw new utils.InputError(parsedPurls.message);
|
|
20166
|
+
}
|
|
20167
|
+
const {
|
|
20168
|
+
purls
|
|
20169
|
+
} = parsedPurls;
|
|
18737
20170
|
const dryRun = !!cli.flags['dryRun'];
|
|
18738
20171
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
18739
20172
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
@@ -18758,7 +20191,8 @@ async function run$t(argv, importMeta, {
|
|
|
18758
20191
|
await handleDependencies({
|
|
18759
20192
|
limit: Number(limit || 0) || 0,
|
|
18760
20193
|
offset: Number(offset || 0) || 0,
|
|
18761
|
-
outputKind
|
|
20194
|
+
outputKind,
|
|
20195
|
+
purls
|
|
18762
20196
|
});
|
|
18763
20197
|
}
|
|
18764
20198
|
|
|
@@ -20112,10 +21546,44 @@ function resolveSocketPatchBin() {
|
|
|
20112
21546
|
// Fallback: assume socket-patch is on PATH.
|
|
20113
21547
|
return 'socket-patch';
|
|
20114
21548
|
}
|
|
21549
|
+
function isSelfUpdate(argv) {
|
|
21550
|
+
return argv.some((arg, index) => arg === '--update' || arg === 'self-update' || arg === 'selfupdate' || arg === 'self_update' || (arg === 'update' || arg === 'upgrade') && (index === 0 || argv[index - 1] === 'socket-patch'));
|
|
21551
|
+
}
|
|
21552
|
+
function validateExplicitSocketPatchPath(binPath) {
|
|
21553
|
+
const absoluteBinPath = path.resolve(binPath);
|
|
21554
|
+
try {
|
|
21555
|
+
const stats = u.statSync(absoluteBinPath);
|
|
21556
|
+
if (!stats.isFile()) {
|
|
21557
|
+
throw new Error('not a regular file');
|
|
21558
|
+
}
|
|
21559
|
+
u.accessSync(absoluteBinPath, u.constants.X_OK);
|
|
21560
|
+
} catch (cause) {
|
|
21561
|
+
throw new Error(`SOCKET_CLI_SOCKET_PATCH_PATH must name an existing executable file: ${absoluteBinPath}`, {
|
|
21562
|
+
cause
|
|
21563
|
+
});
|
|
21564
|
+
}
|
|
21565
|
+
return absoluteBinPath;
|
|
21566
|
+
}
|
|
20115
21567
|
async function run$m(argv, _importMeta, _context) {
|
|
20116
21568
|
const {
|
|
20117
21569
|
ENV
|
|
20118
21570
|
} = constants.default;
|
|
21571
|
+
const standalone = utils.isStandaloneSea();
|
|
21572
|
+
if (standalone && isSelfUpdate(argv)) {
|
|
21573
|
+
throw new Error('socket-patch self-update is unavailable in the standalone Socket build because it cannot replace the bundled executable.');
|
|
21574
|
+
}
|
|
21575
|
+
let explicitBinPath = standalone ? ENV.SOCKET_CLI_SOCKET_PATCH_PATH : undefined;
|
|
21576
|
+
let bundledBinPath;
|
|
21577
|
+
if (standalone) {
|
|
21578
|
+
// The explicit override takes precedence; otherwise extract only the
|
|
21579
|
+
// verified embedded payload. Neither branch consults PATH.
|
|
21580
|
+
if (explicitBinPath) {
|
|
21581
|
+
explicitBinPath = validateExplicitSocketPatchPath(explicitBinPath);
|
|
21582
|
+
} else {
|
|
21583
|
+
bundledBinPath = await utils.getBundledTool('socket-patch');
|
|
21584
|
+
explicitBinPath = bundledBinPath;
|
|
21585
|
+
}
|
|
21586
|
+
}
|
|
20119
21587
|
|
|
20120
21588
|
// Build environment variables for the socket-patch binary.
|
|
20121
21589
|
const spawnEnv = {
|
|
@@ -20146,22 +21614,32 @@ async function run$m(argv, _importMeta, _context) {
|
|
|
20146
21614
|
|
|
20147
21615
|
// Resolve and spawn the socket-patch Rust binary.
|
|
20148
21616
|
// On Windows, node_modules/.bin shims are .cmd scripts that require shell.
|
|
20149
|
-
const binPath = resolveSocketPatchBin();
|
|
20150
|
-
|
|
20151
|
-
|
|
20152
|
-
|
|
20153
|
-
|
|
20154
|
-
|
|
20155
|
-
|
|
20156
|
-
|
|
20157
|
-
|
|
20158
|
-
|
|
20159
|
-
|
|
20160
|
-
|
|
20161
|
-
|
|
20162
|
-
|
|
20163
|
-
|
|
20164
|
-
|
|
21617
|
+
const binPath = explicitBinPath || resolveSocketPatchBin();
|
|
21618
|
+
try {
|
|
21619
|
+
const result = childProcess.spawnSync(binPath, [...argv], {
|
|
21620
|
+
stdio: 'inherit',
|
|
21621
|
+
env: spawnEnv,
|
|
21622
|
+
shell: explicitBinPath ? false : constants.default.WIN32
|
|
21623
|
+
});
|
|
21624
|
+
if (result.error) {
|
|
21625
|
+
throw result.error;
|
|
21626
|
+
}
|
|
21627
|
+
// Propagate signal if the child was killed (e.g. SIGTERM, SIGINT).
|
|
21628
|
+
if (result.signal) {
|
|
21629
|
+
if (bundledBinPath) {
|
|
21630
|
+
await utils.cleanupBundledTool(bundledBinPath);
|
|
21631
|
+
bundledBinPath = undefined;
|
|
21632
|
+
}
|
|
21633
|
+
process.kill(process.pid, result.signal);
|
|
21634
|
+
return;
|
|
21635
|
+
}
|
|
21636
|
+
if (result.status !== null && result.status !== 0) {
|
|
21637
|
+
process.exitCode = result.status;
|
|
21638
|
+
}
|
|
21639
|
+
} finally {
|
|
21640
|
+
if (bundledBinPath) {
|
|
21641
|
+
await utils.cleanupBundledTool(bundledBinPath);
|
|
21642
|
+
}
|
|
20165
21643
|
}
|
|
20166
21644
|
}
|
|
20167
21645
|
|
|
@@ -21406,6 +22884,26 @@ const cmdRepository = {
|
|
|
21406
22884
|
|
|
21407
22885
|
const CLEANUP_SIGNALS = ['SIGHUP', 'SIGINT', 'SIGTERM'];
|
|
21408
22886
|
const UV_SBOM_FILENAME = 'socket-uv-cdx.json';
|
|
22887
|
+
const UV_PATH_ENV = 'SOCKET_CLI_UV_PATH';
|
|
22888
|
+
function resolveUvExecutable() {
|
|
22889
|
+
if (!utils.isStandaloneSea()) {
|
|
22890
|
+
return 'uv';
|
|
22891
|
+
}
|
|
22892
|
+
const override = process.env[UV_PATH_ENV];
|
|
22893
|
+
if (!override) {
|
|
22894
|
+
return '';
|
|
22895
|
+
}
|
|
22896
|
+
const executable = path.resolve(process.cwd(), override);
|
|
22897
|
+
try {
|
|
22898
|
+
u.accessSync(executable, process.platform === 'win32' ? u.constants.F_OK : u.constants.X_OK);
|
|
22899
|
+
if (!u.statSync(executable).isFile()) {
|
|
22900
|
+
throw new Error('not a file');
|
|
22901
|
+
}
|
|
22902
|
+
} catch {
|
|
22903
|
+
throw new utils.InputError(`${UV_PATH_ENV} must point to an executable uv binary, but '${executable}' is missing or not executable.`);
|
|
22904
|
+
}
|
|
22905
|
+
return executable;
|
|
22906
|
+
}
|
|
21409
22907
|
function componentIdentity(component) {
|
|
21410
22908
|
return JSON.stringify([component.name, component.version, component.purl]);
|
|
21411
22909
|
}
|
|
@@ -21421,17 +22919,32 @@ async function exportMemberSbom(memberDir) {
|
|
|
21421
22919
|
}
|
|
21422
22920
|
async function exportSbom(memberDir, groups) {
|
|
21423
22921
|
let content;
|
|
22922
|
+
const uvExecutable = resolveUvExecutable();
|
|
22923
|
+
let bundledExecutable;
|
|
22924
|
+
let childClosed;
|
|
21424
22925
|
try {
|
|
21425
|
-
|
|
21426
|
-
|
|
21427
|
-
}
|
|
22926
|
+
if (!uvExecutable) {
|
|
22927
|
+
bundledExecutable = await utils.getBundledTool('uv');
|
|
22928
|
+
}
|
|
22929
|
+
const child = spawn.spawn(uvExecutable || bundledExecutable, ['export', '--project', memberDir, '--format', 'cyclonedx1.5', '--frozen', '--offline', '--no-python-downloads', '--all-extras', groups], {
|
|
21428
22930
|
cwd: memberDir,
|
|
21429
22931
|
signal: constants.default.abortSignal,
|
|
21430
22932
|
stdio: 'pipe'
|
|
21431
22933
|
});
|
|
22934
|
+
if (child.process) {
|
|
22935
|
+
childClosed = new Promise(resolve => child.process.once('close', resolve));
|
|
22936
|
+
}
|
|
22937
|
+
const {
|
|
22938
|
+
stdout
|
|
22939
|
+
} = await child;
|
|
21432
22940
|
content = stdout;
|
|
21433
22941
|
} catch (e) {
|
|
21434
22942
|
throw new utils.InputError(`Could not export the uv dependency graph for ${memberDir}. Install uv on PATH with CycloneDX export support and check that the directory is a uv project with a uv.lock in it or in its workspace root.`, e && typeof e === 'object' && 'stderr' in e ? String(e.stderr).trim() || utils.getErrorMessage(e) : utils.getErrorMessage(e));
|
|
22943
|
+
} finally {
|
|
22944
|
+
await childClosed;
|
|
22945
|
+
if (bundledExecutable) {
|
|
22946
|
+
await utils.cleanupBundledTool(bundledExecutable);
|
|
22947
|
+
}
|
|
21435
22948
|
}
|
|
21436
22949
|
return parseSbom(content, memberDir);
|
|
21437
22950
|
}
|
|
@@ -21721,7 +23234,7 @@ const generalFlags$1 = {
|
|
|
21721
23234
|
uvMembers: {
|
|
21722
23235
|
type: 'boolean',
|
|
21723
23236
|
default: false,
|
|
21724
|
-
description: 'Scan each TARGET directory as a uv project, using the versions pinned in its uv.lock or its workspace root uv.lock. Uploads a CycloneDX dependency graph per TARGET in place of manifest discovery, including all extras and dependency groups. Requires uv on PATH.'
|
|
23237
|
+
description: 'Scan each TARGET directory as a uv project, using the versions pinned in its uv.lock or its workspace root uv.lock. Uploads a CycloneDX dependency graph per TARGET in place of manifest discovery, including all extras and dependency groups. Requires uv on PATH; standalone builds use SOCKET_CLI_UV_PATH.'
|
|
21725
23238
|
}
|
|
21726
23239
|
};
|
|
21727
23240
|
function hasSocketFactsFileIn(dir) {
|
|
@@ -24054,11 +25567,11 @@ async function runScanReach({
|
|
|
24054
25567
|
reachabilityOptions,
|
|
24055
25568
|
target: targets[0]
|
|
24056
25569
|
});
|
|
24057
|
-
const packagePaths = await utils.getPackageFilesForScan(scanTargets, supportedFiles, {
|
|
25570
|
+
const packagePaths = await withoutDiscardedFacts(await utils.getPackageFilesForScan(scanTargets, supportedFiles, {
|
|
24058
25571
|
additionalIgnores: additionalScaIgnores,
|
|
24059
25572
|
config: socketConfig,
|
|
24060
25573
|
cwd
|
|
24061
|
-
});
|
|
25574
|
+
}), dynamicResult?.discardedFactsPaths);
|
|
24062
25575
|
spinner.successAndStop(`Found ${packagePaths.length} ${words.pluralize('manifest file', packagePaths.length)} for reachability analysis.`);
|
|
24063
25576
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
24064
25577
|
nook: true,
|
|
@@ -26292,5 +27805,5 @@ process.on('unhandledRejection', async (reason, promise) => {
|
|
|
26292
27805
|
// eslint-disable-next-line n/no-process-exit
|
|
26293
27806
|
process.exit(1);
|
|
26294
27807
|
});
|
|
26295
|
-
//# debugId=
|
|
27808
|
+
//# debugId=28a616df-5186-4da5-b072-4df4a843f987
|
|
26296
27809
|
//# sourceMappingURL=cli.js.map
|