@cdxgen/cdxgen 13.5.0 → 13.7.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 +17 -10
- package/bin/audit.js +7 -4
- package/bin/cdxgen.js +260 -37
- package/bin/convert.js +146 -22
- package/bin/evinse.js +28 -3
- package/bin/repl.js +47 -3
- package/bin/sign.js +211 -34
- package/bin/tracebom.js +18 -6
- package/bin/validate.js +24 -3
- package/bin/verify.js +113 -5
- package/data/behavior-taxonomy.schema.json +1491 -0
- package/data/cyclonedx-2.0-bundled.schema.json +18606 -5528
- package/data/cyclonedx-2.0-cryptography-defs.schema.json +857 -0
- package/data/license-aliases.json +24 -2
- package/data/pqc-migration.json +239 -0
- package/data/remediations.json +176 -0
- package/data/rules/ai-bom.yaml +1 -1
- package/data/rules/brotli-decoder.yaml +107 -0
- package/data/rules/cbom-security.yaml +4 -3
- package/data/rules/package-integrity.yaml +28 -0
- package/data/rules/vscode-extensions.yaml +75 -0
- package/data/spdx-license-list.json +121 -7
- package/data/spdx-licenses.json +69 -0
- package/data/spdx.schema.json +845 -2
- package/lib/audit/index.js +25 -3
- package/lib/cli/bomAssembly.js +172 -4
- package/lib/cli/cliOptions.js +121 -17
- package/lib/cli/index.js +720 -902
- package/lib/cli/jsBom.js +156 -64
- package/lib/cli/jvmBom.js +602 -86
- package/lib/cli/managedBom.js +161 -19
- package/lib/cli/nativeBom.js +52 -5
- package/lib/core/boundedFile.js +344 -0
- package/lib/core/brotliProbe.js +182 -0
- package/lib/core/env.js +34 -0
- package/lib/core/fs.js +138 -3
- package/lib/core/globPatterns.js +218 -0
- package/lib/core/httpClient.js +98 -1
- package/lib/core/lockPaths.js +38 -0
- package/lib/core/paths.js +24 -1
- package/lib/core/processTree.js +100 -8
- package/lib/core/projectConfig.js +332 -25
- package/lib/core/toolRegistry.js +184 -0
- package/lib/ecosystems/cppEvidence.js +263 -106
- package/lib/ecosystems/cppIncludeResolver.js +16 -5
- package/lib/ecosystems/denoutils.js +2 -2
- package/lib/ecosystems/ecosystems.js +25 -10
- package/lib/ecosystems/gemHostProbe.js +301 -0
- package/lib/ecosystems/golem.js +3 -8
- package/lib/ecosystems/gradleutils.js +1909 -229
- package/lib/ecosystems/jsEvidence.js +90 -38
- package/lib/ecosystems/kosi.js +3 -5
- package/lib/ecosystems/npmVersionResolution.js +376 -0
- package/lib/ecosystems/parsers-bazel.js +107 -6
- package/lib/ecosystems/parsers-js.js +505 -22
- package/lib/ecosystems/parsers-misc.js +209 -20
- package/lib/ecosystems/parsers-python.js +178 -30
- package/lib/ecosystems/parsers-rust.js +117 -15
- package/lib/ecosystems/pythonutils.js +128 -2
- package/lib/ecosystems/remote/huggingface.js +22 -0
- package/lib/ecosystems/rubyutils.js +538 -31
- package/lib/ecosystems/rusi.js +2 -4
- package/lib/ecosystems/scalacliutils.js +2 -0
- package/lib/ecosystems/scalasem.js +798 -152
- package/lib/ecosystems/vendoredCode.js +237 -3
- package/lib/ecosystems/venvProbe.js +360 -0
- package/lib/evinser/evinser.js +536 -71
- package/lib/evinser/scalasem.js +5 -1
- package/lib/helpers/agenticToolutils.js +525 -94
- package/lib/helpers/bomSigner.js +43 -9
- package/lib/helpers/jssSigner.js +1276 -0
- package/lib/helpers/vsixutils.js +1574 -315
- package/lib/inventory/agentBlueprint.js +193 -0
- package/lib/inventory/agentToolNames.js +145 -0
- package/lib/inventory/aiCollector.js +153 -7
- package/lib/inventory/aiInventory.js +44 -8
- package/lib/inventory/aiProviders.js +324 -0
- package/lib/inventory/atomUtils.js +77 -0
- package/lib/inventory/bomUtils.js +8 -1
- package/lib/inventory/brotliDecoder.js +142 -0
- package/lib/inventory/buildToolRateLimit.js +1 -1
- package/lib/inventory/cbomutils.js +56 -7
- package/lib/inventory/ciParsers/githubActionsLock.js +821 -0
- package/lib/inventory/citations.js +31 -2
- package/lib/inventory/communityAiConfigParser.js +978 -80
- package/lib/inventory/cyclonedx20.js +152 -0
- package/lib/inventory/cyclonedx20Common.js +286 -0
- package/lib/inventory/cyclonedx20Derived.js +159 -0
- package/lib/inventory/cyclonedx20Parties.js +552 -0
- package/lib/inventory/cyclonedx20Read.js +768 -0
- package/lib/inventory/cyclonedx20ReadCommon.js +374 -0
- package/lib/inventory/cyclonedx20ReadComponents.js +692 -0
- package/lib/inventory/cyclonedx20ReadContext.js +380 -0
- package/lib/inventory/cyclonedx20ReadEvidence.js +466 -0
- package/lib/inventory/cyclonedx20ReadSections.js +599 -0
- package/lib/inventory/cyclonedx20Render.js +766 -0
- package/lib/inventory/cyclonedx20RenderComponents.js +716 -0
- package/lib/inventory/cyclonedx20RenderDefinitions.js +405 -0
- package/lib/inventory/cyclonedx20RenderEvidence.js +726 -0
- package/lib/inventory/cyclonedx20RenderHardware.js +203 -0
- package/lib/inventory/cyclonedx20RenderPatents.js +174 -0
- package/lib/inventory/cyclonedx20RenderRefIds.js +314 -0
- package/lib/inventory/cyclonedx20RenderSections.js +499 -0
- package/lib/inventory/cyclonedx20Tables.js +594 -0
- package/lib/inventory/deps.js +141 -13
- package/lib/inventory/dosai.js +375 -6
- package/lib/inventory/dosaiParsers.js +3 -6
- package/lib/inventory/dotnetRuntime.js +367 -0
- package/lib/inventory/ecosystemFormulationParsers.js +979 -0
- package/lib/inventory/envcontext.js +436 -48
- package/lib/inventory/evidenceUtils.js +13 -1
- package/lib/inventory/fetchBatch.js +1 -1
- package/lib/inventory/formulationParsers.js +124 -14
- package/lib/inventory/gtfobins.js +13 -0
- package/lib/inventory/hbom.js +45 -6
- package/lib/inventory/hbomLoader.js +166 -0
- package/lib/inventory/hostRuntimeProbe.js +686 -0
- package/lib/inventory/jvmLocalRepos.js +9 -2
- package/lib/inventory/jvmToolEnv.js +29 -0
- package/lib/inventory/licenseEnhancer.js +12 -0
- package/lib/inventory/mavenCentralMirror.js +534 -0
- package/lib/inventory/mcpConfigParser.js +5 -0
- package/lib/inventory/nodeBuildInfo.js +218 -0
- package/lib/inventory/nodeHostProbe.js +202 -0
- package/lib/inventory/occurrenceKey.js +90 -0
- package/lib/inventory/osPackageResolver.js +182 -0
- package/lib/inventory/phpBuildInfo.js +10 -59
- package/lib/inventory/phpHostProbe.js +32 -488
- package/lib/inventory/pqcMigration.js +426 -0
- package/lib/inventory/rubyBuildInfo.js +972 -0
- package/lib/inventory/rubyHostProbe.js +218 -0
- package/lib/inventory/rustFormulationParser.js +21 -10
- package/lib/inventory/scalaCoords.js +4 -3
- package/lib/inventory/scalaDedupe.js +440 -0
- package/lib/inventory/source.js +114 -8
- package/lib/managers/binary.js +337 -3
- package/lib/managers/docker.js +79 -0
- package/lib/parsers/huggingfaceManifest.js +9 -1
- package/lib/parsers/huggingfaceUtils.js +18 -0
- package/lib/parsers/kiroPermissions.js +166 -0
- package/lib/parsers/largeJson.js +28 -11
- package/lib/parsers/vscodeExtensionId.js +183 -0
- package/lib/server/server.js +48 -35
- package/lib/stages/postgen/postgen.js +41 -1
- package/lib/stages/postgen/ruleEngine.js +13 -5
- package/lib/stages/postgen/specVersionCompat.js +76 -0
- package/lib/stages/pregen/envAudit.js +1 -0
- package/lib/stages/pregen/pregen.js +114 -57
- package/lib/validator/bomValidator.js +14 -2
- package/lib/validator/complianceEngine.js +30 -3
- package/lib/validator/complianceRules.js +1416 -4
- package/lib/validator/generated/validate-1.6.mjs +1 -1
- package/lib/validator/generated/validate-1.7.mjs +1 -1
- package/lib/validator/generated/validate-2.0.mjs +57554 -13851
- package/lib/validator/index.js +49 -8
- package/lib/validator/reporters/json.js +6 -0
- package/package.json +11 -10
- package/types/bin/repl.d.ts.map +1 -1
- package/types/lib/audit/index.d.ts +6 -2
- package/types/lib/audit/index.d.ts.map +1 -1
- package/types/lib/cli/bomAssembly.d.ts +29 -1
- package/types/lib/cli/bomAssembly.d.ts.map +1 -1
- package/types/lib/cli/cliOptions.d.ts +6 -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 +3 -18
- package/types/lib/cli/jsBom.d.ts.map +1 -1
- package/types/lib/cli/jvmBom.d.ts +15 -0
- package/types/lib/cli/jvmBom.d.ts.map +1 -1
- package/types/lib/cli/managedBom.d.ts.map +1 -1
- package/types/lib/cli/nativeBom.d.ts.map +1 -1
- package/types/lib/core/boundedFile.d.ts +100 -0
- package/types/lib/core/boundedFile.d.ts.map +1 -0
- package/types/lib/core/brotliProbe.d.ts +37 -0
- package/types/lib/core/brotliProbe.d.ts.map +1 -0
- package/types/lib/core/env.d.ts +14 -0
- package/types/lib/core/env.d.ts.map +1 -1
- package/types/lib/core/fs.d.ts +4 -0
- package/types/lib/core/fs.d.ts.map +1 -1
- package/types/lib/core/globPatterns.d.ts +70 -0
- package/types/lib/core/globPatterns.d.ts.map +1 -0
- package/types/lib/core/httpClient.d.ts +24 -0
- package/types/lib/core/httpClient.d.ts.map +1 -1
- package/types/lib/core/lockPaths.d.ts +19 -0
- package/types/lib/core/lockPaths.d.ts.map +1 -0
- package/types/lib/core/paths.d.ts +9 -0
- package/types/lib/core/paths.d.ts.map +1 -1
- package/types/lib/core/processTree.d.ts +17 -4
- package/types/lib/core/processTree.d.ts.map +1 -1
- package/types/lib/core/projectConfig.d.ts +47 -8
- package/types/lib/core/projectConfig.d.ts.map +1 -1
- package/types/lib/core/toolRegistry.d.ts +36 -0
- package/types/lib/core/toolRegistry.d.ts.map +1 -0
- package/types/lib/ecosystems/cppEvidence.d.ts +40 -13
- package/types/lib/ecosystems/cppEvidence.d.ts.map +1 -1
- package/types/lib/ecosystems/cppIncludeResolver.d.ts +2 -1
- package/types/lib/ecosystems/cppIncludeResolver.d.ts.map +1 -1
- package/types/lib/ecosystems/ecosystems.d.ts.map +1 -1
- package/types/lib/ecosystems/gemHostProbe.d.ts +28 -0
- package/types/lib/ecosystems/gemHostProbe.d.ts.map +1 -0
- package/types/lib/ecosystems/golem.d.ts.map +1 -1
- package/types/lib/ecosystems/gradleutils.d.ts +294 -20
- package/types/lib/ecosystems/gradleutils.d.ts.map +1 -1
- package/types/lib/ecosystems/jsEvidence.d.ts +14 -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/npmVersionResolution.d.ts +119 -0
- package/types/lib/ecosystems/npmVersionResolution.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-bazel.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-js.d.ts +17 -20
- package/types/lib/ecosystems/parsers-js.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-misc.d.ts +19 -0
- package/types/lib/ecosystems/parsers-misc.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-python.d.ts +10 -0
- package/types/lib/ecosystems/parsers-python.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-rust.d.ts.map +1 -1
- package/types/lib/ecosystems/pythonutils.d.ts +19 -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 +144 -12
- package/types/lib/ecosystems/rubyutils.d.ts.map +1 -1
- package/types/lib/ecosystems/rusi.d.ts.map +1 -1
- package/types/lib/ecosystems/scalacliutils.d.ts.map +1 -1
- package/types/lib/ecosystems/scalasem.d.ts +58 -16
- package/types/lib/ecosystems/scalasem.d.ts.map +1 -1
- package/types/lib/ecosystems/vendoredCode.d.ts +26 -0
- package/types/lib/ecosystems/vendoredCode.d.ts.map +1 -1
- package/types/lib/ecosystems/venvProbe.d.ts +40 -0
- package/types/lib/ecosystems/venvProbe.d.ts.map +1 -0
- package/types/lib/evinser/evinser.d.ts +120 -13
- package/types/lib/evinser/evinser.d.ts.map +1 -1
- package/types/lib/evinser/scalasem.d.ts.map +1 -1
- package/types/lib/helpers/agenticToolutils.d.ts +53 -19
- package/types/lib/helpers/agenticToolutils.d.ts.map +1 -1
- package/types/lib/helpers/bomSigner.d.ts +20 -3
- package/types/lib/helpers/bomSigner.d.ts.map +1 -1
- package/types/lib/helpers/jssSigner.d.ts +288 -0
- package/types/lib/helpers/jssSigner.d.ts.map +1 -0
- package/types/lib/helpers/vsixutils.d.ts +303 -19
- package/types/lib/helpers/vsixutils.d.ts.map +1 -1
- package/types/lib/inventory/agentBlueprint.d.ts +70 -0
- package/types/lib/inventory/agentBlueprint.d.ts.map +1 -0
- package/types/lib/inventory/agentToolNames.d.ts +51 -0
- package/types/lib/inventory/agentToolNames.d.ts.map +1 -0
- package/types/lib/inventory/aiCollector.d.ts.map +1 -1
- package/types/lib/inventory/aiInventory.d.ts.map +1 -1
- package/types/lib/inventory/aiProviders.d.ts +85 -0
- package/types/lib/inventory/aiProviders.d.ts.map +1 -0
- package/types/lib/inventory/atomUtils.d.ts +19 -0
- package/types/lib/inventory/atomUtils.d.ts.map +1 -1
- package/types/lib/inventory/bomUtils.d.ts.map +1 -1
- package/types/lib/inventory/brotliDecoder.d.ts +58 -0
- package/types/lib/inventory/brotliDecoder.d.ts.map +1 -0
- package/types/lib/inventory/cbomutils.d.ts +17 -0
- package/types/lib/inventory/cbomutils.d.ts.map +1 -1
- package/types/lib/inventory/ciParsers/githubActionsLock.d.ts +101 -0
- package/types/lib/inventory/ciParsers/githubActionsLock.d.ts.map +1 -0
- package/types/lib/inventory/citations.d.ts +5 -0
- package/types/lib/inventory/citations.d.ts.map +1 -1
- package/types/lib/inventory/communityAiConfigParser.d.ts.map +1 -1
- package/types/lib/inventory/cyclonedx20.d.ts +99 -0
- package/types/lib/inventory/cyclonedx20.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20Common.d.ts +102 -0
- package/types/lib/inventory/cyclonedx20Common.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20Derived.d.ts +74 -0
- package/types/lib/inventory/cyclonedx20Derived.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20Parties.d.ts +91 -0
- package/types/lib/inventory/cyclonedx20Parties.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20Read.d.ts +51 -0
- package/types/lib/inventory/cyclonedx20Read.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20ReadCommon.d.ts +69 -0
- package/types/lib/inventory/cyclonedx20ReadCommon.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20ReadComponents.d.ts +77 -0
- package/types/lib/inventory/cyclonedx20ReadComponents.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20ReadContext.d.ts +118 -0
- package/types/lib/inventory/cyclonedx20ReadContext.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20ReadEvidence.d.ts +40 -0
- package/types/lib/inventory/cyclonedx20ReadEvidence.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20ReadSections.d.ts +45 -0
- package/types/lib/inventory/cyclonedx20ReadSections.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20Render.d.ts +53 -0
- package/types/lib/inventory/cyclonedx20Render.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20RenderComponents.d.ts +73 -0
- package/types/lib/inventory/cyclonedx20RenderComponents.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20RenderDefinitions.d.ts +29 -0
- package/types/lib/inventory/cyclonedx20RenderDefinitions.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20RenderEvidence.d.ts +110 -0
- package/types/lib/inventory/cyclonedx20RenderEvidence.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20RenderHardware.d.ts +42 -0
- package/types/lib/inventory/cyclonedx20RenderHardware.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20RenderPatents.d.ts +26 -0
- package/types/lib/inventory/cyclonedx20RenderPatents.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20RenderRefIds.d.ts +55 -0
- package/types/lib/inventory/cyclonedx20RenderRefIds.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20RenderSections.d.ts +45 -0
- package/types/lib/inventory/cyclonedx20RenderSections.d.ts.map +1 -0
- package/types/lib/inventory/cyclonedx20Tables.d.ts +134 -0
- package/types/lib/inventory/cyclonedx20Tables.d.ts.map +1 -0
- package/types/lib/inventory/deps.d.ts +35 -2
- package/types/lib/inventory/deps.d.ts.map +1 -1
- package/types/lib/inventory/dosai.d.ts +36 -1
- package/types/lib/inventory/dosai.d.ts.map +1 -1
- package/types/lib/inventory/dosaiParsers.d.ts.map +1 -1
- package/types/lib/inventory/dotnetRuntime.d.ts +91 -0
- package/types/lib/inventory/dotnetRuntime.d.ts.map +1 -0
- package/types/lib/inventory/ecosystemFormulationParsers.d.ts +73 -0
- package/types/lib/inventory/ecosystemFormulationParsers.d.ts.map +1 -0
- package/types/lib/inventory/envcontext.d.ts +74 -12
- package/types/lib/inventory/envcontext.d.ts.map +1 -1
- package/types/lib/inventory/evidenceUtils.d.ts.map +1 -1
- package/types/lib/inventory/formulationParsers.d.ts.map +1 -1
- package/types/lib/inventory/gtfobins.d.ts.map +1 -1
- package/types/lib/inventory/hbom.d.ts +11 -0
- package/types/lib/inventory/hbom.d.ts.map +1 -1
- package/types/lib/inventory/hbomLoader.d.ts +54 -0
- package/types/lib/inventory/hbomLoader.d.ts.map +1 -1
- package/types/lib/inventory/hostRuntimeProbe.d.ts +44 -0
- package/types/lib/inventory/hostRuntimeProbe.d.ts.map +1 -0
- package/types/lib/inventory/jvmLocalRepos.d.ts +5 -1
- package/types/lib/inventory/jvmLocalRepos.d.ts.map +1 -1
- package/types/lib/inventory/jvmToolEnv.d.ts +12 -0
- package/types/lib/inventory/jvmToolEnv.d.ts.map +1 -1
- package/types/lib/inventory/licenseEnhancer.d.ts.map +1 -1
- package/types/lib/inventory/mavenCentralMirror.d.ts +170 -0
- package/types/lib/inventory/mavenCentralMirror.d.ts.map +1 -0
- package/types/lib/inventory/mcpConfigParser.d.ts.map +1 -1
- package/types/lib/inventory/nodeBuildInfo.d.ts +95 -0
- package/types/lib/inventory/nodeBuildInfo.d.ts.map +1 -0
- package/types/lib/inventory/nodeHostProbe.d.ts +15 -0
- package/types/lib/inventory/nodeHostProbe.d.ts.map +1 -0
- package/types/lib/inventory/occurrenceKey.d.ts +52 -0
- package/types/lib/inventory/occurrenceKey.d.ts.map +1 -0
- package/types/lib/inventory/osPackageResolver.d.ts +38 -0
- package/types/lib/inventory/osPackageResolver.d.ts.map +1 -1
- package/types/lib/inventory/phpBuildInfo.d.ts.map +1 -1
- package/types/lib/inventory/phpHostProbe.d.ts.map +1 -1
- package/types/lib/inventory/pqcMigration.d.ts +84 -0
- package/types/lib/inventory/pqcMigration.d.ts.map +1 -0
- package/types/lib/inventory/rubyBuildInfo.d.ts +271 -0
- package/types/lib/inventory/rubyBuildInfo.d.ts.map +1 -0
- package/types/lib/inventory/rubyHostProbe.d.ts +47 -0
- package/types/lib/inventory/rubyHostProbe.d.ts.map +1 -0
- package/types/lib/inventory/rustFormulationParser.d.ts +7 -2
- package/types/lib/inventory/rustFormulationParser.d.ts.map +1 -1
- package/types/lib/inventory/scalaCoords.d.ts.map +1 -1
- package/types/lib/inventory/scalaDedupe.d.ts +43 -0
- package/types/lib/inventory/scalaDedupe.d.ts.map +1 -0
- package/types/lib/inventory/source.d.ts +25 -0
- package/types/lib/inventory/source.d.ts.map +1 -1
- 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/parsers/huggingfaceManifest.d.ts +10 -1
- package/types/lib/parsers/huggingfaceManifest.d.ts.map +1 -1
- package/types/lib/parsers/huggingfaceUtils.d.ts +12 -0
- package/types/lib/parsers/huggingfaceUtils.d.ts.map +1 -1
- package/types/lib/parsers/kiroPermissions.d.ts +62 -0
- package/types/lib/parsers/kiroPermissions.d.ts.map +1 -0
- package/types/lib/parsers/largeJson.d.ts +4 -3
- package/types/lib/parsers/largeJson.d.ts.map +1 -1
- package/types/lib/parsers/vscodeExtensionId.d.ts +48 -0
- package/types/lib/parsers/vscodeExtensionId.d.ts.map +1 -0
- package/types/lib/server/server.d.ts.map +1 -1
- package/types/lib/stages/postgen/postgen.d.ts +7 -0
- package/types/lib/stages/postgen/postgen.d.ts.map +1 -1
- package/types/lib/stages/postgen/ruleEngine.d.ts.map +1 -1
- package/types/lib/stages/postgen/specVersionCompat.d.ts +25 -0
- package/types/lib/stages/postgen/specVersionCompat.d.ts.map +1 -1
- package/types/lib/stages/pregen/envAudit.d.ts.map +1 -1
- package/types/lib/stages/pregen/pregen.d.ts +12 -8
- package/types/lib/stages/pregen/pregen.d.ts.map +1 -1
- package/types/lib/validator/bomValidator.d.ts +5 -1
- package/types/lib/validator/bomValidator.d.ts.map +1 -1
- package/types/lib/validator/complianceEngine.d.ts +4 -4
- package/types/lib/validator/complianceEngine.d.ts.map +1 -1
- package/types/lib/validator/complianceRules.d.ts +14 -2
- package/types/lib/validator/complianceRules.d.ts.map +1 -1
- package/types/lib/validator/index.d.ts +10 -0
- package/types/lib/validator/index.d.ts.map +1 -1
- package/types/lib/validator/reporters/json.d.ts.map +1 -1
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render the CycloneDX 2.0 sections that sit beside the inventory:
|
|
3
|
+
* compositions, annotations, citations, vulnerabilities and formulation.
|
|
4
|
+
* Each converter restores an entry readCycloneDx20 kept as a shadow while
|
|
5
|
+
* the entry is unchanged.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
clone,
|
|
10
|
+
convertEnvironmentVars,
|
|
11
|
+
copyDefined,
|
|
12
|
+
countDrop,
|
|
13
|
+
countUnmapped,
|
|
14
|
+
isNonEmptyString,
|
|
15
|
+
isObjectRecord,
|
|
16
|
+
setDefined,
|
|
17
|
+
takeShadow,
|
|
18
|
+
uniqueByValue,
|
|
19
|
+
} from "./cyclonedx20Common.js";
|
|
20
|
+
import { toCommonContact, toCommonEntity } from "./cyclonedx20Parties.js";
|
|
21
|
+
import {
|
|
22
|
+
convertAttachment,
|
|
23
|
+
convertComponent,
|
|
24
|
+
convertService,
|
|
25
|
+
convertTools,
|
|
26
|
+
} from "./cyclonedx20RenderComponents.js";
|
|
27
|
+
import { AGGREGATE_1X_TO_20 } from "./cyclonedx20Tables.js";
|
|
28
|
+
|
|
29
|
+
/** A unique list of the non-empty string refs of a 1.x composition field. */
|
|
30
|
+
function compositionRefs(value) {
|
|
31
|
+
return Array.isArray(value)
|
|
32
|
+
? [...new Set(value.filter(isNonEmptyString))]
|
|
33
|
+
: [];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Map one 1.x composition onto 2.0 compositions, one per scope: `assemblies`
|
|
38
|
+
* → kind `components` (the inventory when the list is only the subject),
|
|
39
|
+
* `dependencies` → kind `dependencies`, `vulnerabilities` → kind
|
|
40
|
+
* `vulnerabilities` (kind enum in
|
|
41
|
+
* #/$defs/cyclonedx-composition-2.0/$defs/composition). A composition with no
|
|
42
|
+
* scope describes the inventory, as cdxgen's autoCompositions emits it.
|
|
43
|
+
*/
|
|
44
|
+
function compositionsFor(composition, aggregate, inventory, stats) {
|
|
45
|
+
const scoped = [];
|
|
46
|
+
const assemblies = compositionRefs(composition.assemblies);
|
|
47
|
+
if (assemblies.length) {
|
|
48
|
+
const onlySubject =
|
|
49
|
+
inventory.inventoryRefId &&
|
|
50
|
+
assemblies.length === 1 &&
|
|
51
|
+
assemblies[0] === inventory.subjectRef;
|
|
52
|
+
scoped.push({
|
|
53
|
+
kind: "components",
|
|
54
|
+
aggregate,
|
|
55
|
+
targets: onlySubject ? [inventory.inventoryRefId] : assemblies,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
for (const kind of ["dependencies", "vulnerabilities"]) {
|
|
59
|
+
const targets = compositionRefs(composition[kind]);
|
|
60
|
+
if (targets.length) {
|
|
61
|
+
scoped.push({ kind, aggregate, targets });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (scoped.length) {
|
|
65
|
+
return scoped;
|
|
66
|
+
}
|
|
67
|
+
if (inventory.inventoryRefId) {
|
|
68
|
+
return [
|
|
69
|
+
{ kind: "components", aggregate, targets: [inventory.inventoryRefId] },
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
countDrop(stats, "composition (no target in a subject-less document)");
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Render compositions (#/$defs/cyclonedx-composition-2.0/$defs/composition,
|
|
78
|
+
* required `[kind, aggregate, targets]`). The composition's own 1.x
|
|
79
|
+
* `bom-ref` (cdxgen sets it to the subject's bom-ref) is not carried, so it
|
|
80
|
+
* cannot collide with the subject's refId.
|
|
81
|
+
*/
|
|
82
|
+
export function renderCompositions(compositions, inventory, carried, stats) {
|
|
83
|
+
// Compositions a 2.0 read could not express in 1.x (licenses,
|
|
84
|
+
// certifications or custom kinds) come back after the converted ones.
|
|
85
|
+
const carriedCompositions = Array.isArray(carried) ? clone(carried) : [];
|
|
86
|
+
if (
|
|
87
|
+
(!Array.isArray(compositions) || !compositions.length) &&
|
|
88
|
+
!carriedCompositions.length
|
|
89
|
+
) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
const converted = [];
|
|
93
|
+
for (const composition of Array.isArray(compositions) ? compositions : []) {
|
|
94
|
+
const shadow = takeShadow(stats, "composition", composition);
|
|
95
|
+
if (shadow) {
|
|
96
|
+
converted.push(shadow);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const aggregate =
|
|
100
|
+
isObjectRecord(composition) &&
|
|
101
|
+
typeof composition.aggregate === "string" &&
|
|
102
|
+
Object.hasOwn(AGGREGATE_1X_TO_20, composition.aggregate)
|
|
103
|
+
? AGGREGATE_1X_TO_20[composition.aggregate]
|
|
104
|
+
: undefined;
|
|
105
|
+
if (!aggregate) {
|
|
106
|
+
countDrop(stats, "composition (aggregate outside the 2.0 enum)");
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
converted.push(
|
|
110
|
+
...compositionsFor(composition, aggregate, inventory, stats),
|
|
111
|
+
);
|
|
112
|
+
countUnmapped(
|
|
113
|
+
stats,
|
|
114
|
+
"composition",
|
|
115
|
+
composition,
|
|
116
|
+
new Set(["aggregate", "assemblies", "dependencies", "vulnerabilities"]),
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
converted.push(...carriedCompositions);
|
|
120
|
+
const unique = uniqueByValue(converted);
|
|
121
|
+
return unique.length ? unique : undefined;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Convert an annotator. 2.0 allows `organization`, `individual` or
|
|
126
|
+
* `component` (#/$defs/cyclonedx-annotation-2.0/$defs/annotation/properties/annotator),
|
|
127
|
+
* so a 1.x `service` annotator becomes a component of type `service`.
|
|
128
|
+
*/
|
|
129
|
+
function convertAnnotator(annotator, stats) {
|
|
130
|
+
if (!isObjectRecord(annotator)) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
if (isObjectRecord(annotator.component)) {
|
|
134
|
+
return { component: convertComponent(annotator.component, stats) };
|
|
135
|
+
}
|
|
136
|
+
if (isObjectRecord(annotator.service)) {
|
|
137
|
+
return { component: convertService(annotator.service, stats) };
|
|
138
|
+
}
|
|
139
|
+
if (isObjectRecord(annotator.organization)) {
|
|
140
|
+
return { organization: toCommonEntity(annotator.organization, stats) };
|
|
141
|
+
}
|
|
142
|
+
const individual = toCommonContact(annotator.individual, stats);
|
|
143
|
+
return individual ? { individual } : undefined;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Render annotations (#/$defs/cyclonedx-annotation-2.0/$defs/annotation,
|
|
148
|
+
* required `[subjects, annotator, timestamp, text]`). Subjects are checked
|
|
149
|
+
* against the declared refIds once the whole document exists
|
|
150
|
+
* (see resolveAnnotationSubjects).
|
|
151
|
+
*/
|
|
152
|
+
export function renderAnnotations(annotations, stats) {
|
|
153
|
+
if (!Array.isArray(annotations) || !annotations.length) {
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
const converted = [];
|
|
157
|
+
for (const annotation of annotations) {
|
|
158
|
+
if (!isObjectRecord(annotation)) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const shadow = takeShadow(stats, "annotation", annotation);
|
|
162
|
+
if (shadow) {
|
|
163
|
+
converted.push(shadow);
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const annotator = convertAnnotator(annotation.annotator, stats);
|
|
167
|
+
if (!annotator) {
|
|
168
|
+
countDrop(stats, "annotation (no annotator)");
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const entry = {};
|
|
172
|
+
if (isNonEmptyString(annotation["bom-ref"])) {
|
|
173
|
+
entry.refId = annotation["bom-ref"];
|
|
174
|
+
}
|
|
175
|
+
entry.subjects = (annotation.subjects || []).filter(isNonEmptyString);
|
|
176
|
+
entry.annotator = annotator;
|
|
177
|
+
entry.timestamp = annotation.timestamp;
|
|
178
|
+
entry.text = annotation.text;
|
|
179
|
+
if (annotation.signature !== undefined) {
|
|
180
|
+
countDrop(stats, "annotation.signature");
|
|
181
|
+
}
|
|
182
|
+
converted.push(entry);
|
|
183
|
+
}
|
|
184
|
+
return converted.length ? converted : undefined;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Rewrite a 1.x citation JSONPath expression to the 2.0 document shape. The
|
|
189
|
+
* plain inventory statement path and component-targeting paths both start at
|
|
190
|
+
* `$.components` in 1.x and move under inventories (or definitions, when the
|
|
191
|
+
* document has no subject component).
|
|
192
|
+
*/
|
|
193
|
+
function convertCitationExpression(expression, usesInventory) {
|
|
194
|
+
if (typeof expression !== "string") {
|
|
195
|
+
return expression;
|
|
196
|
+
}
|
|
197
|
+
if (expression === "$.components") {
|
|
198
|
+
return usesInventory ? "$.inventories" : "$.definitions.components";
|
|
199
|
+
}
|
|
200
|
+
if (expression.startsWith("$.components")) {
|
|
201
|
+
return usesInventory
|
|
202
|
+
? `$.inventories[0].components${expression.slice("$.components".length)}`
|
|
203
|
+
: `$.definitions.components${expression.slice("$.components".length)}`;
|
|
204
|
+
}
|
|
205
|
+
if (expression === "$.services") {
|
|
206
|
+
return usesInventory
|
|
207
|
+
? "$.inventories[0].components[?(@.type=='service')]"
|
|
208
|
+
: "$.definitions.components[?(@.type=='service')]";
|
|
209
|
+
}
|
|
210
|
+
return expression;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Render citations (#/$defs/cyclonedx-citation-2.0/$defs/citation).
|
|
215
|
+
* `attributedTo` is a refLinkType, so it names a declared object's refId; the
|
|
216
|
+
* cdxgen tool's bom-ref becomes exactly that refId. A citation may carry
|
|
217
|
+
* `attributedTo`, `process` or both, so only the ref rename and the
|
|
218
|
+
* expression rewrite are targeted.
|
|
219
|
+
*/
|
|
220
|
+
export function renderCitations(citations, usesInventory, stats) {
|
|
221
|
+
if (!Array.isArray(citations) || !citations.length) {
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
return citations.filter(isObjectRecord).map((citation) => {
|
|
225
|
+
const shadow = takeShadow(stats, "citation", citation);
|
|
226
|
+
if (shadow) {
|
|
227
|
+
return shadow;
|
|
228
|
+
}
|
|
229
|
+
const converted = clone(citation);
|
|
230
|
+
if (converted["bom-ref"]) {
|
|
231
|
+
converted.refId = converted["bom-ref"];
|
|
232
|
+
delete converted["bom-ref"];
|
|
233
|
+
}
|
|
234
|
+
if (Array.isArray(converted.expressions)) {
|
|
235
|
+
converted.expressions = converted.expressions.map((expression) =>
|
|
236
|
+
convertCitationExpression(expression, usesInventory),
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
return converted;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* 1.x `cwes` numbers as 2.0 weaknesses
|
|
245
|
+
* (#/$defs/cyclonedx-weakness-2.0/$defs/weakness, kind `flaw`, identifier
|
|
246
|
+
* scheme `cwe` with the `CWE-<n>` value).
|
|
247
|
+
*/
|
|
248
|
+
function cwesToWeaknesses(cwes, stats) {
|
|
249
|
+
const weaknesses = [];
|
|
250
|
+
for (const cwe of Array.isArray(cwes) ? cwes : []) {
|
|
251
|
+
if (Number.isInteger(cwe) && cwe >= 0) {
|
|
252
|
+
weaknesses.push({
|
|
253
|
+
kind: "flaw",
|
|
254
|
+
identifiers: [{ scheme: "cwe", value: `CWE-${cwe}` }],
|
|
255
|
+
});
|
|
256
|
+
} else {
|
|
257
|
+
countDrop(stats, "vulnerability.cwes (not a CWE number)");
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return uniqueByValue(weaknesses);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// 1.x vulnerability members whose 2.0 form is the same
|
|
264
|
+
// (#/$defs/cyclonedx-vulnerability-2.0/$defs/vulnerability).
|
|
265
|
+
const VULNERABILITY_COPY_FIELDS = [
|
|
266
|
+
"id",
|
|
267
|
+
"source",
|
|
268
|
+
"references",
|
|
269
|
+
"ratings",
|
|
270
|
+
"description",
|
|
271
|
+
"detail",
|
|
272
|
+
"recommendation",
|
|
273
|
+
"workaround",
|
|
274
|
+
"advisories",
|
|
275
|
+
"created",
|
|
276
|
+
"published",
|
|
277
|
+
"updated",
|
|
278
|
+
"rejected",
|
|
279
|
+
"analysis",
|
|
280
|
+
"affects",
|
|
281
|
+
"properties",
|
|
282
|
+
];
|
|
283
|
+
const VULNERABILITY_HANDLED_FIELDS = new Set([
|
|
284
|
+
...VULNERABILITY_COPY_FIELDS,
|
|
285
|
+
"bom-ref",
|
|
286
|
+
"cwes",
|
|
287
|
+
"credits",
|
|
288
|
+
"proofOfConcept",
|
|
289
|
+
"tools",
|
|
290
|
+
]);
|
|
291
|
+
|
|
292
|
+
/** Credits: organizations and individuals take the 2.0 common shapes. */
|
|
293
|
+
function convertCredits(credits, stats) {
|
|
294
|
+
if (!isObjectRecord(credits)) {
|
|
295
|
+
countDrop(stats, "vulnerability.credits (not an object)");
|
|
296
|
+
return undefined;
|
|
297
|
+
}
|
|
298
|
+
const converted = {};
|
|
299
|
+
const organizations = (
|
|
300
|
+
Array.isArray(credits.organizations) ? credits.organizations : []
|
|
301
|
+
)
|
|
302
|
+
.map((organization) => toCommonEntity(organization, stats))
|
|
303
|
+
.filter((organization) => organization && Object.keys(organization).length);
|
|
304
|
+
if (organizations.length) {
|
|
305
|
+
converted.organizations = organizations;
|
|
306
|
+
}
|
|
307
|
+
const individuals = (
|
|
308
|
+
Array.isArray(credits.individuals) ? credits.individuals : []
|
|
309
|
+
)
|
|
310
|
+
.map((individual) => toCommonContact(individual, stats))
|
|
311
|
+
.filter(Boolean);
|
|
312
|
+
if (individuals.length) {
|
|
313
|
+
converted.individuals = individuals;
|
|
314
|
+
}
|
|
315
|
+
countUnmapped(
|
|
316
|
+
stats,
|
|
317
|
+
"vulnerability.credits",
|
|
318
|
+
credits,
|
|
319
|
+
new Set(["organizations", "individuals"]),
|
|
320
|
+
);
|
|
321
|
+
return Object.keys(converted).length ? converted : undefined;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/** Proof of concept: the supporting material is a list of attachments. */
|
|
325
|
+
function convertProofOfConcept(proofOfConcept, stats) {
|
|
326
|
+
if (!isObjectRecord(proofOfConcept)) {
|
|
327
|
+
countDrop(stats, "vulnerability.proofOfConcept (not an object)");
|
|
328
|
+
return undefined;
|
|
329
|
+
}
|
|
330
|
+
const converted = {};
|
|
331
|
+
copyDefined(converted, proofOfConcept, ["reproductionSteps", "environment"]);
|
|
332
|
+
if (Array.isArray(proofOfConcept.supportingMaterial)) {
|
|
333
|
+
const material = proofOfConcept.supportingMaterial
|
|
334
|
+
.map((attachment) =>
|
|
335
|
+
convertAttachment(
|
|
336
|
+
attachment,
|
|
337
|
+
stats,
|
|
338
|
+
"vulnerability.proofOfConcept.supportingMaterial",
|
|
339
|
+
),
|
|
340
|
+
)
|
|
341
|
+
.filter(Boolean);
|
|
342
|
+
if (material.length) {
|
|
343
|
+
converted.supportingMaterial = material;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
countUnmapped(
|
|
347
|
+
stats,
|
|
348
|
+
"vulnerability.proofOfConcept",
|
|
349
|
+
proofOfConcept,
|
|
350
|
+
new Set(["reproductionSteps", "environment", "supportingMaterial"]),
|
|
351
|
+
);
|
|
352
|
+
return Object.keys(converted).length ? converted : undefined;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Render vulnerabilities: `bom-ref` → `refId`, `cwes` → `weaknesses`, the
|
|
357
|
+
* tools object, credits as 2.0 organizations and contacts and the proof of
|
|
358
|
+
* concept's attachments. Members 2.0 has no field for are counted; `affects`
|
|
359
|
+
* references are resolved once every refId is known (resolveAffectsRefs).
|
|
360
|
+
*/
|
|
361
|
+
export function renderVulnerabilities(vulnerabilities, stats) {
|
|
362
|
+
if (!Array.isArray(vulnerabilities) || !vulnerabilities.length) {
|
|
363
|
+
return undefined;
|
|
364
|
+
}
|
|
365
|
+
return vulnerabilities.map((vulnerability) => {
|
|
366
|
+
if (!isObjectRecord(vulnerability)) {
|
|
367
|
+
return clone(vulnerability);
|
|
368
|
+
}
|
|
369
|
+
const shadow = takeShadow(stats, "vulnerability", vulnerability);
|
|
370
|
+
if (shadow) {
|
|
371
|
+
return shadow;
|
|
372
|
+
}
|
|
373
|
+
const converted = {};
|
|
374
|
+
if (isNonEmptyString(vulnerability["bom-ref"])) {
|
|
375
|
+
converted.refId = vulnerability["bom-ref"];
|
|
376
|
+
}
|
|
377
|
+
for (const [key, value] of Object.entries(vulnerability)) {
|
|
378
|
+
if (value === undefined || !VULNERABILITY_HANDLED_FIELDS.has(key)) {
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
if (VULNERABILITY_COPY_FIELDS.includes(key)) {
|
|
382
|
+
converted[key] = clone(value);
|
|
383
|
+
} else if (key === "cwes") {
|
|
384
|
+
const weaknesses = cwesToWeaknesses(value, stats);
|
|
385
|
+
if (weaknesses.length) {
|
|
386
|
+
converted.weaknesses = weaknesses;
|
|
387
|
+
}
|
|
388
|
+
} else if (key === "credits") {
|
|
389
|
+
setDefined(converted, "credits", convertCredits(value, stats));
|
|
390
|
+
} else if (key === "proofOfConcept") {
|
|
391
|
+
setDefined(
|
|
392
|
+
converted,
|
|
393
|
+
"proofOfConcept",
|
|
394
|
+
convertProofOfConcept(value, stats),
|
|
395
|
+
);
|
|
396
|
+
} else if (key === "tools") {
|
|
397
|
+
setDefined(converted, "tools", convertTools(value, stats));
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
countUnmapped(
|
|
401
|
+
stats,
|
|
402
|
+
"vulnerability",
|
|
403
|
+
vulnerability,
|
|
404
|
+
VULNERABILITY_HANDLED_FIELDS,
|
|
405
|
+
);
|
|
406
|
+
return converted;
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** Convert formulation inputs/outputs, whose entries may carry env vars. */
|
|
411
|
+
function convertFormulationIo(entries, stats) {
|
|
412
|
+
return entries.map((entry) => {
|
|
413
|
+
const converted = clone(entry);
|
|
414
|
+
if (isObjectRecord(converted) && converted.environmentVars !== undefined) {
|
|
415
|
+
converted.environmentVars = convertEnvironmentVars(
|
|
416
|
+
converted.environmentVars,
|
|
417
|
+
stats,
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
return converted;
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* formulation → workflows/tasks/triggers with refId renames. The 2.0 formula
|
|
426
|
+
* allows only refId, properties and workflows
|
|
427
|
+
* (#/$defs/cyclonedx-formulation-2.0/$defs/formula), so the 1.x
|
|
428
|
+
* formula.components move to definitions.components (upstream's
|
|
429
|
+
* valid-formulation-2.0.json declares them there too) and are collected in
|
|
430
|
+
* `stats.formulaComponents`.
|
|
431
|
+
*/
|
|
432
|
+
export function convertFormulation(formulation, stats) {
|
|
433
|
+
if (!Array.isArray(formulation)) {
|
|
434
|
+
return clone(formulation);
|
|
435
|
+
}
|
|
436
|
+
const refIdSubjects = (entry) => {
|
|
437
|
+
if (!isObjectRecord(entry)) {
|
|
438
|
+
return clone(entry);
|
|
439
|
+
}
|
|
440
|
+
const converted = {};
|
|
441
|
+
if (entry["bom-ref"]) {
|
|
442
|
+
converted.refId = entry["bom-ref"];
|
|
443
|
+
}
|
|
444
|
+
for (const [key, value] of Object.entries(entry)) {
|
|
445
|
+
if (key === "bom-ref") {
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
if (key === "components" && Array.isArray(value)) {
|
|
449
|
+
stats.formulaComponents.push(
|
|
450
|
+
...value.map((c) => convertComponent(c, stats)),
|
|
451
|
+
);
|
|
452
|
+
} else if (key === "services" && Array.isArray(value)) {
|
|
453
|
+
stats.formulaComponents.push(
|
|
454
|
+
...value.map((s) => convertService(s, stats)),
|
|
455
|
+
);
|
|
456
|
+
} else if (FORMULATION_LIST_KEYS.has(key) && Array.isArray(value)) {
|
|
457
|
+
converted[key] = value.map(refIdSubjects);
|
|
458
|
+
} else if (key === "trigger" && isObjectRecord(value)) {
|
|
459
|
+
converted.trigger = refIdSubjects(value);
|
|
460
|
+
} else if (key === "environmentVars") {
|
|
461
|
+
converted.environmentVars = convertEnvironmentVars(value, stats);
|
|
462
|
+
} else if (
|
|
463
|
+
(key === "inputs" || key === "outputs") &&
|
|
464
|
+
Array.isArray(value)
|
|
465
|
+
) {
|
|
466
|
+
converted[key] = convertFormulationIo(value, stats);
|
|
467
|
+
} else {
|
|
468
|
+
converted[key] = clone(value);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return converted;
|
|
472
|
+
};
|
|
473
|
+
return formulation.map((formula, index) => {
|
|
474
|
+
if (!isObjectRecord(formula)) {
|
|
475
|
+
return clone(formula);
|
|
476
|
+
}
|
|
477
|
+
// A formula read from 2.0 is restored while unchanged; its components
|
|
478
|
+
// still go to definitions. The refIds of each formula's components are
|
|
479
|
+
// kept in stats.formulaMembership for a subject-less document (see
|
|
480
|
+
// cyclonedx20Render.js).
|
|
481
|
+
const start = stats.formulaComponents.length;
|
|
482
|
+
const { components, services, ...own } = formula;
|
|
483
|
+
const shadow = takeShadow(stats, "formula", own);
|
|
484
|
+
let converted;
|
|
485
|
+
if (shadow) {
|
|
486
|
+
refIdSubjects({ components, services });
|
|
487
|
+
converted = shadow;
|
|
488
|
+
} else {
|
|
489
|
+
converted = refIdSubjects(formula);
|
|
490
|
+
}
|
|
491
|
+
stats.formulaMembership[index] = stats.formulaComponents.slice(start);
|
|
492
|
+
return converted;
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// Formulation members holding lists of objects that carry a bom-ref.
|
|
497
|
+
const FORMULATION_LIST_KEYS = Object.freeze(
|
|
498
|
+
new Set(["workflows", "tasks", "triggers", "workspaces"]),
|
|
499
|
+
);
|