@socketsecurity/cli 1.15.0 → 1.16.1
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 +24 -0
- package/README.md +16 -9
- package/dist/.config/tsconfig.dts.tsbuildinfo +1 -0
- package/dist/cli.js +2467 -961
- 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 -3
- 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 +519 -123
- package/dist/utils.js.map +1 -1
- package/external/@socketsecurity/registry/lib/packages.js +12 -9
- package/package.json +33 -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,
|
|
@@ -1937,21 +1995,12 @@ async function performReachabilityAnalysis(options) {
|
|
|
1937
1995
|
}
|
|
1938
1996
|
|
|
1939
1997
|
// Build Coana arguments.
|
|
1940
|
-
const coanaArgs = ['run', analysisTarget, '--output-dir', path.dirname(outputFilePath), '--socket-mode', outputFilePath, '--disable-report-submission', ...(isOmittedReachValue(reachabilityOptions.reachAnalysisTimeout) ? [] : ['--analysis-timeout', reachabilityOptions.reachAnalysisTimeout]), ...(isOmittedReachValue(reachabilityOptions.reachAnalysisMemoryLimit) ? [] : ['--memory-limit', reachabilityOptions.reachAnalysisMemoryLimit]), ...(reachabilityOptions.reachConcurrency ? ['--concurrency', `${reachabilityOptions.reachConcurrency}`] : []), ...(reachabilityOptions.reachContinueOnAnalysisErrors ? ['--reach-continue-on-analysis-errors'] : []), ...(reachabilityOptions.reachContinueOnInstallErrors ? ['--reach-continue-on-install-errors'] : []), ...(reachabilityOptions.reachContinueOnMissingLockFiles ? ['--reach-continue-on-missing-lock-files'] : []), ...(reachabilityOptions.reachContinueOnNoSourceFiles ? ['--reach-continue-on-no-source-files'] : []), ...(reachabilityOptions.reachDebug ? ['--debug'] : []), ...(reachabilityOptions.reachDetailedAnalysisLogFile ? ['--print-analysis-log-file'] : []), ...(reachabilityOptions.reachDisableAnalytics ? ['--disable-analytics-sharing'] : []), ...(reachabilityOptions.reachDisableDependencyDownloads ? ['--disable-dependency-downloads'] : []), ...(reachabilityOptions.reachDisableExternalToolChecks ? ['--disable-external-tool-checks'] : []),
|
|
1998
|
+
const coanaArgs = ['run', analysisTarget, '--output-dir', path.dirname(outputFilePath), '--socket-mode', outputFilePath, '--disable-report-submission', ...(isOmittedReachValue(reachabilityOptions.reachAnalysisTimeout) ? [] : ['--analysis-timeout', reachabilityOptions.reachAnalysisTimeout]), ...(isOmittedReachValue(reachabilityOptions.reachAnalysisMemoryLimit) ? [] : ['--memory-limit', reachabilityOptions.reachAnalysisMemoryLimit]), ...(reachabilityOptions.reachConcurrency ? ['--concurrency', `${reachabilityOptions.reachConcurrency}`] : []), ...(reachabilityOptions.reachContinueOnAnalysisErrors ? ['--reach-continue-on-analysis-errors'] : []), ...(reachabilityOptions.reachContinueOnInstallErrors ? ['--reach-continue-on-install-errors'] : []), ...(reachabilityOptions.reachContinueOnMissingLockFiles ? ['--reach-continue-on-missing-lock-files'] : []), ...(reachabilityOptions.reachContinueOnNoSourceFiles ? ['--reach-continue-on-no-source-files'] : []), ...(reachabilityOptions.reachDebug ? ['--debug'] : []), ...(reachabilityOptions.reachDetailedAnalysisLogFile ? ['--print-analysis-log-file'] : []), ...(reachabilityOptions.reachDisableAnalytics ? ['--disable-analytics-sharing'] : []), ...(reachabilityOptions.reachDisableDependencyDownloads ? ['--disable-dependency-downloads'] : []), ...(reachabilityOptions.reachDisableExternalToolChecks ? ['--disable-external-tool-checks'] : []),
|
|
1999
|
+
// Older Coana versions split analyses unless this is passed.
|
|
2000
|
+
'--disable-analysis-splitting', '--run-without-docker', '--manifests-tar-hash', tarHash,
|
|
1941
2001
|
// Empty reachEcosystems implies scanning all ecosystems.
|
|
1942
2002
|
...(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
2003
|
|
|
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
2004
|
// In machine-readable modes (--json/--markdown) the final payload is written
|
|
1956
2005
|
// to stdout by the output layer. Coana streams progress/logs over stdout
|
|
1957
2006
|
// under `inherit`, which would corrupt that payload, so redirect the child's
|
|
@@ -1963,7 +2012,7 @@ async function performReachabilityAnalysis(options) {
|
|
|
1963
2012
|
const coanaResult = await utils.spawnCoana(coanaArgs, orgSlug, {
|
|
1964
2013
|
coanaVersion: reachabilityOptions.reachVersion,
|
|
1965
2014
|
cwd,
|
|
1966
|
-
|
|
2015
|
+
repoName,
|
|
1967
2016
|
spinner,
|
|
1968
2017
|
stdio: coanaStdio
|
|
1969
2018
|
});
|
|
@@ -2034,6 +2083,32 @@ function buildToolLabelsFor(purlTypes) {
|
|
|
2034
2083
|
|
|
2035
2084
|
// Purl types whose packages have no namespace (NuGet ids are flat).
|
|
2036
2085
|
const NAMESPACELESS_PURL_TYPES = new Set(['nuget']);
|
|
2086
|
+
const BUILD_TOOL_PATH_ENV = {
|
|
2087
|
+
__proto__: null,
|
|
2088
|
+
gradle: 'SOCKET_CLI_GRADLE_PATH',
|
|
2089
|
+
maven: 'SOCKET_CLI_MAVEN_PATH',
|
|
2090
|
+
sbt: 'SOCKET_CLI_SBT_PATH'
|
|
2091
|
+
};
|
|
2092
|
+
function validatedEnvBuildToolPath(tool, projectDir) {
|
|
2093
|
+
const envName = BUILD_TOOL_PATH_ENV[tool];
|
|
2094
|
+
const selected = process.env[envName];
|
|
2095
|
+
if (!selected) {
|
|
2096
|
+
throw new Error(`Standalone Socket does not support ${tool} manifest execution without ${envName}: JVM runtime and toolchain assets are not bundled.`);
|
|
2097
|
+
}
|
|
2098
|
+
const executable = path.resolve(projectDir, selected);
|
|
2099
|
+
return validateExecutablePath(envName, selected, executable);
|
|
2100
|
+
}
|
|
2101
|
+
function validateExecutablePath(envName, selected, executable) {
|
|
2102
|
+
try {
|
|
2103
|
+
if (!u.statSync(executable).isFile()) {
|
|
2104
|
+
throw new Error('not a regular file');
|
|
2105
|
+
}
|
|
2106
|
+
u.accessSync(executable, u.constants.X_OK);
|
|
2107
|
+
return executable;
|
|
2108
|
+
} catch {
|
|
2109
|
+
throw new Error(`${envName} must point to a regular executable file; received '${selected}'.`);
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2037
2112
|
|
|
2038
2113
|
// PATH fallback when no `bin` and no project wrapper.
|
|
2039
2114
|
const DEFAULT_BUILD_TOOL_BIN = {
|
|
@@ -2066,23 +2141,28 @@ const BUILD_FILES = {
|
|
|
2066
2141
|
byFile: true,
|
|
2067
2142
|
nocaseGlob: '*.{sln,slnx,csproj,fsproj,vbproj}',
|
|
2068
2143
|
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
2144
|
// A solution covers the projects it lists.
|
|
2072
2145
|
entryRank: file => isDotnetSolution(file) ? 0 : 1
|
|
2073
2146
|
},
|
|
2074
2147
|
gradle: {
|
|
2075
2148
|
byFile: false,
|
|
2076
|
-
names: ['build.gradle', 'build.gradle.kts', 'settings.gradle', 'settings.gradle.kts']
|
|
2149
|
+
names: ['build.gradle', 'build.gradle.kts', 'settings.gradle', 'settings.gradle.kts'],
|
|
2150
|
+
rootMarkers: ['settings.gradle', 'settings.gradle.kts'],
|
|
2151
|
+
// Gradle builds `buildSrc` on its own.
|
|
2152
|
+
loadsAncestorBuild: {
|
|
2153
|
+
except: ['buildSrc']
|
|
2154
|
+
}
|
|
2077
2155
|
},
|
|
2078
2156
|
maven: {
|
|
2079
2157
|
byFile: true,
|
|
2080
2158
|
nocaseGlob: '{*-*.,}pom{.xml,}',
|
|
2081
2159
|
walkGlob: '*[pP][oO][mM]*'
|
|
2082
2160
|
},
|
|
2161
|
+
// A subproject's own `project/` is ignored by the build that includes it.
|
|
2083
2162
|
sbt: {
|
|
2084
2163
|
byFile: false,
|
|
2085
|
-
names: ['build.sbt']
|
|
2164
|
+
names: ['build.sbt'],
|
|
2165
|
+
rootMarkers: ['project']
|
|
2086
2166
|
}
|
|
2087
2167
|
};
|
|
2088
2168
|
|
|
@@ -2092,7 +2172,14 @@ const BUILD_FILES = {
|
|
|
2092
2172
|
function looksLikeSbtBuild(projectDir) {
|
|
2093
2173
|
return u.existsSync(path.resolve(projectDir, 'build.sbt')) || u.existsSync(path.resolve(projectDir, 'project'));
|
|
2094
2174
|
}
|
|
2095
|
-
function resolveBuildToolBin(tool, projectDir, bin) {
|
|
2175
|
+
function resolveBuildToolBin(tool, projectDir, bin, standalone = false) {
|
|
2176
|
+
if (standalone) {
|
|
2177
|
+
return validatedEnvBuildToolPath(tool, projectDir);
|
|
2178
|
+
}
|
|
2179
|
+
const envOverride = process.env[BUILD_TOOL_PATH_ENV[tool]];
|
|
2180
|
+
if (envOverride) {
|
|
2181
|
+
return validateExecutablePath(BUILD_TOOL_PATH_ENV[tool], envOverride, path.resolve(projectDir, envOverride));
|
|
2182
|
+
}
|
|
2096
2183
|
if (bin) {
|
|
2097
2184
|
return bin;
|
|
2098
2185
|
}
|
|
@@ -2229,6 +2316,7 @@ function buildPerRoot(parsed) {
|
|
|
2229
2316
|
out.set(rootId, {
|
|
2230
2317
|
projectKey: r.projectKey,
|
|
2231
2318
|
prod: r.prod,
|
|
2319
|
+
onClasspath: r.onClasspath,
|
|
2232
2320
|
target: r.target,
|
|
2233
2321
|
nodes
|
|
2234
2322
|
});
|
|
@@ -2314,17 +2402,22 @@ function buildSubprojectGraphs(perRoot) {
|
|
|
2314
2402
|
const graphs = new Map();
|
|
2315
2403
|
for (const {
|
|
2316
2404
|
nodes,
|
|
2405
|
+
onClasspath,
|
|
2317
2406
|
projectKey
|
|
2318
2407
|
} of perRoot.values()) {
|
|
2319
2408
|
let g = graphs.get(projectKey);
|
|
2320
2409
|
if (!g) {
|
|
2321
2410
|
g = {
|
|
2322
2411
|
children: new Map(),
|
|
2412
|
+
classpath: new Set(),
|
|
2323
2413
|
direct: new Set()
|
|
2324
2414
|
};
|
|
2325
2415
|
graphs.set(projectKey, g);
|
|
2326
2416
|
}
|
|
2327
2417
|
for (const [coordId, node] of nodes) {
|
|
2418
|
+
if (onClasspath) {
|
|
2419
|
+
g.classpath.add(coordId);
|
|
2420
|
+
}
|
|
2328
2421
|
let set = g.children.get(coordId);
|
|
2329
2422
|
if (!set) {
|
|
2330
2423
|
set = new Set();
|
|
@@ -2507,8 +2600,8 @@ function buildArtifactPaths(finalNodes, projects, excludedProjects, graphs, exis
|
|
|
2507
2600
|
}
|
|
2508
2601
|
return {
|
|
2509
2602
|
pathsById,
|
|
2510
|
-
classpathByProject: byProject(projects, graphs, g => g.
|
|
2511
|
-
directDependenciesByProject: byProject(projects, graphs, g => g.direct)
|
|
2603
|
+
classpathByProject: byProject(projects, graphs, g => g.classpath),
|
|
2604
|
+
directDependenciesByProject: byProject(projects, graphs, g => [...g.direct].filter(id => g.classpath.has(id)))
|
|
2512
2605
|
};
|
|
2513
2606
|
}
|
|
2514
2607
|
|
|
@@ -2830,6 +2923,7 @@ function serializeExcludePathPatterns(paths) {
|
|
|
2830
2923
|
// projectBuild projectKey path (build-root-relative; may be absent on disk)
|
|
2831
2924
|
// excludedProject projectKey (--with-files only; paths without a project)
|
|
2832
2925
|
// root rootId projectKey config prod(0|1) [framework runtime alias] (dotnet: NuGet short folder name, RID, TargetFrameworks entry)
|
|
2926
|
+
// noClasspath rootId (its nodes are on no classpath: in the SBOM, not on a reachability classpath)
|
|
2833
2927
|
// node rootId coordId group name version ext classifier direct(0|1) project
|
|
2834
2928
|
// edge rootId parentCoordId childCoordId
|
|
2835
2929
|
// file rootId coordId path (--with-files only)
|
|
@@ -2910,6 +3004,7 @@ function parseRecords(text) {
|
|
|
2910
3004
|
rootId: id,
|
|
2911
3005
|
projectKey: '',
|
|
2912
3006
|
prod: false,
|
|
3007
|
+
onClasspath: true,
|
|
2913
3008
|
nodes: new Map(),
|
|
2914
3009
|
edges: []
|
|
2915
3010
|
};
|
|
@@ -3072,6 +3167,11 @@ function parseRecords(text) {
|
|
|
3072
3167
|
}
|
|
3073
3168
|
break;
|
|
3074
3169
|
}
|
|
3170
|
+
case 'noClasspath':
|
|
3171
|
+
{
|
|
3172
|
+
root(f[1] ?? '').onClasspath = false;
|
|
3173
|
+
break;
|
|
3174
|
+
}
|
|
3075
3175
|
case 'unfetched':
|
|
3076
3176
|
{
|
|
3077
3177
|
const node = root(f[1] ?? '').nodes.get(f[2] ?? '');
|
|
@@ -3306,10 +3406,10 @@ function dotnetToolArgs(opts) {
|
|
|
3306
3406
|
});
|
|
3307
3407
|
}
|
|
3308
3408
|
async function invokeGradle(opts, initScriptFilename, task, tmpDirPrefix) {
|
|
3409
|
+
const bin = resolveBuildToolBin('gradle', opts.projectDir, opts.bin, utils.isStandaloneSea());
|
|
3309
3410
|
const initScript = manifestScriptsPath(initScriptFilename);
|
|
3310
3411
|
return await utils.withTmpDir(tmpDirPrefix, async tmp => {
|
|
3311
3412
|
const recordsFile = path.join(tmp, 'records.tsv');
|
|
3312
|
-
const bin = resolveBuildToolBin('gradle', opts.projectDir, opts.bin);
|
|
3313
3413
|
// Disable the configuration cache: the init script's legacy
|
|
3314
3414
|
// resolvedConfiguration API and shared accumulator aren't cache-safe.
|
|
3315
3415
|
const args = ['--init-script', initScript, '-Dorg.gradle.configuration-cache=false',
|
|
@@ -3327,6 +3427,7 @@ async function enumerateGradleWorkspaces(opts) {
|
|
|
3327
3427
|
return await invokeGradle(opts, 'socket-workspaces.init.gradle', WORKSPACES_TASK, 'socket-gradle-workspaces-');
|
|
3328
3428
|
}
|
|
3329
3429
|
async function invokeSbtIn(globalBase, opts, pluginSourceFilename, pluginDestFilename, task) {
|
|
3430
|
+
const bin = resolveBuildToolBin('sbt', opts.projectDir, opts.bin, utils.isStandaloneSea());
|
|
3330
3431
|
await writeSbtPlugin(globalBase, pluginSourceFilename, pluginDestFilename);
|
|
3331
3432
|
const recordsFile = path.join(globalBase, 'records.tsv');
|
|
3332
3433
|
// The global base is shared across sbt roots: a build that dies before
|
|
@@ -3334,7 +3435,6 @@ async function invokeSbtIn(globalBase, opts, pluginSourceFilename, pluginDestFil
|
|
|
3334
3435
|
await u.promises.rm(recordsFile, {
|
|
3335
3436
|
force: true
|
|
3336
3437
|
});
|
|
3337
|
-
const bin = resolveBuildToolBin('sbt', opts.projectDir, opts.bin);
|
|
3338
3438
|
// Fresh per-run global base (not ~/.sbt): sbt executes everything under
|
|
3339
3439
|
// plugins/, so a shared path is a code-injection surface. BSP off for this
|
|
3340
3440
|
// run. sbt also provisions the project's Scala toolchain under
|
|
@@ -3365,11 +3465,11 @@ async function enumerateSbtWorkspaces(opts) {
|
|
|
3365
3465
|
return await utils.withTmpDir('socket-sbt-workspaces-', run);
|
|
3366
3466
|
}
|
|
3367
3467
|
async function invokeMaven(opts, coanaTask, tmpDirPrefix) {
|
|
3468
|
+
const bin = resolveBuildToolBin('maven', opts.projectDir, opts.bin, utils.isStandaloneSea());
|
|
3368
3469
|
const jarPath = manifestScriptsPath('maven-extension', 'coana-maven-extension.jar');
|
|
3369
3470
|
assertBundledAssetBuilt(jarPath, 'Maven manifest extension jar', 'build:maven-extension');
|
|
3370
3471
|
return await utils.withTmpDir(tmpDirPrefix, async tmp => {
|
|
3371
3472
|
const recordsFile = path.join(tmp, 'records.tsv');
|
|
3372
|
-
const bin = resolveBuildToolBin('maven', opts.projectDir, opts.bin);
|
|
3373
3473
|
// `validate` is the cheapest phase that triggers the extension; no compile
|
|
3374
3474
|
// needed (analysis uses configured paths, not classes).
|
|
3375
3475
|
const props = [`-Dmaven.ext.class.path=${jarPath}`, `-Dcoana.task=${coanaTask}`, `-Dsocket.recordsFile=${recordsFile}`, ...commonProps(opts, '-D')];
|
|
@@ -3499,6 +3599,18 @@ const BUILD_FILE_MATCHERS = new Map(BUILD_TOOLS.map(tool => {
|
|
|
3499
3599
|
nocase: true
|
|
3500
3600
|
}) : basename => files.names.includes(basename)];
|
|
3501
3601
|
}));
|
|
3602
|
+
function pathKey(value) {
|
|
3603
|
+
return value.replaceAll('\\', '/');
|
|
3604
|
+
}
|
|
3605
|
+
function containsPath(paths, value) {
|
|
3606
|
+
const key = pathKey(value);
|
|
3607
|
+
for (const candidate of paths) {
|
|
3608
|
+
if (pathKey(candidate) === key) {
|
|
3609
|
+
return true;
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
return false;
|
|
3613
|
+
}
|
|
3502
3614
|
|
|
3503
3615
|
// `entryFile` (a basename in `dir`) is set only for a tool that addresses its
|
|
3504
3616
|
// builds by file, where one directory can hold several builds.
|
|
@@ -3554,30 +3666,76 @@ async function realFilePath(file) {
|
|
|
3554
3666
|
return path.join(await utils.realpathOrResolved(path.dirname(file)), path.basename(file));
|
|
3555
3667
|
}
|
|
3556
3668
|
|
|
3557
|
-
//
|
|
3558
|
-
//
|
|
3559
|
-
//
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3669
|
+
// What a build loaded: its projects' directories and build files,
|
|
3670
|
+
// realpath-resolved. Gradle reports a project's build file even when absent,
|
|
3671
|
+
// which names nothing.
|
|
3672
|
+
|
|
3673
|
+
function emptyMembership() {
|
|
3674
|
+
return {
|
|
3675
|
+
dirs: new Set(),
|
|
3676
|
+
files: new Set()
|
|
3677
|
+
};
|
|
3678
|
+
}
|
|
3679
|
+
function addMembership(into, from) {
|
|
3680
|
+
for (const dir of from.dirs) {
|
|
3681
|
+
into.dirs.add(dir);
|
|
3682
|
+
}
|
|
3683
|
+
for (const file of from.files) {
|
|
3684
|
+
into.files.add(file);
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3687
|
+
function unionMemberships(memberships) {
|
|
3688
|
+
const union = emptyMembership();
|
|
3689
|
+
for (const membership of memberships) {
|
|
3690
|
+
addMembership(union, membership);
|
|
3691
|
+
}
|
|
3692
|
+
return union;
|
|
3693
|
+
}
|
|
3694
|
+
function isPathInside$1(dir, file) {
|
|
3695
|
+
return file === dir || file.startsWith(`${dir}${path.sep}`);
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3698
|
+
// Paths are relative to `buildRoot`. Only what lies inside `scanRoot` (when
|
|
3699
|
+
// given) counts, as only that can be a candidate.
|
|
3700
|
+
async function membershipOf(buildRoot, projects, scanRoot) {
|
|
3701
|
+
const realScanRoot = scanRoot ? await utils.realpathOrResolved(scanRoot) : undefined;
|
|
3702
|
+
const inScan = p => !realScanRoot || isPathInside$1(realScanRoot, p);
|
|
3703
|
+
const membership = emptyMembership();
|
|
3704
|
+
const [dirs, files] = await Promise.all([Promise.all(projects.map(({
|
|
3705
|
+
subprojectDir
|
|
3706
|
+
}) => utils.realpathOrResolved(path.resolve(buildRoot, subprojectDir)))), Promise.all(projects.flatMap(project => project.manifestFiles ?? []).map(({
|
|
3565
3707
|
file
|
|
3566
|
-
}) => realFilePath(path.resolve(buildRoot, file))));
|
|
3708
|
+
}) => realFilePath(path.resolve(buildRoot, file))))]);
|
|
3709
|
+
for (const dir of dirs) {
|
|
3710
|
+
if (inScan(dir)) {
|
|
3711
|
+
membership.dirs.add(dir);
|
|
3712
|
+
}
|
|
3713
|
+
}
|
|
3567
3714
|
for (const file of files) {
|
|
3568
|
-
if ((
|
|
3569
|
-
|
|
3715
|
+
if (inScan(file) && u.existsSync(file)) {
|
|
3716
|
+
membership.files.add(file);
|
|
3570
3717
|
}
|
|
3571
3718
|
}
|
|
3719
|
+
return membership;
|
|
3720
|
+
}
|
|
3721
|
+
const rootMarkerByDir = new Map();
|
|
3722
|
+
function hasRootMarker(tool, root) {
|
|
3723
|
+
const files = BUILD_FILES[tool];
|
|
3724
|
+
if (files.byFile) {
|
|
3725
|
+
return false;
|
|
3726
|
+
}
|
|
3727
|
+
return utils.getOrInsert(rootMarkerByDir, `${tool}\0${root.dir}`, () => files.rootMarkers.some(marker => u.existsSync(path.join(root.dir, marker))));
|
|
3572
3728
|
}
|
|
3573
3729
|
|
|
3574
|
-
// `root
|
|
3730
|
+
// Whether a build loaded `root`'s project; a build of its own (see
|
|
3731
|
+
// hasRootMarker) is more than that project. `root.dir` must be
|
|
3732
|
+
// realpath-resolved, as findBuildToolCandidates returns it.
|
|
3575
3733
|
function isBuildRootCovered(covered, tool, root) {
|
|
3576
3734
|
const files = BUILD_FILES[tool];
|
|
3577
3735
|
if (files.byFile) {
|
|
3578
|
-
return !!root.entryFile && covered.
|
|
3736
|
+
return !!root.entryFile && containsPath(covered.files, buildRootPath(root));
|
|
3579
3737
|
}
|
|
3580
|
-
return files.names.some(name => covered.
|
|
3738
|
+
return containsPath(covered.dirs, root.dir) || files.names.some(name => containsPath(covered.files, path.join(root.dir, name)));
|
|
3581
3739
|
}
|
|
3582
3740
|
|
|
3583
3741
|
// A dotnet solution is covered once every project it builds is, or, when the
|
|
@@ -3592,7 +3750,7 @@ async function isSolutionCovered(covered, root, opts, listMembers = listDotnetEn
|
|
|
3592
3750
|
}
|
|
3593
3751
|
const twin = entryFile.replace(/\.slnx?$/i, ext => ext.toLowerCase() === '.sln' ? '.slnx' : '.sln');
|
|
3594
3752
|
const hasTwin = u.existsSync(path.join(root.dir, twin));
|
|
3595
|
-
if (!covered.size && !hasTwin) {
|
|
3753
|
+
if (!covered.files.size && !hasTwin) {
|
|
3596
3754
|
return false;
|
|
3597
3755
|
}
|
|
3598
3756
|
const list = file => listMembers({
|
|
@@ -3609,8 +3767,19 @@ async function isSolutionCovered(covered, root, opts, listMembers = listDotnetEn
|
|
|
3609
3767
|
logger.logger.warn(`Skipping ${buildRootPath(root)}: the .NET SDK could not read it; ${twin} beside it is built instead.`);
|
|
3610
3768
|
return true;
|
|
3611
3769
|
}
|
|
3612
|
-
const members = await
|
|
3613
|
-
return !!members.length && members.every(member => covered.
|
|
3770
|
+
const members = await realMembers(listed);
|
|
3771
|
+
return !!members.length && members.every(member => containsPath(covered.files, member));
|
|
3772
|
+
}
|
|
3773
|
+
|
|
3774
|
+
// The SDK's member listings are memoized, so their resolved paths are too.
|
|
3775
|
+
const realMembersByListing = new WeakMap();
|
|
3776
|
+
function realMembers(listed) {
|
|
3777
|
+
let members = realMembersByListing.get(listed);
|
|
3778
|
+
if (!members) {
|
|
3779
|
+
members = Promise.all(listed.map(realFilePath));
|
|
3780
|
+
realMembersByListing.set(listed, members);
|
|
3781
|
+
}
|
|
3782
|
+
return members;
|
|
3614
3783
|
}
|
|
3615
3784
|
|
|
3616
3785
|
// Whether earlier builds cover `root`: its own build files, or every project
|
|
@@ -3618,6 +3787,18 @@ async function isSolutionCovered(covered, root, opts, listMembers = listDotnetEn
|
|
|
3618
3787
|
async function isRootCovered(covered, tool, root, opts, listMembers = listDotnetEntryProjects) {
|
|
3619
3788
|
return isBuildRootCovered(covered, tool, root) || tool === 'dotnet' && (await isSolutionCovered(covered, root, opts, listMembers));
|
|
3620
3789
|
}
|
|
3790
|
+
|
|
3791
|
+
// A build of its own (see hasRootMarker) is covered only by builds that load
|
|
3792
|
+
// all of `own`, what it loads itself.
|
|
3793
|
+
async function isBuildCovered(covered, tool, root, opts, own) {
|
|
3794
|
+
if (!hasRootMarker(tool, root)) {
|
|
3795
|
+
return await isRootCovered(covered, tool, root, opts);
|
|
3796
|
+
}
|
|
3797
|
+
const pick = membership => BUILD_FILES[tool].byFile ? membership.files : membership.dirs;
|
|
3798
|
+
const members = own ? pick(own) : new Set();
|
|
3799
|
+
const loaded = pick(covered);
|
|
3800
|
+
return !!members.size && [...members].every(member => loaded.has(member));
|
|
3801
|
+
}
|
|
3621
3802
|
function compareStrings(a, b) {
|
|
3622
3803
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
3623
3804
|
}
|
|
@@ -3693,57 +3874,170 @@ async function findBuildToolCandidates({
|
|
|
3693
3874
|
return result;
|
|
3694
3875
|
}
|
|
3695
3876
|
|
|
3696
|
-
//
|
|
3697
|
-
|
|
3698
|
-
//
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3877
|
+
// The setting that makes the effective `disabled` true.
|
|
3878
|
+
|
|
3879
|
+
// Gradle and sbt name a build by any build file of its directory.
|
|
3880
|
+
function namesBuildFile(key) {
|
|
3881
|
+
return BUILD_TOOLS.some(tool => {
|
|
3882
|
+
const files = BUILD_FILES[tool];
|
|
3883
|
+
return files.byFile ? isBuildFile(tool, key) : files.names.includes(key);
|
|
3884
|
+
});
|
|
3885
|
+
}
|
|
3886
|
+
|
|
3887
|
+
// The `builds` keys naming an existing build file of `tool`'s build in `dir`:
|
|
3888
|
+
// its entry file, or any of a Gradle or sbt directory's build files.
|
|
3889
|
+
function ownEntryKeys(tool, dir, builds, entryFile) {
|
|
3890
|
+
const files = BUILD_FILES[tool];
|
|
3891
|
+
if (files.byFile) {
|
|
3892
|
+
return entryFile && Object.hasOwn(builds, entryFile) ? [entryFile] : [];
|
|
3706
3893
|
}
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3894
|
+
return files.names.filter(name => Object.hasOwn(builds, name) && u.existsSync(path.join(dir, name)));
|
|
3895
|
+
}
|
|
3896
|
+
function validateBuilds({
|
|
3897
|
+
dir,
|
|
3898
|
+
sockJson
|
|
3899
|
+
}) {
|
|
3900
|
+
const builds = sockJson.defaults?.manifest?.builds;
|
|
3901
|
+
if (builds === undefined) {
|
|
3902
|
+
return;
|
|
3903
|
+
}
|
|
3904
|
+
const file = socketJsonPath(dir);
|
|
3905
|
+
if (!objects.isObjectObject(builds)) {
|
|
3906
|
+
throw new utils.InputError(`defaults.manifest.builds in ${file} must be an object keyed by build file name.`);
|
|
3907
|
+
}
|
|
3908
|
+
for (const {
|
|
3909
|
+
0: key,
|
|
3910
|
+
1: entry
|
|
3911
|
+
} of Object.entries(builds)) {
|
|
3912
|
+
if (key.includes('/') || key.includes('\\') || !namesBuildFile(key)) {
|
|
3913
|
+
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.`);
|
|
3914
|
+
}
|
|
3915
|
+
if (!objects.isObjectObject(entry)) {
|
|
3916
|
+
throw new utils.InputError(`${buildsSetting(key)} in ${file} must be an object.`);
|
|
3917
|
+
}
|
|
3918
|
+
if (entry['disabled'] !== undefined && typeof entry['disabled'] !== 'boolean') {
|
|
3919
|
+
throw new utils.InputError(`${buildsSetting(key)}.disabled in ${file} must be true or false.`);
|
|
3920
|
+
}
|
|
3921
|
+
}
|
|
3922
|
+
for (const tool of BUILD_TOOLS) {
|
|
3923
|
+
const keys = ownEntryKeys(tool, dir, builds);
|
|
3924
|
+
if (keys.length > 1) {
|
|
3925
|
+
throw new utils.InputError(`${keys.map(buildsSetting).join(' and ')} in ${file} configure the same ${tool} build. Keep one of them.`);
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3928
|
+
}
|
|
3929
|
+
function warnMissingFiles({
|
|
3930
|
+
dir,
|
|
3931
|
+
sockJson
|
|
3932
|
+
}, warned) {
|
|
3933
|
+
for (const key of Object.keys(sockJson.defaults?.manifest?.builds ?? {})) {
|
|
3934
|
+
const file = path.join(dir, key);
|
|
3935
|
+
if (!warned.has(file) && !u.existsSync(file)) {
|
|
3936
|
+
warned.add(file);
|
|
3937
|
+
logger.logger.warn(`${buildsSetting(key)} in ${socketJsonPath(dir)} names a file that is not there, so it applies to no build.`);
|
|
3938
|
+
}
|
|
3939
|
+
}
|
|
3940
|
+
}
|
|
3941
|
+
function buildsSetting(key) {
|
|
3942
|
+
return `defaults.manifest.builds[${JSON.stringify(key)}]`;
|
|
3943
|
+
}
|
|
3944
|
+
|
|
3945
|
+
// Resolves the socket.json settings of build roots once, reading and
|
|
3946
|
+
// validating each socket.json once. `readChain` lists a directory's socket.json files,
|
|
3947
|
+
// farthest first; resolvers sharing `warned` warn about a file once.
|
|
3948
|
+
function createBuildRootSettingsResolver(readChain = utils.readSocketJsonChain, warned = new Set()) {
|
|
3949
|
+
const chains = new Map();
|
|
3950
|
+
const resolved = new Map();
|
|
3951
|
+
const validated = new Set();
|
|
3952
|
+
const chainFor = dir => {
|
|
3953
|
+
let chain = chains.get(dir);
|
|
3954
|
+
if (!chain) {
|
|
3955
|
+
chain = readChain(dir);
|
|
3956
|
+
for (const file of chain) {
|
|
3957
|
+
if (!validated.has(file.dir)) {
|
|
3958
|
+
validated.add(file.dir);
|
|
3959
|
+
validateBuilds(file);
|
|
3960
|
+
warnMissingFiles(file, warned);
|
|
3961
|
+
}
|
|
3719
3962
|
}
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3963
|
+
chains.set(dir, chain);
|
|
3964
|
+
}
|
|
3965
|
+
return chain;
|
|
3966
|
+
};
|
|
3967
|
+
const resolve = (tool, root) => {
|
|
3968
|
+
const chain = chainFor(root.dir);
|
|
3969
|
+
const merged = utils.mergeSocketJsonChain(chain);
|
|
3970
|
+
const section = {
|
|
3971
|
+
...merged.defaults?.manifest?.[tool]
|
|
3972
|
+
};
|
|
3973
|
+
let sectionDisabledBy;
|
|
3974
|
+
for (const {
|
|
3975
|
+
dir,
|
|
3976
|
+
sockJson
|
|
3977
|
+
} of chain) {
|
|
3978
|
+
if (sockJson.defaults?.manifest?.[tool]?.disabled !== undefined) {
|
|
3979
|
+
sectionDisabledBy = {
|
|
3980
|
+
dir
|
|
3981
|
+
};
|
|
3725
3982
|
}
|
|
3726
|
-
}
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3983
|
+
}
|
|
3984
|
+
const directorySkip = section['disabled'] === true;
|
|
3985
|
+
const own = chain.at(-1);
|
|
3986
|
+
const builds = own?.dir === root.dir ? own.sockJson.defaults?.manifest?.builds : undefined;
|
|
3987
|
+
// Validation leaves at most one.
|
|
3988
|
+
const entryKey = builds ? ownEntryKeys(tool, root.dir, builds, root.entryFile)[0] : undefined;
|
|
3989
|
+
let entryDisabledBy;
|
|
3990
|
+
if (entryKey) {
|
|
3991
|
+
const entry = builds[entryKey];
|
|
3992
|
+
Object.assign(section, entry);
|
|
3993
|
+
if (entry.disabled !== undefined) {
|
|
3994
|
+
entryDisabledBy = {
|
|
3995
|
+
dir: root.dir,
|
|
3996
|
+
key: entryKey
|
|
3997
|
+
};
|
|
3737
3998
|
}
|
|
3738
|
-
} else {
|
|
3739
|
-
current += ch;
|
|
3740
|
-
hasToken = true;
|
|
3741
3999
|
}
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
4000
|
+
|
|
4001
|
+
// An entry can turn a build in a skipped directory back on; skipping it
|
|
4002
|
+
// there too changes nothing, as nothing in the directory is loaded.
|
|
4003
|
+
let disabledBy;
|
|
4004
|
+
if (section['disabled']) {
|
|
4005
|
+
disabledBy = directorySkip ? sectionDisabledBy : entryDisabledBy;
|
|
4006
|
+
}
|
|
4007
|
+
return {
|
|
4008
|
+
disabledBy,
|
|
4009
|
+
entryKey,
|
|
4010
|
+
sockJson: {
|
|
4011
|
+
...merged,
|
|
4012
|
+
defaults: {
|
|
4013
|
+
...merged.defaults,
|
|
4014
|
+
manifest: {
|
|
4015
|
+
...merged.defaults?.manifest,
|
|
4016
|
+
[tool]: section
|
|
4017
|
+
}
|
|
4018
|
+
}
|
|
4019
|
+
}
|
|
4020
|
+
};
|
|
4021
|
+
};
|
|
4022
|
+
return (tool, root) => utils.getOrInsert(resolved, `${tool}\0${buildRootPath(root)}`, () => resolve(tool, root));
|
|
4023
|
+
}
|
|
4024
|
+
|
|
4025
|
+
// The setting that skips builds, as `<socket.json> sets <setting>`.
|
|
4026
|
+
function describeDisabledBy(tool, {
|
|
4027
|
+
dir,
|
|
4028
|
+
key
|
|
4029
|
+
}) {
|
|
4030
|
+
const setting = key ? `${buildsSetting(key)}.disabled` : `defaults.manifest.${tool}.disabled`;
|
|
4031
|
+
return `${socketJsonPath(dir)} sets ${setting}`;
|
|
4032
|
+
}
|
|
4033
|
+
|
|
4034
|
+
// Relative to the user's shell when inside it, else absolute.
|
|
4035
|
+
function displayPath(file) {
|
|
4036
|
+
const rel = path.relative(process.cwd(), file);
|
|
4037
|
+
return rel.startsWith('..') || path.isAbsolute(rel) ? file : rel || '.';
|
|
4038
|
+
}
|
|
4039
|
+
function socketJsonPath(dir) {
|
|
4040
|
+
return displayPath(path.join(dir, constants.SOCKET_JSON));
|
|
3747
4041
|
}
|
|
3748
4042
|
|
|
3749
4043
|
const ENV_VAR_REF = /\$\$|\$\{(\w+)\}|\$(\w+)/g;
|
|
@@ -4505,198 +4799,647 @@ async function runManifestFacts({
|
|
|
4505
4799
|
};
|
|
4506
4800
|
}
|
|
4507
4801
|
|
|
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);
|
|
4802
|
+
// Cheap subproject discovery (no dependency resolution), for builds that are
|
|
4803
|
+
// not resolved: the setup wizard's, and skipped ones. Callers decide whether
|
|
4804
|
+
// a failure fails the command.
|
|
4805
|
+
async function enumerateWorkspaces({
|
|
4806
|
+
bin,
|
|
4807
|
+
buildOpts,
|
|
4808
|
+
cwd,
|
|
4809
|
+
ecosystem,
|
|
4810
|
+
entryFile,
|
|
4811
|
+
excludeBase,
|
|
4812
|
+
excludePaths,
|
|
4813
|
+
javaHome,
|
|
4814
|
+
verbose
|
|
4815
|
+
}) {
|
|
4816
|
+
let resolvedJavaHome;
|
|
4817
|
+
if (javaHome) {
|
|
4818
|
+
const expanded = expandEnvVarRefs(javaHome);
|
|
4819
|
+
if (expanded.missing) {
|
|
4820
|
+
logger.logger.fail(`javaHome (\`${javaHome}\`) ${formatMissingEnvVarRefs(expanded.missing)}.`);
|
|
4821
|
+
return;
|
|
4546
4822
|
}
|
|
4823
|
+
resolvedJavaHome = expanded.value;
|
|
4547
4824
|
}
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4825
|
+
const scriptOpts = {
|
|
4826
|
+
bin: bin || undefined,
|
|
4827
|
+
entryFile,
|
|
4828
|
+
excludeBase,
|
|
4829
|
+
excludePaths: excludePaths?.length ? excludePaths : undefined,
|
|
4830
|
+
// `env` replaces the spawned process's whole environment, not just JAVA_HOME.
|
|
4831
|
+
env: resolvedJavaHome ? {
|
|
4832
|
+
...process.env,
|
|
4833
|
+
JAVA_HOME: resolvedJavaHome
|
|
4834
|
+
} : undefined,
|
|
4835
|
+
projectDir: cwd,
|
|
4836
|
+
stdio: verbose ? 'inherit' : 'pipe',
|
|
4837
|
+
toolOpts: buildOpts
|
|
4838
|
+
};
|
|
4839
|
+
let result;
|
|
4840
|
+
try {
|
|
4841
|
+
result = await enumerateWorkspaces$1(ecosystem, scriptOpts);
|
|
4842
|
+
} catch (e) {
|
|
4843
|
+
logger.logger.fail(`Could not run the ${ecosystem} build tool: ${utils.getErrorMessageOr(e, String(e))}`);
|
|
4844
|
+
return;
|
|
4845
|
+
}
|
|
4846
|
+
if (!result.projects.length) {
|
|
4847
|
+
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.`);
|
|
4848
|
+
const tail = verbose ? '' : tailBuildOutput(result.stdout, result.stderr);
|
|
4849
|
+
if (tail) {
|
|
4850
|
+
logger.logger.group('Build output:');
|
|
4851
|
+
logger.logger.error(tail);
|
|
4852
|
+
logger.logger.groupEnd();
|
|
4562
4853
|
}
|
|
4854
|
+
return;
|
|
4855
|
+
}
|
|
4856
|
+
if (!result.buildRoot) {
|
|
4857
|
+
logger.logger.fail(`The ${ecosystem} build did not report its build root, so its projects' paths cannot be located.`);
|
|
4858
|
+
return;
|
|
4563
4859
|
}
|
|
4564
|
-
return
|
|
4860
|
+
return {
|
|
4861
|
+
buildRoot: result.buildRoot,
|
|
4862
|
+
projects: result.projects
|
|
4863
|
+
};
|
|
4565
4864
|
}
|
|
4566
|
-
|
|
4567
|
-
|
|
4865
|
+
|
|
4866
|
+
// Lets the build tool load a build, resolving nothing, for what it includes.
|
|
4867
|
+
async function loadBuild({
|
|
4868
|
+
config,
|
|
4869
|
+
ecosystem,
|
|
4568
4870
|
excludePaths,
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
rootSockJson,
|
|
4573
|
-
sbtTmpDir,
|
|
4574
|
-
sidecarAcc,
|
|
4575
|
-
verbose,
|
|
4576
|
-
withFiles
|
|
4871
|
+
root,
|
|
4872
|
+
scanRoot,
|
|
4873
|
+
verbose
|
|
4577
4874
|
}) {
|
|
4578
|
-
const
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4875
|
+
const result = await enumerateWorkspaces({
|
|
4876
|
+
bin: config.bin,
|
|
4877
|
+
buildOpts: config.buildOpts,
|
|
4878
|
+
cwd: root.dir,
|
|
4879
|
+
ecosystem,
|
|
4880
|
+
entryFile: root.entryFile,
|
|
4881
|
+
excludeBase: scanRoot,
|
|
4882
|
+
excludePaths,
|
|
4883
|
+
javaHome: config.javaHome,
|
|
4884
|
+
verbose: verbose || config.verbose
|
|
4885
|
+
});
|
|
4886
|
+
if (!result) {
|
|
4887
|
+
return undefined;
|
|
4888
|
+
}
|
|
4889
|
+
return {
|
|
4890
|
+
membership: await membershipOf(result.buildRoot, result.projects, scanRoot),
|
|
4891
|
+
modules: Math.max(0, result.projects.length - 1)
|
|
4892
|
+
};
|
|
4893
|
+
}
|
|
4894
|
+
|
|
4895
|
+
// `label`, followed by how many modules it has, when any.
|
|
4896
|
+
function withModules(label, modules) {
|
|
4897
|
+
return modules ? `${label} and its ${modules} ${words.pluralize('module', modules)}` : label;
|
|
4898
|
+
}
|
|
4899
|
+
|
|
4900
|
+
// Tokenizes a build-tool options string (e.g. the value of `--gradle-opts`,
|
|
4901
|
+
// `--sbt-opts`, `--maven-opts`) into individual argv tokens. Splits on
|
|
4902
|
+
// whitespace but honors single and double quotes so a value containing spaces,
|
|
4903
|
+
// such as a settings path (`-s "my settings.xml"`), survives as one token
|
|
4904
|
+
// instead of being shredded into three. Quotes are consumed (not emitted), and
|
|
4905
|
+
// quoting is intra-token aware (`-Dkey="a b"` -> `-Dkey=a b`). For unquoted
|
|
4906
|
+
// input this is equivalent to the previous whitespace split.
|
|
4907
|
+
function parseBuildToolOpts(opts) {
|
|
4908
|
+
if (!opts) {
|
|
4909
|
+
return [];
|
|
4910
|
+
}
|
|
4911
|
+
const tokens = [];
|
|
4912
|
+
let current = '';
|
|
4913
|
+
let hasToken = false;
|
|
4914
|
+
let inSingle = false;
|
|
4915
|
+
let inDouble = false;
|
|
4916
|
+
for (let i = 0; i < opts.length; i += 1) {
|
|
4917
|
+
const ch = opts[i];
|
|
4918
|
+
if (inSingle) {
|
|
4919
|
+
if (ch === "'") {
|
|
4920
|
+
inSingle = false;
|
|
4921
|
+
} else {
|
|
4922
|
+
current += ch;
|
|
4923
|
+
}
|
|
4924
|
+
} else if (inDouble) {
|
|
4925
|
+
if (ch === '"') {
|
|
4926
|
+
inDouble = false;
|
|
4927
|
+
} else {
|
|
4928
|
+
current += ch;
|
|
4929
|
+
}
|
|
4930
|
+
} else if (ch === "'") {
|
|
4931
|
+
inSingle = true;
|
|
4932
|
+
hasToken = true;
|
|
4933
|
+
} else if (ch === '"') {
|
|
4934
|
+
inDouble = true;
|
|
4935
|
+
hasToken = true;
|
|
4936
|
+
} else if (ch === ' ' || ch === '\t') {
|
|
4937
|
+
if (hasToken) {
|
|
4938
|
+
tokens.push(current);
|
|
4939
|
+
current = '';
|
|
4940
|
+
hasToken = false;
|
|
4941
|
+
}
|
|
4942
|
+
} else {
|
|
4943
|
+
current += ch;
|
|
4944
|
+
hasToken = true;
|
|
4945
|
+
}
|
|
4946
|
+
}
|
|
4947
|
+
if (hasToken) {
|
|
4948
|
+
tokens.push(current);
|
|
4949
|
+
}
|
|
4950
|
+
return tokens;
|
|
4951
|
+
}
|
|
4952
|
+
|
|
4953
|
+
function normalizePathKey(value) {
|
|
4954
|
+
return value.replaceAll('\\', '/');
|
|
4955
|
+
}
|
|
4956
|
+
// A cascaded (not just root-level) disabled additionally skips this one build
|
|
4957
|
+
// root here, on top of its existing root-only ecosystem-wide meaning for
|
|
4958
|
+
// auto/gradle/etc. facts:false has no pom-mode equivalent here (facts-only),
|
|
4959
|
+
// so it skips too.
|
|
4960
|
+
function getSkipReason(ecosystem, disabled, facts) {
|
|
4961
|
+
if (disabled) {
|
|
4962
|
+
return `defaults.manifest.${ecosystem}.disabled is true`;
|
|
4963
|
+
}
|
|
4964
|
+
if (facts === false) {
|
|
4965
|
+
return `defaults.manifest.${ecosystem}.facts is false (pom mode)`;
|
|
4966
|
+
}
|
|
4967
|
+
return undefined;
|
|
4968
|
+
}
|
|
4969
|
+
|
|
4970
|
+
// Maven 3's options starting with `f`; its GnuParser takes a long name after
|
|
4971
|
+
// one dash too, and splits `-fX` and `-f=X` into `-f X`.
|
|
4972
|
+
const MAVEN_FILE_OPTS = new Set(['f', 'file']);
|
|
4973
|
+
const MAVEN_OTHER_F_OPTS = new Set(['fae', 'fail-at-end', 'fail-fast', 'fail-never', 'ff', 'fn']);
|
|
4974
|
+
|
|
4975
|
+
// Each POM is built by its own `--file`, so a user one is dropped.
|
|
4976
|
+
function withoutMavenFileOpts(dir, opts) {
|
|
4977
|
+
const kept = [];
|
|
4978
|
+
for (let i = 0, {
|
|
4979
|
+
length
|
|
4980
|
+
} = opts; i < length; i += 1) {
|
|
4981
|
+
const opt = opts[i];
|
|
4982
|
+
const name = opt.replace(/^--?/, '');
|
|
4983
|
+
if (opt === name || MAVEN_OTHER_F_OPTS.has(name)) {
|
|
4984
|
+
kept.push(opt);
|
|
4985
|
+
} else if (MAVEN_FILE_OPTS.has(name)) {
|
|
4986
|
+
i += 1;
|
|
4987
|
+
} else if (!MAVEN_FILE_OPTS.has(name.split('=')[0]) && !(opt.startsWith('-f') && !opt.startsWith('--'))) {
|
|
4988
|
+
kept.push(opt);
|
|
4989
|
+
}
|
|
4990
|
+
}
|
|
4991
|
+
if (kept.length !== opts.length) {
|
|
4992
|
+
logger.logger.warn(`Ignoring --file in mavenOpts for ${dir}: each POM there is built by its own file.`);
|
|
4993
|
+
}
|
|
4994
|
+
return kept;
|
|
4995
|
+
}
|
|
4996
|
+
|
|
4997
|
+
// A copy of a facts file, if there was one, and its sidecar entry.
|
|
4998
|
+
|
|
4999
|
+
// A build skipped by its own `builds` entry, loaded to skip what it loads.
|
|
5000
|
+
|
|
5001
|
+
// What loads a build another build covers, for messages.
|
|
5002
|
+
function describeLoader(loader) {
|
|
5003
|
+
return loader?.skipped ? `it is part of ${loader.path}, which is skipped` : `${loader?.path ?? 'another build'} builds it`;
|
|
5004
|
+
}
|
|
5005
|
+
function statusOf(loader) {
|
|
5006
|
+
return loader?.skipped ? 'skippedDisabled' : 'skippedCovered';
|
|
5007
|
+
}
|
|
5008
|
+
|
|
5009
|
+
// The options the build-tool scripts take besides the build itself.
|
|
5010
|
+
function buildToolScriptOptions(config, excludeBase, excludePaths) {
|
|
5011
|
+
return {
|
|
5012
|
+
bin: config.bin,
|
|
5013
|
+
excludeBase,
|
|
5014
|
+
excludePaths,
|
|
5015
|
+
toolOpts: config.buildOpts
|
|
5016
|
+
};
|
|
5017
|
+
}
|
|
5018
|
+
async function everyAsync(items, test) {
|
|
5019
|
+
for (const item of items) {
|
|
5020
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5021
|
+
if (!(await test(item))) {
|
|
5022
|
+
return false;
|
|
5023
|
+
}
|
|
5024
|
+
}
|
|
5025
|
+
return true;
|
|
5026
|
+
}
|
|
5027
|
+
|
|
5028
|
+
// Order-independent: a run that a later build turns out to load is dropped.
|
|
5029
|
+
async function walkTool(ctx, ecosystem, roots) {
|
|
5030
|
+
const buildFiles = BUILD_FILES[ecosystem];
|
|
5031
|
+
const candidates = roots.map((root, index) => ({
|
|
5032
|
+
index,
|
|
5033
|
+
marker: hasRootMarker(ecosystem, root),
|
|
5034
|
+
root
|
|
5035
|
+
}));
|
|
5036
|
+
// The tool run in a directory without a root marker loads the build of the
|
|
5037
|
+
// nearest ancestor that has one, so that build's skip applies to it.
|
|
5038
|
+
const ancestorBuild = candidates.map(candidate => {
|
|
5039
|
+
if (buildFiles.byFile || !buildFiles.loadsAncestorBuild || buildFiles.loadsAncestorBuild.except.includes(path.basename(candidate.root.dir)) || candidate.marker) {
|
|
5040
|
+
return undefined;
|
|
5041
|
+
}
|
|
5042
|
+
let nearest;
|
|
5043
|
+
for (const other of candidates) {
|
|
5044
|
+
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)) {
|
|
5045
|
+
nearest = other;
|
|
5046
|
+
}
|
|
5047
|
+
}
|
|
5048
|
+
return nearest;
|
|
5049
|
+
});
|
|
5050
|
+
const resolvedFor = ({
|
|
5051
|
+
root
|
|
5052
|
+
}) => ctx.resolveSettings(ecosystem, root);
|
|
5053
|
+
const configs = new Map();
|
|
5054
|
+
const configFor = candidate => {
|
|
5055
|
+
const {
|
|
5056
|
+
entryKey,
|
|
5057
|
+
sockJson
|
|
5058
|
+
} = resolvedFor(candidate);
|
|
5059
|
+
const {
|
|
5060
|
+
dir
|
|
5061
|
+
} = candidate.root;
|
|
5062
|
+
// Builds sharing a directory and its settings resolve them once.
|
|
5063
|
+
return utils.getOrInsert(configs, `${dir}\0${entryKey ?? ''}`, () => resolveEcosystemConfig(ecosystem, dir, sockJson));
|
|
5064
|
+
};
|
|
5065
|
+
|
|
5066
|
+
// 'load' when the build's own entry skips it, 'skip' when a directory
|
|
5067
|
+
// setting or the build it belongs to does.
|
|
5068
|
+
const skips = new Map();
|
|
5069
|
+
const warnedSkips = new Set();
|
|
5070
|
+
const warnOnce = message => {
|
|
5071
|
+
if (!warnedSkips.has(message)) {
|
|
5072
|
+
warnedSkips.add(message);
|
|
5073
|
+
logger.logger.warn(message);
|
|
5074
|
+
}
|
|
5075
|
+
};
|
|
5076
|
+
const skipOf = candidate => utils.getOrInsert(skips, candidate.index, () => {
|
|
5077
|
+
const {
|
|
5078
|
+
disabledBy
|
|
5079
|
+
} = resolvedFor(candidate);
|
|
5080
|
+
const {
|
|
5081
|
+
skipReason
|
|
5082
|
+
} = configFor(candidate);
|
|
5083
|
+
const ancestor = ancestorBuild[candidate.index];
|
|
5084
|
+
if (disabledBy?.key) {
|
|
5085
|
+
return 'load';
|
|
5086
|
+
}
|
|
5087
|
+
if (skipReason) {
|
|
5088
|
+
// One line per setting, not per build root it skips.
|
|
5089
|
+
warnOnce(disabledBy ? `Skipping ${ecosystem} builds in and beneath ${displayPath(disabledBy.dir)}: ${describeDisabledBy(ecosystem, disabledBy)}.` : `Skipping ${buildRootPath(candidate.root)} (${ecosystem}): ${skipReason}.`);
|
|
5090
|
+
return 'skip';
|
|
5091
|
+
}
|
|
5092
|
+
return ancestor && skipOf(ancestor) ? 'skip' : undefined;
|
|
5093
|
+
});
|
|
5094
|
+
const scriptOpts = candidate => buildToolScriptOptions(configFor(candidate), ctx.realCwd, ctx.excludePaths);
|
|
5095
|
+
|
|
5096
|
+
// A solution the SDK cannot read, built through its twin instead.
|
|
5097
|
+
const superseded = new Map();
|
|
5098
|
+
const isSuperseded = candidate => utils.getOrInsert(superseded, candidate.index, async () => ecosystem === 'dotnet' ? await isRootCovered(emptyMembership(), ecosystem, candidate.root, scriptOpts(candidate)) : false);
|
|
5099
|
+
const isCovered = (covered, candidate) => isBuildCovered(covered, ecosystem, candidate.root, scriptOpts(candidate));
|
|
5100
|
+
const isRunCovered = (covered, run) => isBuildCovered(covered, ecosystem, run.root, scriptOpts(run), run.membership);
|
|
5101
|
+
// Whether a build loads `candidate`'s project, even one that is a build of
|
|
5102
|
+
// its own: what excuses its failure.
|
|
5103
|
+
const isLoadedBy = (covered, candidate) => isRootCovered(covered, ecosystem, candidate.root, scriptOpts(candidate));
|
|
5104
|
+
const isCheaplyCovered = (covered, candidate) => !candidate.marker && isBuildRootCovered(covered, ecosystem, candidate.root);
|
|
5105
|
+
const runs = new Map();
|
|
5106
|
+
const loads = new Map();
|
|
5107
|
+
const failures = [];
|
|
5108
|
+
|
|
5109
|
+
// Drops, latest first, each run the others or the skipped builds cover
|
|
5110
|
+
// while every run dropped before stays covered.
|
|
5111
|
+
const keptRuns = async () => {
|
|
5112
|
+
const ordered = [...runs.values()].sort((a, b) => a.index - b.index);
|
|
5113
|
+
const kept = new Set(ordered);
|
|
5114
|
+
const dropped = [];
|
|
5115
|
+
const skipped = [...loads.values()].map(load => load.membership);
|
|
5116
|
+
// How many kept runs and skipped builds load each path: only a run whose
|
|
5117
|
+
// own paths another loads too can be covered, so most skip the union.
|
|
5118
|
+
const loaders = new Map();
|
|
5119
|
+
const count = (membership, by) => {
|
|
5120
|
+
for (const key of [...membership.dirs, ...membership.files]) {
|
|
5121
|
+
const normalized = normalizePathKey(key);
|
|
5122
|
+
loaders.set(normalized, (loaders.get(normalized) ?? 0) + by);
|
|
5123
|
+
}
|
|
5124
|
+
};
|
|
5125
|
+
const loadedByOthers = (run, key) => (loaders.get(normalizePathKey(key)) ?? 0) - ([...run.membership.dirs, ...run.membership.files].some(candidate => normalizePathKey(candidate) === normalizePathKey(key)) ? 1 : 0) > 0;
|
|
5126
|
+
// Covering a run takes another loading its root or something it loads.
|
|
5127
|
+
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));
|
|
5128
|
+
for (const membership of [...skipped, ...ordered.map(r => r.membership)]) {
|
|
5129
|
+
count(membership, 1);
|
|
5130
|
+
}
|
|
5131
|
+
const latestFirst = [...ordered].sort((a, b) => b.index - a.index);
|
|
5132
|
+
for (const run of latestFirst) {
|
|
5133
|
+
if (!mayBeCovered(run)) {
|
|
4597
5134
|
continue;
|
|
4598
5135
|
}
|
|
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
|
-
}
|
|
5136
|
+
const others = unionMemberships([...skipped, ...[...kept].filter(other => other !== run).map(other => other.membership)]);
|
|
5137
|
+
if (
|
|
5138
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5139
|
+
(await isRunCovered(others, run)) && (
|
|
5140
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5141
|
+
await everyAsync(dropped, done => isRunCovered(others, done)))) {
|
|
5142
|
+
kept.delete(run);
|
|
5143
|
+
dropped.push(run);
|
|
5144
|
+
count(run.membership, -1);
|
|
4619
5145
|
}
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
5146
|
+
}
|
|
5147
|
+
return ordered.filter(run => kept.has(run));
|
|
5148
|
+
};
|
|
5149
|
+
let kept = [];
|
|
5150
|
+
let coverage = emptyMembership();
|
|
5151
|
+
let skippedCoverage = emptyMembership();
|
|
5152
|
+
let uncoveredFailures = [];
|
|
5153
|
+
// Set when a run or load is added: only then can coverage change.
|
|
5154
|
+
let unsettled = false;
|
|
5155
|
+
const settle = async () => {
|
|
5156
|
+
if (unsettled) {
|
|
5157
|
+
unsettled = false;
|
|
5158
|
+
kept = await keptRuns();
|
|
5159
|
+
coverage = unionMemberships(kept.map(run => run.membership));
|
|
5160
|
+
skippedCoverage = unionMemberships([...loads.values()].map(load => load.membership));
|
|
5161
|
+
}
|
|
5162
|
+
const stillFailed = [];
|
|
5163
|
+
for (const failure of failures) {
|
|
5164
|
+
if (
|
|
5165
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5166
|
+
!(await isLoadedBy(coverage, failure)) &&
|
|
5167
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5168
|
+
!(await isLoadedBy(skippedCoverage, failure))) {
|
|
5169
|
+
stillFailed.push(failure);
|
|
5170
|
+
}
|
|
5171
|
+
}
|
|
5172
|
+
uncoveredFailures = stillFailed;
|
|
5173
|
+
};
|
|
5174
|
+
const isAborted = candidate => uncoveredFailures.some(failure => failure !== candidate && isPathInside$1(failure.root.dir, candidate.root.dir));
|
|
5175
|
+
for (;;) {
|
|
5176
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5177
|
+
await settle();
|
|
5178
|
+
let next;
|
|
5179
|
+
for (const candidate of candidates) {
|
|
5180
|
+
const {
|
|
5181
|
+
index
|
|
5182
|
+
} = candidate;
|
|
5183
|
+
if (runs.has(index) || loads.has(index) || failures.includes(candidate) || isAborted(candidate) || isCheaplyCovered(coverage, candidate) || isCheaplyCovered(skippedCoverage, candidate) || skipOf(candidate) === 'skip' || (
|
|
5184
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5185
|
+
await isSuperseded(candidate)) || (
|
|
5186
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5187
|
+
await isCovered(coverage, candidate)) || (
|
|
5188
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5189
|
+
await isCovered(skippedCoverage, candidate))) {
|
|
4626
5190
|
continue;
|
|
4627
5191
|
}
|
|
5192
|
+
next = candidate;
|
|
5193
|
+
break;
|
|
5194
|
+
}
|
|
5195
|
+
if (!next) {
|
|
5196
|
+
break;
|
|
5197
|
+
}
|
|
5198
|
+
if (skipOf(next) === 'load') {
|
|
4628
5199
|
// 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,
|
|
5200
|
+
const loaded = await loadBuild({
|
|
5201
|
+
config: configFor(next),
|
|
4636
5202
|
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
|
|
5203
|
+
excludePaths: ctx.excludePaths,
|
|
5204
|
+
root: next.root,
|
|
5205
|
+
scanRoot: ctx.realCwd,
|
|
5206
|
+
verbose: ctx.verbose
|
|
4651
5207
|
});
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
5208
|
+
const why = describeDisabledBy(ecosystem, resolvedFor(next).disabledBy);
|
|
5209
|
+
if (loaded) {
|
|
5210
|
+
loads.set(next.index, {
|
|
5211
|
+
...next,
|
|
5212
|
+
...loaded
|
|
4657
5213
|
});
|
|
4658
|
-
|
|
5214
|
+
unsettled = true;
|
|
5215
|
+
} else {
|
|
5216
|
+
failures.push(next);
|
|
5217
|
+
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
5218
|
}
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
5219
|
+
continue;
|
|
5220
|
+
}
|
|
5221
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5222
|
+
const run = await runCandidate(ctx, ecosystem, next, configFor(next));
|
|
5223
|
+
if (run) {
|
|
5224
|
+
runs.set(next.index, run);
|
|
5225
|
+
unsettled = true;
|
|
5226
|
+
} else {
|
|
5227
|
+
failures.push(next);
|
|
5228
|
+
}
|
|
5229
|
+
}
|
|
5230
|
+
|
|
5231
|
+
// The first kept run, or else skipped build, that loads `candidate`.
|
|
5232
|
+
const loaderOf = async candidate => {
|
|
5233
|
+
const ownRun = runs.get(candidate.index);
|
|
5234
|
+
const loaders = [...kept.filter(run => run !== ownRun).map(run => ({
|
|
5235
|
+
...run,
|
|
5236
|
+
skipped: false
|
|
5237
|
+
})), ...[...loads.values()].map(load => ({
|
|
5238
|
+
...load,
|
|
5239
|
+
skipped: true
|
|
5240
|
+
}))];
|
|
5241
|
+
for (const loader of loaders) {
|
|
5242
|
+
if (
|
|
5243
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5244
|
+
await (ownRun ? isRunCovered(loader.membership, ownRun) : isLoadedBy(loader.membership, candidate))) {
|
|
5245
|
+
return {
|
|
5246
|
+
path: buildRootPath(loader.root),
|
|
5247
|
+
skipped: loader.skipped
|
|
5248
|
+
};
|
|
4678
5249
|
}
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
5250
|
+
}
|
|
5251
|
+
return undefined;
|
|
5252
|
+
};
|
|
5253
|
+
const keptSet = new Set(kept);
|
|
5254
|
+
const keptKeys = new Set(kept.map(run => run.factsKey));
|
|
5255
|
+
const outcomes = [];
|
|
5256
|
+
for (const candidate of candidates) {
|
|
5257
|
+
const {
|
|
5258
|
+
index,
|
|
5259
|
+
root
|
|
5260
|
+
} = candidate;
|
|
5261
|
+
const run = runs.get(index);
|
|
5262
|
+
if (run && keptSet.has(run)) {
|
|
5263
|
+
if (run.result) {
|
|
5264
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5265
|
+
await putFacts(ctx, run.result.factsPath, run.factsKey, run.output);
|
|
4686
5266
|
}
|
|
4687
5267
|
outcomes.push({
|
|
4688
5268
|
...root,
|
|
4689
5269
|
ecosystem,
|
|
4690
|
-
|
|
4691
|
-
|
|
5270
|
+
...(run.result ? {
|
|
5271
|
+
factsPath: run.result.factsPath
|
|
5272
|
+
} : {}),
|
|
5273
|
+
status: run.result ? 'generated' : 'empty'
|
|
4692
5274
|
});
|
|
5275
|
+
continue;
|
|
5276
|
+
}
|
|
5277
|
+
let status;
|
|
5278
|
+
let discardedFactsPath;
|
|
5279
|
+
if (run) {
|
|
5280
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5281
|
+
const loader = await loaderOf(candidate);
|
|
5282
|
+
if (run.result) {
|
|
5283
|
+
logger.logger.info(`Dropping the Socket facts of ${buildRootPath(root)}: ${describeLoader(loader)}.`);
|
|
5284
|
+
if (!keptKeys.has(run.factsKey)) {
|
|
5285
|
+
discardedFactsPath = run.factsKey;
|
|
5286
|
+
}
|
|
5287
|
+
}
|
|
5288
|
+
status = statusOf(loader);
|
|
5289
|
+
} else if (loads.has(index)) {
|
|
5290
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5291
|
+
if (await isCovered(coverage, candidate)) {
|
|
5292
|
+
status = 'skippedCovered';
|
|
5293
|
+
} else {
|
|
5294
|
+
status = 'skippedDisabled';
|
|
5295
|
+
logger.logger.warn(`Skipping ${withModules(buildRootPath(root), loads.get(index).modules)}: ${describeDisabledBy(ecosystem, resolvedFor(candidate).disabledBy)}.`);
|
|
5296
|
+
}
|
|
5297
|
+
} else if (failures.includes(candidate)) {
|
|
5298
|
+
if (uncoveredFailures.includes(candidate)) {
|
|
5299
|
+
status = 'failed';
|
|
5300
|
+
} else {
|
|
5301
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5302
|
+
const loader = await loaderOf(candidate);
|
|
5303
|
+
if (skipOf(candidate) !== 'load') {
|
|
5304
|
+
logger.logger.info(`${buildRootPath(root)} failed to generate Socket facts on its own, but ${describeLoader(loader)}, so its failure is ignored.`);
|
|
5305
|
+
}
|
|
5306
|
+
status = statusOf(loader);
|
|
5307
|
+
}
|
|
5308
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5309
|
+
} else if (await isCovered(coverage, candidate)) {
|
|
5310
|
+
status = 'skippedCovered';
|
|
5311
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5312
|
+
} else if (await isCovered(skippedCoverage, candidate)) {
|
|
5313
|
+
status = 'skippedDisabled';
|
|
5314
|
+
} else if (isAborted(candidate)) {
|
|
5315
|
+
status = 'aborted';
|
|
5316
|
+
} else if (skipOf(candidate)) {
|
|
5317
|
+
status = 'skippedDisabled';
|
|
5318
|
+
} else {
|
|
5319
|
+
// A solution the SDK cannot read, built through its twin.
|
|
5320
|
+
status = 'skippedCovered';
|
|
5321
|
+
}
|
|
5322
|
+
if (status === 'skippedCovered') {
|
|
5323
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5324
|
+
await warnUnappliedEntry(candidate, resolvedFor(candidate).entryKey, () => loaderOf(candidate));
|
|
5325
|
+
}
|
|
5326
|
+
outcomes.push({
|
|
5327
|
+
...root,
|
|
5328
|
+
...(discardedFactsPath ? {
|
|
5329
|
+
discardedFactsPath
|
|
5330
|
+
} : {}),
|
|
5331
|
+
ecosystem,
|
|
5332
|
+
status
|
|
5333
|
+
});
|
|
5334
|
+
}
|
|
5335
|
+
for (const failure of uncoveredFailures) {
|
|
5336
|
+
const aborted = candidates.filter(candidate => isAborted(candidate) && !failures.includes(candidate) && isPathInside$1(failure.root.dir, candidate.root.dir));
|
|
5337
|
+
if (aborted.length) {
|
|
5338
|
+
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
5339
|
}
|
|
4694
5340
|
}
|
|
4695
5341
|
return outcomes;
|
|
4696
5342
|
}
|
|
4697
5343
|
|
|
4698
|
-
//
|
|
4699
|
-
//
|
|
5344
|
+
// A build root's own entry applies to nothing when another build loads it:
|
|
5345
|
+
// that build resolves it with its own settings.
|
|
5346
|
+
async function warnUnappliedEntry(candidate, entryKey, loaderOf) {
|
|
5347
|
+
if (!entryKey) {
|
|
5348
|
+
return;
|
|
5349
|
+
}
|
|
5350
|
+
const loader = await loaderOf();
|
|
5351
|
+
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.`);
|
|
5352
|
+
}
|
|
5353
|
+
async function runCandidate(ctx, ecosystem, candidate, dirConfig) {
|
|
5354
|
+
const {
|
|
5355
|
+
root
|
|
5356
|
+
} = candidate;
|
|
5357
|
+
const expectedFactsPath = path.join(root.dir, socketFactsFileName(ecosystem, root.entryFile) ?? '');
|
|
5358
|
+
const expectedKey = await utils.realpathOrResolved(expectedFactsPath);
|
|
5359
|
+
if (!ctx.originals.has(expectedKey)) {
|
|
5360
|
+
ctx.originals.set(expectedKey, await saveFacts(ctx, expectedFactsPath, expectedKey, `${ecosystem}-${candidate.index}`));
|
|
5361
|
+
}
|
|
5362
|
+
const result = await runManifestFacts({
|
|
5363
|
+
bin: dirConfig.bin,
|
|
5364
|
+
buildOpts: dirConfig.buildOpts,
|
|
5365
|
+
cwd: root.dir,
|
|
5366
|
+
ecosystem,
|
|
5367
|
+
entryFile: root.entryFile,
|
|
5368
|
+
// Relative to the scan root: a build can reach modules outside its own
|
|
5369
|
+
// directory (Maven `../x` modules, relocated Gradle projects).
|
|
5370
|
+
excludeBase: ctx.realCwd,
|
|
5371
|
+
excludeConfigs: dirConfig.excludeConfigs,
|
|
5372
|
+
excludePaths: ctx.excludePaths,
|
|
5373
|
+
hints: {
|
|
5374
|
+
continueOnInstallErrorsFlag: ctx.withFiles ? REACH_CONTINUE_ON_INSTALL_ERRORS_FLAG : undefined,
|
|
5375
|
+
flags: ctx.optionFlags,
|
|
5376
|
+
setupCommand: DSI_SETUP_COMMAND,
|
|
5377
|
+
socketJson: socketJsonPath(root.dir)
|
|
5378
|
+
},
|
|
5379
|
+
ignoreUnresolved: ctx.ignoreUnresolved ?? dirConfig.ignoreUnresolved,
|
|
5380
|
+
includeConfigs: dirConfig.includeConfigs,
|
|
5381
|
+
javaHome: dirConfig.javaHome,
|
|
5382
|
+
sidecarAcc: ctx.sidecarAcc,
|
|
5383
|
+
tmpDir: ecosystem === 'sbt' ? ctx.sbtTmpDir : undefined,
|
|
5384
|
+
verbose: ctx.verbose || dirConfig.verbose,
|
|
5385
|
+
withFiles: ctx.withFiles
|
|
5386
|
+
});
|
|
5387
|
+
if (result === null) {
|
|
5388
|
+
return undefined;
|
|
5389
|
+
}
|
|
5390
|
+
let factsKey;
|
|
5391
|
+
let output;
|
|
5392
|
+
if (result) {
|
|
5393
|
+
factsKey = await utils.realpathOrResolved(result.factsPath);
|
|
5394
|
+
output = await saveFacts(ctx, result.factsPath, factsKey, `${ecosystem}-${candidate.index}.out`);
|
|
5395
|
+
if (!ctx.originals.has(factsKey)) {
|
|
5396
|
+
ctx.originals.set(factsKey, undefined);
|
|
5397
|
+
}
|
|
5398
|
+
await putFacts(ctx, result.factsPath, factsKey, ctx.originals.get(factsKey));
|
|
5399
|
+
}
|
|
5400
|
+
return {
|
|
5401
|
+
...candidate,
|
|
5402
|
+
factsKey,
|
|
5403
|
+
// Gradle's `-p` can root the build away from `root.dir`.
|
|
5404
|
+
membership: result ? await membershipOf(path.dirname(result.factsPath), result.projects, ctx.realCwd) : emptyMembership(),
|
|
5405
|
+
output,
|
|
5406
|
+
result: result ?? undefined
|
|
5407
|
+
};
|
|
5408
|
+
}
|
|
5409
|
+
|
|
5410
|
+
// Puts `state` in place of a facts file and its sidecar entry; an unknown state
|
|
5411
|
+
// leaves the file and drops the entry.
|
|
5412
|
+
async function putFacts(ctx, file, key, state) {
|
|
5413
|
+
if (state?.sidecar) {
|
|
5414
|
+
ctx.sidecarAcc?.set(key, state.sidecar);
|
|
5415
|
+
} else {
|
|
5416
|
+
ctx.sidecarAcc?.delete(key);
|
|
5417
|
+
}
|
|
5418
|
+
if (!state) {
|
|
5419
|
+
return;
|
|
5420
|
+
}
|
|
5421
|
+
if (state.facts) {
|
|
5422
|
+
await u.promises.copyFile(state.facts, file);
|
|
5423
|
+
} else {
|
|
5424
|
+
await u.promises.rm(file, {
|
|
5425
|
+
force: true
|
|
5426
|
+
});
|
|
5427
|
+
}
|
|
5428
|
+
}
|
|
5429
|
+
async function saveFacts(ctx, file, key, name) {
|
|
5430
|
+
let facts;
|
|
5431
|
+
if (u.existsSync(file)) {
|
|
5432
|
+
facts = path.join(await ctx.backupDir(), name);
|
|
5433
|
+
await u.promises.copyFile(file, facts);
|
|
5434
|
+
}
|
|
5435
|
+
return {
|
|
5436
|
+
facts,
|
|
5437
|
+
sidecar: ctx.sidecarAcc?.get(key)
|
|
5438
|
+
};
|
|
5439
|
+
}
|
|
5440
|
+
|
|
5441
|
+
// Builds `root` unless earlier builds cover it, then adds what it loaded to
|
|
5442
|
+
// `covered`.
|
|
4700
5443
|
async function buildUncoveredRoot({
|
|
4701
5444
|
config,
|
|
4702
5445
|
covered,
|
|
@@ -4714,12 +5457,7 @@ async function buildUncoveredRoot({
|
|
|
4714
5457
|
bin,
|
|
4715
5458
|
buildOpts
|
|
4716
5459
|
} = config;
|
|
4717
|
-
if (await isRootCovered(covered, ecosystem, root, {
|
|
4718
|
-
bin,
|
|
4719
|
-
excludeBase,
|
|
4720
|
-
excludePaths,
|
|
4721
|
-
toolOpts: buildOpts
|
|
4722
|
-
})) {
|
|
5460
|
+
if (await isRootCovered(covered, ecosystem, root, buildToolScriptOptions(config, excludeBase, excludePaths))) {
|
|
4723
5461
|
return 'covered';
|
|
4724
5462
|
}
|
|
4725
5463
|
const result = await runManifestFacts({
|
|
@@ -4741,14 +5479,12 @@ async function buildUncoveredRoot({
|
|
|
4741
5479
|
withFiles
|
|
4742
5480
|
});
|
|
4743
5481
|
if (result) {
|
|
4744
|
-
|
|
4745
|
-
await addCoveredBuildFiles(covered, ecosystem, path.dirname(result.factsPath), result.projects);
|
|
5482
|
+
addMembership(covered, await membershipOf(path.dirname(result.factsPath), result.projects));
|
|
4746
5483
|
}
|
|
4747
5484
|
return result;
|
|
4748
5485
|
}
|
|
4749
5486
|
|
|
4750
|
-
// A
|
|
4751
|
-
// files it would have covered are all its own tool's.
|
|
5487
|
+
// A failure fails the walk only when no kept or skipped build loads it.
|
|
4752
5488
|
async function generateRecursiveManifests({
|
|
4753
5489
|
cwd,
|
|
4754
5490
|
excludePaths,
|
|
@@ -4765,9 +5501,8 @@ async function generateRecursiveManifests({
|
|
|
4765
5501
|
// must match or every boundary/relative-path comparison below breaks as
|
|
4766
5502
|
// soon as cwd contains a symlink (macOS /tmp -> /private/tmp, etc.).
|
|
4767
5503
|
const realCwd = await utils.realpathOrResolved(cwd);
|
|
4768
|
-
// A
|
|
4769
|
-
//
|
|
4770
|
-
// what actually decides skip vs. include.
|
|
5504
|
+
// A nested socket.json may re-enable an ecosystem the root disables, so the
|
|
5505
|
+
// per-root settings below decide skips, not this scan.
|
|
4771
5506
|
const candidatesByTool = await findBuildToolCandidates({
|
|
4772
5507
|
cwd,
|
|
4773
5508
|
excludePaths,
|
|
@@ -4775,18 +5510,46 @@ async function generateRecursiveManifests({
|
|
|
4775
5510
|
socketConfig: utils.loadSocketConfig(cwd),
|
|
4776
5511
|
sockJson: withoutDisabledFlags(rootSockJson)
|
|
4777
5512
|
});
|
|
4778
|
-
const
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
5513
|
+
const resolveSettings = createBuildRootSettingsResolver();
|
|
5514
|
+
// Invalid settings fail the scan before any build runs.
|
|
5515
|
+
for (const {
|
|
5516
|
+
0: tool,
|
|
5517
|
+
1: roots
|
|
5518
|
+
} of candidatesByTool) {
|
|
5519
|
+
for (const root of roots) {
|
|
5520
|
+
resolveSettings(tool, root);
|
|
5521
|
+
}
|
|
5522
|
+
}
|
|
5523
|
+
// A failure another build excuses leaves the exit code it set.
|
|
5524
|
+
const exitCodeBefore = process.exitCode;
|
|
5525
|
+
let backupDir;
|
|
5526
|
+
const runAll = async resolvedSbtTmpDir => {
|
|
5527
|
+
const ctx = {
|
|
5528
|
+
backupDir: async () => {
|
|
5529
|
+
backupDir ??= await u.promises.mkdtemp(path.join(os.tmpdir(), 'socket-facts-backup-'));
|
|
5530
|
+
return backupDir;
|
|
5531
|
+
},
|
|
5532
|
+
excludePaths,
|
|
5533
|
+
ignoreUnresolved,
|
|
5534
|
+
optionFlags,
|
|
5535
|
+
originals: new Map(),
|
|
5536
|
+
realCwd,
|
|
5537
|
+
resolveSettings,
|
|
5538
|
+
sbtTmpDir: resolvedSbtTmpDir,
|
|
5539
|
+
sidecarAcc,
|
|
5540
|
+
verbose,
|
|
5541
|
+
withFiles
|
|
5542
|
+
};
|
|
5543
|
+
const outcomes = [];
|
|
5544
|
+
for (const {
|
|
5545
|
+
0: ecosystem,
|
|
5546
|
+
1: roots
|
|
5547
|
+
} of candidatesByTool) {
|
|
5548
|
+
// eslint-disable-next-line no-await-in-loop
|
|
5549
|
+
outcomes.push(...(await walkTool(ctx, ecosystem, roots)));
|
|
5550
|
+
}
|
|
5551
|
+
return outcomes;
|
|
5552
|
+
};
|
|
4790
5553
|
|
|
4791
5554
|
// A shared global base across every sbt root in this run lets sbt's own
|
|
4792
5555
|
// Scala-toolchain cache under <base>/boot survive between invocations
|
|
@@ -4795,7 +5558,20 @@ async function generateRecursiveManifests({
|
|
|
4795
5558
|
// caller-supplied sbtTmpDir is reused as-is (the caller owns its lifetime);
|
|
4796
5559
|
// otherwise one is allocated and cleaned up here, but only when there's an
|
|
4797
5560
|
// sbt root to benefit from sharing it at all.
|
|
4798
|
-
|
|
5561
|
+
let outcomes;
|
|
5562
|
+
try {
|
|
5563
|
+
outcomes = sbtTmpDir ? await runAll(sbtTmpDir) : candidatesByTool.get('sbt')?.length ? await utils.withTmpDir('socket-sbt-facts-shared-', runAll) : await runAll(undefined);
|
|
5564
|
+
} finally {
|
|
5565
|
+
if (backupDir) {
|
|
5566
|
+
await u.promises.rm(backupDir, {
|
|
5567
|
+
recursive: true,
|
|
5568
|
+
force: true
|
|
5569
|
+
});
|
|
5570
|
+
}
|
|
5571
|
+
}
|
|
5572
|
+
if (!outcomes.some(o => o.status === 'failed')) {
|
|
5573
|
+
process.exitCode = exitCodeBefore;
|
|
5574
|
+
}
|
|
4799
5575
|
if (verbose) {
|
|
4800
5576
|
logger.logger.info(`Discovered ${outcomes.length} build-tool candidate(s).`);
|
|
4801
5577
|
}
|
|
@@ -4861,6 +5637,8 @@ function resolveEcosystemConfig(ecosystem, dir, sockJson) {
|
|
|
4861
5637
|
};
|
|
4862
5638
|
}
|
|
4863
5639
|
|
|
5640
|
+
const DSI_SETTINGS_DOCS_URL = 'https://github.com/SocketDev/socket-cli/blob/v1.x/docs/dynamic-sbom-inference-settings.md';
|
|
5641
|
+
|
|
4864
5642
|
// Who consumes the facts: Coana for `fix` and `reach` (which also resolves
|
|
4865
5643
|
// artifact paths), or only the scan upload.
|
|
4866
5644
|
|
|
@@ -4910,19 +5688,32 @@ async function runDynamicSbomInference({
|
|
|
4910
5688
|
// Fail loud rather than silently proceed with a partial multi-root result:
|
|
4911
5689
|
// matches handleManifestDynamicSbomInference's own check.
|
|
4912
5690
|
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).');
|
|
5691
|
+
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
5692
|
}
|
|
4915
5693
|
const factsPaths = outcomes.filter(o => o.status === 'generated').map(o => o.factsPath);
|
|
4916
5694
|
if (coanaReadsFacts) {
|
|
4917
5695
|
checkFactsForCoana(outcomes, consumer, !!factsPaths.length);
|
|
4918
5696
|
}
|
|
4919
5697
|
return {
|
|
5698
|
+
discardedFactsPaths: outcomes.flatMap(o => o.discardedFactsPath ? [o.discardedFactsPath] : []),
|
|
4920
5699
|
factsOnlyTypes,
|
|
4921
5700
|
factsPaths,
|
|
4922
5701
|
resolvedPathsSidecar: sidecarAcc && hasSidecarEntries(sidecarAcc) ? serializeSidecar(sidecarAcc) : undefined
|
|
4923
5702
|
};
|
|
4924
5703
|
}
|
|
4925
5704
|
|
|
5705
|
+
// `paths` without the facts files discovery discarded: each holds what was
|
|
5706
|
+
// there before the scan, or a dropped run's facts, not a kept build's.
|
|
5707
|
+
async function withoutDiscardedFacts(paths, discarded) {
|
|
5708
|
+
if (!discarded?.length) {
|
|
5709
|
+
return paths;
|
|
5710
|
+
}
|
|
5711
|
+
const names = new Set(discarded.map(p => path.basename(p)));
|
|
5712
|
+
const keys = new Set(discarded);
|
|
5713
|
+
const isDiscarded = await Promise.all(paths.map(async p => names.has(path.basename(p)) && keys.has(await utils.realpathOrResolved(p))));
|
|
5714
|
+
return paths.filter((_, index) => !isDiscarded[index]);
|
|
5715
|
+
}
|
|
5716
|
+
|
|
4926
5717
|
// The point here is to attempt to detect the various supported manifest files
|
|
4927
5718
|
// the CLI can generate. This would be environments that we can't do server side
|
|
4928
5719
|
|
|
@@ -5074,7 +5865,7 @@ function isNodeScript(bin) {
|
|
|
5074
5865
|
if (/\.[cm]?js$/i.test(bin)) {
|
|
5075
5866
|
return true;
|
|
5076
5867
|
}
|
|
5077
|
-
if (path.extname(bin) ||
|
|
5868
|
+
if (path.extname(bin) || !u.existsSync(bin)) {
|
|
5078
5869
|
return false;
|
|
5079
5870
|
}
|
|
5080
5871
|
const fd = u.openSync(bin, 'r');
|
|
@@ -5255,6 +6046,31 @@ function buildBazelStartupFlags(opts) {
|
|
|
5255
6046
|
* 4. If neither is found, throw InputError with install instructions.
|
|
5256
6047
|
*/
|
|
5257
6048
|
async function resolveBazelBinary(explicit, env, cwd) {
|
|
6049
|
+
if (utils.isStandaloneSea()) {
|
|
6050
|
+
const override = explicit ?? env['SOCKET_CLI_BAZEL_PATH'];
|
|
6051
|
+
if (!override) {
|
|
6052
|
+
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.');
|
|
6053
|
+
}
|
|
6054
|
+
const resolved = path.resolve(cwd, override);
|
|
6055
|
+
try {
|
|
6056
|
+
if (!u.existsSync(resolved) || !u.statSync(resolved).isFile()) {
|
|
6057
|
+
throw new Error('not a file');
|
|
6058
|
+
}
|
|
6059
|
+
if (process.platform !== 'win32') {
|
|
6060
|
+
u.accessSync(resolved, u.constants.X_OK);
|
|
6061
|
+
}
|
|
6062
|
+
} catch {
|
|
6063
|
+
throw new utils.InputError(`The standalone Bazel path '${resolved}' is missing or not executable.`);
|
|
6064
|
+
}
|
|
6065
|
+
const bin = resolveBazelExecutable(resolved);
|
|
6066
|
+
if (/^bazelisk(?:\.exe)?$/i.test(path.basename(bin))) {
|
|
6067
|
+
throw new utils.InputError('Standalone Socket requires an installed Bazel binary and will not use Bazelisk to download a Bazel version.');
|
|
6068
|
+
}
|
|
6069
|
+
if (bin === process.execPath || isNodeScript(bin)) {
|
|
6070
|
+
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.');
|
|
6071
|
+
}
|
|
6072
|
+
return bin;
|
|
6073
|
+
}
|
|
5258
6074
|
if (explicit) {
|
|
5259
6075
|
const resolved = path.resolve(cwd, explicit);
|
|
5260
6076
|
if (!u.existsSync(resolved)) {
|
|
@@ -5564,7 +6380,7 @@ function buildBazelArgv(queryStr, opts, output = 'build') {
|
|
|
5564
6380
|
// `--keep_going --output=label` keeps it fast even on partial-analysis
|
|
5565
6381
|
// repos and avoids paying for `--output=jsonproto` plus
|
|
5566
6382
|
// `--proto:output_rule_attrs` (which the heavier metadata extraction in
|
|
5567
|
-
// `
|
|
6383
|
+
// `cquery.mts` needs but the probe does not).
|
|
5568
6384
|
function buildBazelProbeCqueryArgv(repoName, opts) {
|
|
5569
6385
|
const userFlags = splitBazelFlags(opts.bazelFlags);
|
|
5570
6386
|
return [...buildBazelStartupFlags(opts), 'cquery', '--lockfile_mode=off', '--noshow_progress', ...opts.invocationFlags, `@${repoName}//...`, '--output=label', '--keep_going', ...userFlags];
|
|
@@ -5731,7 +6547,7 @@ async function runBazelModShowVisibleRepos(opts) {
|
|
|
5731
6547
|
/**
|
|
5732
6548
|
* Bzlmod-native Maven hub enumeration via the rules_jvm_external maven
|
|
5733
6549
|
* extension. The text-format report lists every repo the extension
|
|
5734
|
-
* generated; `parseShowExtensionOutput` (
|
|
6550
|
+
* generated; `parseShowExtensionOutput` (repo-discovery.mts)
|
|
5735
6551
|
* extracts the hubs from the `Fetched repositories:` section.
|
|
5736
6552
|
*/
|
|
5737
6553
|
async function runBazelModShowMavenExtension(opts) {
|
|
@@ -5748,7 +6564,7 @@ async function runBazelModShowPipExtension(opts) {
|
|
|
5748
6564
|
}
|
|
5749
6565
|
|
|
5750
6566
|
/**
|
|
5751
|
-
* Build a `RepoProbe` (compatible with
|
|
6567
|
+
* Build a `RepoProbe` (compatible with repo-discovery's tri-state
|
|
5752
6568
|
* classifier) bound to opts. Runs the lightweight presence-check cquery
|
|
5753
6569
|
* `@<name>//... --output=label --keep_going` — cheap enough to attempt
|
|
5754
6570
|
* every conventional Maven hub name without triggering `repository_rule`
|
|
@@ -6298,6 +7114,18 @@ function validateOutputBase(outputBase, cwd) {
|
|
|
6298
7114
|
}
|
|
6299
7115
|
}
|
|
6300
7116
|
|
|
7117
|
+
const BAZEL_AUTO_MANIFEST_DIR_NAME = '.socket-auto-manifest';
|
|
7118
|
+
const BAZEL_MANIFESTS_DIR_NAME = 'bazel-manifests';
|
|
7119
|
+
const BAZEL_SYNTHETIC_OUTPUT_DIR_NAMES = new Set([BAZEL_AUTO_MANIFEST_DIR_NAME, BAZEL_MANIFESTS_DIR_NAME]);
|
|
7120
|
+
const SOCKET_WORKSPACE_DIR_NAME = '.socket';
|
|
7121
|
+
const DEFAULT_BAZEL_MANIFEST_OUTPUT_DISPLAY_PATH = `./${SOCKET_WORKSPACE_DIR_NAME}/${BAZEL_MANIFESTS_DIR_NAME}/`;
|
|
7122
|
+
function getBazelAutoManifestDirectory(out) {
|
|
7123
|
+
return path.join(out, BAZEL_AUTO_MANIFEST_DIR_NAME);
|
|
7124
|
+
}
|
|
7125
|
+
function getDefaultBazelManifestDirectory(repo) {
|
|
7126
|
+
return path.join(repo, SOCKET_WORKSPACE_DIR_NAME, BAZEL_MANIFESTS_DIR_NAME);
|
|
7127
|
+
}
|
|
7128
|
+
|
|
6301
7129
|
function isPython3(executable, env, cwd) {
|
|
6302
7130
|
try {
|
|
6303
7131
|
const version = childProcess.execFileSync(executable, ['-c', 'import sys\nprint(sys.version_info.major)'], {
|
|
@@ -6312,11 +7140,58 @@ function isPython3(executable, env, cwd) {
|
|
|
6312
7140
|
// Windows application aliases can resolve without a working interpreter.
|
|
6313
7141
|
return false;
|
|
6314
7142
|
}
|
|
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) {
|
|
7143
|
+
}
|
|
7144
|
+
function notPython3Error(executable) {
|
|
7145
|
+
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.`);
|
|
7146
|
+
}
|
|
7147
|
+
async function provisionPythonShim(env, cwd) {
|
|
7148
|
+
if (utils.isStandaloneSea()) {
|
|
7149
|
+
const override = env['SOCKET_CLI_PYTHON_PATH'];
|
|
7150
|
+
if (!override) {
|
|
7151
|
+
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.');
|
|
7152
|
+
}
|
|
7153
|
+
const executable = path.resolve(cwd, override);
|
|
7154
|
+
try {
|
|
7155
|
+
u.accessSync(executable, process.platform === 'win32' ? u.constants.F_OK : u.constants.X_OK);
|
|
7156
|
+
if (!u.statSync(executable).isFile()) {
|
|
7157
|
+
throw new Error('not a file');
|
|
7158
|
+
}
|
|
7159
|
+
} catch {
|
|
7160
|
+
throw new utils.InputError(`SOCKET_CLI_PYTHON_PATH must point to an executable Python 3 binary, but '${executable}' is missing or not executable.`);
|
|
7161
|
+
}
|
|
7162
|
+
if (process.platform === 'win32' && path.extname(executable).toLowerCase() !== '.exe') {
|
|
7163
|
+
throw new utils.InputError('Bazel on Windows requires SOCKET_CLI_PYTHON_PATH to point to a native Python 3 python.exe.');
|
|
7164
|
+
}
|
|
7165
|
+
if (!isPython3(executable, env, cwd)) {
|
|
7166
|
+
throw notPython3Error(executable);
|
|
7167
|
+
}
|
|
7168
|
+
if (process.platform === 'win32') {
|
|
7169
|
+
if (path.basename(executable).toLowerCase() !== 'python.exe') {
|
|
7170
|
+
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.");
|
|
7171
|
+
}
|
|
7172
|
+
return {
|
|
7173
|
+
env: prependBazelPath(env, path.dirname(executable)),
|
|
7174
|
+
shimDir: undefined
|
|
7175
|
+
};
|
|
7176
|
+
}
|
|
7177
|
+
const shimDir = u.mkdtempSync(path.join(os.tmpdir(), 'socket-bazel-python-'));
|
|
7178
|
+
try {
|
|
7179
|
+
for (const name of ['python', 'python3']) {
|
|
7180
|
+
const alias = path.join(shimDir, name);
|
|
7181
|
+
u.symlinkSync(executable, alias);
|
|
7182
|
+
}
|
|
7183
|
+
} catch (error) {
|
|
7184
|
+
u.rmSync(shimDir, {
|
|
7185
|
+
recursive: true,
|
|
7186
|
+
force: true
|
|
7187
|
+
});
|
|
7188
|
+
throw error;
|
|
7189
|
+
}
|
|
7190
|
+
return {
|
|
7191
|
+
env: prependBazelPath(env, shimDir),
|
|
7192
|
+
shimDir
|
|
7193
|
+
};
|
|
7194
|
+
}
|
|
6320
7195
|
const python = await findBazelExecutable('python', env, cwd);
|
|
6321
7196
|
if (python) {
|
|
6322
7197
|
if (process.platform === 'win32' && path.extname(python).toLowerCase() !== '.exe') {
|
|
@@ -6819,7 +7694,7 @@ const COMPLETENESS_SUMMARY_FILE_NAME = 'socket-bazel-manifest-summary.json';
|
|
|
6819
7694
|
// `socket manifest bazel` command nor `--auto-manifest`) can omit it and let
|
|
6820
7695
|
// the walk descend `node_modules`/VCS/vendored trees. Callers may
|
|
6821
7696
|
// 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',
|
|
7697
|
+
const DEFAULT_BAZEL_WALKER_IGNORE_DIR_NAMES = new Set([...utils.IGNORED_DIRS, '.hg', '.idea', '.pnpm-store', BAZEL_AUTO_MANIFEST_DIR_NAME, '.svn', '.vscode']);
|
|
6823
7698
|
// Bazel's `bazel-*` output_base symlinks.
|
|
6824
7699
|
const DEFAULT_BAZEL_WALKER_IGNORE_DIR_PREFIXES = ['bazel-'];
|
|
6825
7700
|
// Splits "g:a:v" -> { groupArtifact: "g:a", version: "v" }.
|
|
@@ -6974,8 +7849,6 @@ function hubManifestFileName(repoName) {
|
|
|
6974
7849
|
// the explicit-command default output dir. The gate must never read a file in
|
|
6975
7850
|
// one of these as evidence of committed coverage, or a stale prior-run
|
|
6976
7851
|
// 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
7852
|
// Does a committed lockfile already cover THIS hub at THIS hub's own workspace
|
|
6980
7853
|
// root? Each workspace is processed independently by the caller, and a
|
|
6981
7854
|
// committed lockfile covers the workspace it lives IN — a nested workspace's
|
|
@@ -7000,7 +7873,7 @@ function committedLockfileCovers(args) {
|
|
|
7000
7873
|
const workspaceRootResolved = path.resolve(workspaceRoot);
|
|
7001
7874
|
// The committed lockfile, if any, lives directly in the hub's own workspace
|
|
7002
7875
|
// root — not in a nested workspace and not in the CLI's output dir.
|
|
7003
|
-
if (workspaceRootResolved === manifestDirResolved ||
|
|
7876
|
+
if (workspaceRootResolved === manifestDirResolved || BAZEL_SYNTHETIC_OUTPUT_DIR_NAMES.has(path.basename(workspaceRootResolved))) {
|
|
7004
7877
|
// The workspace root IS an output location; nothing here is committed.
|
|
7005
7878
|
return undefined;
|
|
7006
7879
|
}
|
|
@@ -7289,7 +8162,7 @@ async function extractBazelToMaven(opts) {
|
|
|
7289
8162
|
logger.logger.log(`[VERBOSE] initial --output_user_root=${outputUserRoot} (will be reaped on completion)`);
|
|
7290
8163
|
}
|
|
7291
8164
|
const layout = opts.outLayout ?? 'standalone';
|
|
7292
|
-
const manifestDir = layout === 'flat' ?
|
|
8165
|
+
const manifestDir = layout === 'flat' ? getBazelAutoManifestDirectory(out) : out;
|
|
7293
8166
|
// One manifest per (workspace, hub), written best-effort: a single wedged
|
|
7294
8167
|
// hub must not discard the manifests every other hub produced.
|
|
7295
8168
|
const manifestPaths = [];
|
|
@@ -7709,7 +8582,7 @@ async function convertDotnetToFacts({
|
|
|
7709
8582
|
return null;
|
|
7710
8583
|
}
|
|
7711
8584
|
const dir = await utils.realpathOrResolved(cwd);
|
|
7712
|
-
const covered =
|
|
8585
|
+
const covered = emptyMembership();
|
|
7713
8586
|
let last;
|
|
7714
8587
|
for (const entry of entries) {
|
|
7715
8588
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -7852,9 +8725,18 @@ async function convertGradleToMaven({
|
|
|
7852
8725
|
}) {
|
|
7853
8726
|
// TODO: Implement json/md.
|
|
7854
8727
|
|
|
8728
|
+
let selectedBin;
|
|
8729
|
+
try {
|
|
8730
|
+
selectedBin = resolveBuildToolBin('gradle', cwd, bin, utils.isStandaloneSea());
|
|
8731
|
+
} catch (error) {
|
|
8732
|
+
process.exitCode = 1;
|
|
8733
|
+
logger.logger.fail(error instanceof Error ? error.message : String(error));
|
|
8734
|
+
return;
|
|
8735
|
+
}
|
|
8736
|
+
|
|
7855
8737
|
// Note: use resolve because the bin could be an absolute path, away from cwd
|
|
7856
8738
|
// TODO: what about $PATH resolved commands? (`gradlew` without dir prefix)
|
|
7857
|
-
const rBin = path.resolve(cwd,
|
|
8739
|
+
const rBin = path.resolve(cwd, selectedBin);
|
|
7858
8740
|
const binExists = u.existsSync(rBin);
|
|
7859
8741
|
const cwdExists = u.existsSync(cwd);
|
|
7860
8742
|
logger.logger.group('gradle2maven:');
|
|
@@ -7881,9 +8763,9 @@ async function convertGradleToMaven({
|
|
|
7881
8763
|
const excludeProps = excludePaths?.length ? [`-Psocket.excludePaths=${excludePaths.join(',')}`] : [];
|
|
7882
8764
|
const commandArgs = ['--init-script', initLocation, ...excludeProps, ...gradleOpts, 'pom'];
|
|
7883
8765
|
if (verbose) {
|
|
7884
|
-
logger.logger.log('[VERBOSE] Executing:', [
|
|
8766
|
+
logger.logger.log('[VERBOSE] Executing:', [selectedBin], ', args:', commandArgs);
|
|
7885
8767
|
}
|
|
7886
|
-
logger.logger.log(`Converting gradle to maven from \`${
|
|
8768
|
+
logger.logger.log(`Converting gradle to maven from \`${selectedBin}\` on \`${cwd}\` ...`);
|
|
7887
8769
|
const output = await execGradle(rBin, commandArgs, cwd, verbose);
|
|
7888
8770
|
if (output.code) {
|
|
7889
8771
|
process.exitCode = 1;
|
|
@@ -7994,22 +8876,30 @@ async function convertSbtToMaven({
|
|
|
7994
8876
|
}) {
|
|
7995
8877
|
// TODO: Implement json/md.
|
|
7996
8878
|
|
|
8879
|
+
let selectedBin;
|
|
8880
|
+
try {
|
|
8881
|
+
selectedBin = resolveBuildToolBin('sbt', cwd, bin, utils.isStandaloneSea());
|
|
8882
|
+
} catch (error) {
|
|
8883
|
+
process.exitCode = 1;
|
|
8884
|
+
logger.logger.fail(error instanceof Error ? error.message : String(error));
|
|
8885
|
+
return;
|
|
8886
|
+
}
|
|
7997
8887
|
const {
|
|
7998
8888
|
spinner
|
|
7999
8889
|
} = constants.default;
|
|
8000
8890
|
logger.logger.group('sbt2maven:');
|
|
8001
|
-
logger.logger.info(`- executing: \`${
|
|
8891
|
+
logger.logger.info(`- executing: \`${selectedBin}\``);
|
|
8002
8892
|
logger.logger.info(`- src dir: \`${cwd}\``);
|
|
8003
8893
|
logger.logger.groupEnd();
|
|
8004
8894
|
try {
|
|
8005
|
-
spinner.start(`Converting sbt to maven from \`${
|
|
8895
|
+
spinner.start(`Converting sbt to maven from \`${selectedBin}\` on \`${cwd}\`...`);
|
|
8006
8896
|
|
|
8007
8897
|
// Run sbt with the init script we provide which should yield zero or more
|
|
8008
8898
|
// pom files. We have to figure out where to store those pom files such that
|
|
8009
8899
|
// we can upload them and predict them through the GitHub API. We could do a
|
|
8010
8900
|
// .socket folder. We could do a socket.pom.gz with all the poms, although
|
|
8011
8901
|
// I'd prefer something plain-text if it is to be committed.
|
|
8012
|
-
const output = await spawn.spawn(
|
|
8902
|
+
const output = await spawn.spawn(selectedBin, ['makePom', ...sbtOpts], {
|
|
8013
8903
|
cwd
|
|
8014
8904
|
});
|
|
8015
8905
|
spinner.stop();
|
|
@@ -8560,6 +9450,7 @@ async function createNewScan({
|
|
|
8560
9450
|
// Sidecar forwarded to reachability; populated only when reach runs.
|
|
8561
9451
|
let resolvedPathsSidecar;
|
|
8562
9452
|
let factsOnlyTypes;
|
|
9453
|
+
let discardedFactsPaths;
|
|
8563
9454
|
|
|
8564
9455
|
// sbt provisions its Scala toolchain under the directory passed as its
|
|
8565
9456
|
// isolated global base; reach's artifactPaths point into it, so it must
|
|
@@ -8590,6 +9481,7 @@ async function createNewScan({
|
|
|
8590
9481
|
scanTargets = Array.from(new Set([...scanTargets, ...dynamicResult.factsPaths]));
|
|
8591
9482
|
resolvedPathsSidecar = dynamicResult.resolvedPathsSidecar;
|
|
8592
9483
|
factsOnlyTypes = dynamicResult.factsOnlyTypes;
|
|
9484
|
+
discardedFactsPaths = dynamicResult.discardedFactsPaths;
|
|
8593
9485
|
}
|
|
8594
9486
|
if (autoManifest) {
|
|
8595
9487
|
const sockJson = utils.readOrDefaultSocketJson(cwd);
|
|
@@ -8655,11 +9547,11 @@ async function createNewScan({
|
|
|
8655
9547
|
reachabilityOptions: reach,
|
|
8656
9548
|
target: targets[0]
|
|
8657
9549
|
});
|
|
8658
|
-
const packagePaths = scanFiles ?? (await utils.getPackageFilesForScan(scanTargets, supportedFiles, {
|
|
9550
|
+
const packagePaths = scanFiles ?? (await withoutDiscardedFacts(await utils.getPackageFilesForScan(scanTargets, supportedFiles, {
|
|
8659
9551
|
additionalIgnores: additionalScaIgnores,
|
|
8660
9552
|
config: socketConfig,
|
|
8661
9553
|
cwd
|
|
8662
|
-
}));
|
|
9554
|
+
}), discardedFactsPaths));
|
|
8663
9555
|
spinner.successAndStop(`Found ${packagePaths.length} ${words.pluralize('file', packagePaths.length)} to include in scan.`);
|
|
8664
9556
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
8665
9557
|
nook: true,
|
|
@@ -8700,7 +9592,6 @@ async function createNewScan({
|
|
|
8700
9592
|
});
|
|
8701
9593
|
spinner.start();
|
|
8702
9594
|
const reachResult = await performReachabilityAnalysis({
|
|
8703
|
-
branchName,
|
|
8704
9595
|
cwd,
|
|
8705
9596
|
factsOnlyTypes,
|
|
8706
9597
|
orgSlug,
|
|
@@ -8905,7 +9796,6 @@ async function handleCi(autoManifest) {
|
|
|
8905
9796
|
reachDisableDependencyDownloads: false,
|
|
8906
9797
|
reachDisableExternalToolChecks: false,
|
|
8907
9798
|
reachEcosystems: [],
|
|
8908
|
-
reachEnableAnalysisSplitting: false,
|
|
8909
9799
|
reachExcludePaths: [],
|
|
8910
9800
|
reachFallbackToRegularScan: false,
|
|
8911
9801
|
reachRetainFactsFile: false,
|
|
@@ -10269,10 +11159,12 @@ async function generateSocketFactsForFix({
|
|
|
10269
11159
|
await restoreAll(originals);
|
|
10270
11160
|
};
|
|
10271
11161
|
let artifactsFlags;
|
|
11162
|
+
let discardedPaths;
|
|
10272
11163
|
let paths;
|
|
10273
11164
|
const sidecarFile = path.join(tmpDir, 'sidecar.json');
|
|
10274
11165
|
try {
|
|
10275
11166
|
const {
|
|
11167
|
+
discardedFactsPaths,
|
|
10276
11168
|
factsOnlyTypes,
|
|
10277
11169
|
factsPaths,
|
|
10278
11170
|
resolvedPathsSidecar
|
|
@@ -10284,6 +11176,7 @@ async function generateSocketFactsForFix({
|
|
|
10284
11176
|
sbtTmpDir: undefined
|
|
10285
11177
|
});
|
|
10286
11178
|
artifactsFlags = utils.useOnlySocketFactsArtifactsFlags(factsOnlyTypes);
|
|
11179
|
+
discardedPaths = discardedFactsPaths;
|
|
10287
11180
|
paths = factsPaths.map(p => path.resolve(cwd, p));
|
|
10288
11181
|
// Written even when empty, as for reach; applying fixes looks each facts
|
|
10289
11182
|
// file up in it, so an empty one is the same as none.
|
|
@@ -10299,9 +11192,11 @@ async function generateSocketFactsForFix({
|
|
|
10299
11192
|
}) => !generated.has(source)), ...(await backUp(paths, path.join(tmpDir, 'generated')))];
|
|
10300
11193
|
return {
|
|
10301
11194
|
artifactsFlags,
|
|
11195
|
+
discardedPaths,
|
|
10302
11196
|
paths,
|
|
10303
11197
|
sidecarFile,
|
|
10304
|
-
|
|
11198
|
+
// A discarded file a run left as written is removed too.
|
|
11199
|
+
remove: () => reset([...paths, ...discardedPaths]),
|
|
10305
11200
|
restore: () => restoreAll(backups)
|
|
10306
11201
|
};
|
|
10307
11202
|
}
|
|
@@ -10523,7 +11418,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
|
|
|
10523
11418
|
cwd,
|
|
10524
11419
|
outputPath: constants.DOT_SOCKET_DOT_FACTS_JSON
|
|
10525
11420
|
}));
|
|
10526
|
-
|
|
11421
|
+
let scanFilepaths = await findScanFilepaths();
|
|
10527
11422
|
if (factsSlot) {
|
|
10528
11423
|
if (!silence) {
|
|
10529
11424
|
spinner?.stop();
|
|
@@ -10536,6 +11431,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
|
|
|
10536
11431
|
findFactsPaths: async () => (await findScanFilepaths()).filter(utils.isSocketFactsFile),
|
|
10537
11432
|
tmpDir: factsSlot.tmpDir
|
|
10538
11433
|
});
|
|
11434
|
+
scanFilepaths = await withoutDiscardedFacts(scanFilepaths, factsSlot.generated.discardedPaths);
|
|
10539
11435
|
const known = new Set(scanFilepaths);
|
|
10540
11436
|
scanFilepaths.push(...factsSlot.generated.paths.filter(p => !known.has(p)));
|
|
10541
11437
|
if (!silence) {
|
|
@@ -11264,7 +12160,8 @@ const reachabilityFlags = {
|
|
|
11264
12160
|
reachEnableAnalysisSplitting: {
|
|
11265
12161
|
type: 'boolean',
|
|
11266
12162
|
default: false,
|
|
11267
|
-
|
|
12163
|
+
hidden: true,
|
|
12164
|
+
description: 'Deprecated: Analysis splitting is no longer supported. This flag is a no-op.'
|
|
11268
12165
|
},
|
|
11269
12166
|
reachEcosystems: {
|
|
11270
12167
|
type: 'string',
|
|
@@ -12367,6 +13264,161 @@ async function run$K(argv, importMeta, {
|
|
|
12367
13264
|
await attemptLogout();
|
|
12368
13265
|
}
|
|
12369
13266
|
|
|
13267
|
+
async function runCdxgen$1(projectPath, outputPath, options, beforeExit) {
|
|
13268
|
+
const isolatedRoot = await u.promises.mkdtemp(path.join(os.tmpdir(), 'socket-cdxgen-api-'));
|
|
13269
|
+
try {
|
|
13270
|
+
const packageJson = JSON.parse(await u.promises.readFile(path.join(projectPath, 'package.json'), 'utf8'));
|
|
13271
|
+
if (typeof packageJson['name'] !== 'string' || !packageJson['name']) {
|
|
13272
|
+
// cdxgen otherwise uses the directory basename as its fallback project
|
|
13273
|
+
// name; retain the user's project identity while scanning the temp root.
|
|
13274
|
+
packageJson['name'] = path.basename(path.resolve(projectPath));
|
|
13275
|
+
}
|
|
13276
|
+
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'))]);
|
|
13277
|
+
} catch (error) {
|
|
13278
|
+
await u.promises.rm(isolatedRoot, {
|
|
13279
|
+
recursive: true,
|
|
13280
|
+
force: true
|
|
13281
|
+
});
|
|
13282
|
+
throw error;
|
|
13283
|
+
}
|
|
13284
|
+
const process = new require$$0$2.EventEmitter();
|
|
13285
|
+
const cleanTemp = async () => await u.promises.rm(isolatedRoot, {
|
|
13286
|
+
recursive: true,
|
|
13287
|
+
force: true
|
|
13288
|
+
});
|
|
13289
|
+
const embeddedPromise = utils.runEmbeddedJsTool('cdxgen', [], {
|
|
13290
|
+
cwd: options?.cwd,
|
|
13291
|
+
env: {
|
|
13292
|
+
CDXGEN_PLUGINS_DIR: 'plugins-empty'
|
|
13293
|
+
},
|
|
13294
|
+
inheritEnv: false,
|
|
13295
|
+
signal: options?.signal,
|
|
13296
|
+
stdio: options?.stdio,
|
|
13297
|
+
ipc: {
|
|
13298
|
+
projectPath: isolatedRoot,
|
|
13299
|
+
sourceRoot: path.resolve(projectPath),
|
|
13300
|
+
outputPath
|
|
13301
|
+
}
|
|
13302
|
+
});
|
|
13303
|
+
const finalize = async (code, signal) => {
|
|
13304
|
+
const cleanupResults = await Promise.allSettled([cleanTemp(), Promise.resolve().then(async () => await beforeExit?.())]);
|
|
13305
|
+
const cleanupErrors = cleanupResults.flatMap(result => result.status === 'rejected' ? [result.reason] : []);
|
|
13306
|
+
const failure = cleanupErrors.length === 0 ? undefined : cleanupErrors.length === 1 ? cleanupErrors[0] : new AggregateError(cleanupErrors, 'cdxgen cleanup failed');
|
|
13307
|
+
process.emit('exit', failure ? 1 : code, failure ? null : signal);
|
|
13308
|
+
if (failure) {
|
|
13309
|
+
throw failure;
|
|
13310
|
+
}
|
|
13311
|
+
};
|
|
13312
|
+
const spawnPromise = embeddedPromise.then(async result => {
|
|
13313
|
+
await finalize(result.code, result.signal);
|
|
13314
|
+
return result;
|
|
13315
|
+
}, async error => {
|
|
13316
|
+
await finalize(1, null);
|
|
13317
|
+
throw error;
|
|
13318
|
+
});
|
|
13319
|
+
Object.defineProperty(spawnPromise, 'process', {
|
|
13320
|
+
value: process
|
|
13321
|
+
});
|
|
13322
|
+
return {
|
|
13323
|
+
spawnPromise
|
|
13324
|
+
};
|
|
13325
|
+
}
|
|
13326
|
+
|
|
13327
|
+
async function removeIfOwned(filename, identity) {
|
|
13328
|
+
try {
|
|
13329
|
+
const stat = await u.promises.lstat(filename);
|
|
13330
|
+
if (String(stat.dev) === identity.dev && String(stat.ino) === identity.ino) {
|
|
13331
|
+
await u.promises.unlink(filename);
|
|
13332
|
+
}
|
|
13333
|
+
} catch (error) {
|
|
13334
|
+
if (!(error instanceof Error && 'code' in error && error.code === 'ENOENT')) {
|
|
13335
|
+
throw error;
|
|
13336
|
+
}
|
|
13337
|
+
}
|
|
13338
|
+
}
|
|
13339
|
+
async function removeOwnedPackageLock(owner) {
|
|
13340
|
+
if (!owner) {
|
|
13341
|
+
return;
|
|
13342
|
+
}
|
|
13343
|
+
try {
|
|
13344
|
+
const [stat, contents] = await Promise.all([u.promises.lstat(owner.path), u.promises.readFile(owner.path)]);
|
|
13345
|
+
const digest = require$$0.createHash('sha256').update(contents).digest('hex');
|
|
13346
|
+
if (String(stat.dev) === owner.dev && String(stat.ino) === owner.ino && stat.size === owner.size && digest === owner.sha256) {
|
|
13347
|
+
await u.promises.unlink(owner.path);
|
|
13348
|
+
}
|
|
13349
|
+
} catch (error) {
|
|
13350
|
+
if (!(error instanceof Error && 'code' in error && error.code === 'ENOENT')) {
|
|
13351
|
+
throw error;
|
|
13352
|
+
}
|
|
13353
|
+
}
|
|
13354
|
+
}
|
|
13355
|
+
async function convertYarnClassicToNpmLock(projectPath, signal) {
|
|
13356
|
+
utils.assertEmbeddedToolAvailable('synp');
|
|
13357
|
+
const root = path.resolve(projectPath);
|
|
13358
|
+
const packageLockPath = path.join(root, 'package-lock.json');
|
|
13359
|
+
const temporaryPath = path.join(root, `.socket-cdxgen-lock-${require$$0.randomUUID()}.tmp`);
|
|
13360
|
+
const placeholder = await u.promises.open(temporaryPath, 'wx', 0o600);
|
|
13361
|
+
const placeholderStat = await placeholder.stat();
|
|
13362
|
+
await placeholder.close();
|
|
13363
|
+
const placeholderIdentity = {
|
|
13364
|
+
dev: String(placeholderStat.dev),
|
|
13365
|
+
ino: String(placeholderStat.ino)
|
|
13366
|
+
};
|
|
13367
|
+
let packageLockOwner;
|
|
13368
|
+
try {
|
|
13369
|
+
const result = await utils.runEmbeddedJsTool('synp', [], {
|
|
13370
|
+
cwd: root,
|
|
13371
|
+
inheritEnv: false,
|
|
13372
|
+
env: {},
|
|
13373
|
+
signal,
|
|
13374
|
+
stdio: 'pipe',
|
|
13375
|
+
ipc: {
|
|
13376
|
+
projectPath: root,
|
|
13377
|
+
outputPath: temporaryPath,
|
|
13378
|
+
tempDev: placeholderIdentity.dev,
|
|
13379
|
+
tempIno: placeholderIdentity.ino
|
|
13380
|
+
}
|
|
13381
|
+
});
|
|
13382
|
+
if (result.code !== 0 || result.cancelled) {
|
|
13383
|
+
throw Object.assign(new Error(result.stderr?.trim() || 'Embedded Synp failed to convert yarn.lock.'), {
|
|
13384
|
+
code: result.signal ?? undefined
|
|
13385
|
+
});
|
|
13386
|
+
}
|
|
13387
|
+
let converted;
|
|
13388
|
+
try {
|
|
13389
|
+
converted = JSON.parse(result.stdout ?? '');
|
|
13390
|
+
} catch {
|
|
13391
|
+
throw new Error('Embedded Synp returned invalid ownership metadata.');
|
|
13392
|
+
}
|
|
13393
|
+
if (converted.dev !== placeholderIdentity.dev || converted.ino !== placeholderIdentity.ino || !Number.isSafeInteger(converted.size) || converted.size <= 0 || !/^[a-f0-9]{64}$/.test(converted.sha256)) {
|
|
13394
|
+
throw new Error('Embedded Synp returned invalid ownership metadata.');
|
|
13395
|
+
}
|
|
13396
|
+
const [tempStat, tempContents] = await Promise.all([u.promises.lstat(temporaryPath), u.promises.readFile(temporaryPath)]);
|
|
13397
|
+
const tempDigest = require$$0.createHash('sha256').update(tempContents).digest('hex');
|
|
13398
|
+
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) {
|
|
13399
|
+
throw new Error('Embedded Synp output failed ownership or format verification.');
|
|
13400
|
+
}
|
|
13401
|
+
|
|
13402
|
+
// link() creates the destination atomically and fails if another process
|
|
13403
|
+
// created package-lock.json after our initial absence check.
|
|
13404
|
+
await u.promises.link(temporaryPath, packageLockPath);
|
|
13405
|
+
packageLockOwner = {
|
|
13406
|
+
path: packageLockPath,
|
|
13407
|
+
dev: converted.dev,
|
|
13408
|
+
ino: converted.ino,
|
|
13409
|
+
size: converted.size,
|
|
13410
|
+
sha256: converted.sha256
|
|
13411
|
+
};
|
|
13412
|
+
await u.promises.unlink(temporaryPath);
|
|
13413
|
+
return packageLockOwner;
|
|
13414
|
+
} catch (error) {
|
|
13415
|
+
await removeOwnedPackageLock(packageLockOwner);
|
|
13416
|
+
throw error;
|
|
13417
|
+
} finally {
|
|
13418
|
+
await removeIfOwned(temporaryPath, placeholderIdentity);
|
|
13419
|
+
}
|
|
13420
|
+
}
|
|
13421
|
+
|
|
12370
13422
|
const {
|
|
12371
13423
|
PACKAGE_LOCK_JSON,
|
|
12372
13424
|
PNPM_LOCK_YAML,
|
|
@@ -12408,6 +13460,167 @@ function argvObjectToArray(argvObj) {
|
|
|
12408
13460
|
return result;
|
|
12409
13461
|
}
|
|
12410
13462
|
async function runCdxgen(argvObj) {
|
|
13463
|
+
if (utils.isStandaloneSea()) {
|
|
13464
|
+
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']);
|
|
13465
|
+
for (const key of Object.keys(argvObj)) {
|
|
13466
|
+
if (unsupported.has(key)) {
|
|
13467
|
+
const value = argvObj[key];
|
|
13468
|
+
if (value !== false && value !== undefined && value !== null) {
|
|
13469
|
+
throw new Error(`The standalone cdxgen build does not support --${key}.`);
|
|
13470
|
+
}
|
|
13471
|
+
} else if (!['_', '--', 'output', 'type', 'lifecycle', 'help'].includes(key)) {
|
|
13472
|
+
throw new Error(`The standalone cdxgen build does not support --${key}.`);
|
|
13473
|
+
}
|
|
13474
|
+
}
|
|
13475
|
+
if (argvObj['help']) {
|
|
13476
|
+
throw new Error('Help output is handled before cdxgen execution.');
|
|
13477
|
+
}
|
|
13478
|
+
if (argvObj['lifecycle'] && argvObj['lifecycle'] !== 'pre-build') {
|
|
13479
|
+
throw new Error('The standalone cdxgen build supports only the pre-build lifecycle.');
|
|
13480
|
+
}
|
|
13481
|
+
if (argvObj['type'] && !['npm', 'nodejs', 'javascript', 'js', 'typescript', 'ts', 'tsx'].includes(String(argvObj['type']).toLowerCase())) {
|
|
13482
|
+
throw new Error('The standalone cdxgen build supports only npm projects.');
|
|
13483
|
+
}
|
|
13484
|
+
const positional = Array.isArray(argvObj['_']) ? argvObj['_'] : [];
|
|
13485
|
+
if (positional.length > 1 || positional[0] && path.resolve(String(positional[0])) !== process.cwd()) {
|
|
13486
|
+
throw new Error('The standalone cdxgen build supports one project at the current working directory.');
|
|
13487
|
+
}
|
|
13488
|
+
if (Array.isArray(argvObj['--']) && argvObj['--'].length) {
|
|
13489
|
+
throw new Error('The standalone cdxgen build does not support arguments after --.');
|
|
13490
|
+
}
|
|
13491
|
+
const root = process.cwd();
|
|
13492
|
+
const packageLockPath = path.join(root, PACKAGE_LOCK_JSON);
|
|
13493
|
+
const yarnLockPath = path.join(root, YARN_LOCK);
|
|
13494
|
+
if (u.existsSync(path.join(root, 'npm-shrinkwrap.json')) || u.existsSync(path.join(root, 'rush.json')) || u.existsSync(path.join(root, PNPM_LOCK_YAML))) {
|
|
13495
|
+
throw new Error('The standalone cdxgen build supports one npm or Yarn Classic project without shrinkwrap, pnpm, or Rush configuration.');
|
|
13496
|
+
}
|
|
13497
|
+
let packageJson;
|
|
13498
|
+
try {
|
|
13499
|
+
packageJson = JSON.parse(await u.promises.readFile(path.join(root, 'package.json'), 'utf8'));
|
|
13500
|
+
} catch {
|
|
13501
|
+
throw new Error('The standalone cdxgen build requires a valid root package.json.');
|
|
13502
|
+
}
|
|
13503
|
+
if (!packageJson || typeof packageJson !== 'object' || Array.isArray(packageJson)) {
|
|
13504
|
+
throw new Error('The standalone cdxgen build requires a valid root package.json object.');
|
|
13505
|
+
}
|
|
13506
|
+
if (packageJson.workspaces || packageJson.workspace) {
|
|
13507
|
+
throw new Error('The standalone cdxgen build does not support workspaces.');
|
|
13508
|
+
}
|
|
13509
|
+
const localDependency = value => typeof value === 'string' && /^(?:file:|link:|workspace:)/i.test(value);
|
|
13510
|
+
for (const group of [packageJson.dependencies, packageJson.devDependencies, packageJson.optionalDependencies, packageJson.peerDependencies]) {
|
|
13511
|
+
if (Object.values(group ?? {}).some(localDependency)) {
|
|
13512
|
+
throw new Error('The standalone cdxgen build does not support local or workspace dependencies.');
|
|
13513
|
+
}
|
|
13514
|
+
}
|
|
13515
|
+
const hasPackageLock = u.existsSync(packageLockPath);
|
|
13516
|
+
const hasYarnLock = u.existsSync(yarnLockPath);
|
|
13517
|
+
if (hasPackageLock && hasYarnLock) {
|
|
13518
|
+
throw new Error('The standalone cdxgen build does not support projects with both npm and Yarn lockfiles.');
|
|
13519
|
+
}
|
|
13520
|
+
let generatedLock;
|
|
13521
|
+
const abortController = new AbortController();
|
|
13522
|
+
const onSigint = () => abortController.abort(Object.assign(new Error('Interrupted'), {
|
|
13523
|
+
code: 'SIGINT'
|
|
13524
|
+
}));
|
|
13525
|
+
const onSigterm = () => abortController.abort(Object.assign(new Error('Terminated'), {
|
|
13526
|
+
code: 'SIGTERM'
|
|
13527
|
+
}));
|
|
13528
|
+
const onSighup = () => abortController.abort(Object.assign(new Error('Hangup'), {
|
|
13529
|
+
code: 'SIGHUP'
|
|
13530
|
+
}));
|
|
13531
|
+
let signalHandlersInstalled = false;
|
|
13532
|
+
const installSignalHandlers = () => {
|
|
13533
|
+
if (signalHandlersInstalled) {
|
|
13534
|
+
return;
|
|
13535
|
+
}
|
|
13536
|
+
signalHandlersInstalled = true;
|
|
13537
|
+
process.once('SIGINT', onSigint);
|
|
13538
|
+
process.once('SIGTERM', onSigterm);
|
|
13539
|
+
process.once('SIGHUP', onSighup);
|
|
13540
|
+
};
|
|
13541
|
+
const removeSignalHandlers = () => {
|
|
13542
|
+
if (!signalHandlersInstalled) {
|
|
13543
|
+
return;
|
|
13544
|
+
}
|
|
13545
|
+
signalHandlersInstalled = false;
|
|
13546
|
+
process.removeListener('SIGINT', onSigint);
|
|
13547
|
+
process.removeListener('SIGTERM', onSigterm);
|
|
13548
|
+
process.removeListener('SIGHUP', onSighup);
|
|
13549
|
+
};
|
|
13550
|
+
if (hasPackageLock) {
|
|
13551
|
+
let lock;
|
|
13552
|
+
try {
|
|
13553
|
+
lock = JSON.parse(await u.promises.readFile(packageLockPath, 'utf8'));
|
|
13554
|
+
} catch {
|
|
13555
|
+
throw new Error('The standalone cdxgen build requires a valid npm package-lock.json.');
|
|
13556
|
+
}
|
|
13557
|
+
if (lock.lockfileVersion !== 3) {
|
|
13558
|
+
throw new Error('The standalone cdxgen build requires npm package-lock v3; only Yarn Classic conversion uses v1.');
|
|
13559
|
+
}
|
|
13560
|
+
utils.assertEmbeddedToolAvailable('cdxgen', 'manifest-cdxgen-npm-lock-v3');
|
|
13561
|
+
} else if (hasYarnLock) {
|
|
13562
|
+
const yarnText = await u.promises.readFile(yarnLockPath, 'utf8');
|
|
13563
|
+
if (!/^# yarn lockfile v1(?:\r?\n|$)/m.test(yarnText) || /^__metadata:\s*$/m.test(yarnText) || u.existsSync(path.join(root, '.yarnrc.yml'))) {
|
|
13564
|
+
throw new Error('The standalone cdxgen build supports Yarn Classic lockfile v1 only; Yarn Berry is unavailable.');
|
|
13565
|
+
}
|
|
13566
|
+
if (!u.existsSync(path.join(root, 'node_modules'))) {
|
|
13567
|
+
throw new Error('Yarn Classic conversion requires an existing node_modules directory.');
|
|
13568
|
+
}
|
|
13569
|
+
utils.assertEmbeddedToolAvailable('cdxgen', 'manifest-cdxgen-yarn-classic');
|
|
13570
|
+
utils.assertEmbeddedToolAvailable('synp');
|
|
13571
|
+
installSignalHandlers();
|
|
13572
|
+
try {
|
|
13573
|
+
generatedLock = await convertYarnClassicToNpmLock(root, abortController.signal);
|
|
13574
|
+
} catch (error) {
|
|
13575
|
+
removeSignalHandlers();
|
|
13576
|
+
if (abortController.signal.aborted) {
|
|
13577
|
+
const reason = abortController.signal.reason;
|
|
13578
|
+
if (typeof reason?.code === 'string') {
|
|
13579
|
+
if (utils.isStandaloneSea()) {
|
|
13580
|
+
await removeOwnedPackageLock(generatedLock);
|
|
13581
|
+
const canceled = Promise.resolve({
|
|
13582
|
+
code: null,
|
|
13583
|
+
signal: reason.code,
|
|
13584
|
+
cancelled: true
|
|
13585
|
+
});
|
|
13586
|
+
Object.defineProperty(canceled, 'process', {
|
|
13587
|
+
value: new require$$0$2.EventEmitter()
|
|
13588
|
+
});
|
|
13589
|
+
return {
|
|
13590
|
+
spawnPromise: canceled
|
|
13591
|
+
};
|
|
13592
|
+
}
|
|
13593
|
+
process.kill(process.pid, reason.code);
|
|
13594
|
+
}
|
|
13595
|
+
}
|
|
13596
|
+
throw error;
|
|
13597
|
+
}
|
|
13598
|
+
} else {
|
|
13599
|
+
throw new Error('The standalone cdxgen build requires npm package-lock v3 or Yarn Classic lockfile v1 with node_modules.');
|
|
13600
|
+
}
|
|
13601
|
+
const output = typeof argvObj['output'] === 'string' ? argvObj['output'] : 'socket-cdx.json';
|
|
13602
|
+
const outputPath = output === '-' ? '-' : path.resolve(root, output);
|
|
13603
|
+
if (generatedLock && outputPath === packageLockPath) {
|
|
13604
|
+
await removeOwnedPackageLock(generatedLock);
|
|
13605
|
+
removeSignalHandlers();
|
|
13606
|
+
throw new Error('The standalone cdxgen build cannot use package-lock.json as the SBOM output path.');
|
|
13607
|
+
}
|
|
13608
|
+
installSignalHandlers();
|
|
13609
|
+
try {
|
|
13610
|
+
const embedded = await runCdxgen$1(root, outputPath, {
|
|
13611
|
+
stdio: 'inherit',
|
|
13612
|
+
signal: abortController.signal
|
|
13613
|
+
}, async () => {
|
|
13614
|
+
removeSignalHandlers();
|
|
13615
|
+
await removeOwnedPackageLock(generatedLock);
|
|
13616
|
+
});
|
|
13617
|
+
return embedded;
|
|
13618
|
+
} catch (error) {
|
|
13619
|
+
removeSignalHandlers();
|
|
13620
|
+
await removeOwnedPackageLock(generatedLock);
|
|
13621
|
+
throw error;
|
|
13622
|
+
}
|
|
13623
|
+
}
|
|
12411
13624
|
const argvMutable = {
|
|
12412
13625
|
__proto__: null,
|
|
12413
13626
|
...argvObj
|
|
@@ -12734,6 +13947,25 @@ async function run$J(argv, importMeta, context) {
|
|
|
12734
13947
|
return;
|
|
12735
13948
|
}
|
|
12736
13949
|
|
|
13950
|
+
// The standalone build must not start cdxgen just to display its help:
|
|
13951
|
+
// cdxgen is an optional payload and can be unavailable for this target.
|
|
13952
|
+
// Keep this local help useful without resolving or installing that payload.
|
|
13953
|
+
if (yargv.help && utils.isStandaloneSea()) {
|
|
13954
|
+
logger.logger.log(`
|
|
13955
|
+
Usage
|
|
13956
|
+
socket manifest cdxgen [options] [path]
|
|
13957
|
+
|
|
13958
|
+
Options
|
|
13959
|
+
-h, --help Show this help
|
|
13960
|
+
-o, --output <file> Output file (default: socket-cdx.json)
|
|
13961
|
+
-t, --type <type> npm, nodejs, javascript, js, typescript, ts, or tsx
|
|
13962
|
+
--lifecycle pre-build Read dependency metadata without running project installs
|
|
13963
|
+
|
|
13964
|
+
Generates a CycloneDX SBOM from a root npm package-lock.json v3.
|
|
13965
|
+
Only one npm project is supported in this standalone build. Other cdxgen modes are unavailable.`);
|
|
13966
|
+
return;
|
|
13967
|
+
}
|
|
13968
|
+
|
|
12737
13969
|
// Change defaults when not passing the --help flag.
|
|
12738
13970
|
if (!yargv.help) {
|
|
12739
13971
|
// Make 'lifecycle' default to 'pre-build', which also sets 'install-deps' to `false`,
|
|
@@ -12752,6 +13984,21 @@ async function run$J(argv, importMeta, context) {
|
|
|
12752
13984
|
const {
|
|
12753
13985
|
spawnPromise
|
|
12754
13986
|
} = await runCdxgen(yargv);
|
|
13987
|
+
if (utils.isStandaloneSea()) {
|
|
13988
|
+
// The embedded Worker exposes an awaited result. Avoid translating its
|
|
13989
|
+
// synthetic exit event into process.exit(), which can bypass CLI error
|
|
13990
|
+
// formatting and telemetry drain on rejection or cancellation.
|
|
13991
|
+
const result = await spawnPromise;
|
|
13992
|
+
if (result.signal) {
|
|
13993
|
+
process.exitCode = 128 + (os.constants.signals[result.signal] ?? 1);
|
|
13994
|
+
} else {
|
|
13995
|
+
process.exitCode = typeof result.code === 'number' ? result.code : 1;
|
|
13996
|
+
if (result.code === 0 && typeof yargv.output === 'string' && yargv.output !== '-' && u.existsSync(path.resolve(process.cwd(), yargv.output))) {
|
|
13997
|
+
logger.logger.log(vendor.yoctocolorsCjsExports.cyanBright(`${yargv.output} created!`));
|
|
13998
|
+
}
|
|
13999
|
+
}
|
|
14000
|
+
return;
|
|
14001
|
+
}
|
|
12755
14002
|
|
|
12756
14003
|
// See https://nodejs.org/api/child_process.html#event-exit.
|
|
12757
14004
|
spawnPromise.process.on('exit', (code, signalName) => {
|
|
@@ -12819,7 +14066,7 @@ function resolveBazelManifestSettings({
|
|
|
12819
14066
|
const socketJsonOut = config.out;
|
|
12820
14067
|
const outFromSocketJson = !cliOut && typeof socketJsonOut === 'string';
|
|
12821
14068
|
const outValue = cliOut ?? socketJsonOut;
|
|
12822
|
-
const resolvedOut = outValue ? path.resolve(cwd, outValue) :
|
|
14069
|
+
const resolvedOut = outValue ? path.resolve(cwd, outValue) : getDefaultBazelManifestDirectory(cwd);
|
|
12823
14070
|
const canonicalCwd = canonicalizeForContainment(cwd);
|
|
12824
14071
|
const canonicalOut = canonicalizeForContainment(resolvedOut);
|
|
12825
14072
|
const relativeOut = path.relative(canonicalCwd, canonicalOut);
|
|
@@ -13561,7 +14808,7 @@ async function extractBazelToPypi(opts) {
|
|
|
13561
14808
|
logger.logger.groupEnd();
|
|
13562
14809
|
let pythonShimDir;
|
|
13563
14810
|
try {
|
|
13564
|
-
if (process.platform === 'win32') {
|
|
14811
|
+
if ((opts.platform ?? process.platform) === 'win32') {
|
|
13565
14812
|
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
14813
|
}
|
|
13567
14814
|
// Validate caller-provided Bazel filesystem settings before invoking Bazel.
|
|
@@ -13696,7 +14943,7 @@ async function extractBazelToPypi(opts) {
|
|
|
13696
14943
|
const sorted = sortPackageLines(allLines);
|
|
13697
14944
|
const lines = sorted.map(p => `${p.name}==${p.version}\n`);
|
|
13698
14945
|
const layout = opts.outLayout ?? 'standalone';
|
|
13699
|
-
const manifestDir = layout === 'flat' ?
|
|
14946
|
+
const manifestDir = layout === 'flat' ? getBazelAutoManifestDirectory(out) : out;
|
|
13700
14947
|
u.mkdirSync(manifestDir, {
|
|
13701
14948
|
recursive: true
|
|
13702
14949
|
});
|
|
@@ -13852,7 +15099,7 @@ const config$h = {
|
|
|
13852
15099
|
},
|
|
13853
15100
|
out: {
|
|
13854
15101
|
type: 'string',
|
|
13855
|
-
description:
|
|
15102
|
+
description: `Output directory for generated manifests; default: ${DEFAULT_BAZEL_MANIFEST_OUTPUT_DISPLAY_PATH}`
|
|
13856
15103
|
},
|
|
13857
15104
|
perRepoTimeout: {
|
|
13858
15105
|
type: 'number',
|
|
@@ -16341,71 +17588,7 @@ function notCanceled$2() {
|
|
|
16341
17588
|
};
|
|
16342
17589
|
}
|
|
16343
17590
|
|
|
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.
|
|
17591
|
+
// The builds of one tool in one directory.
|
|
16409
17592
|
|
|
16410
17593
|
const ROOT_ECOSYSTEMS = ['maven', 'gradle', 'sbt', 'dotnet'];
|
|
16411
17594
|
|
|
@@ -16490,6 +17673,7 @@ async function discoverBuildRoots({
|
|
|
16490
17673
|
}) {
|
|
16491
17674
|
const realCwd = await utils.realpathOrResolved(cwd);
|
|
16492
17675
|
const included = [];
|
|
17676
|
+
const excludedBuilds = [];
|
|
16493
17677
|
const ignorePatterns = (excludePaths ?? []).flatMap(excludePathToScanIgnores);
|
|
16494
17678
|
const ecosystemsByRoot = new Map();
|
|
16495
17679
|
for (const [ecosystem, fullRoots] of fullByTool) {
|
|
@@ -16526,10 +17710,12 @@ async function discoverBuildRoots({
|
|
|
16526
17710
|
ecosystem,
|
|
16527
17711
|
roots: includedRoots
|
|
16528
17712
|
});
|
|
16529
|
-
// `disabled`
|
|
16530
|
-
// without its included siblings.
|
|
17713
|
+
// A section's `disabled` would also skip the included siblings.
|
|
16531
17714
|
for (const root of excludedRoots) {
|
|
16532
|
-
|
|
17715
|
+
excludedBuilds.push({
|
|
17716
|
+
ecosystem,
|
|
17717
|
+
root
|
|
17718
|
+
});
|
|
16533
17719
|
}
|
|
16534
17720
|
continue;
|
|
16535
17721
|
}
|
|
@@ -16545,438 +17731,552 @@ async function discoverBuildRoots({
|
|
|
16545
17731
|
dir,
|
|
16546
17732
|
ecosystems: [...ecosystems].sort()
|
|
16547
17733
|
})),
|
|
17734
|
+
excludedBuilds,
|
|
16548
17735
|
included
|
|
16549
17736
|
};
|
|
16550
17737
|
}
|
|
16551
17738
|
|
|
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
|
-
}
|
|
17739
|
+
// Changes to socket.json files, kept until the user confirms them.
|
|
17740
|
+
|
|
17741
|
+
function createSettingsDraft() {
|
|
16616
17742
|
return {
|
|
16617
|
-
|
|
16618
|
-
|
|
17743
|
+
files: new Map(),
|
|
17744
|
+
notes: new Map(),
|
|
17745
|
+
resolver: undefined,
|
|
17746
|
+
warned: new Set()
|
|
16619
17747
|
};
|
|
16620
17748
|
}
|
|
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();
|
|
17749
|
+
function setDraftFile(draft, dir, sockJson) {
|
|
17750
|
+
draft.files.set(dir, sockJson);
|
|
17751
|
+
draft.resolver = undefined;
|
|
17752
|
+
}
|
|
17753
|
+
function cloneSocketJson(sockJson) {
|
|
17754
|
+
return JSON.parse(JSON.stringify(sockJson));
|
|
16658
17755
|
}
|
|
16659
17756
|
|
|
16660
|
-
//
|
|
16661
|
-
|
|
16662
|
-
|
|
16663
|
-
|
|
16664
|
-
|
|
16665
|
-
|
|
16666
|
-
|
|
16667
|
-
|
|
17757
|
+
// `dir`'s own socket.json as it will be written.
|
|
17758
|
+
function draftSettings(draft, dir) {
|
|
17759
|
+
return cloneSocketJson(draft.files.get(dir) ?? utils.readOrDefaultSocketJson(dir));
|
|
17760
|
+
}
|
|
17761
|
+
function stageSettings(draft, dir, sockJson, note) {
|
|
17762
|
+
setDraftFile(draft, dir, sockJson);
|
|
17763
|
+
const notes = utils.getOrInsert(draft.notes, dir, () => []);
|
|
17764
|
+
if (!notes.includes(note)) {
|
|
17765
|
+
notes.push(note);
|
|
17766
|
+
}
|
|
17767
|
+
}
|
|
17768
|
+
function manifestOf(sockJson) {
|
|
17769
|
+
if (!sockJson.defaults) {
|
|
17770
|
+
sockJson.defaults = {};
|
|
16668
17771
|
}
|
|
16669
|
-
if (
|
|
16670
|
-
|
|
16671
|
-
factsOnly: true
|
|
16672
|
-
});
|
|
17772
|
+
if (!sockJson.defaults.manifest) {
|
|
17773
|
+
sockJson.defaults.manifest = {};
|
|
16673
17774
|
}
|
|
16674
|
-
|
|
16675
|
-
|
|
17775
|
+
return sockJson.defaults.manifest;
|
|
17776
|
+
}
|
|
17777
|
+
|
|
17778
|
+
// The socket.json files from the filesystem root down to `dir`, as they will
|
|
17779
|
+
// be written.
|
|
17780
|
+
function draftChain(draft, dir) {
|
|
17781
|
+
const byDir = new Map(utils.readSocketJsonChain(dir).map(file => [file.dir, file.sockJson]));
|
|
17782
|
+
for (const {
|
|
17783
|
+
0: fileDir,
|
|
17784
|
+
1: sockJson
|
|
17785
|
+
} of draft.files) {
|
|
17786
|
+
if (isPathInside$1(fileDir, dir)) {
|
|
17787
|
+
byDir.set(fileDir, sockJson);
|
|
17788
|
+
}
|
|
16676
17789
|
}
|
|
16677
|
-
return
|
|
16678
|
-
|
|
16679
|
-
|
|
17790
|
+
return [...byDir].sort((a, b) => a[0].length - b[0].length).map(({
|
|
17791
|
+
0: fileDir,
|
|
17792
|
+
1: sockJson
|
|
17793
|
+
}) => ({
|
|
17794
|
+
dir: fileDir,
|
|
17795
|
+
sockJson
|
|
17796
|
+
}));
|
|
17797
|
+
}
|
|
17798
|
+
function draftCascade(draft, dir) {
|
|
17799
|
+
return utils.mergeSocketJsonChain(draftChain(draft, dir));
|
|
17800
|
+
}
|
|
17801
|
+
function resolveDraftSettings(draft, ecosystem, root) {
|
|
17802
|
+
draft.resolver ??= createBuildRootSettingsResolver(dir => draftChain(draft, dir), draft.warned);
|
|
17803
|
+
return draft.resolver(ecosystem, root);
|
|
16680
17804
|
}
|
|
16681
17805
|
|
|
16682
|
-
//
|
|
16683
|
-
|
|
16684
|
-
|
|
16685
|
-
|
|
16686
|
-
|
|
16687
|
-
cwd,
|
|
16688
|
-
|
|
17806
|
+
// "other build", or "3 other builds".
|
|
17807
|
+
function otherBuilds(count) {
|
|
17808
|
+
return count === 1 ? 'other build' : `${count} other builds`;
|
|
17809
|
+
}
|
|
17810
|
+
function relPath(cwd, file) {
|
|
17811
|
+
return (path.relative(cwd, file) || '.').split(path.sep).join('/');
|
|
17812
|
+
}
|
|
17813
|
+
|
|
17814
|
+
// One build of the walk; a directory holding several builds of one tool has
|
|
17815
|
+
// a prompt, and settings, per build file.
|
|
17816
|
+
|
|
17817
|
+
function buildKey({
|
|
16689
17818
|
ecosystem,
|
|
16690
|
-
|
|
17819
|
+
root
|
|
16691
17820
|
}) {
|
|
16692
|
-
|
|
16693
|
-
|
|
16694
|
-
|
|
16695
|
-
|
|
16696
|
-
|
|
16697
|
-
|
|
16698
|
-
|
|
17821
|
+
return `${ecosystem}\0${buildRootPath(root)}`;
|
|
17822
|
+
}
|
|
17823
|
+
function buildLabel(cwd, {
|
|
17824
|
+
ecosystem,
|
|
17825
|
+
root,
|
|
17826
|
+
sharesDir
|
|
17827
|
+
}) {
|
|
17828
|
+
const where = sharesDir ? relPath(cwd, buildRootPath(root)) : root.dir === cwd ? 'This project' : relPath(cwd, root.dir);
|
|
17829
|
+
return `${where} (${ecosystem})`;
|
|
17830
|
+
}
|
|
17831
|
+
|
|
17832
|
+
// The build file a build's own `builds` entry is keyed by: the one its entry
|
|
17833
|
+
// names, else the first one in its directory.
|
|
17834
|
+
function buildsKeyOf(draft, {
|
|
17835
|
+
ecosystem,
|
|
17836
|
+
root
|
|
17837
|
+
}) {
|
|
17838
|
+
const files = BUILD_FILES[ecosystem];
|
|
17839
|
+
if (files.byFile) {
|
|
17840
|
+
return root.entryFile ?? '';
|
|
16699
17841
|
}
|
|
17842
|
+
return resolveDraftSettings(draft, ecosystem, root).entryKey ?? files.names.find(name => u.existsSync(path.join(root.dir, name))) ?? files.names[0];
|
|
17843
|
+
}
|
|
17844
|
+
// Whether a build's settings go in its own entry, rather than in its
|
|
17845
|
+
// directory's section, which the builds beneath inherit.
|
|
17846
|
+
function writesOwnEntry(draft, build) {
|
|
17847
|
+
return build.sharesDir || !!resolveDraftSettings(draft, build.ecosystem, build.root).entryKey;
|
|
17848
|
+
}
|
|
17849
|
+
function membershipFor(map, ecosystem) {
|
|
17850
|
+
return utils.getOrInsert(map, ecosystem, emptyMembership);
|
|
17851
|
+
}
|
|
17852
|
+
function buildConfig(walk, {
|
|
17853
|
+
ecosystem,
|
|
17854
|
+
root
|
|
17855
|
+
}) {
|
|
17856
|
+
return resolveEcosystemConfig(ecosystem, root.dir, resolveDraftSettings(walk.draft, ecosystem, root).sockJson);
|
|
17857
|
+
}
|
|
17858
|
+
|
|
17859
|
+
// Whether a build `covered` stands for already loads `build`.
|
|
17860
|
+
async function isLoadedBy(walk, covered, build) {
|
|
17861
|
+
return await isBuildCovered(covered, build.ecosystem, build.root, buildToolScriptOptions(buildConfig(walk, build), walk.cwd, walk.excludePaths));
|
|
17862
|
+
}
|
|
16700
17863
|
|
|
16701
|
-
|
|
16702
|
-
|
|
16703
|
-
|
|
16704
|
-
|
|
16705
|
-
|
|
16706
|
-
|
|
17864
|
+
// Keeps only answers that differ from what the build would inherit; a
|
|
17865
|
+
// directory section also sets defaults for the builds beneath it.
|
|
17866
|
+
async function configureBuild(draft, cwd, build) {
|
|
17867
|
+
const {
|
|
17868
|
+
ecosystem,
|
|
17869
|
+
root
|
|
17870
|
+
} = build;
|
|
17871
|
+
const key = buildsKeyOf(draft, build);
|
|
17872
|
+
const own = draftSettings(draft, root.dir);
|
|
17873
|
+
const manifest = manifestOf(own);
|
|
17874
|
+
const builds = {
|
|
17875
|
+
...manifest['builds']
|
|
17876
|
+
};
|
|
17877
|
+
const intoEntry = writesOwnEntry(draft, build);
|
|
17878
|
+
const target = intoEntry ? {
|
|
17879
|
+
...builds[key]
|
|
17880
|
+
} : {
|
|
17881
|
+
...getEcosystemSection(own, ecosystem)
|
|
17882
|
+
};
|
|
17883
|
+
const inherited = getEcosystemSection(draftCascade(draft, intoEntry ? root.dir : path.dirname(root.dir)), ecosystem);
|
|
16707
17884
|
const seed = {
|
|
16708
|
-
...getEcosystemSection(
|
|
16709
|
-
...getEcosystemSection(ownSockJson, ecosystem)
|
|
17885
|
+
...getEcosystemSection(resolveDraftSettings(draft, ecosystem, root).sockJson, ecosystem)
|
|
16710
17886
|
};
|
|
17887
|
+
const seeded = Object.keys(seed);
|
|
16711
17888
|
const result = await runEcosystemWizard(ecosystem, seed);
|
|
16712
17889
|
if (!result.ok || result.data.canceled) {
|
|
16713
17890
|
return result;
|
|
16714
17891
|
}
|
|
16715
|
-
const
|
|
16716
|
-
|
|
16717
|
-
|
|
16718
|
-
|
|
17892
|
+
const before = JSON.stringify(target);
|
|
17893
|
+
// An answer the wizard removed leaves the field to inheritance.
|
|
17894
|
+
for (const field of new Set([...seeded, ...Object.keys(seed)])) {
|
|
17895
|
+
if (!Object.hasOwn(seed, field) || seed[field] === inherited[field]) {
|
|
17896
|
+
delete target[field];
|
|
17897
|
+
} else {
|
|
17898
|
+
target[field] = seed[field];
|
|
16719
17899
|
}
|
|
16720
17900
|
}
|
|
16721
|
-
|
|
16722
|
-
|
|
16723
|
-
|
|
16724
|
-
logger.logger.log(`No changes for ${relDir} (${ecosystem}); nothing written.`);
|
|
17901
|
+
const label = buildLabel(cwd, build);
|
|
17902
|
+
if (JSON.stringify(target) === before) {
|
|
17903
|
+
logger.logger.log(`No changes for ${label}.`);
|
|
16725
17904
|
return notCanceled$1();
|
|
16726
17905
|
}
|
|
16727
|
-
|
|
16728
|
-
|
|
16729
|
-
|
|
16730
|
-
|
|
16731
|
-
|
|
17906
|
+
if (intoEntry) {
|
|
17907
|
+
manifest['builds'] = {
|
|
17908
|
+
...builds,
|
|
17909
|
+
[key]: target
|
|
17910
|
+
};
|
|
17911
|
+
stageSettings(draft, root.dir, own, `configure ${key}`);
|
|
17912
|
+
} else {
|
|
17913
|
+
manifest[ecosystem] = target;
|
|
17914
|
+
stageSettings(draft, root.dir, own, `configure ${ecosystem} builds`);
|
|
16732
17915
|
}
|
|
16733
|
-
logger.logger.success(`Configured ${
|
|
17916
|
+
logger.logger.success(`Configured ${label}`);
|
|
16734
17917
|
return notCanceled$1();
|
|
16735
17918
|
}
|
|
16736
|
-
|
|
16737
|
-
//
|
|
16738
|
-
//
|
|
16739
|
-
|
|
17919
|
+
|
|
17920
|
+
// Sets `disabled` for every `ecosystems` in `dir`'s section, so their builds
|
|
17921
|
+
// in and beneath it are skipped, unless the settings above already do.
|
|
17922
|
+
function disableDirectory(draft, dir, ecosystems) {
|
|
17923
|
+
const cascade = draftCascade(draft, dir);
|
|
17924
|
+
const needed = ecosystems.filter(ecosystem => getEcosystemSection(cascade, ecosystem)['disabled'] !== true);
|
|
17925
|
+
if (needed.length) {
|
|
17926
|
+
const own = draftSettings(draft, dir);
|
|
17927
|
+
const manifest = manifestOf(own);
|
|
17928
|
+
for (const ecosystem of needed) {
|
|
17929
|
+
manifest[ecosystem] = {
|
|
17930
|
+
...getEcosystemSection(own, ecosystem),
|
|
17931
|
+
disabled: true
|
|
17932
|
+
};
|
|
17933
|
+
}
|
|
17934
|
+
stageSettings(draft, dir, own, `skip ${needed.join(', ')} builds in and beneath it`);
|
|
17935
|
+
}
|
|
17936
|
+
return needed;
|
|
17937
|
+
}
|
|
17938
|
+
|
|
17939
|
+
// Skips just this build and what it loads, under its own build file.
|
|
17940
|
+
function disableBuild(draft, build) {
|
|
17941
|
+
const {
|
|
17942
|
+
root
|
|
17943
|
+
} = build;
|
|
17944
|
+
const key = buildsKeyOf(draft, build);
|
|
17945
|
+
const own = draftSettings(draft, root.dir);
|
|
17946
|
+
const manifest = manifestOf(own);
|
|
17947
|
+
const builds = manifest['builds'] ?? {};
|
|
17948
|
+
if (builds[key]?.['disabled'] === true) {
|
|
17949
|
+
return;
|
|
17950
|
+
}
|
|
17951
|
+
manifest['builds'] = {
|
|
17952
|
+
...builds,
|
|
17953
|
+
[key]: {
|
|
17954
|
+
...builds[key],
|
|
17955
|
+
disabled: true
|
|
17956
|
+
}
|
|
17957
|
+
};
|
|
17958
|
+
stageSettings(draft, root.dir, own, `skip ${key}`);
|
|
17959
|
+
}
|
|
17960
|
+
|
|
17961
|
+
// Turns a skipped build back on at the setting that skipped it: dropping that
|
|
17962
|
+
// setting where nothing above skips the build too, else overriding it.
|
|
17963
|
+
function enableBuild(draft, build, disabledBy) {
|
|
17964
|
+
const {
|
|
17965
|
+
ecosystem,
|
|
17966
|
+
root
|
|
17967
|
+
} = build;
|
|
17968
|
+
const own = draftSettings(draft, disabledBy.dir);
|
|
17969
|
+
const manifest = manifestOf(own);
|
|
17970
|
+
const target = disabledBy.key ? {
|
|
17971
|
+
...manifest['builds']?.[disabledBy.key]
|
|
17972
|
+
} : getEcosystemSection(own, ecosystem);
|
|
17973
|
+
delete target['disabled'];
|
|
17974
|
+
const place = value => {
|
|
17975
|
+
if (disabledBy.key) {
|
|
17976
|
+
manifest['builds'] = {
|
|
17977
|
+
...manifest['builds'],
|
|
17978
|
+
[disabledBy.key]: value
|
|
17979
|
+
};
|
|
17980
|
+
} else {
|
|
17981
|
+
manifest[ecosystem] = value;
|
|
17982
|
+
}
|
|
17983
|
+
};
|
|
17984
|
+
place(target);
|
|
17985
|
+
setDraftFile(draft, disabledBy.dir, own);
|
|
17986
|
+
if (resolveDraftSettings(draft, ecosystem, root).disabledBy) {
|
|
17987
|
+
place({
|
|
17988
|
+
...target,
|
|
17989
|
+
disabled: false
|
|
17990
|
+
});
|
|
17991
|
+
}
|
|
17992
|
+
stageSettings(draft, disabledBy.dir, own, disabledBy.key ? `build ${disabledBy.key} again` : `build ${ecosystem} builds here again`);
|
|
17993
|
+
}
|
|
17994
|
+
// The build tool could not load `build`. Fixing its settings comes first: a
|
|
17995
|
+
// build Socket can load is built once with its modules, and skips exactly.
|
|
17996
|
+
async function askCantLoad(walk, build, allowDirectory) {
|
|
17997
|
+
const label = buildLabel(walk.cwd, build);
|
|
17998
|
+
const relDir = relPath(walk.cwd, build.root.dir);
|
|
17999
|
+
const beneath = walk.builds.filter(other => other !== build && isPathInside$1(build.root.dir, other.root.dir) && !walk.decided.has(buildKey(other))).length;
|
|
18000
|
+
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
18001
|
return await prompts.select({
|
|
16741
|
-
message:
|
|
18002
|
+
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
18003
|
choices: [{
|
|
16743
|
-
name: '
|
|
16744
|
-
value: 'inherit',
|
|
16745
|
-
description: "Make no change - keep this project's current effective configuration"
|
|
16746
|
-
}, {
|
|
16747
|
-
name: 'Configure',
|
|
18004
|
+
name: 'Configure it and try again',
|
|
16748
18005
|
value: 'configure',
|
|
16749
|
-
description: 'Set
|
|
18006
|
+
description: 'Set the JDK, build tool or options, then load it again'
|
|
18007
|
+
}, allowDirectory ? {
|
|
18008
|
+
name: `Skip ${relDir}/ and everything beneath it, without loading it`,
|
|
18009
|
+
value: 'directory',
|
|
18010
|
+
description: skipNotes.join(' ')
|
|
18011
|
+
} : {
|
|
18012
|
+
name: 'Go on without loading it',
|
|
18013
|
+
value: 'directory',
|
|
18014
|
+
description: 'The builds it would include are asked about separately'
|
|
18015
|
+
}, {
|
|
18016
|
+
name: 'Stop',
|
|
18017
|
+
value: 'stop'
|
|
16750
18018
|
}],
|
|
16751
|
-
default: '
|
|
18019
|
+
default: 'configure'
|
|
16752
18020
|
});
|
|
16753
18021
|
}
|
|
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
|
|
18022
|
+
// Loads `build`, and while that fails, asks how to go on.
|
|
18023
|
+
async function loadOrAsk(walk, build, allowDirectory = true) {
|
|
18024
|
+
for (;;) {
|
|
18025
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18026
|
+
const loaded = await loadBuild({
|
|
18027
|
+
config: buildConfig(walk, build),
|
|
18028
|
+
ecosystem: build.ecosystem,
|
|
18029
|
+
excludePaths: walk.excludePaths,
|
|
18030
|
+
root: build.root,
|
|
18031
|
+
scanRoot: walk.cwd,
|
|
18032
|
+
verbose: false
|
|
16782
18033
|
});
|
|
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.
|
|
18034
|
+
if (loaded) {
|
|
16820
18035
|
return {
|
|
16821
18036
|
ok: true,
|
|
16822
18037
|
data: {
|
|
16823
18038
|
canceled: false,
|
|
16824
|
-
|
|
16825
|
-
reenabled: false
|
|
18039
|
+
loaded
|
|
16826
18040
|
}
|
|
16827
18041
|
};
|
|
16828
18042
|
}
|
|
16829
|
-
|
|
16830
|
-
|
|
16831
|
-
|
|
18043
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18044
|
+
const action = await askCantLoad(walk, build, allowDirectory);
|
|
18045
|
+
if (action === null || action === undefined) {
|
|
18046
|
+
return canceledByUser$1();
|
|
18047
|
+
}
|
|
18048
|
+
if (action === 'stop') {
|
|
16832
18049
|
return {
|
|
16833
|
-
ok:
|
|
16834
|
-
|
|
16835
|
-
canceled: true,
|
|
16836
|
-
outcome: 'skipped',
|
|
16837
|
-
reenabled: false
|
|
16838
|
-
}
|
|
18050
|
+
ok: false,
|
|
18051
|
+
message: `Stopped: Socket could not load ${buildLabel(walk.cwd, build)}.`
|
|
16839
18052
|
};
|
|
16840
18053
|
}
|
|
16841
|
-
if (
|
|
18054
|
+
if (action === 'directory') {
|
|
16842
18055
|
return {
|
|
16843
18056
|
ok: true,
|
|
16844
18057
|
data: {
|
|
16845
18058
|
canceled: false,
|
|
16846
|
-
|
|
16847
|
-
reenabled: false
|
|
18059
|
+
loaded: 'directory'
|
|
16848
18060
|
}
|
|
16849
18061
|
};
|
|
16850
18062
|
}
|
|
16851
|
-
|
|
16852
|
-
|
|
16853
|
-
|
|
16854
|
-
|
|
16855
|
-
ownSockJson.defaults.manifest = {};
|
|
18063
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18064
|
+
const configured = await configureBuild(walk.draft, walk.cwd, build);
|
|
18065
|
+
if (!configured.ok || configured.data.canceled) {
|
|
18066
|
+
return configured;
|
|
16856
18067
|
}
|
|
16857
|
-
|
|
16858
|
-
|
|
16859
|
-
|
|
16860
|
-
|
|
16861
|
-
|
|
16862
|
-
|
|
16863
|
-
|
|
16864
|
-
|
|
18068
|
+
}
|
|
18069
|
+
}
|
|
18070
|
+
|
|
18071
|
+
// Skips `build`'s directory and everything beneath it, unasked.
|
|
18072
|
+
function skipDirectory(walk, build) {
|
|
18073
|
+
const beneath = walk.builds.filter(other => other !== build && isPathInside$1(build.root.dir, other.root.dir));
|
|
18074
|
+
disableDirectory(walk.draft, build.root.dir, [...new Set([build.ecosystem, ...beneath.map(other => other.ecosystem)])]);
|
|
18075
|
+
for (const other of [build, ...beneath]) {
|
|
18076
|
+
if (!walk.decided.has(buildKey(other))) {
|
|
18077
|
+
walk.decided.add(buildKey(other));
|
|
18078
|
+
walk.counts.skipped += 1;
|
|
16865
18079
|
}
|
|
16866
|
-
|
|
16867
|
-
|
|
16868
|
-
|
|
16869
|
-
|
|
16870
|
-
|
|
16871
|
-
|
|
16872
|
-
|
|
16873
|
-
|
|
16874
|
-
|
|
16875
|
-
|
|
18080
|
+
}
|
|
18081
|
+
logger.logger.success(`Skipped ${relPath(walk.cwd, build.root.dir)}/ and everything beneath it.`);
|
|
18082
|
+
}
|
|
18083
|
+
|
|
18084
|
+
// A scan skips the modules of a build skipped under its own name, so the
|
|
18085
|
+
// wizard doesn't ask about them either.
|
|
18086
|
+
async function loadInto(walk, build, into, {
|
|
18087
|
+
allowDirectory = true,
|
|
18088
|
+
announce = true
|
|
18089
|
+
} = {}) {
|
|
18090
|
+
const result = await loadOrAsk(walk, build, allowDirectory);
|
|
18091
|
+
if (!result.ok || result.data.canceled) {
|
|
18092
|
+
return result;
|
|
18093
|
+
}
|
|
18094
|
+
const {
|
|
18095
|
+
loaded
|
|
18096
|
+
} = result.data;
|
|
18097
|
+
if (loaded === 'directory') {
|
|
18098
|
+
if (allowDirectory) {
|
|
18099
|
+
skipDirectory(walk, build);
|
|
16876
18100
|
}
|
|
16877
|
-
|
|
16878
|
-
|
|
16879
|
-
|
|
16880
|
-
|
|
16881
|
-
|
|
18101
|
+
} else if (loaded) {
|
|
18102
|
+
addMembership(membershipFor(walk[into], build.ecosystem), loaded.membership);
|
|
18103
|
+
if (into === 'skipped') {
|
|
18104
|
+
disableBuild(walk.draft, build);
|
|
18105
|
+
walk.counts.skipped += 1;
|
|
18106
|
+
if (announce) {
|
|
18107
|
+
logger.logger.success(`Skipped ${withModules(relPath(walk.cwd, buildRootPath(build.root)), loaded.modules)}.`);
|
|
16882
18108
|
}
|
|
16883
|
-
}
|
|
18109
|
+
}
|
|
16884
18110
|
}
|
|
16885
|
-
|
|
16886
|
-
|
|
16887
|
-
|
|
16888
|
-
|
|
16889
|
-
|
|
16890
|
-
|
|
18111
|
+
return notCanceled$1();
|
|
18112
|
+
}
|
|
18113
|
+
async function askBuildAction(label) {
|
|
18114
|
+
return await prompts.select({
|
|
18115
|
+
message: label,
|
|
18116
|
+
choices: [{
|
|
18117
|
+
name: 'Leave as-is',
|
|
18118
|
+
value: 'inherit',
|
|
18119
|
+
description: 'Build it with its current settings'
|
|
18120
|
+
}, {
|
|
18121
|
+
name: 'Configure',
|
|
18122
|
+
value: 'configure',
|
|
18123
|
+
description: 'Set the JDK, build tool or options for it'
|
|
18124
|
+
}, {
|
|
18125
|
+
name: 'Skip',
|
|
18126
|
+
value: 'skip',
|
|
18127
|
+
description: "Don't build it or its modules"
|
|
18128
|
+
}],
|
|
18129
|
+
default: 'inherit'
|
|
16891
18130
|
});
|
|
16892
|
-
|
|
16893
|
-
|
|
16894
|
-
}
|
|
18131
|
+
}
|
|
18132
|
+
function decided(load) {
|
|
16895
18133
|
return {
|
|
16896
18134
|
ok: true,
|
|
16897
18135
|
data: {
|
|
16898
|
-
|
|
16899
|
-
|
|
18136
|
+
canceled: false,
|
|
18137
|
+
load
|
|
16900
18138
|
}
|
|
16901
18139
|
};
|
|
16902
18140
|
}
|
|
16903
18141
|
|
|
16904
|
-
//
|
|
16905
|
-
|
|
16906
|
-
|
|
16907
|
-
|
|
16908
|
-
|
|
16909
|
-
|
|
16910
|
-
|
|
16911
|
-
|
|
18142
|
+
// What to load `build` into, as decided; none for a build skipped unloaded.
|
|
18143
|
+
async function reviewBuild(walk, build) {
|
|
18144
|
+
walk.decided.add(buildKey(build));
|
|
18145
|
+
const label = buildLabel(walk.cwd, build);
|
|
18146
|
+
const {
|
|
18147
|
+
disabledBy
|
|
18148
|
+
} = resolveDraftSettings(walk.draft, build.ecosystem, build.root);
|
|
18149
|
+
if (disabledBy) {
|
|
18150
|
+
// A directory skip from above covers this build silently; the setting
|
|
18151
|
+
// that names this build or its directory is offered back.
|
|
18152
|
+
if (!disabledBy.key && disabledBy.dir !== build.root.dir) {
|
|
18153
|
+
walk.counts.skipped += 1;
|
|
18154
|
+
return notCanceled$1();
|
|
18155
|
+
}
|
|
18156
|
+
const again = await askYesNo(`${label} is skipped. Build it again?`);
|
|
18157
|
+
if (again === null || again === undefined) {
|
|
18158
|
+
return canceledByUser$1();
|
|
18159
|
+
}
|
|
18160
|
+
if (!again) {
|
|
18161
|
+
if (!disabledBy.key) {
|
|
18162
|
+
walk.counts.skipped += 1;
|
|
18163
|
+
return notCanceled$1();
|
|
18164
|
+
}
|
|
18165
|
+
return decided({
|
|
18166
|
+
announce: false,
|
|
18167
|
+
into: 'skipped'
|
|
18168
|
+
});
|
|
18169
|
+
}
|
|
18170
|
+
enableBuild(walk.draft, build, disabledBy);
|
|
16912
18171
|
}
|
|
16913
|
-
|
|
16914
|
-
|
|
16915
|
-
|
|
16916
|
-
|
|
16917
|
-
|
|
16918
|
-
|
|
16919
|
-
|
|
16920
|
-
|
|
16921
|
-
|
|
16922
|
-
|
|
16923
|
-
|
|
16924
|
-
|
|
16925
|
-
|
|
18172
|
+
const action = await askBuildAction(label);
|
|
18173
|
+
if (action === null || action === undefined) {
|
|
18174
|
+
return canceledByUser$1();
|
|
18175
|
+
}
|
|
18176
|
+
if (action === 'skip') {
|
|
18177
|
+
return decided({
|
|
18178
|
+
announce: true,
|
|
18179
|
+
into: 'skipped'
|
|
18180
|
+
});
|
|
18181
|
+
}
|
|
18182
|
+
if (action === 'configure') {
|
|
18183
|
+
const configured = await configureBuild(walk.draft, walk.cwd, build);
|
|
18184
|
+
if (!configured.ok || configured.data.canceled) {
|
|
18185
|
+
return configured;
|
|
18186
|
+
}
|
|
18187
|
+
walk.counts.configured += 1;
|
|
18188
|
+
} else {
|
|
18189
|
+
walk.counts.inherited += 1;
|
|
18190
|
+
}
|
|
18191
|
+
return decided({
|
|
18192
|
+
announce: true,
|
|
18193
|
+
into: 'covered'
|
|
16926
18194
|
});
|
|
16927
18195
|
}
|
|
16928
18196
|
|
|
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`);
|
|
18197
|
+
// Dispatches to the right ecosystem-specific wizard. `factsOnly` skips the
|
|
18198
|
+
// facts/pom question - dynamic-sbom-inference never generates a pom.xml, it
|
|
18199
|
+
// just skips a project resolved to `facts: false` (see
|
|
18200
|
+
// generateRecursiveManifests' skipReason), so offering that choice here
|
|
18201
|
+
// would be misleading.
|
|
18202
|
+
async function runEcosystemWizard(ecosystem, config) {
|
|
18203
|
+
if (ecosystem === 'dotnet') {
|
|
18204
|
+
return await setupDotnet(config);
|
|
16942
18205
|
}
|
|
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;
|
|
18206
|
+
if (ecosystem === 'gradle') {
|
|
18207
|
+
return await setupGradle(config, {
|
|
18208
|
+
factsOnly: true
|
|
18209
|
+
});
|
|
16954
18210
|
}
|
|
16955
|
-
|
|
16956
|
-
|
|
16957
|
-
sockJson.defaults = {};
|
|
18211
|
+
if (ecosystem === 'maven') {
|
|
18212
|
+
return await setupMaven(config);
|
|
16958
18213
|
}
|
|
16959
|
-
|
|
16960
|
-
|
|
18214
|
+
return await setupSbt(config, {
|
|
18215
|
+
factsOnly: true
|
|
18216
|
+
});
|
|
18217
|
+
}
|
|
18218
|
+
|
|
18219
|
+
// Accepting every prompt's default leaves an ecosystem's section empty (see
|
|
18220
|
+
// askForBin in setup-manifest-config.mts); an empty one changes nothing.
|
|
18221
|
+
function dropIfEmpty(manifest, ecosystem) {
|
|
18222
|
+
const section = manifest[ecosystem];
|
|
18223
|
+
if (section && Object.keys(section).length) {
|
|
18224
|
+
return true;
|
|
16961
18225
|
}
|
|
16962
|
-
|
|
16963
|
-
|
|
18226
|
+
delete manifest[ecosystem];
|
|
18227
|
+
return false;
|
|
18228
|
+
}
|
|
18229
|
+
async function askYesNo(message) {
|
|
18230
|
+
return await prompts.select({
|
|
18231
|
+
message,
|
|
18232
|
+
choices: [{
|
|
18233
|
+
name: 'Yes',
|
|
18234
|
+
value: true
|
|
18235
|
+
}, {
|
|
18236
|
+
name: 'No',
|
|
18237
|
+
value: false
|
|
18238
|
+
}]
|
|
18239
|
+
});
|
|
18240
|
+
}
|
|
18241
|
+
|
|
18242
|
+
// Defaults for the builds in and beneath cwd. A skip that applies here, from
|
|
18243
|
+
// this directory's socket.json or one above it, is offered back first. A tool's
|
|
18244
|
+
// only build at cwd, without an entry of its own, sets them from its prompt.
|
|
18245
|
+
async function setupRootDefaults(draft, cwd, ecosystems, buildsAtCwd) {
|
|
16964
18246
|
for (const ecosystem of ecosystems) {
|
|
16965
18247
|
const label = ECOSYSTEM_LABELS[ecosystem];
|
|
16966
|
-
const
|
|
16967
|
-
|
|
18248
|
+
const {
|
|
18249
|
+
disabledBy
|
|
18250
|
+
} = resolveDraftSettings(draft, ecosystem, {
|
|
18251
|
+
dir: cwd
|
|
18252
|
+
});
|
|
18253
|
+
if (disabledBy && !disabledBy.key) {
|
|
18254
|
+
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
18255
|
// eslint-disable-next-line no-await-in-loop
|
|
16969
|
-
const
|
|
16970
|
-
if (
|
|
18256
|
+
const again = await askYesNo(`${where} Build the ${label} projects here?`);
|
|
18257
|
+
if (again === null || again === undefined) {
|
|
16971
18258
|
return canceledByUser$1();
|
|
16972
18259
|
}
|
|
16973
|
-
if (!
|
|
18260
|
+
if (!again) {
|
|
16974
18261
|
continue;
|
|
16975
18262
|
}
|
|
16976
|
-
|
|
16977
|
-
|
|
18263
|
+
const own = draftSettings(draft, cwd);
|
|
18264
|
+
const manifest = manifestOf(own);
|
|
18265
|
+
manifest[ecosystem] = {
|
|
18266
|
+
...getEcosystemSection(own, ecosystem),
|
|
18267
|
+
disabled: false
|
|
18268
|
+
};
|
|
18269
|
+
stageSettings(draft, cwd, own, `build ${label} projects here again`);
|
|
18270
|
+
}
|
|
18271
|
+
const atCwd = buildsAtCwd(ecosystem);
|
|
18272
|
+
if (atCwd.length === 1 && !writesOwnEntry(draft, {
|
|
18273
|
+
ecosystem,
|
|
18274
|
+
root: atCwd[0],
|
|
18275
|
+
sharesDir: false
|
|
18276
|
+
})) {
|
|
18277
|
+
continue;
|
|
16978
18278
|
}
|
|
16979
|
-
const message =
|
|
18279
|
+
const message = atCwd.length ? `Configure ${label} defaults for the projects here and beneath?` : `Configure ${label} defaults for any nested projects?`;
|
|
16980
18280
|
// eslint-disable-next-line no-await-in-loop
|
|
16981
18281
|
const wants = await askYesNo(message);
|
|
16982
18282
|
if (wants === undefined || wants === null) {
|
|
@@ -16985,49 +18285,66 @@ async function setupRecursiveRootDefaults(cwd, defaultOnReadError, ecosystems, e
|
|
|
16985
18285
|
if (!wants) {
|
|
16986
18286
|
continue;
|
|
16987
18287
|
}
|
|
16988
|
-
|
|
16989
|
-
|
|
16990
|
-
|
|
18288
|
+
const own = draftSettings(draft, cwd);
|
|
18289
|
+
const manifest = manifestOf(own);
|
|
18290
|
+
const section = {
|
|
18291
|
+
...getEcosystemSection(own, ecosystem)
|
|
18292
|
+
};
|
|
18293
|
+
manifest[ecosystem] = section;
|
|
16991
18294
|
// eslint-disable-next-line no-await-in-loop
|
|
16992
|
-
const result = await runEcosystemWizard(ecosystem,
|
|
18295
|
+
const result = await runEcosystemWizard(ecosystem, section);
|
|
16993
18296
|
if (!result.ok || result.data.canceled) {
|
|
16994
18297
|
return result;
|
|
16995
18298
|
}
|
|
16996
18299
|
if (dropIfEmpty(manifest, ecosystem)) {
|
|
16997
|
-
|
|
18300
|
+
stageSettings(draft, cwd, own, `configure ${label} defaults`);
|
|
16998
18301
|
}
|
|
16999
18302
|
}
|
|
17000
|
-
|
|
17001
|
-
|
|
17002
|
-
|
|
18303
|
+
return notCanceled$1();
|
|
18304
|
+
}
|
|
18305
|
+
async function confirmAndWrite(draft, cwd) {
|
|
18306
|
+
if (!draft.files.size) {
|
|
18307
|
+
logger.logger.log('Nothing to write: no settings changed.');
|
|
17003
18308
|
return notCanceled$1();
|
|
17004
18309
|
}
|
|
17005
|
-
|
|
17006
|
-
|
|
17007
|
-
|
|
17008
|
-
|
|
17009
|
-
|
|
17010
|
-
|
|
18310
|
+
const dirs = [...draft.files.keys()].sort();
|
|
18311
|
+
const files = dirs.map(dir => relPath(cwd, path.join(dir, constants.SOCKET_JSON)));
|
|
18312
|
+
const width = Math.max(...files.map(file => file.length));
|
|
18313
|
+
logger.logger.log(`Ready to write ${dirs.length} ${words.pluralize('file', dirs.length)}:`);
|
|
18314
|
+
for (const {
|
|
18315
|
+
0: index,
|
|
18316
|
+
1: dir
|
|
18317
|
+
} of dirs.entries()) {
|
|
18318
|
+
logger.logger.log(` ${files[index].padEnd(width)} ${(draft.notes.get(dir) ?? []).join('; ')}`);
|
|
18319
|
+
}
|
|
18320
|
+
const write = await askYesNo(dirs.length === 1 ? 'Write it?' : 'Write them?');
|
|
18321
|
+
if (write === null || write === undefined) {
|
|
18322
|
+
return canceledByUser$1();
|
|
18323
|
+
}
|
|
18324
|
+
if (!write) {
|
|
18325
|
+
logger.logger.log('Nothing written.');
|
|
18326
|
+
return notCanceled$1();
|
|
18327
|
+
}
|
|
18328
|
+
for (const dir of dirs) {
|
|
18329
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18330
|
+
const result = await utils.writeSocketJson(dir, draft.files.get(dir));
|
|
18331
|
+
if (!result.ok) {
|
|
18332
|
+
return result;
|
|
18333
|
+
}
|
|
17011
18334
|
}
|
|
18335
|
+
logger.logger.success(`Wrote ${arrays.joinAnd(files)}`);
|
|
17012
18336
|
return notCanceled$1();
|
|
17013
18337
|
}
|
|
17014
18338
|
|
|
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.
|
|
18339
|
+
// Nothing is written until the user confirms the draft.
|
|
17024
18340
|
async function setupRecursiveManifestConfig(cwd, defaultOnReadError, excludePaths) {
|
|
17025
18341
|
logger.logger.log('');
|
|
17026
18342
|
logger.logger.log(`Configuring ${cwd} ...`);
|
|
17027
|
-
const
|
|
17028
|
-
|
|
17029
|
-
|
|
17030
|
-
|
|
18343
|
+
const ownRead = utils.readSocketJsonSync(cwd, defaultOnReadError);
|
|
18344
|
+
if (!ownRead.ok) {
|
|
18345
|
+
return ownRead;
|
|
18346
|
+
}
|
|
18347
|
+
// Candidate dirs come back realpath-resolved; cwd must match.
|
|
17031
18348
|
const realCwd = await utils.realpathOrResolved(cwd);
|
|
17032
18349
|
logger.logger.log('');
|
|
17033
18350
|
logger.logger.log('Scanning for build roots ...');
|
|
@@ -17037,20 +18354,16 @@ async function setupRecursiveManifestConfig(cwd, defaultOnReadError, excludePath
|
|
|
17037
18354
|
} = await scanBuildRoots({
|
|
17038
18355
|
cwd,
|
|
17039
18356
|
excludePaths,
|
|
17040
|
-
sockJson: withoutDisabledFlags(
|
|
18357
|
+
sockJson: withoutDisabledFlags(ownRead.data)
|
|
17041
18358
|
});
|
|
17042
|
-
// includedByTool
|
|
17043
|
-
//
|
|
17044
|
-
// either - there'd be nothing left for its root defaults to apply to.
|
|
18359
|
+
// includedByTool, so an ecosystem whose only builds --exclude-paths
|
|
18360
|
+
// excludes isn't offered.
|
|
17045
18361
|
const detectedEcosystems = ROOT_ECOSYSTEMS.filter(ecosystem => (includedByTool.get(ecosystem)?.length ?? 0) > 0);
|
|
17046
18362
|
if (detectedEcosystems.length) {
|
|
17047
18363
|
logger.logger.log(`Detected: ${detectedEcosystems.map(ecosystem => ECOSYSTEM_LABELS[ecosystem]).join(', ')}.`);
|
|
17048
18364
|
} else {
|
|
17049
18365
|
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.
|
|
18366
|
+
// Builds that --exclude-paths excludes are a choice, not an absence.
|
|
17054
18367
|
const hasAnyBuildRoot = ROOT_ECOSYSTEMS.some(ecosystem => (fullByTool.get(ecosystem)?.length ?? 0) > 0);
|
|
17055
18368
|
if (!hasAnyBuildRoot) {
|
|
17056
18369
|
return {
|
|
@@ -17061,22 +18374,15 @@ async function setupRecursiveManifestConfig(cwd, defaultOnReadError, excludePath
|
|
|
17061
18374
|
}
|
|
17062
18375
|
}
|
|
17063
18376
|
logger.logger.log('');
|
|
17064
|
-
|
|
17065
|
-
|
|
17066
|
-
|
|
17067
|
-
|
|
17068
|
-
const rootResult = await setupRecursiveRootDefaults(cwd, defaultOnReadError, detectedEcosystems, ecosystemsAtCwd);
|
|
17069
|
-
if (!rootResult.ok) {
|
|
18377
|
+
const draft = createSettingsDraft();
|
|
18378
|
+
const atCwd = ecosystem => (includedByTool.get(ecosystem) ?? []).filter(root => root.dir === realCwd);
|
|
18379
|
+
const rootResult = await setupRootDefaults(draft, realCwd, detectedEcosystems, atCwd);
|
|
18380
|
+
if (!rootResult.ok || rootResult.data.canceled) {
|
|
17070
18381
|
return rootResult;
|
|
17071
18382
|
}
|
|
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
18383
|
const {
|
|
17079
18384
|
excluded,
|
|
18385
|
+
excludedBuilds,
|
|
17080
18386
|
included
|
|
17081
18387
|
} = await discoverBuildRoots({
|
|
17082
18388
|
cwd,
|
|
@@ -17084,133 +18390,152 @@ async function setupRecursiveManifestConfig(cwd, defaultOnReadError, excludePath
|
|
|
17084
18390
|
fullByTool,
|
|
17085
18391
|
includedByTool
|
|
17086
18392
|
});
|
|
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();
|
|
18393
|
+
for (const {
|
|
18394
|
+
ecosystem,
|
|
18395
|
+
root
|
|
18396
|
+
} of excludedBuilds) {
|
|
18397
|
+
disableBuild(draft, {
|
|
18398
|
+
ecosystem,
|
|
18399
|
+
root});
|
|
17113
18400
|
}
|
|
17114
|
-
|
|
17115
|
-
|
|
17116
|
-
|
|
17117
|
-
|
|
18401
|
+
for (const {
|
|
18402
|
+
dir,
|
|
18403
|
+
ecosystems
|
|
18404
|
+
} of sortByDepthThenPath(excluded, realCwd)) {
|
|
18405
|
+
disableDirectory(draft, dir, ecosystems);
|
|
17118
18406
|
}
|
|
17119
|
-
if (!
|
|
17120
|
-
logger.logger.log('');
|
|
17121
|
-
logger.logger.success('Recursive setup complete.');
|
|
17122
|
-
return notCanceled$1();
|
|
18407
|
+
if (excludePaths?.length && !excluded.length && !excludedBuilds.length) {
|
|
18408
|
+
logger.logger.log('None matched --exclude-paths; nothing skipped.');
|
|
17123
18409
|
}
|
|
17124
|
-
|
|
17125
|
-
|
|
17126
|
-
|
|
17127
|
-
|
|
18410
|
+
const builds = sortByDepthThenPath(included, realCwd).flatMap(({
|
|
18411
|
+
ecosystem,
|
|
18412
|
+
roots
|
|
18413
|
+
}) => sortByDepthThenPath(roots, realCwd, ecosystem).map(root => ({
|
|
18414
|
+
ecosystem,
|
|
18415
|
+
root,
|
|
18416
|
+
sharesDir: roots.length > 1
|
|
18417
|
+
})));
|
|
18418
|
+
const walk = {
|
|
18419
|
+
builds,
|
|
18420
|
+
counts: {
|
|
18421
|
+
configured: 0,
|
|
18422
|
+
covered: 0,
|
|
18423
|
+
inherited: 0,
|
|
18424
|
+
skipped: 0
|
|
18425
|
+
},
|
|
18426
|
+
covered: new Map(),
|
|
18427
|
+
cwd: realCwd,
|
|
18428
|
+
decided: new Set(),
|
|
18429
|
+
draft,
|
|
18430
|
+
excludePaths,
|
|
18431
|
+
skipped: new Map()
|
|
18432
|
+
};
|
|
17128
18433
|
|
|
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,
|
|
18434
|
+
// The builds at cwd are decided first, and loaded only for the review below:
|
|
18435
|
+
// what they include isn't asked about.
|
|
18436
|
+
const cwdBuilds = ROOT_ECOSYSTEMS.flatMap(ecosystem => {
|
|
18437
|
+
const roots = atCwd(ecosystem);
|
|
18438
|
+
return roots.map(root => ({
|
|
17141
18439
|
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) {
|
|
18440
|
+
root,
|
|
18441
|
+
sharesDir: roots.length > 1
|
|
18442
|
+
}));
|
|
18443
|
+
}).filter(build => {
|
|
17161
18444
|
const {
|
|
17162
|
-
|
|
17163
|
-
} =
|
|
17164
|
-
|
|
17165
|
-
|
|
17166
|
-
|
|
17167
|
-
|
|
17168
|
-
|
|
18445
|
+
disabledBy
|
|
18446
|
+
} = resolveDraftSettings(draft, build.ecosystem, build.root);
|
|
18447
|
+
return !disabledBy || !!disabledBy.key;
|
|
18448
|
+
});
|
|
18449
|
+
const cwdLoads = [];
|
|
18450
|
+
for (const build of cwdBuilds) {
|
|
17169
18451
|
// 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) {
|
|
18452
|
+
const result = await reviewBuild(walk, build);
|
|
18453
|
+
if (!result.ok || result.data.canceled) {
|
|
17177
18454
|
return result;
|
|
17178
18455
|
}
|
|
17179
|
-
|
|
17180
|
-
|
|
17181
|
-
|
|
17182
|
-
|
|
17183
|
-
|
|
17184
|
-
|
|
17185
|
-
|
|
17186
|
-
|
|
17187
|
-
|
|
18456
|
+
const {
|
|
18457
|
+
load
|
|
18458
|
+
} = result.data;
|
|
18459
|
+
if (load) {
|
|
18460
|
+
if (load.into === 'skipped') {
|
|
18461
|
+
disableBuild(draft, build);
|
|
18462
|
+
}
|
|
18463
|
+
cwdLoads.push({
|
|
18464
|
+
build,
|
|
18465
|
+
into: load.into
|
|
18466
|
+
});
|
|
17188
18467
|
}
|
|
17189
|
-
|
|
17190
|
-
|
|
17191
|
-
|
|
17192
|
-
|
|
17193
|
-
|
|
18468
|
+
}
|
|
18469
|
+
if (builds.length) {
|
|
18470
|
+
logger.logger.log('');
|
|
18471
|
+
const review = await askYesNo(`Review the ${otherBuilds(builds.length)} found beneath this one?`);
|
|
18472
|
+
if (review === null || review === undefined) {
|
|
18473
|
+
return canceledByUser$1();
|
|
17194
18474
|
}
|
|
17195
|
-
|
|
17196
|
-
|
|
17197
|
-
|
|
17198
|
-
|
|
17199
|
-
|
|
17200
|
-
|
|
17201
|
-
|
|
17202
|
-
|
|
17203
|
-
|
|
17204
|
-
|
|
17205
|
-
|
|
17206
|
-
|
|
17207
|
-
|
|
17208
|
-
|
|
17209
|
-
|
|
18475
|
+
if (review) {
|
|
18476
|
+
for (const {
|
|
18477
|
+
build,
|
|
18478
|
+
into
|
|
18479
|
+
} of cwdLoads) {
|
|
18480
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18481
|
+
const result = await loadInto(walk, build, into, {
|
|
18482
|
+
allowDirectory: false,
|
|
18483
|
+
announce: false
|
|
18484
|
+
});
|
|
18485
|
+
if (!result.ok || result.data.canceled) {
|
|
18486
|
+
return result;
|
|
18487
|
+
}
|
|
18488
|
+
}
|
|
18489
|
+
for (const build of builds) {
|
|
18490
|
+
if (walk.decided.has(buildKey(build))) {
|
|
18491
|
+
continue;
|
|
18492
|
+
}
|
|
18493
|
+
let loaded = false;
|
|
18494
|
+
for (const into of ['covered', 'skipped']) {
|
|
18495
|
+
if (!loaded && (
|
|
18496
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18497
|
+
await isLoadedBy(walk, membershipFor(walk[into], build.ecosystem), build))) {
|
|
18498
|
+
loaded = true;
|
|
18499
|
+
walk.decided.add(buildKey(build));
|
|
18500
|
+
walk.counts[into] += 1;
|
|
18501
|
+
}
|
|
18502
|
+
}
|
|
18503
|
+
if (loaded) {
|
|
18504
|
+
continue;
|
|
18505
|
+
}
|
|
18506
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18507
|
+
const result = await reviewBuild(walk, build);
|
|
18508
|
+
if (!result.ok || result.data.canceled) {
|
|
18509
|
+
return result;
|
|
18510
|
+
}
|
|
18511
|
+
const {
|
|
18512
|
+
load
|
|
18513
|
+
} = result.data;
|
|
18514
|
+
if (load) {
|
|
18515
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18516
|
+
const loaded = await loadInto(walk, build, load.into, {
|
|
18517
|
+
announce: load.announce
|
|
18518
|
+
});
|
|
18519
|
+
if (!loaded.ok || loaded.data.canceled) {
|
|
18520
|
+
return loaded;
|
|
18521
|
+
}
|
|
18522
|
+
}
|
|
18523
|
+
}
|
|
18524
|
+
const {
|
|
18525
|
+
configured,
|
|
18526
|
+
covered,
|
|
18527
|
+
inherited,
|
|
18528
|
+
skipped
|
|
18529
|
+
} = walk.counts;
|
|
18530
|
+
logger.logger.log('');
|
|
18531
|
+
logger.logger.log(`${configured} configured, ${inherited} left as-is, ${skipped} skipped, ${covered} part of another build.`);
|
|
17210
18532
|
}
|
|
17211
18533
|
}
|
|
17212
18534
|
logger.logger.log('');
|
|
17213
|
-
|
|
18535
|
+
const written = await confirmAndWrite(draft, realCwd);
|
|
18536
|
+
if (!written.ok || written.data.canceled) {
|
|
18537
|
+
return written;
|
|
18538
|
+
}
|
|
17214
18539
|
logger.logger.log('');
|
|
17215
18540
|
logger.logger.success('Recursive setup complete.');
|
|
17216
18541
|
return notCanceled$1();
|
|
@@ -17870,7 +19195,7 @@ async function lsPnpm(pkgEnvDetails, options) {
|
|
|
17870
19195
|
__proto__: null,
|
|
17871
19196
|
...options
|
|
17872
19197
|
};
|
|
17873
|
-
if (npmExecPath && npmExecPath !== NPM$1) {
|
|
19198
|
+
if (!constants.default.WIN32 && npmExecPath && npmExecPath !== NPM$1) {
|
|
17874
19199
|
const result = await npmQuery(npmExecPath, cwd);
|
|
17875
19200
|
if (result) {
|
|
17876
19201
|
return result;
|
|
@@ -18565,6 +19890,90 @@ async function run$u(argv, importMeta, {
|
|
|
18565
19890
|
});
|
|
18566
19891
|
}
|
|
18567
19892
|
|
|
19893
|
+
function parsePurlsOption(argv, suppliedPurls) {
|
|
19894
|
+
const hasPurlsOption = argv.some(argument => argument === '--purls' || argument.startsWith('--purls='));
|
|
19895
|
+
if (suppliedPurls === undefined) {
|
|
19896
|
+
return hasPurlsOption ? parseDependenciesPurls([]) : {
|
|
19897
|
+
ok: true,
|
|
19898
|
+
purls: undefined
|
|
19899
|
+
};
|
|
19900
|
+
}
|
|
19901
|
+
if (!hasPurlsOption && Array.isArray(suppliedPurls) && suppliedPurls.length === 0) {
|
|
19902
|
+
return {
|
|
19903
|
+
ok: true,
|
|
19904
|
+
purls: undefined
|
|
19905
|
+
};
|
|
19906
|
+
}
|
|
19907
|
+
if (!Array.isArray(suppliedPurls) || !suppliedPurls.every(value => typeof value === 'string')) {
|
|
19908
|
+
return {
|
|
19909
|
+
ok: false,
|
|
19910
|
+
message: 'Provide at least one non-empty PURL with --purls.'
|
|
19911
|
+
};
|
|
19912
|
+
}
|
|
19913
|
+
return parseDependenciesPurls(suppliedPurls);
|
|
19914
|
+
}
|
|
19915
|
+
function parseDependenciesPurls(values) {
|
|
19916
|
+
if (values === undefined) {
|
|
19917
|
+
return {
|
|
19918
|
+
ok: true,
|
|
19919
|
+
purls: undefined
|
|
19920
|
+
};
|
|
19921
|
+
}
|
|
19922
|
+
const purls = [];
|
|
19923
|
+
const seen = new Set();
|
|
19924
|
+
const purlValues = values.flatMap(value => value.split(','));
|
|
19925
|
+
for (const value of purlValues) {
|
|
19926
|
+
const purl = utils.normalizePurl(value.trim());
|
|
19927
|
+
const parsed = utils.getPurlObject(purl, {
|
|
19928
|
+
throws: false
|
|
19929
|
+
});
|
|
19930
|
+
if (!parsed) {
|
|
19931
|
+
return {
|
|
19932
|
+
ok: false,
|
|
19933
|
+
message: `Invalid PURL "${value}". Use a full PURL such as pkg:npm/minimist@1.2.3.`
|
|
19934
|
+
};
|
|
19935
|
+
}
|
|
19936
|
+
if (Object.keys(parsed.qualifiers ?? {}).length > 0 || parsed.subpath) {
|
|
19937
|
+
return {
|
|
19938
|
+
ok: false,
|
|
19939
|
+
message: `PURL "${value}" includes qualifiers or a subpath, which this search does not support. Search by package identity and version only.`
|
|
19940
|
+
};
|
|
19941
|
+
}
|
|
19942
|
+
if (!seen.has(purl)) {
|
|
19943
|
+
seen.add(purl);
|
|
19944
|
+
purls.push(purl);
|
|
19945
|
+
}
|
|
19946
|
+
}
|
|
19947
|
+
if (purls.length === 0) {
|
|
19948
|
+
return {
|
|
19949
|
+
ok: false,
|
|
19950
|
+
message: 'Provide at least one non-empty PURL with --purls.'
|
|
19951
|
+
};
|
|
19952
|
+
}
|
|
19953
|
+
return {
|
|
19954
|
+
ok: true,
|
|
19955
|
+
purls
|
|
19956
|
+
};
|
|
19957
|
+
}
|
|
19958
|
+
function matchesConfirmedPurls(requested, filters) {
|
|
19959
|
+
if (typeof filters !== 'object' || filters === null) {
|
|
19960
|
+
return false;
|
|
19961
|
+
}
|
|
19962
|
+
if (!('valid' in filters) || !('invalid' in filters)) {
|
|
19963
|
+
return false;
|
|
19964
|
+
}
|
|
19965
|
+
const {
|
|
19966
|
+
invalid,
|
|
19967
|
+
valid
|
|
19968
|
+
} = filters;
|
|
19969
|
+
if (!Array.isArray(valid) || !valid.every(value => typeof value === 'string') || !Array.isArray(invalid) || !invalid.every(value => typeof value === 'string') || invalid.length > 0) {
|
|
19970
|
+
return false;
|
|
19971
|
+
}
|
|
19972
|
+
const expected = new Set(requested);
|
|
19973
|
+
const actual = new Set(valid);
|
|
19974
|
+
return expected.size === requested.length && actual.size === valid.length && expected.size === actual.size && [...expected].every(value => actual.has(value));
|
|
19975
|
+
}
|
|
19976
|
+
|
|
18568
19977
|
async function fetchDependencies(config, options) {
|
|
18569
19978
|
const {
|
|
18570
19979
|
sdkOpts
|
|
@@ -18579,17 +19988,26 @@ async function fetchDependencies(config, options) {
|
|
|
18579
19988
|
const sockSdk = sockSdkCResult.data;
|
|
18580
19989
|
const {
|
|
18581
19990
|
limit,
|
|
18582
|
-
offset
|
|
18583
|
-
|
|
18584
|
-
|
|
18585
|
-
|
|
18586
|
-
};
|
|
18587
|
-
return await utils.handleApiCall(sockSdk.searchDependencies({
|
|
19991
|
+
offset,
|
|
19992
|
+
purls
|
|
19993
|
+
} = config;
|
|
19994
|
+
const result = await utils.handleApiCall(sockSdk.searchDependencies({
|
|
18588
19995
|
limit,
|
|
18589
|
-
offset
|
|
19996
|
+
offset,
|
|
19997
|
+
...(purls === undefined ? {} : {
|
|
19998
|
+
purls
|
|
19999
|
+
})
|
|
18590
20000
|
}), {
|
|
18591
20001
|
description: 'organization dependencies'
|
|
18592
20002
|
});
|
|
20003
|
+
if (result.ok && purls !== undefined && !matchesConfirmedPurls(purls, result.data.purlFilters)) {
|
|
20004
|
+
return {
|
|
20005
|
+
ok: false,
|
|
20006
|
+
message: 'The server did not confirm every requested PURL filter.',
|
|
20007
|
+
cause: 'Review the PURLs and try again. No dependency results were displayed because the filters may not have been applied.'
|
|
20008
|
+
};
|
|
20009
|
+
}
|
|
20010
|
+
return result;
|
|
18593
20011
|
}
|
|
18594
20012
|
|
|
18595
20013
|
// @ts-ignore
|
|
@@ -18655,17 +20073,20 @@ function outputMarkdown(result, {
|
|
|
18655
20073
|
async function handleDependencies({
|
|
18656
20074
|
limit,
|
|
18657
20075
|
offset,
|
|
18658
|
-
outputKind
|
|
20076
|
+
outputKind,
|
|
20077
|
+
purls
|
|
18659
20078
|
}) {
|
|
18660
20079
|
debug.debugFn('notice', `Fetching dependencies with limit=${limit}, offset=${offset}`);
|
|
18661
20080
|
debug.debugDir('inspect', {
|
|
18662
20081
|
limit,
|
|
18663
20082
|
offset,
|
|
18664
|
-
outputKind
|
|
20083
|
+
outputKind,
|
|
20084
|
+
purls
|
|
18665
20085
|
});
|
|
18666
20086
|
const result = await fetchDependencies({
|
|
18667
20087
|
limit,
|
|
18668
|
-
offset
|
|
20088
|
+
offset,
|
|
20089
|
+
purls
|
|
18669
20090
|
});
|
|
18670
20091
|
debug.debugFn('notice', `Dependencies ${result.ok ? 'fetched successfully' : 'fetch failed'}`);
|
|
18671
20092
|
debug.debugDir('inspect', {
|
|
@@ -18703,7 +20124,12 @@ async function run$t(argv, importMeta, {
|
|
|
18703
20124
|
offset: {
|
|
18704
20125
|
type: 'number',
|
|
18705
20126
|
default: 0,
|
|
18706
|
-
description: '
|
|
20127
|
+
description: 'Number of dependencies to skip'
|
|
20128
|
+
},
|
|
20129
|
+
purls: {
|
|
20130
|
+
type: 'string',
|
|
20131
|
+
isMultiple: true,
|
|
20132
|
+
description: 'Search by PURL; pkg: is optional. Comma-separate values or repeat this flag'
|
|
18707
20133
|
},
|
|
18708
20134
|
...flags.outputFlags
|
|
18709
20135
|
},
|
|
@@ -18720,6 +20146,7 @@ async function run$t(argv, importMeta, {
|
|
|
18720
20146
|
Examples
|
|
18721
20147
|
${command}
|
|
18722
20148
|
${command} --limit 20 --offset 10
|
|
20149
|
+
${command} --purls 'npm/minimist@0.0.4,pkg:pypi/requests'
|
|
18723
20150
|
`
|
|
18724
20151
|
};
|
|
18725
20152
|
const cli = utils.meowOrExit({
|
|
@@ -18732,8 +20159,16 @@ async function run$t(argv, importMeta, {
|
|
|
18732
20159
|
json,
|
|
18733
20160
|
limit,
|
|
18734
20161
|
markdown,
|
|
18735
|
-
offset
|
|
20162
|
+
offset,
|
|
20163
|
+
purls: suppliedPurls
|
|
18736
20164
|
} = cli.flags;
|
|
20165
|
+
const parsedPurls = parsePurlsOption(argv, suppliedPurls);
|
|
20166
|
+
if (!parsedPurls.ok) {
|
|
20167
|
+
throw new utils.InputError(parsedPurls.message);
|
|
20168
|
+
}
|
|
20169
|
+
const {
|
|
20170
|
+
purls
|
|
20171
|
+
} = parsedPurls;
|
|
18737
20172
|
const dryRun = !!cli.flags['dryRun'];
|
|
18738
20173
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
18739
20174
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
@@ -18758,7 +20193,8 @@ async function run$t(argv, importMeta, {
|
|
|
18758
20193
|
await handleDependencies({
|
|
18759
20194
|
limit: Number(limit || 0) || 0,
|
|
18760
20195
|
offset: Number(offset || 0) || 0,
|
|
18761
|
-
outputKind
|
|
20196
|
+
outputKind,
|
|
20197
|
+
purls
|
|
18762
20198
|
});
|
|
18763
20199
|
}
|
|
18764
20200
|
|
|
@@ -20112,10 +21548,44 @@ function resolveSocketPatchBin() {
|
|
|
20112
21548
|
// Fallback: assume socket-patch is on PATH.
|
|
20113
21549
|
return 'socket-patch';
|
|
20114
21550
|
}
|
|
21551
|
+
function isSelfUpdate(argv) {
|
|
21552
|
+
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'));
|
|
21553
|
+
}
|
|
21554
|
+
function validateExplicitSocketPatchPath(binPath) {
|
|
21555
|
+
const absoluteBinPath = path.resolve(binPath);
|
|
21556
|
+
try {
|
|
21557
|
+
const stats = u.statSync(absoluteBinPath);
|
|
21558
|
+
if (!stats.isFile()) {
|
|
21559
|
+
throw new Error('not a regular file');
|
|
21560
|
+
}
|
|
21561
|
+
u.accessSync(absoluteBinPath, u.constants.X_OK);
|
|
21562
|
+
} catch (cause) {
|
|
21563
|
+
throw new Error(`SOCKET_CLI_SOCKET_PATCH_PATH must name an existing executable file: ${absoluteBinPath}`, {
|
|
21564
|
+
cause
|
|
21565
|
+
});
|
|
21566
|
+
}
|
|
21567
|
+
return absoluteBinPath;
|
|
21568
|
+
}
|
|
20115
21569
|
async function run$m(argv, _importMeta, _context) {
|
|
20116
21570
|
const {
|
|
20117
21571
|
ENV
|
|
20118
21572
|
} = constants.default;
|
|
21573
|
+
const standalone = utils.isStandaloneSea();
|
|
21574
|
+
if (standalone && isSelfUpdate(argv)) {
|
|
21575
|
+
throw new Error('socket-patch self-update is unavailable in the standalone Socket build because it cannot replace the bundled executable.');
|
|
21576
|
+
}
|
|
21577
|
+
let explicitBinPath = standalone ? ENV.SOCKET_CLI_SOCKET_PATCH_PATH : undefined;
|
|
21578
|
+
let bundledBinPath;
|
|
21579
|
+
if (standalone) {
|
|
21580
|
+
// The explicit override takes precedence; otherwise extract only the
|
|
21581
|
+
// verified embedded payload. Neither branch consults PATH.
|
|
21582
|
+
if (explicitBinPath) {
|
|
21583
|
+
explicitBinPath = validateExplicitSocketPatchPath(explicitBinPath);
|
|
21584
|
+
} else {
|
|
21585
|
+
bundledBinPath = await utils.getBundledTool('socket-patch');
|
|
21586
|
+
explicitBinPath = bundledBinPath;
|
|
21587
|
+
}
|
|
21588
|
+
}
|
|
20119
21589
|
|
|
20120
21590
|
// Build environment variables for the socket-patch binary.
|
|
20121
21591
|
const spawnEnv = {
|
|
@@ -20146,22 +21616,32 @@ async function run$m(argv, _importMeta, _context) {
|
|
|
20146
21616
|
|
|
20147
21617
|
// Resolve and spawn the socket-patch Rust binary.
|
|
20148
21618
|
// 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
|
-
|
|
21619
|
+
const binPath = explicitBinPath || resolveSocketPatchBin();
|
|
21620
|
+
try {
|
|
21621
|
+
const result = childProcess.spawnSync(binPath, [...argv], {
|
|
21622
|
+
stdio: 'inherit',
|
|
21623
|
+
env: spawnEnv,
|
|
21624
|
+
shell: explicitBinPath ? false : constants.default.WIN32
|
|
21625
|
+
});
|
|
21626
|
+
if (result.error) {
|
|
21627
|
+
throw result.error;
|
|
21628
|
+
}
|
|
21629
|
+
// Propagate signal if the child was killed (e.g. SIGTERM, SIGINT).
|
|
21630
|
+
if (result.signal) {
|
|
21631
|
+
if (bundledBinPath) {
|
|
21632
|
+
await utils.cleanupBundledTool(bundledBinPath);
|
|
21633
|
+
bundledBinPath = undefined;
|
|
21634
|
+
}
|
|
21635
|
+
process.kill(process.pid, result.signal);
|
|
21636
|
+
return;
|
|
21637
|
+
}
|
|
21638
|
+
if (result.status !== null && result.status !== 0) {
|
|
21639
|
+
process.exitCode = result.status;
|
|
21640
|
+
}
|
|
21641
|
+
} finally {
|
|
21642
|
+
if (bundledBinPath) {
|
|
21643
|
+
await utils.cleanupBundledTool(bundledBinPath);
|
|
21644
|
+
}
|
|
20165
21645
|
}
|
|
20166
21646
|
}
|
|
20167
21647
|
|
|
@@ -21406,6 +22886,26 @@ const cmdRepository = {
|
|
|
21406
22886
|
|
|
21407
22887
|
const CLEANUP_SIGNALS = ['SIGHUP', 'SIGINT', 'SIGTERM'];
|
|
21408
22888
|
const UV_SBOM_FILENAME = 'socket-uv-cdx.json';
|
|
22889
|
+
const UV_PATH_ENV = 'SOCKET_CLI_UV_PATH';
|
|
22890
|
+
function resolveUvExecutable() {
|
|
22891
|
+
if (!utils.isStandaloneSea()) {
|
|
22892
|
+
return 'uv';
|
|
22893
|
+
}
|
|
22894
|
+
const override = process.env[UV_PATH_ENV];
|
|
22895
|
+
if (!override) {
|
|
22896
|
+
return '';
|
|
22897
|
+
}
|
|
22898
|
+
const executable = path.resolve(process.cwd(), override);
|
|
22899
|
+
try {
|
|
22900
|
+
u.accessSync(executable, process.platform === 'win32' ? u.constants.F_OK : u.constants.X_OK);
|
|
22901
|
+
if (!u.statSync(executable).isFile()) {
|
|
22902
|
+
throw new Error('not a file');
|
|
22903
|
+
}
|
|
22904
|
+
} catch {
|
|
22905
|
+
throw new utils.InputError(`${UV_PATH_ENV} must point to an executable uv binary, but '${executable}' is missing or not executable.`);
|
|
22906
|
+
}
|
|
22907
|
+
return executable;
|
|
22908
|
+
}
|
|
21409
22909
|
function componentIdentity(component) {
|
|
21410
22910
|
return JSON.stringify([component.name, component.version, component.purl]);
|
|
21411
22911
|
}
|
|
@@ -21421,17 +22921,32 @@ async function exportMemberSbom(memberDir) {
|
|
|
21421
22921
|
}
|
|
21422
22922
|
async function exportSbom(memberDir, groups) {
|
|
21423
22923
|
let content;
|
|
22924
|
+
const uvExecutable = resolveUvExecutable();
|
|
22925
|
+
let bundledExecutable;
|
|
22926
|
+
let childClosed;
|
|
21424
22927
|
try {
|
|
21425
|
-
|
|
21426
|
-
|
|
21427
|
-
}
|
|
22928
|
+
if (!uvExecutable) {
|
|
22929
|
+
bundledExecutable = await utils.getBundledTool('uv');
|
|
22930
|
+
}
|
|
22931
|
+
const child = spawn.spawn(uvExecutable || bundledExecutable, ['export', '--project', memberDir, '--format', 'cyclonedx1.5', '--frozen', '--offline', '--no-python-downloads', '--all-extras', groups], {
|
|
21428
22932
|
cwd: memberDir,
|
|
21429
22933
|
signal: constants.default.abortSignal,
|
|
21430
22934
|
stdio: 'pipe'
|
|
21431
22935
|
});
|
|
22936
|
+
if (child.process) {
|
|
22937
|
+
childClosed = new Promise(resolve => child.process.once('close', resolve));
|
|
22938
|
+
}
|
|
22939
|
+
const {
|
|
22940
|
+
stdout
|
|
22941
|
+
} = await child;
|
|
21432
22942
|
content = stdout;
|
|
21433
22943
|
} catch (e) {
|
|
21434
22944
|
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));
|
|
22945
|
+
} finally {
|
|
22946
|
+
await childClosed;
|
|
22947
|
+
if (bundledExecutable) {
|
|
22948
|
+
await utils.cleanupBundledTool(bundledExecutable);
|
|
22949
|
+
}
|
|
21435
22950
|
}
|
|
21436
22951
|
return parseSbom(content, memberDir);
|
|
21437
22952
|
}
|
|
@@ -21611,7 +23126,7 @@ const CMD_NAME$a = 'create';
|
|
|
21611
23126
|
|
|
21612
23127
|
// Accepted for backwards compatibility but forwarded nowhere, so passing one
|
|
21613
23128
|
// must not imply --reach.
|
|
21614
|
-
const DEPRECATED_NO_OP_REACH_FLAGS = new Set(['reachDisableAnalysisSplitting', 'reachLazyMode']);
|
|
23129
|
+
const DEPRECATED_NO_OP_REACH_FLAGS = new Set(['reachDisableAnalysisSplitting', 'reachEnableAnalysisSplitting', 'reachLazyMode']);
|
|
21615
23130
|
const description$c = 'Create a new Socket scan and report';
|
|
21616
23131
|
const hidden$a = false;
|
|
21617
23132
|
const generalFlags$1 = {
|
|
@@ -21721,7 +23236,7 @@ const generalFlags$1 = {
|
|
|
21721
23236
|
uvMembers: {
|
|
21722
23237
|
type: 'boolean',
|
|
21723
23238
|
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.'
|
|
23239
|
+
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
23240
|
}
|
|
21726
23241
|
};
|
|
21727
23242
|
function hasSocketFactsFileIn(dir) {
|
|
@@ -21828,13 +23343,10 @@ async function run$d(argv, importMeta, {
|
|
|
21828
23343
|
reachContinueOnNoSourceFiles,
|
|
21829
23344
|
reachDebug,
|
|
21830
23345
|
reachDetailedAnalysisLogFile,
|
|
21831
|
-
reachDisableAnalysisSplitting: _reachDisableAnalysisSplitting,
|
|
21832
23346
|
reachDisableAnalytics,
|
|
21833
23347
|
reachDisableDependencyDownloads,
|
|
21834
23348
|
reachDisableExternalToolChecks,
|
|
21835
|
-
reachEnableAnalysisSplitting,
|
|
21836
23349
|
reachFallbackToRegularScan,
|
|
21837
|
-
reachLazyMode: _reachLazyMode,
|
|
21838
23350
|
reachRetainFactsFile,
|
|
21839
23351
|
reachSkipCache,
|
|
21840
23352
|
reachUseOnlyPregeneratedSboms,
|
|
@@ -22105,7 +23617,6 @@ async function run$d(argv, importMeta, {
|
|
|
22105
23617
|
reachDisableDependencyDownloads: Boolean(reachDisableDependencyDownloads),
|
|
22106
23618
|
reachDisableExternalToolChecks: Boolean(reachDisableExternalToolChecks),
|
|
22107
23619
|
reachEcosystems,
|
|
22108
|
-
reachEnableAnalysisSplitting: Boolean(reachEnableAnalysisSplitting),
|
|
22109
23620
|
reachExcludePaths,
|
|
22110
23621
|
reachFallbackToRegularScan: Boolean(reachFallbackToRegularScan),
|
|
22111
23622
|
reachRetainFactsFile: Boolean(reachRetainFactsFile),
|
|
@@ -22825,7 +24336,6 @@ async function scanOneRepo(repoSlug, {
|
|
|
22825
24336
|
reachDisableDependencyDownloads: false,
|
|
22826
24337
|
reachDisableExternalToolChecks: false,
|
|
22827
24338
|
reachEcosystems: [],
|
|
22828
|
-
reachEnableAnalysisSplitting: false,
|
|
22829
24339
|
reachExcludePaths: [],
|
|
22830
24340
|
reachFallbackToRegularScan: false,
|
|
22831
24341
|
reachRetainFactsFile: false,
|
|
@@ -24054,11 +25564,11 @@ async function runScanReach({
|
|
|
24054
25564
|
reachabilityOptions,
|
|
24055
25565
|
target: targets[0]
|
|
24056
25566
|
});
|
|
24057
|
-
const packagePaths = await utils.getPackageFilesForScan(scanTargets, supportedFiles, {
|
|
25567
|
+
const packagePaths = await withoutDiscardedFacts(await utils.getPackageFilesForScan(scanTargets, supportedFiles, {
|
|
24058
25568
|
additionalIgnores: additionalScaIgnores,
|
|
24059
25569
|
config: socketConfig,
|
|
24060
25570
|
cwd
|
|
24061
|
-
});
|
|
25571
|
+
}), dynamicResult?.discardedFactsPaths);
|
|
24062
25572
|
spinner.successAndStop(`Found ${packagePaths.length} ${words.pluralize('manifest file', packagePaths.length)} for reachability analysis.`);
|
|
24063
25573
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
24064
25574
|
nook: true,
|
|
@@ -24227,12 +25737,9 @@ async function run$7(argv, importMeta, {
|
|
|
24227
25737
|
reachContinueOnNoSourceFiles,
|
|
24228
25738
|
reachDebug,
|
|
24229
25739
|
reachDetailedAnalysisLogFile,
|
|
24230
|
-
reachDisableAnalysisSplitting: _reachDisableAnalysisSplitting,
|
|
24231
25740
|
reachDisableAnalytics,
|
|
24232
25741
|
reachDisableDependencyDownloads,
|
|
24233
25742
|
reachDisableExternalToolChecks,
|
|
24234
|
-
reachEnableAnalysisSplitting,
|
|
24235
|
-
reachLazyMode: _reachLazyMode,
|
|
24236
25743
|
reachRetainFactsFile,
|
|
24237
25744
|
reachSkipCache,
|
|
24238
25745
|
reachUseOnlyPregeneratedSboms,
|
|
@@ -24340,7 +25847,6 @@ async function run$7(argv, importMeta, {
|
|
|
24340
25847
|
reachDisableDependencyDownloads: Boolean(reachDisableDependencyDownloads),
|
|
24341
25848
|
reachDisableExternalToolChecks: Boolean(reachDisableExternalToolChecks),
|
|
24342
25849
|
reachEcosystems,
|
|
24343
|
-
reachEnableAnalysisSplitting: Boolean(reachEnableAnalysisSplitting),
|
|
24344
25850
|
reachExcludePaths,
|
|
24345
25851
|
reachRetainFactsFile: Boolean(reachRetainFactsFile),
|
|
24346
25852
|
reachSkipCache: Boolean(reachSkipCache),
|
|
@@ -26292,5 +27798,5 @@ process.on('unhandledRejection', async (reason, promise) => {
|
|
|
26292
27798
|
// eslint-disable-next-line n/no-process-exit
|
|
26293
27799
|
process.exit(1);
|
|
26294
27800
|
});
|
|
26295
|
-
//# debugId=
|
|
27801
|
+
//# debugId=7fcef745-747c-4f9c-9e90-a5e5f1059e5e
|
|
26296
27802
|
//# sourceMappingURL=cli.js.map
|