@cdxgen/cdxgen 13.3.0 → 13.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -9
- package/bin/cdxgen-secure.js +15 -0
- package/bin/cdxgen.js +115 -31
- package/bin/evinse.js +23 -1
- package/bin/hbom.js +15 -7
- package/bin/repl.js +115 -0
- package/bin/sign.js +45 -15
- package/bin/tracebom.js +5 -1
- package/bin/validate.js +84 -18
- package/bin/verify.js +155 -86
- package/data/cbomosdb-queries.json +13 -1
- package/data/component-tags.json +8 -0
- package/data/helpers/init.gradle +46 -21
- package/data/queries-darwin.json +25 -1
- package/data/queries-win.json +19 -1
- package/data/queries.json +41 -0
- package/data/remediations.json +344 -1
- package/data/rules/cbom-security.yaml +235 -4
- package/data/rules/dependency-sources.yaml +67 -0
- package/data/rules/go-binaries.yaml +46 -0
- package/data/rules/golem-go.yaml +80 -0
- package/data/rules/hbom-compliance.yaml +40 -22
- package/data/rules/hbom-performance.yaml +7 -1
- package/data/rules/host-topology.yaml +1 -1
- package/data/rules/obom-runtime.yaml +31 -2
- package/data/rules/php-runtime.yaml +143 -0
- package/data/rules/scala-evidence.yaml +115 -0
- package/lib/audit/index.js +52 -6
- package/lib/cli/bomAssembly.js +28 -3
- package/lib/cli/cliOptions.js +110 -3
- package/lib/cli/index.js +186 -58
- package/lib/cli/jsBom.js +50 -29
- package/lib/cli/jvmBom.js +779 -146
- package/lib/cli/managedBom.js +1021 -261
- package/lib/cli/nativeBom.js +364 -58
- package/lib/core/activity.js +12 -0
- package/lib/core/env.js +47 -17
- package/lib/core/fs.js +31 -21
- package/lib/core/httpClient.js +233 -69
- package/lib/core/pluginRun.js +184 -0
- package/lib/core/processTree.js +100 -0
- package/lib/core/projectConfig.js +1 -0
- package/lib/core/projectTooling.js +97 -0
- package/lib/core/propertySanitizer.js +72 -0
- package/lib/core/runState.js +39 -0
- package/lib/core/toml.js +72 -0
- package/lib/ecosystems/asarutils.js +4 -2
- package/lib/ecosystems/bunutils.js +5 -7
- package/lib/ecosystems/cargoCache.js +231 -8
- package/lib/ecosystems/cmakeResolver.js +10 -21
- package/lib/ecosystems/cppBuildContext.js +631 -0
- package/lib/ecosystems/cppEvidence.js +337 -22
- package/lib/ecosystems/cppIncludeResolver.js +294 -0
- package/lib/ecosystems/denoutils.js +93 -66
- package/lib/ecosystems/ecosystems.js +1967 -788
- package/lib/ecosystems/golem.js +578 -18
- package/lib/ecosystems/gradleutils.js +340 -46
- package/lib/ecosystems/jsEvidence.js +85 -24
- package/lib/ecosystems/kosi.js +21 -4
- package/lib/ecosystems/npmutils.js +64 -0
- package/lib/ecosystems/parsers-dotnet.js +668 -153
- package/lib/ecosystems/parsers-elm.js +46 -28
- package/lib/ecosystems/parsers-gleam.js +3 -4
- package/lib/ecosystems/parsers-go.js +1283 -297
- package/lib/ecosystems/parsers-js.js +92 -26
- package/lib/ecosystems/parsers-julia.js +2 -3
- package/lib/ecosystems/parsers-jvm.js +463 -29
- package/lib/ecosystems/parsers-misc.js +405 -93
- package/lib/ecosystems/parsers-python.js +152 -20
- package/lib/ecosystems/parsers-rust.js +4 -4
- package/lib/ecosystems/parsers-terraform.js +1573 -19
- package/lib/ecosystems/pythonutils.js +102 -6
- package/lib/ecosystems/remote/huggingface.js +3 -0
- package/lib/ecosystems/rubyutils.js +73 -20
- package/lib/ecosystems/rusi.js +32 -9
- package/lib/ecosystems/sbtutils.js +243 -187
- package/lib/ecosystems/scalacliutils.js +343 -0
- package/lib/ecosystems/scalasem.js +2620 -0
- package/lib/ecosystems/terraformRegistry.js +288 -0
- package/lib/ecosystems/utils.js +2 -0
- package/lib/ecosystems/vendoredCode.js +156 -0
- package/lib/evinser/evinser.js +695 -78
- package/lib/evinser/swiftsem.js +68 -5
- package/lib/helpers/agenticToolutils.js +2 -2
- package/lib/helpers/bomSigner.js +576 -128
- package/lib/inventory/agentSkillSpec.js +17 -0
- package/lib/inventory/aiCollector.js +4 -1
- package/lib/inventory/analyzer.js +110 -127
- package/lib/inventory/apkInstalledDb.js +243 -0
- package/lib/inventory/atomUtils.js +204 -48
- package/lib/inventory/auditCategories.js +10 -3
- package/lib/inventory/buildToolRateLimit.js +144 -0
- package/lib/inventory/cacheCommands.js +2 -1
- package/lib/inventory/cacheDir.js +52 -9
- package/lib/inventory/certificates.js +2371 -0
- package/lib/inventory/cmakeBuildDirs.js +254 -0
- package/lib/inventory/communityAiConfigParser.js +4 -9
- package/lib/inventory/deps.js +507 -128
- package/lib/inventory/display.js +200 -3
- package/lib/inventory/dosai.js +747 -101
- package/lib/inventory/dosaiParsers.js +310 -15
- package/lib/inventory/dynamic.js +96 -8
- package/lib/inventory/envcontext.js +168 -5
- package/lib/inventory/evidenceUtils.js +590 -132
- package/lib/inventory/fetchBatch.js +574 -38
- package/lib/inventory/fetchDiskCache.js +597 -0
- package/lib/inventory/forgeEnricher.js +14 -5
- package/lib/inventory/formulationParsers.js +3 -2
- package/lib/inventory/goBuildInfo.js +140 -0
- package/lib/inventory/hbom.js +67 -7
- package/lib/inventory/hbomAnalysis.js +16 -0
- package/lib/inventory/hostTopology.js +21 -0
- package/lib/inventory/jvmLocalRepos.js +917 -0
- package/lib/inventory/mcpConfigParser.js +2 -3
- package/lib/inventory/osPackagePurl.js +244 -0
- package/lib/inventory/osPackageResolver.js +89 -87
- package/lib/inventory/osinfo.js +79 -31
- package/lib/inventory/osqueryTransform.js +114 -5
- package/lib/inventory/parentSelection.js +146 -0
- package/lib/inventory/phpBuildInfo.js +487 -0
- package/lib/inventory/phpHostProbe.js +641 -0
- package/lib/inventory/rootfsCerts.js +426 -0
- package/lib/inventory/rustFormulationParser.js +3 -4
- package/lib/inventory/scalaCoords.js +153 -0
- package/lib/inventory/source.js +215 -11
- package/lib/inventory/spdx.js +245 -0
- package/lib/inventory/traceRunner.js +93 -8
- package/lib/inventory/tracedCrypto.js +423 -0
- package/lib/managers/binary.js +529 -183
- package/lib/managers/docker.js +199 -44
- package/lib/managers/oci.js +24 -2
- package/lib/parsers/cmakeCache.js +69 -0
- package/lib/parsers/cmakeLists.js +16 -2
- package/lib/parsers/cmakePresets.js +400 -0
- package/lib/parsers/compileCommands.js +557 -0
- package/lib/parsers/email.js +277 -0
- package/lib/parsers/largeJson.js +34 -2
- package/lib/parsers/strictJson.js +322 -0
- package/lib/parsers/terraformConfig.js +1073 -0
- package/lib/parsers/terraformSource.js +652 -0
- package/lib/server/server.js +209 -1
- package/lib/stages/postgen/annotator.js +17 -1
- package/lib/stages/postgen/introspection/markers.js +1 -1
- package/lib/stages/postgen/introspection/reflect.js +4 -1
- package/lib/stages/postgen/postgen.js +20 -6
- package/lib/stages/postgen/ruleEngine.js +58 -1
- package/lib/stages/postgen/specVersionCompat.js +62 -0
- package/lib/stages/pregen/pregen.js +117 -5
- package/lib/validator/bomValidator.js +26 -5
- package/lib/validator/generated/runtime.mjs +13 -0
- package/lib/validator/generated/validate-1.6.mjs +26 -7
- package/lib/validator/generated/validate-1.7.mjs +31 -12
- package/lib/validator/generated/validate-2.0.mjs +30 -11
- package/lib/validator/index.js +25 -10
- package/lib/validator/reporters/json.js +1 -0
- package/package.json +23 -23
- package/types/bin/cdxgen-secure.d.ts +3 -0
- package/types/bin/cdxgen-secure.d.ts.map +1 -0
- package/types/bin/repl.d.ts.map +1 -1
- package/types/lib/audit/index.d.ts.map +1 -1
- package/types/lib/cli/bomAssembly.d.ts +9 -2
- package/types/lib/cli/bomAssembly.d.ts.map +1 -1
- package/types/lib/cli/cliOptions.d.ts +43 -0
- package/types/lib/cli/cliOptions.d.ts.map +1 -1
- package/types/lib/cli/index.d.ts.map +1 -1
- package/types/lib/cli/jsBom.d.ts.map +1 -1
- package/types/lib/cli/jvmBom.d.ts +44 -1
- package/types/lib/cli/jvmBom.d.ts.map +1 -1
- package/types/lib/cli/managedBom.d.ts +7 -4
- package/types/lib/cli/managedBom.d.ts.map +1 -1
- package/types/lib/cli/nativeBom.d.ts +3 -1
- package/types/lib/cli/nativeBom.d.ts.map +1 -1
- package/types/lib/core/activity.d.ts.map +1 -1
- package/types/lib/core/env.d.ts +27 -2
- package/types/lib/core/env.d.ts.map +1 -1
- package/types/lib/core/fs.d.ts.map +1 -1
- package/types/lib/core/httpClient.d.ts +13 -8
- package/types/lib/core/httpClient.d.ts.map +1 -1
- package/types/lib/core/pluginRun.d.ts +97 -0
- package/types/lib/core/pluginRun.d.ts.map +1 -0
- package/types/lib/core/processTree.d.ts +36 -0
- package/types/lib/core/processTree.d.ts.map +1 -0
- package/types/lib/core/projectConfig.d.ts.map +1 -1
- package/types/lib/core/projectTooling.d.ts +41 -0
- package/types/lib/core/projectTooling.d.ts.map +1 -0
- package/types/lib/core/propertySanitizer.d.ts +26 -0
- package/types/lib/core/propertySanitizer.d.ts.map +1 -1
- package/types/lib/core/runState.d.ts +29 -0
- package/types/lib/core/runState.d.ts.map +1 -0
- package/types/lib/core/toml.d.ts +20 -0
- package/types/lib/core/toml.d.ts.map +1 -0
- package/types/lib/ecosystems/asarutils.d.ts.map +1 -1
- package/types/lib/ecosystems/bunutils.d.ts.map +1 -1
- package/types/lib/ecosystems/cargoCache.d.ts +12 -0
- package/types/lib/ecosystems/cargoCache.d.ts.map +1 -1
- package/types/lib/ecosystems/cmakeResolver.d.ts +5 -3
- package/types/lib/ecosystems/cmakeResolver.d.ts.map +1 -1
- package/types/lib/ecosystems/cppBuildContext.d.ts +55 -0
- package/types/lib/ecosystems/cppBuildContext.d.ts.map +1 -0
- package/types/lib/ecosystems/cppEvidence.d.ts +19 -3
- package/types/lib/ecosystems/cppEvidence.d.ts.map +1 -1
- package/types/lib/ecosystems/cppIncludeResolver.d.ts +92 -0
- package/types/lib/ecosystems/cppIncludeResolver.d.ts.map +1 -0
- package/types/lib/ecosystems/denoutils.d.ts +9 -3
- package/types/lib/ecosystems/denoutils.d.ts.map +1 -1
- package/types/lib/ecosystems/ecosystems.d.ts +62 -13
- package/types/lib/ecosystems/ecosystems.d.ts.map +1 -1
- package/types/lib/ecosystems/golem.d.ts +81 -1
- package/types/lib/ecosystems/golem.d.ts.map +1 -1
- package/types/lib/ecosystems/gradleutils.d.ts +59 -7
- package/types/lib/ecosystems/gradleutils.d.ts.map +1 -1
- package/types/lib/ecosystems/jsEvidence.d.ts.map +1 -1
- package/types/lib/ecosystems/kosi.d.ts.map +1 -1
- package/types/lib/ecosystems/npmutils.d.ts +15 -0
- package/types/lib/ecosystems/npmutils.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-dotnet.d.ts +155 -5
- package/types/lib/ecosystems/parsers-dotnet.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-elm.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-gleam.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-go.d.ts +119 -5
- package/types/lib/ecosystems/parsers-go.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-js.d.ts +6 -1
- package/types/lib/ecosystems/parsers-js.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-julia.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-jvm.d.ts +74 -3
- package/types/lib/ecosystems/parsers-jvm.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-misc.d.ts +21 -59
- package/types/lib/ecosystems/parsers-misc.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-python.d.ts +57 -6
- package/types/lib/ecosystems/parsers-python.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-terraform.d.ts +38 -21
- package/types/lib/ecosystems/parsers-terraform.d.ts.map +1 -1
- package/types/lib/ecosystems/pythonutils.d.ts +26 -1
- package/types/lib/ecosystems/pythonutils.d.ts.map +1 -1
- package/types/lib/ecosystems/remote/huggingface.d.ts.map +1 -1
- package/types/lib/ecosystems/rubyutils.d.ts +21 -1
- package/types/lib/ecosystems/rubyutils.d.ts.map +1 -1
- package/types/lib/ecosystems/rusi.d.ts.map +1 -1
- package/types/lib/ecosystems/sbtutils.d.ts +88 -2
- package/types/lib/ecosystems/sbtutils.d.ts.map +1 -1
- package/types/lib/ecosystems/scalacliutils.d.ts +56 -0
- package/types/lib/ecosystems/scalacliutils.d.ts.map +1 -0
- package/types/lib/ecosystems/scalasem.d.ts +311 -0
- package/types/lib/ecosystems/scalasem.d.ts.map +1 -0
- package/types/lib/ecosystems/terraformRegistry.d.ts +9 -0
- package/types/lib/ecosystems/terraformRegistry.d.ts.map +1 -0
- package/types/lib/ecosystems/utils.d.ts +2 -2
- package/types/lib/ecosystems/utils.d.ts.map +1 -1
- package/types/lib/ecosystems/vendoredCode.d.ts +32 -0
- package/types/lib/ecosystems/vendoredCode.d.ts.map +1 -0
- package/types/lib/evinser/evinser.d.ts +100 -8
- package/types/lib/evinser/evinser.d.ts.map +1 -1
- package/types/lib/evinser/swiftsem.d.ts +10 -0
- package/types/lib/evinser/swiftsem.d.ts.map +1 -1
- package/types/lib/helpers/bomSigner.d.ts +80 -4
- package/types/lib/helpers/bomSigner.d.ts.map +1 -1
- package/types/lib/inventory/agentSkillSpec.d.ts +13 -0
- package/types/lib/inventory/agentSkillSpec.d.ts.map +1 -0
- package/types/lib/inventory/aiCollector.d.ts.map +1 -1
- package/types/lib/inventory/analyzer.d.ts.map +1 -1
- package/types/lib/inventory/apkInstalledDb.d.ts +42 -0
- package/types/lib/inventory/apkInstalledDb.d.ts.map +1 -0
- package/types/lib/inventory/atomUtils.d.ts +96 -10
- package/types/lib/inventory/atomUtils.d.ts.map +1 -1
- package/types/lib/inventory/auditCategories.d.ts +3 -0
- package/types/lib/inventory/auditCategories.d.ts.map +1 -1
- package/types/lib/inventory/buildToolRateLimit.d.ts +38 -0
- package/types/lib/inventory/buildToolRateLimit.d.ts.map +1 -0
- package/types/lib/inventory/cacheCommands.d.ts +2 -1
- package/types/lib/inventory/cacheCommands.d.ts.map +1 -1
- package/types/lib/inventory/cacheDir.d.ts +12 -4
- package/types/lib/inventory/cacheDir.d.ts.map +1 -1
- package/types/lib/inventory/certificates.d.ts +205 -0
- package/types/lib/inventory/certificates.d.ts.map +1 -0
- package/types/lib/inventory/cmakeBuildDirs.d.ts +58 -0
- package/types/lib/inventory/cmakeBuildDirs.d.ts.map +1 -0
- package/types/lib/inventory/communityAiConfigParser.d.ts.map +1 -1
- package/types/lib/inventory/deps.d.ts +61 -2
- package/types/lib/inventory/deps.d.ts.map +1 -1
- package/types/lib/inventory/display.d.ts +18 -0
- package/types/lib/inventory/display.d.ts.map +1 -1
- package/types/lib/inventory/dosai.d.ts +202 -14
- package/types/lib/inventory/dosai.d.ts.map +1 -1
- package/types/lib/inventory/dosaiParsers.d.ts +53 -7
- package/types/lib/inventory/dosaiParsers.d.ts.map +1 -1
- package/types/lib/inventory/dynamic.d.ts +16 -1
- package/types/lib/inventory/dynamic.d.ts.map +1 -1
- package/types/lib/inventory/envcontext.d.ts +40 -2
- package/types/lib/inventory/envcontext.d.ts.map +1 -1
- package/types/lib/inventory/evidenceUtils.d.ts +48 -14
- package/types/lib/inventory/evidenceUtils.d.ts.map +1 -1
- package/types/lib/inventory/fetchBatch.d.ts +83 -14
- package/types/lib/inventory/fetchBatch.d.ts.map +1 -1
- package/types/lib/inventory/fetchDiskCache.d.ts +169 -0
- package/types/lib/inventory/fetchDiskCache.d.ts.map +1 -0
- package/types/lib/inventory/forgeEnricher.d.ts.map +1 -1
- package/types/lib/inventory/formulationParsers.d.ts.map +1 -1
- package/types/lib/inventory/goBuildInfo.d.ts +10 -0
- package/types/lib/inventory/goBuildInfo.d.ts.map +1 -0
- package/types/lib/inventory/hbom.d.ts.map +1 -1
- package/types/lib/inventory/hbomAnalysis.d.ts +10 -0
- package/types/lib/inventory/hbomAnalysis.d.ts.map +1 -1
- package/types/lib/inventory/hostTopology.d.ts.map +1 -1
- package/types/lib/inventory/jvmLocalRepos.d.ts +178 -0
- package/types/lib/inventory/jvmLocalRepos.d.ts.map +1 -0
- package/types/lib/inventory/mcpConfigParser.d.ts.map +1 -1
- package/types/lib/inventory/osPackagePurl.d.ts +99 -0
- package/types/lib/inventory/osPackagePurl.d.ts.map +1 -0
- package/types/lib/inventory/osPackageResolver.d.ts +6 -2
- package/types/lib/inventory/osPackageResolver.d.ts.map +1 -1
- package/types/lib/inventory/osinfo.d.ts +31 -6
- package/types/lib/inventory/osinfo.d.ts.map +1 -1
- package/types/lib/inventory/osqueryTransform.d.ts +51 -0
- package/types/lib/inventory/osqueryTransform.d.ts.map +1 -1
- package/types/lib/inventory/parentSelection.d.ts +34 -0
- package/types/lib/inventory/parentSelection.d.ts.map +1 -0
- package/types/lib/inventory/phpBuildInfo.d.ts +142 -0
- package/types/lib/inventory/phpBuildInfo.d.ts.map +1 -0
- package/types/lib/inventory/phpHostProbe.d.ts +35 -0
- package/types/lib/inventory/phpHostProbe.d.ts.map +1 -0
- package/types/lib/inventory/rootfsCerts.d.ts +27 -0
- package/types/lib/inventory/rootfsCerts.d.ts.map +1 -0
- package/types/lib/inventory/rustFormulationParser.d.ts.map +1 -1
- package/types/lib/inventory/scalaCoords.d.ts +80 -0
- package/types/lib/inventory/scalaCoords.d.ts.map +1 -0
- package/types/lib/inventory/source.d.ts +28 -0
- package/types/lib/inventory/source.d.ts.map +1 -1
- package/types/lib/inventory/spdx.d.ts +24 -0
- package/types/lib/inventory/spdx.d.ts.map +1 -1
- package/types/lib/inventory/traceRunner.d.ts +16 -1
- package/types/lib/inventory/traceRunner.d.ts.map +1 -1
- package/types/lib/inventory/tracedCrypto.d.ts +64 -0
- package/types/lib/inventory/tracedCrypto.d.ts.map +1 -0
- package/types/lib/managers/binary.d.ts +10 -0
- package/types/lib/managers/binary.d.ts.map +1 -1
- package/types/lib/managers/docker.d.ts +12 -0
- package/types/lib/managers/docker.d.ts.map +1 -1
- package/types/lib/managers/oci.d.ts +3 -1
- package/types/lib/managers/oci.d.ts.map +1 -1
- package/types/lib/parsers/cmakeCache.d.ts +16 -0
- package/types/lib/parsers/cmakeCache.d.ts.map +1 -1
- package/types/lib/parsers/cmakeLists.d.ts +2 -1
- package/types/lib/parsers/cmakeLists.d.ts.map +1 -1
- package/types/lib/parsers/cmakePresets.d.ts +78 -0
- package/types/lib/parsers/cmakePresets.d.ts.map +1 -0
- package/types/lib/parsers/compileCommands.d.ts +115 -0
- package/types/lib/parsers/compileCommands.d.ts.map +1 -0
- package/types/lib/parsers/email.d.ts +19 -0
- package/types/lib/parsers/email.d.ts.map +1 -0
- package/types/lib/parsers/largeJson.d.ts +13 -0
- package/types/lib/parsers/largeJson.d.ts.map +1 -1
- package/types/lib/parsers/strictJson.d.ts +46 -0
- package/types/lib/parsers/strictJson.d.ts.map +1 -0
- package/types/lib/parsers/terraformConfig.d.ts +70 -0
- package/types/lib/parsers/terraformConfig.d.ts.map +1 -0
- package/types/lib/parsers/terraformSource.d.ts +66 -0
- package/types/lib/parsers/terraformSource.d.ts.map +1 -0
- package/types/lib/server/server.d.ts +8 -0
- package/types/lib/server/server.d.ts.map +1 -1
- package/types/lib/stages/postgen/annotator.d.ts.map +1 -1
- package/types/lib/stages/postgen/introspection/reflect.d.ts.map +1 -1
- package/types/lib/stages/postgen/postgen.d.ts.map +1 -1
- package/types/lib/stages/postgen/ruleEngine.d.ts +7 -4
- package/types/lib/stages/postgen/ruleEngine.d.ts.map +1 -1
- package/types/lib/stages/postgen/specVersionCompat.d.ts.map +1 -1
- package/types/lib/stages/pregen/pregen.d.ts +14 -1
- package/types/lib/stages/pregen/pregen.d.ts.map +1 -1
- package/types/lib/validator/bomValidator.d.ts.map +1 -1
- package/types/lib/validator/index.d.ts +8 -0
- package/types/lib/validator/index.d.ts.map +1 -1
- package/types/lib/validator/reporters/json.d.ts.map +1 -1
- package/lib/third-party/arborist/snapshots/calc-dep-flags.test.cjs +0 -462
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, join, relative } from "node:path";
|
|
3
|
-
import process from "node:process";
|
|
4
3
|
import { URL } from "node:url";
|
|
5
4
|
|
|
6
5
|
import { build } from "@cdxgen/cdx-purl";
|
|
7
|
-
import * as toml from "smol-toml";
|
|
8
6
|
import { parse as _load } from "yaml";
|
|
9
7
|
|
|
10
8
|
import { DEBUG_MODE } from "../core/activity.js";
|
|
11
9
|
import { recordDegradation } from "../core/buildLedger.js";
|
|
12
10
|
import { getAllFiles, safeExistsSync, safeSpawnSync } from "../core/fs.js";
|
|
13
11
|
import { PYTHON_STD_MODULES } from "../core/state.js";
|
|
12
|
+
import { parseToml } from "../core/toml.js";
|
|
14
13
|
import { tryBuildPurl } from "../inventory/purl.js";
|
|
15
14
|
import {
|
|
16
15
|
createExternalReferenceKey,
|
|
@@ -95,8 +94,11 @@ export function parsePyRequiresDist(dist_string) {
|
|
|
95
94
|
* Method to parse pipfile.lock data
|
|
96
95
|
*
|
|
97
96
|
* @param {Object} lockData JSON data from Pipfile.lock
|
|
97
|
+
* @param {Object[]} [installedMetadata] Components parsed from the installed
|
|
98
|
+
* `*.dist-info/METADATA` files of this machine, which answer before PyPI
|
|
99
|
+
* is asked
|
|
98
100
|
*/
|
|
99
|
-
export async function parsePiplockData(lockData) {
|
|
101
|
+
export async function parsePiplockData(lockData, installedMetadata) {
|
|
100
102
|
const pkgList = [];
|
|
101
103
|
Object.keys(lockData)
|
|
102
104
|
.filter((i) => i !== "_meta")
|
|
@@ -112,6 +114,9 @@ export async function parsePiplockData(lockData) {
|
|
|
112
114
|
}
|
|
113
115
|
});
|
|
114
116
|
});
|
|
117
|
+
// The installed distributions answer first, so PyPI is asked only about
|
|
118
|
+
// the packages they do not cover.
|
|
119
|
+
enrichFromInstalledMetadata(pkgList, installedMetadata);
|
|
115
120
|
return await getPyMetadata(pkgList, false);
|
|
116
121
|
}
|
|
117
122
|
|
|
@@ -274,8 +279,12 @@ function collectPythonManifestSource(pkg) {
|
|
|
274
279
|
{ kind: "url", value: pkg?.vcs?.url },
|
|
275
280
|
{ kind: "url", value: pkg?.source?.url },
|
|
276
281
|
{ kind: "path", value: pkg?.source?.path },
|
|
282
|
+
{ kind: "path", value: pkg?.source?.directory },
|
|
277
283
|
{ kind: "path", value: pkg?.source?.editable },
|
|
278
284
|
{ kind: "path", value: pkg?.source?.virtual },
|
|
285
|
+
{ kind: "path", value: pkg?.directory?.path },
|
|
286
|
+
{ kind: "url", value: pkg?.archive?.url },
|
|
287
|
+
{ kind: "path", value: pkg?.archive?.path },
|
|
279
288
|
];
|
|
280
289
|
for (const candidate of sourceCandidates) {
|
|
281
290
|
if (typeof candidate.value !== "string" || !candidate.value.trim()) {
|
|
@@ -395,7 +404,7 @@ export function parsePyProjectTomlFile(tomlFile) {
|
|
|
395
404
|
const groupDepsKeys = {};
|
|
396
405
|
const dependencySourceMap = {};
|
|
397
406
|
try {
|
|
398
|
-
tomlData =
|
|
407
|
+
tomlData = parseToml(readFileSync(tomlFile, { encoding: "utf-8" }));
|
|
399
408
|
} catch (err) {
|
|
400
409
|
console.log(`Error while parsing the pyproject file ${tomlFile}.`, err);
|
|
401
410
|
}
|
|
@@ -788,14 +797,114 @@ function collectPythonLockMetadataDistributionReferences(fileEntries) {
|
|
|
788
797
|
return distributionReferences;
|
|
789
798
|
}
|
|
790
799
|
|
|
800
|
+
/**
|
|
801
|
+
* Normalise a Python distribution name the way PEP 503 does, so an installed
|
|
802
|
+
* distribution and the lockfile entry it belongs to compare equal whatever
|
|
803
|
+
* separator and case each of them used.
|
|
804
|
+
*
|
|
805
|
+
* @param {string} value Distribution name
|
|
806
|
+
* @returns {string|undefined} The normalised name, or undefined for no name
|
|
807
|
+
*/
|
|
808
|
+
export function normalizePep503Name(value) {
|
|
809
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
810
|
+
return undefined;
|
|
811
|
+
}
|
|
812
|
+
return value
|
|
813
|
+
.trim()
|
|
814
|
+
.toLowerCase()
|
|
815
|
+
.replaceAll(/[-_.]+/g, "-");
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* The key an installed distribution and a lockfile entry are matched by: the
|
|
820
|
+
* PEP 503 normalised name and the version.
|
|
821
|
+
*
|
|
822
|
+
* @param {Object} p Component with `name` and `version`
|
|
823
|
+
* @returns {string|undefined} The key, or undefined without a name or version
|
|
824
|
+
*/
|
|
825
|
+
export function installedMetadataKey(p) {
|
|
826
|
+
const name = normalizePep503Name(p?.name);
|
|
827
|
+
const version = typeof p?.version === "string" ? p.version.trim() : "";
|
|
828
|
+
return name && version ? `${name}@${version}` : undefined;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Enrich lockfile entries from the installed distributions on this machine,
|
|
833
|
+
* before PyPI is asked.
|
|
834
|
+
*
|
|
835
|
+
* Each entry of `installedMetadata` is a component as
|
|
836
|
+
* {@link parseBdistMetadata} builds it from an installed `*.dist-info/METADATA`
|
|
837
|
+
* file. An entry is matched to the lockfile component with the same PEP 503
|
|
838
|
+
* normalised name and the same version, and fills the fields it lacks, so the
|
|
839
|
+
* registry is left only what the installed distributions do not answer. An
|
|
840
|
+
* installed release of another version describes a different release, so it
|
|
841
|
+
* enriches nothing. The distributions enrich the entries in place; no new
|
|
842
|
+
* components are created.
|
|
843
|
+
*
|
|
844
|
+
* @param {Object[]} pkgList Lockfile components, enriched in place
|
|
845
|
+
* @param {Object[]} installedMetadata Components parsed from installed
|
|
846
|
+
* `*.dist-info/METADATA` files
|
|
847
|
+
* @returns {Set<string>} The keys of the installations that enriched an entry,
|
|
848
|
+
* as {@link installedMetadataKey} builds them, so a caller that also walks
|
|
849
|
+
* the METADATA files can skip those as components
|
|
850
|
+
*/
|
|
851
|
+
export function enrichFromInstalledMetadata(pkgList, installedMetadata) {
|
|
852
|
+
const byKey = new Map();
|
|
853
|
+
for (const p of pkgList || []) {
|
|
854
|
+
const key = installedMetadataKey(p);
|
|
855
|
+
if (key && !byKey.has(key)) {
|
|
856
|
+
byKey.set(key, p);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
const enriched = new Set();
|
|
860
|
+
for (const md of installedMetadata || []) {
|
|
861
|
+
const key = installedMetadataKey(md);
|
|
862
|
+
const p = key ? byKey.get(key) : undefined;
|
|
863
|
+
if (!p) {
|
|
864
|
+
continue;
|
|
865
|
+
}
|
|
866
|
+
enriched.add(key);
|
|
867
|
+
if (!p.description?.trim() && md.description?.trim()) {
|
|
868
|
+
p.description = md.description;
|
|
869
|
+
}
|
|
870
|
+
if (!p.license && md.licenses?.length) {
|
|
871
|
+
// The licence field holds the names a lockfile consumer expects; the
|
|
872
|
+
// CycloneDX licence objects travel in `licenses`.
|
|
873
|
+
p.license = md.licenses
|
|
874
|
+
.map((alicense) => alicense.expression || alicense.license?.name)
|
|
875
|
+
.filter((aname) => aname?.length);
|
|
876
|
+
p.licenses = md.licenses;
|
|
877
|
+
}
|
|
878
|
+
if (!p.homepage && md.homepage) {
|
|
879
|
+
p.homepage = md.homepage;
|
|
880
|
+
}
|
|
881
|
+
if (!p.repository && md.repository) {
|
|
882
|
+
p.repository = md.repository;
|
|
883
|
+
}
|
|
884
|
+
if (!p.author && md.author) {
|
|
885
|
+
p.author = md.author;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
return enriched;
|
|
889
|
+
}
|
|
890
|
+
|
|
791
891
|
/**
|
|
792
892
|
* Method to parse python lock files such as poetry.lock, pdm.lock, uv.lock, and pylock.toml.
|
|
793
893
|
*
|
|
794
894
|
* @param {string} lockData Raw TOML text from poetry.lock, pdm.lock, uv.lock, or pylock.toml
|
|
795
895
|
* @param {string} lockFile Lock file name for evidence
|
|
796
896
|
* @param {string} pyProjectFile pyproject.toml file
|
|
897
|
+
* @param {Object} [options] Options
|
|
898
|
+
* @param {Object[]} [options.installedMetadata] Components parsed from the
|
|
899
|
+
* installed `*.dist-info/METADATA` files of this machine, which answer
|
|
900
|
+
* before PyPI is asked
|
|
797
901
|
*/
|
|
798
|
-
export async function parsePyLockData(
|
|
902
|
+
export async function parsePyLockData(
|
|
903
|
+
lockData,
|
|
904
|
+
lockFile,
|
|
905
|
+
pyProjectFile,
|
|
906
|
+
options = {},
|
|
907
|
+
) {
|
|
799
908
|
let pkgList = [];
|
|
800
909
|
const rootList = [];
|
|
801
910
|
const dependenciesList = [];
|
|
@@ -942,7 +1051,7 @@ export async function parsePyLockData(lockData, lockFile, pyProjectFile) {
|
|
|
942
1051
|
}
|
|
943
1052
|
let lockTomlObj;
|
|
944
1053
|
try {
|
|
945
|
-
lockTomlObj =
|
|
1054
|
+
lockTomlObj = parseToml(lockData);
|
|
946
1055
|
} catch (err) {
|
|
947
1056
|
if (lockFile) {
|
|
948
1057
|
// The failing file names the manager whose lock command regenerates
|
|
@@ -1418,6 +1527,9 @@ export async function parsePyLockData(lockData, lockFile, pyProjectFile) {
|
|
|
1418
1527
|
dependsOn: [...dependsOnList].sort(),
|
|
1419
1528
|
});
|
|
1420
1529
|
}
|
|
1530
|
+
// The installed distributions answer first, so PyPI is asked only about the
|
|
1531
|
+
// packages they do not cover.
|
|
1532
|
+
enrichFromInstalledMetadata(pkgList, options.installedMetadata);
|
|
1421
1533
|
pkgList = await getPyMetadata(pkgList, false);
|
|
1422
1534
|
return {
|
|
1423
1535
|
parentComponent,
|
|
@@ -1444,11 +1556,18 @@ const PEP440_VERSION_CLAUSE = /(===|==|!=|<=|>=|~=|<|>)\s*([0-9A-Za-z.*_+!-]*)/;
|
|
|
1444
1556
|
*
|
|
1445
1557
|
* @param {String} reqFile Requirements.txt file
|
|
1446
1558
|
* @param {Boolean} fetchDepsInfo Fetch dependencies info from pypi
|
|
1559
|
+
* @param {Object[]} [installedMetadata] Components parsed from the installed
|
|
1560
|
+
* `*.dist-info/METADATA` files of this machine, which answer before PyPI
|
|
1561
|
+
* is asked
|
|
1447
1562
|
*
|
|
1448
1563
|
* @returns {Promise[Array<Object>]} List of direct dependencies from the requirements file
|
|
1449
1564
|
*/
|
|
1450
|
-
export async function parseReqFile(
|
|
1451
|
-
|
|
1565
|
+
export async function parseReqFile(
|
|
1566
|
+
reqFile,
|
|
1567
|
+
fetchDepsInfo = false,
|
|
1568
|
+
installedMetadata = undefined,
|
|
1569
|
+
) {
|
|
1570
|
+
return await parseReqData(reqFile, null, fetchDepsInfo, installedMetadata);
|
|
1452
1571
|
}
|
|
1453
1572
|
|
|
1454
1573
|
const LICENSE_ID_COMMENTS_PATTERN =
|
|
@@ -1477,9 +1596,17 @@ function parseLicenseComment(comment) {
|
|
|
1477
1596
|
* @param {String} reqFile Requirements.txt file
|
|
1478
1597
|
* @param {Object} reqData Requirements.txt data for internal invocations from setup.py file etc.
|
|
1479
1598
|
* @param {Boolean} fetchDepsInfo Fetch dependencies info from pypi
|
|
1599
|
+
* @param {Object[]} [installedMetadata] Components parsed from the installed
|
|
1600
|
+
* `*.dist-info/METADATA` files of this machine, which answer before PyPI
|
|
1601
|
+
* is asked
|
|
1480
1602
|
* @returns {Promise<Array<Object>>} List of direct dependencies from the requirements file
|
|
1481
1603
|
*/
|
|
1482
|
-
async function parseReqData(
|
|
1604
|
+
async function parseReqData(
|
|
1605
|
+
reqFile,
|
|
1606
|
+
reqData = null,
|
|
1607
|
+
fetchDepsInfo = false,
|
|
1608
|
+
installedMetadata = undefined,
|
|
1609
|
+
) {
|
|
1483
1610
|
const pkgList = [];
|
|
1484
1611
|
let compScope;
|
|
1485
1612
|
if (!reqFile && !reqData) {
|
|
@@ -1732,6 +1859,9 @@ async function parseReqData(reqFile, reqData = null, fetchDepsInfo = false) {
|
|
|
1732
1859
|
pkgList.push(apkg);
|
|
1733
1860
|
}
|
|
1734
1861
|
}
|
|
1862
|
+
// The installed distributions answer first, so PyPI is asked only about
|
|
1863
|
+
// the packages they do not cover.
|
|
1864
|
+
enrichFromInstalledMetadata(pkgList, installedMetadata);
|
|
1735
1865
|
return await getPyMetadata(pkgList, fetchDepsInfo);
|
|
1736
1866
|
}
|
|
1737
1867
|
|
|
@@ -2042,7 +2172,7 @@ export function parsePixiTomlFile(pixiToml) {
|
|
|
2042
2172
|
const pixiTomlFile = readFileSync(pixiToml, { encoding: "utf-8" });
|
|
2043
2173
|
let tomlData;
|
|
2044
2174
|
try {
|
|
2045
|
-
tomlData =
|
|
2175
|
+
tomlData = parseToml(pixiTomlFile);
|
|
2046
2176
|
} catch (err) {
|
|
2047
2177
|
console.log(`Error while parsing the pixi file ${pixiToml}.`, err);
|
|
2048
2178
|
return {};
|
|
@@ -2074,28 +2204,30 @@ export function parsePixiTomlFile(pixiToml) {
|
|
|
2074
2204
|
}
|
|
2075
2205
|
|
|
2076
2206
|
/**
|
|
2077
|
-
* Method to run cli command `pixi install`
|
|
2078
|
-
*
|
|
2207
|
+
* Method to run cli command `pixi install` in the project directory.
|
|
2079
2208
|
*
|
|
2209
|
+
* @param {string} projectPath Directory containing pixi.toml
|
|
2210
|
+
* @returns {boolean} true when pixi install succeeded
|
|
2080
2211
|
*/
|
|
2081
|
-
export function generatePixiLockFile(
|
|
2082
|
-
const result = safeSpawnSync("pixi", ["install"]);
|
|
2212
|
+
export function generatePixiLockFile(projectPath) {
|
|
2213
|
+
const result = safeSpawnSync("pixi", ["install"], { cwd: projectPath });
|
|
2083
2214
|
|
|
2084
2215
|
if (result.status !== 0) {
|
|
2085
|
-
// Handle errors
|
|
2216
|
+
// Handle errors. The caller carries on without a lock file: exiting here
|
|
2217
|
+
// would also stop a long-running cdxgen server.
|
|
2086
2218
|
if (result.error && result.error.code === "ENOENT") {
|
|
2087
2219
|
console.error(
|
|
2088
2220
|
"Error: pixi command not found. Make sure pixi.js is installed globally.",
|
|
2089
2221
|
);
|
|
2090
2222
|
} else {
|
|
2091
2223
|
console.error(
|
|
2092
|
-
`Error executing pixi install: ${result.error || result.stderr
|
|
2224
|
+
`Error executing pixi install: ${result.error || result.stderr?.toString()}`,
|
|
2093
2225
|
);
|
|
2094
2226
|
}
|
|
2095
|
-
|
|
2096
|
-
} else {
|
|
2097
|
-
console.log("Dependencies installed successfully.");
|
|
2227
|
+
return false;
|
|
2098
2228
|
}
|
|
2229
|
+
console.log("Dependencies installed successfully.");
|
|
2230
|
+
return true;
|
|
2099
2231
|
}
|
|
2100
2232
|
|
|
2101
2233
|
/**
|
|
@@ -2118,7 +2250,7 @@ export function generatePixiLockFile(_path) {
|
|
|
2118
2250
|
export function parseMojoProject(mojoProjectFile) {
|
|
2119
2251
|
let manifest;
|
|
2120
2252
|
try {
|
|
2121
|
-
manifest =
|
|
2253
|
+
manifest = parseToml(readFileSync(mojoProjectFile, "utf-8"));
|
|
2122
2254
|
} catch (error) {
|
|
2123
2255
|
console.warn(`Failed to parse ${mojoProjectFile}: ${error.message}`);
|
|
2124
2256
|
return { pkgList: [], parentComponent: {} };
|
|
@@ -3,12 +3,12 @@ import { sep as _sep, basename, dirname, join, resolve } from "node:path";
|
|
|
3
3
|
|
|
4
4
|
import { build } from "@cdxgen/cdx-purl";
|
|
5
5
|
import { globSync } from "glob";
|
|
6
|
-
import * as toml from "smol-toml";
|
|
7
6
|
|
|
8
7
|
import { DEBUG_MODE } from "../core/activity.js";
|
|
9
8
|
import { shouldFetchLicense } from "../core/env.js";
|
|
10
9
|
import { safeExistsSync } from "../core/fs.js";
|
|
11
10
|
import { traceLog } from "../core/logger.js";
|
|
11
|
+
import { parseToml } from "../core/toml.js";
|
|
12
12
|
import { getCratesMetadata, normalizeCargoIntegrity } from "./ecosystems.js";
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -204,7 +204,7 @@ function readCargoTomlData(cargoTomlFile) {
|
|
|
204
204
|
return undefined;
|
|
205
205
|
}
|
|
206
206
|
try {
|
|
207
|
-
return
|
|
207
|
+
return parseToml(readFileSync(cargoTomlFile, { encoding: "utf-8" }));
|
|
208
208
|
} catch (error) {
|
|
209
209
|
traceLog("cargo", {
|
|
210
210
|
cargoTomlFile,
|
|
@@ -1082,7 +1082,7 @@ export async function parseCargoData(
|
|
|
1082
1082
|
return pkgList;
|
|
1083
1083
|
}
|
|
1084
1084
|
|
|
1085
|
-
const cargoData =
|
|
1085
|
+
const cargoData = parseToml(
|
|
1086
1086
|
readFileSync(cargoLockFile, { encoding: "utf-8" }),
|
|
1087
1087
|
);
|
|
1088
1088
|
if (!cargoData) {
|
|
@@ -1290,7 +1290,7 @@ export function parseCargoManifestDependencyData(cargoTomlFile, context = {}) {
|
|
|
1290
1290
|
*/
|
|
1291
1291
|
export function parseCargoDependencyData(cargoLockData) {
|
|
1292
1292
|
const purlFromPackageInfo = (pkg) => decodeURIComponent(buildCargoPurl(pkg));
|
|
1293
|
-
const cargoData =
|
|
1293
|
+
const cargoData = parseToml(cargoLockData);
|
|
1294
1294
|
const packageNode = cargoData?.package;
|
|
1295
1295
|
if (!packageNode || !Array.isArray(packageNode)) {
|
|
1296
1296
|
return [];
|