@cdxgen/cdxgen 0.0.1 → 13.0.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/README.md +921 -87
- package/bin/audit.js +239 -0
- package/bin/cdxgen.js +2335 -0
- package/bin/convert.js +220 -0
- package/bin/evinse.js +353 -0
- package/bin/hbom.js +504 -0
- package/bin/repl.js +2224 -0
- package/bin/sign.js +195 -0
- package/bin/tracebom.js +303 -0
- package/bin/validate.js +268 -0
- package/bin/verify.js +189 -0
- package/data/README.md +307 -0
- package/data/bom-1.4.schema.json +1605 -0
- package/data/bom-1.5.schema.json +3660 -0
- package/data/bom-1.6.schema.json +5511 -0
- package/data/bom-1.7.schema.json +6700 -0
- package/data/cbomosdb-queries.json +68 -0
- package/data/component-tags.json +339 -0
- package/data/container-knowledge-index.json +125 -0
- package/data/cosdb-queries.json +17 -0
- package/data/crypto-oid.json +1998 -0
- package/data/cryptography-defs.json +3793 -0
- package/data/cryptography-defs.schema.json +576 -0
- package/data/cyclonedx-2.0-bundled.schema.json +7182 -0
- package/data/frameworks-list.json +219 -0
- package/data/glibc-stdlib.json +117 -0
- package/data/gtfobins-index.json +6296 -0
- package/data/helpers/init.gradle +71 -0
- package/data/jsf-0.82.schema.json +211 -0
- package/data/known-licenses.json +82 -0
- package/data/lic-mapping.json +338 -0
- package/data/license-aliases.json +6624 -0
- package/data/license-db.json +39059 -0
- package/data/license-deprecations.json +302 -0
- package/data/lolbas-index.json +150 -0
- package/data/predictive-audit-allowlist.json +11 -0
- package/data/pypi-pkg-aliases.json +1199 -0
- package/data/python-stdlib.json +308 -0
- package/data/queries-darwin.json +193 -0
- package/data/queries-win.json +257 -0
- package/data/queries.json +268 -0
- package/data/ruby-known-modules.json +281 -0
- package/data/rules/ai-agent-governance.yaml +323 -0
- package/data/rules/ai-bom.yaml +268 -0
- package/data/rules/ai-oversight.yaml +186 -0
- package/data/rules/ai-provenance.yaml +92 -0
- package/data/rules/asar-archives.yaml +150 -0
- package/data/rules/cbom-security.yaml +165 -0
- package/data/rules/chrome-extensions.yaml +248 -0
- package/data/rules/ci-permissions.yaml +802 -0
- package/data/rules/container-risk.yaml +353 -0
- package/data/rules/dependency-sources.yaml +236 -0
- package/data/rules/golem-go.yaml +229 -0
- package/data/rules/hbom-compliance.yaml +325 -0
- package/data/rules/hbom-performance.yaml +307 -0
- package/data/rules/hbom-security.yaml +248 -0
- package/data/rules/host-topology.yaml +165 -0
- package/data/rules/mcp-servers.yaml +388 -0
- package/data/rules/obom-runtime.yaml +1776 -0
- package/data/rules/package-integrity.yaml +364 -0
- package/data/rules/rootfs-hardening.yaml +179 -0
- package/data/rules/vscode-extensions.yaml +237 -0
- package/data/spdx-export.schema.json +6794 -0
- package/data/spdx-license-list.json +7449 -0
- package/data/spdx-licenses.json +759 -0
- package/data/spdx.schema.json +819 -0
- package/data/templates/README.md +3 -0
- package/data/templates/asvs-4.0.3.cdx.json +2943 -0
- package/data/templates/asvs-5.0.cdx.json +3046 -0
- package/data/templates/bsimm-v13.cdx.json +1008 -0
- package/data/templates/masvs-2.0.0.cdx.json +225 -0
- package/data/templates/nist-ssdf-1.1.cdx.json +828 -0
- package/data/templates/pcissc-secure-slc-1.1.cdx.json +1027 -0
- package/data/templates/scvs-1.0.0.cdx.json +813 -0
- package/data/templates/ssaf-DRAFT-2023-11.cdx.json +127 -0
- package/data/vendor-alias.json +41967 -0
- package/data/wrapdb-releases.json +4227 -0
- package/index.cjs +15 -0
- package/lib/audit/index.js +2800 -0
- package/lib/audit/progress.js +114 -0
- package/lib/audit/reporters.js +937 -0
- package/lib/audit/scoring.js +560 -0
- package/lib/audit/targets.js +798 -0
- package/lib/cli/bomAssembly.js +1882 -0
- package/lib/cli/cliOptions.js +543 -0
- package/lib/cli/index.js +2759 -0
- package/lib/cli/jsBom.js +2087 -0
- package/lib/cli/jvmBom.js +1858 -0
- package/lib/cli/managedBom.js +2083 -0
- package/lib/cli/nativeBom.js +2125 -0
- package/lib/core/activity.js +1087 -0
- package/lib/core/env.js +719 -0
- package/lib/core/fs.js +1058 -0
- package/lib/core/httpClient.js +730 -0
- package/lib/core/logger.js +280 -0
- package/lib/core/parallel.js +323 -0
- package/lib/core/paths.js +70 -0
- package/lib/core/projectConfig.js +122 -0
- package/lib/core/propertySanitizer.js +174 -0
- package/lib/core/spdx.js +5 -0
- package/lib/core/state.js +59 -0
- package/lib/core/text.js +207 -0
- package/lib/core/ui.js +920 -0
- package/lib/core/urls.js +84 -0
- package/lib/ecosystems/asarutils.js +1636 -0
- package/lib/ecosystems/bunutils.js +402 -0
- package/lib/ecosystems/caxa.js +77 -0
- package/lib/ecosystems/chromextutils.js +1174 -0
- package/lib/ecosystems/cmakeResolver.js +587 -0
- package/lib/ecosystems/cppEvidence.js +305 -0
- package/lib/ecosystems/denoutils.js +1094 -0
- package/lib/ecosystems/dotnetutils.js +132 -0
- package/lib/ecosystems/ecosystems.js +2772 -0
- package/lib/ecosystems/golem.js +1807 -0
- package/lib/ecosystems/gradleutils.js +1048 -0
- package/lib/ecosystems/jsEvidence.js +317 -0
- package/lib/ecosystems/npmutils.js +586 -0
- package/lib/ecosystems/parsers-bazel.js +875 -0
- package/lib/ecosystems/parsers-dotnet.js +1430 -0
- package/lib/ecosystems/parsers-gleam.js +302 -0
- package/lib/ecosystems/parsers-go.js +818 -0
- package/lib/ecosystems/parsers-js.js +4222 -0
- package/lib/ecosystems/parsers-jvm.js +948 -0
- package/lib/ecosystems/parsers-misc.js +3191 -0
- package/lib/ecosystems/parsers-python.js +2070 -0
- package/lib/ecosystems/parsers-rust.js +1294 -0
- package/lib/ecosystems/parsers-zig.js +861 -0
- package/lib/ecosystems/pep770.js +341 -0
- package/lib/ecosystems/pylockutils.js +427 -0
- package/lib/ecosystems/pythonutils.js +1281 -0
- package/lib/ecosystems/registryProvenance.js +1003 -0
- package/lib/ecosystems/remote/huggingface.js +1343 -0
- package/lib/ecosystems/rubyutils.js +1629 -0
- package/lib/ecosystems/rusi.js +820 -0
- package/lib/ecosystems/sbtutils.js +972 -0
- package/lib/ecosystems/tea.js +607 -0
- package/lib/ecosystems/utils.js +583 -0
- package/lib/ecosystems/zigResolver.js +410 -0
- package/lib/evinser/db.js +145 -0
- package/lib/evinser/evinser.js +2362 -0
- package/lib/evinser/scalasem.js +65 -0
- package/lib/evinser/swiftsem.js +767 -0
- package/lib/helpers/annotationFormatter.js +84 -0
- package/lib/helpers/bomSigner.js +312 -0
- package/lib/helpers/exportUtils.js +160 -0
- package/lib/helpers/remote/dependency-track.js +117 -0
- package/lib/helpers/versutils.js +202 -0
- package/lib/helpers/vsixutils.js +1069 -0
- package/lib/inventory/agentFormulationParser.js +322 -0
- package/lib/inventory/aiCollector.js +2140 -0
- package/lib/inventory/aiInventory.js +414 -0
- package/lib/inventory/aiModelVariants.js +121 -0
- package/lib/inventory/aiOversightCollector.js +661 -0
- package/lib/inventory/aiProvenanceCollector.js +822 -0
- package/lib/inventory/analyzer.js +6089 -0
- package/lib/inventory/analyzerScope.js +807 -0
- package/lib/inventory/astWorker.js +20 -0
- package/lib/inventory/atomUtils.js +1092 -0
- package/lib/inventory/auditCategories.js +192 -0
- package/lib/inventory/bomUtils.js +369 -0
- package/lib/inventory/cacheCommands.js +182 -0
- package/lib/inventory/cacheDir.js +104 -0
- package/lib/inventory/cbomutils.js +590 -0
- package/lib/inventory/cdxrs.js +434 -0
- package/lib/inventory/ciParsers/azurePipelines.js +295 -0
- package/lib/inventory/ciParsers/circleCi.js +286 -0
- package/lib/inventory/ciParsers/common.js +24 -0
- package/lib/inventory/ciParsers/githubActions.js +2434 -0
- package/lib/inventory/ciParsers/gitlabCi.js +213 -0
- package/lib/inventory/ciParsers/jenkins.js +180 -0
- package/lib/inventory/citations.js +234 -0
- package/lib/inventory/communityAiConfigParser.js +756 -0
- package/lib/inventory/containerRisk.js +204 -0
- package/lib/inventory/cryptoAlgorithmFamily.js +258 -0
- package/lib/inventory/deps.js +807 -0
- package/lib/inventory/depsUtils.js +588 -0
- package/lib/inventory/display.js +2128 -0
- package/lib/inventory/dosai.js +601 -0
- package/lib/inventory/dosaiParsers.js +154 -0
- package/lib/inventory/dynamic.js +145 -0
- package/lib/inventory/envcontext.js +1793 -0
- package/lib/inventory/evidenceUtils.js +774 -0
- package/lib/inventory/fetchBatch.js +779 -0
- package/lib/inventory/fetchRate.js +255 -0
- package/lib/inventory/forgeEnricher.js +300 -0
- package/lib/inventory/formulationParsers.js +422 -0
- package/lib/inventory/gtfobins.js +339 -0
- package/lib/inventory/hbom.js +719 -0
- package/lib/inventory/hbomAnalysis.js +310 -0
- package/lib/inventory/hbomLoader.js +35 -0
- package/lib/inventory/hostTopology.js +835 -0
- package/lib/inventory/inventoryStats.js +100 -0
- package/lib/inventory/jsonLike.js +121 -0
- package/lib/inventory/licenseEnhancer.js +918 -0
- package/lib/inventory/lolbas.js +285 -0
- package/lib/inventory/mcp.js +253 -0
- package/lib/inventory/mcpConfigParser.js +683 -0
- package/lib/inventory/mcpDiscovery.js +112 -0
- package/lib/inventory/mcpPinning.js +209 -0
- package/lib/inventory/osPackageResolver.js +493 -0
- package/lib/inventory/osinfo.js +383 -0
- package/lib/inventory/osqueryTransform.js +274 -0
- package/lib/inventory/plugins.js +466 -0
- package/lib/inventory/protobom.js +231 -0
- package/lib/inventory/protobomLoader.js +43 -0
- package/lib/inventory/provenanceUtils.js +224 -0
- package/lib/inventory/purl.js +749 -0
- package/lib/inventory/rustFormulationParser.js +339 -0
- package/lib/inventory/sbomDocument.js +340 -0
- package/lib/inventory/source.js +1488 -0
- package/lib/inventory/spdx.js +361 -0
- package/lib/inventory/spdxExpression.js +512 -0
- package/lib/inventory/spdxUtils.js +107 -0
- package/lib/inventory/table.js +267 -0
- package/lib/inventory/traceRunner.js +439 -0
- package/lib/inventory/unicodeScan.js +147 -0
- package/lib/managers/binary.js +3459 -0
- package/lib/managers/containerutils.js +125 -0
- package/lib/managers/docker.js +2145 -0
- package/lib/managers/dockerConnection.js +162 -0
- package/lib/managers/oci.js +704 -0
- package/lib/managers/piptree.js +267 -0
- package/lib/parsers/cmakeCache.js +199 -0
- package/lib/parsers/gguf.js +492 -0
- package/lib/parsers/gitAiNotes.js +233 -0
- package/lib/parsers/gitmodules.js +239 -0
- package/lib/parsers/htmlExtract.js +610 -0
- package/lib/parsers/huggingfaceManifest.js +551 -0
- package/lib/parsers/huggingfaceUtils.js +506 -0
- package/lib/parsers/iri.js +618 -0
- package/lib/parsers/npmrc.js +99 -0
- package/lib/parsers/ollama.js +101 -0
- package/lib/parsers/xml.js +841 -0
- package/lib/server/openapi.yaml +433 -0
- package/lib/server/server.js +616 -0
- package/lib/stages/postgen/annotator.js +977 -0
- package/lib/stages/postgen/auditBom.js +468 -0
- package/lib/stages/postgen/postgen.js +1239 -0
- package/lib/stages/postgen/ruleEngine.js +731 -0
- package/lib/stages/postgen/sortBom.js +195 -0
- package/lib/stages/postgen/spdxConverter.js +796 -0
- package/lib/stages/postgen/specVersionCompat.js +703 -0
- package/lib/stages/pregen/envAudit.js +388 -0
- package/lib/stages/pregen/pregen.js +637 -0
- package/lib/third-party/README.md +9 -0
- package/lib/third-party/arborist/CHANGELOG.md +1109 -0
- package/lib/third-party/arborist/LICENSE.md +20 -0
- package/lib/third-party/arborist/README.md +315 -0
- package/lib/third-party/arborist/lib/arborist/index.js +258 -0
- package/lib/third-party/arborist/lib/arborist/load-actual.js +605 -0
- package/lib/third-party/arborist/lib/arborist/load-virtual.js +300 -0
- package/lib/third-party/arborist/lib/bin-links.js +120 -0
- package/lib/third-party/arborist/lib/calc-dep-flags.js +130 -0
- package/lib/third-party/arborist/lib/case-insensitive-map.js +51 -0
- package/lib/third-party/arborist/lib/consistent-resolve.js +42 -0
- package/lib/third-party/arborist/lib/debug.js +50 -0
- package/lib/third-party/arborist/lib/dep-valid.js +190 -0
- package/lib/third-party/arborist/lib/edge.js +417 -0
- package/lib/third-party/arborist/lib/from-path.js +36 -0
- package/lib/third-party/arborist/lib/gather-dep-set.js +43 -0
- package/lib/third-party/arborist/lib/index.js +22 -0
- package/lib/third-party/arborist/lib/inventory.js +138 -0
- package/lib/third-party/arborist/lib/link.js +169 -0
- package/lib/third-party/arborist/lib/node.js +1673 -0
- package/lib/third-party/arborist/lib/npm-extension.js +45 -0
- package/lib/third-party/arborist/lib/override-resolves.js +11 -0
- package/lib/third-party/arborist/lib/override-set.js +319 -0
- package/lib/third-party/arborist/lib/package-extensions.js +289 -0
- package/lib/third-party/arborist/lib/printable.js +210 -0
- package/lib/third-party/arborist/lib/proc-log.js +30 -0
- package/lib/third-party/arborist/lib/realpath.js +100 -0
- package/lib/third-party/arborist/lib/relpath.js +4 -0
- package/lib/third-party/arborist/lib/shrinkwrap.js +1291 -0
- package/lib/third-party/arborist/lib/spec-from-lock.js +34 -0
- package/lib/third-party/arborist/lib/tree-check.js +165 -0
- package/lib/third-party/arborist/lib/validate-npm-package-name.js +107 -0
- package/lib/third-party/arborist/lib/version-from-tgz.js +51 -0
- package/lib/third-party/arborist/lib/yarn-lock.js +397 -0
- package/lib/validator/bomValidator.js +985 -0
- package/lib/validator/complianceEngine.js +241 -0
- package/lib/validator/complianceRules.js +1680 -0
- package/lib/validator/generated/runtime.mjs +17 -0
- package/lib/validator/generated/validate-1.6.mjs +21258 -0
- package/lib/validator/generated/validate-1.7.mjs +24803 -0
- package/lib/validator/generated/validate-2.0.mjs +22931 -0
- package/lib/validator/index.js +246 -0
- package/lib/validator/reporters/annotations.js +142 -0
- package/lib/validator/reporters/console.js +160 -0
- package/lib/validator/reporters/index.js +41 -0
- package/lib/validator/reporters/json.js +37 -0
- package/lib/validator/reporters/sarif.js +184 -0
- package/package.json +209 -26
- package/types/bin/audit.d.ts +3 -0
- package/types/bin/audit.d.ts.map +1 -0
- package/types/bin/cdxgen.d.ts +3 -0
- package/types/bin/cdxgen.d.ts.map +1 -0
- package/types/bin/convert.d.ts +3 -0
- package/types/bin/convert.d.ts.map +1 -0
- package/types/bin/evinse.d.ts +3 -0
- package/types/bin/evinse.d.ts.map +1 -0
- package/types/bin/hbom.d.ts +3 -0
- package/types/bin/hbom.d.ts.map +1 -0
- package/types/bin/repl.d.ts +3 -0
- package/types/bin/repl.d.ts.map +1 -0
- package/types/bin/sign.d.ts +3 -0
- package/types/bin/sign.d.ts.map +1 -0
- package/types/bin/tracebom.d.ts +3 -0
- package/types/bin/tracebom.d.ts.map +1 -0
- package/types/bin/validate.d.ts +14 -0
- package/types/bin/validate.d.ts.map +1 -0
- package/types/bin/verify.d.ts +3 -0
- package/types/bin/verify.d.ts.map +1 -0
- package/types/lib/audit/index.d.ts +153 -0
- package/types/lib/audit/index.d.ts.map +1 -0
- package/types/lib/audit/progress.d.ts +31 -0
- package/types/lib/audit/progress.d.ts.map +1 -0
- package/types/lib/audit/reporters.d.ts +62 -0
- package/types/lib/audit/reporters.d.ts.map +1 -0
- package/types/lib/audit/scoring.d.ts +36 -0
- package/types/lib/audit/scoring.d.ts.map +1 -0
- package/types/lib/audit/targets.d.ts +77 -0
- package/types/lib/audit/targets.d.ts.map +1 -0
- package/types/lib/cli/bomAssembly.d.ts +329 -0
- package/types/lib/cli/bomAssembly.d.ts.map +1 -0
- package/types/lib/cli/cliOptions.d.ts +156 -0
- package/types/lib/cli/cliOptions.d.ts.map +1 -0
- package/types/lib/cli/index.d.ts +107 -0
- package/types/lib/cli/index.d.ts.map +1 -0
- package/types/lib/cli/jsBom.d.ts +94 -0
- package/types/lib/cli/jsBom.d.ts.map +1 -0
- package/types/lib/cli/jvmBom.d.ts +54 -0
- package/types/lib/cli/jvmBom.d.ts.map +1 -0
- package/types/lib/cli/managedBom.d.ts +105 -0
- package/types/lib/cli/managedBom.d.ts.map +1 -0
- package/types/lib/cli/nativeBom.d.ts +143 -0
- package/types/lib/cli/nativeBom.d.ts.map +1 -0
- package/types/lib/core/activity.d.ts +178 -0
- package/types/lib/core/activity.d.ts.map +1 -0
- package/types/lib/core/env.d.ts +192 -0
- package/types/lib/core/env.d.ts.map +1 -0
- package/types/lib/core/fs.d.ts +158 -0
- package/types/lib/core/fs.d.ts.map +1 -0
- package/types/lib/core/httpClient.d.ts +149 -0
- package/types/lib/core/httpClient.d.ts.map +1 -0
- package/types/lib/core/logger.d.ts +50 -0
- package/types/lib/core/logger.d.ts.map +1 -0
- package/types/lib/core/parallel.d.ts +95 -0
- package/types/lib/core/parallel.d.ts.map +1 -0
- package/types/lib/core/paths.d.ts +36 -0
- package/types/lib/core/paths.d.ts.map +1 -0
- package/types/lib/core/projectConfig.d.ts +23 -0
- package/types/lib/core/projectConfig.d.ts.map +1 -0
- package/types/lib/core/propertySanitizer.d.ts +23 -0
- package/types/lib/core/propertySanitizer.d.ts.map +1 -0
- package/types/lib/core/spdx.d.ts +5 -0
- package/types/lib/core/spdx.d.ts.map +1 -0
- package/types/lib/core/state.d.ts +20 -0
- package/types/lib/core/state.d.ts.map +1 -0
- package/types/lib/core/text.d.ts +78 -0
- package/types/lib/core/text.d.ts.map +1 -0
- package/types/lib/core/ui.d.ts +87 -0
- package/types/lib/core/ui.d.ts.map +1 -0
- package/types/lib/core/urls.d.ts +43 -0
- package/types/lib/core/urls.d.ts.map +1 -0
- package/types/lib/ecosystems/asarutils.d.ts +71 -0
- package/types/lib/ecosystems/asarutils.d.ts.map +1 -0
- package/types/lib/ecosystems/bunutils.d.ts +38 -0
- package/types/lib/ecosystems/bunutils.d.ts.map +1 -0
- package/types/lib/ecosystems/caxa.d.ts +8 -0
- package/types/lib/ecosystems/caxa.d.ts.map +1 -0
- package/types/lib/ecosystems/chromextutils.d.ts +97 -0
- package/types/lib/ecosystems/chromextutils.d.ts.map +1 -0
- package/types/lib/ecosystems/cmakeResolver.d.ts +176 -0
- package/types/lib/ecosystems/cmakeResolver.d.ts.map +1 -0
- package/types/lib/ecosystems/cppEvidence.d.ts +35 -0
- package/types/lib/ecosystems/cppEvidence.d.ts.map +1 -0
- package/types/lib/ecosystems/denoutils.d.ts +76 -0
- package/types/lib/ecosystems/denoutils.d.ts.map +1 -0
- package/types/lib/ecosystems/dotnetutils.d.ts +45 -0
- package/types/lib/ecosystems/dotnetutils.d.ts.map +1 -0
- package/types/lib/ecosystems/ecosystems.d.ts +279 -0
- package/types/lib/ecosystems/ecosystems.d.ts.map +1 -0
- package/types/lib/ecosystems/golem.d.ts +60 -0
- package/types/lib/ecosystems/golem.d.ts.map +1 -0
- package/types/lib/ecosystems/gradleutils.d.ts +139 -0
- package/types/lib/ecosystems/gradleutils.d.ts.map +1 -0
- package/types/lib/ecosystems/jsEvidence.d.ts +17 -0
- package/types/lib/ecosystems/jsEvidence.d.ts.map +1 -0
- package/types/lib/ecosystems/npmutils.d.ts +183 -0
- package/types/lib/ecosystems/npmutils.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-bazel.d.ts +36 -0
- package/types/lib/ecosystems/parsers-bazel.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-dotnet.d.ts +116 -0
- package/types/lib/ecosystems/parsers-dotnet.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-gleam.d.ts +33 -0
- package/types/lib/ecosystems/parsers-gleam.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-go.d.ts +92 -0
- package/types/lib/ecosystems/parsers-go.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-js.d.ts +242 -0
- package/types/lib/ecosystems/parsers-js.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-jvm.d.ts +100 -0
- package/types/lib/ecosystems/parsers-jvm.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-misc.d.ts +450 -0
- package/types/lib/ecosystems/parsers-misc.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-python.d.ts +145 -0
- package/types/lib/ecosystems/parsers-python.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-rust.d.ts +56 -0
- package/types/lib/ecosystems/parsers-rust.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-zig.d.ts +83 -0
- package/types/lib/ecosystems/parsers-zig.d.ts.map +1 -0
- package/types/lib/ecosystems/pep770.d.ts +38 -0
- package/types/lib/ecosystems/pep770.d.ts.map +1 -0
- package/types/lib/ecosystems/pylockutils.d.ts +68 -0
- package/types/lib/ecosystems/pylockutils.d.ts.map +1 -0
- package/types/lib/ecosystems/pythonutils.d.ts +70 -0
- package/types/lib/ecosystems/pythonutils.d.ts.map +1 -0
- package/types/lib/ecosystems/registryProvenance.d.ts +26 -0
- package/types/lib/ecosystems/registryProvenance.d.ts.map +1 -0
- package/types/lib/ecosystems/remote/huggingface.d.ts +31 -0
- package/types/lib/ecosystems/remote/huggingface.d.ts.map +1 -0
- package/types/lib/ecosystems/rubyutils.d.ts +182 -0
- package/types/lib/ecosystems/rubyutils.d.ts.map +1 -0
- package/types/lib/ecosystems/rusi.d.ts +40 -0
- package/types/lib/ecosystems/rusi.d.ts.map +1 -0
- package/types/lib/ecosystems/sbtutils.d.ts +179 -0
- package/types/lib/ecosystems/sbtutils.d.ts.map +1 -0
- package/types/lib/ecosystems/tea.d.ts +180 -0
- package/types/lib/ecosystems/tea.d.ts.map +1 -0
- package/types/lib/ecosystems/utils.d.ts +41 -0
- package/types/lib/ecosystems/utils.d.ts.map +1 -0
- package/types/lib/ecosystems/zigResolver.d.ts +70 -0
- package/types/lib/ecosystems/zigResolver.d.ts.map +1 -0
- package/types/lib/evinser/db.d.ts +17 -0
- package/types/lib/evinser/db.d.ts.map +1 -0
- package/types/lib/evinser/evinser.d.ts +354 -0
- package/types/lib/evinser/evinser.d.ts.map +1 -0
- package/types/lib/evinser/scalasem.d.ts +15 -0
- package/types/lib/evinser/scalasem.d.ts.map +1 -0
- package/types/lib/evinser/swiftsem.d.ts +103 -0
- package/types/lib/evinser/swiftsem.d.ts.map +1 -0
- package/types/lib/helpers/annotationFormatter.d.ts +23 -0
- package/types/lib/helpers/annotationFormatter.d.ts.map +1 -0
- package/types/lib/helpers/bomSigner.d.ts +28 -0
- package/types/lib/helpers/bomSigner.d.ts.map +1 -0
- package/types/lib/helpers/exportUtils.d.ts +52 -0
- package/types/lib/helpers/exportUtils.d.ts.map +1 -0
- package/types/lib/helpers/remote/dependency-track.d.ts +23 -0
- package/types/lib/helpers/remote/dependency-track.d.ts.map +1 -0
- package/types/lib/helpers/versutils.d.ts +8 -0
- package/types/lib/helpers/versutils.d.ts.map +1 -0
- package/types/lib/helpers/vsixutils.d.ts +130 -0
- package/types/lib/helpers/vsixutils.d.ts.map +1 -0
- package/types/lib/inventory/agentFormulationParser.d.ts +21 -0
- package/types/lib/inventory/agentFormulationParser.d.ts.map +1 -0
- package/types/lib/inventory/aiCollector.d.ts +61 -0
- package/types/lib/inventory/aiCollector.d.ts.map +1 -0
- package/types/lib/inventory/aiInventory.d.ts +103 -0
- package/types/lib/inventory/aiInventory.d.ts.map +1 -0
- package/types/lib/inventory/aiModelVariants.d.ts +31 -0
- package/types/lib/inventory/aiModelVariants.d.ts.map +1 -0
- package/types/lib/inventory/aiOversightCollector.d.ts +28 -0
- package/types/lib/inventory/aiOversightCollector.d.ts.map +1 -0
- package/types/lib/inventory/aiProvenanceCollector.d.ts +13 -0
- package/types/lib/inventory/aiProvenanceCollector.d.ts.map +1 -0
- package/types/lib/inventory/analyzer.d.ts +157 -0
- package/types/lib/inventory/analyzer.d.ts.map +1 -0
- package/types/lib/inventory/analyzerScope.d.ts +106 -0
- package/types/lib/inventory/analyzerScope.d.ts.map +1 -0
- package/types/lib/inventory/astWorker.d.ts +9 -0
- package/types/lib/inventory/astWorker.d.ts.map +1 -0
- package/types/lib/inventory/atomUtils.d.ts +159 -0
- package/types/lib/inventory/atomUtils.d.ts.map +1 -0
- package/types/lib/inventory/auditCategories.d.ts +80 -0
- package/types/lib/inventory/auditCategories.d.ts.map +1 -0
- package/types/lib/inventory/bomUtils.d.ts +145 -0
- package/types/lib/inventory/bomUtils.d.ts.map +1 -0
- package/types/lib/inventory/cacheCommands.d.ts +28 -0
- package/types/lib/inventory/cacheCommands.d.ts.map +1 -0
- package/types/lib/inventory/cacheDir.d.ts +55 -0
- package/types/lib/inventory/cacheDir.d.ts.map +1 -0
- package/types/lib/inventory/cbomutils.d.ts +37 -0
- package/types/lib/inventory/cbomutils.d.ts.map +1 -0
- package/types/lib/inventory/cdxrs.d.ts +90 -0
- package/types/lib/inventory/cdxrs.d.ts.map +1 -0
- package/types/lib/inventory/ciParsers/azurePipelines.d.ts +27 -0
- package/types/lib/inventory/ciParsers/azurePipelines.d.ts.map +1 -0
- package/types/lib/inventory/ciParsers/circleCi.d.ts +27 -0
- package/types/lib/inventory/ciParsers/circleCi.d.ts.map +1 -0
- package/types/lib/inventory/ciParsers/common.d.ts +11 -0
- package/types/lib/inventory/ciParsers/common.d.ts.map +1 -0
- package/types/lib/inventory/ciParsers/githubActions.d.ts +38 -0
- package/types/lib/inventory/ciParsers/githubActions.d.ts.map +1 -0
- package/types/lib/inventory/ciParsers/gitlabCi.d.ts +26 -0
- package/types/lib/inventory/ciParsers/gitlabCi.d.ts.map +1 -0
- package/types/lib/inventory/ciParsers/jenkins.d.ts +26 -0
- package/types/lib/inventory/ciParsers/jenkins.d.ts.map +1 -0
- package/types/lib/inventory/citations.d.ts +90 -0
- package/types/lib/inventory/citations.d.ts.map +1 -0
- package/types/lib/inventory/communityAiConfigParser.d.ts +14 -0
- package/types/lib/inventory/communityAiConfigParser.d.ts.map +1 -0
- package/types/lib/inventory/containerRisk.d.ts +20 -0
- package/types/lib/inventory/containerRisk.d.ts.map +1 -0
- package/types/lib/inventory/cryptoAlgorithmFamily.d.ts +37 -0
- package/types/lib/inventory/cryptoAlgorithmFamily.d.ts.map +1 -0
- package/types/lib/inventory/deps.d.ts +140 -0
- package/types/lib/inventory/deps.d.ts.map +1 -0
- package/types/lib/inventory/depsUtils.d.ts +74 -0
- package/types/lib/inventory/depsUtils.d.ts.map +1 -0
- package/types/lib/inventory/display.d.ts +227 -0
- package/types/lib/inventory/display.d.ts.map +1 -0
- package/types/lib/inventory/dosai.d.ts +130 -0
- package/types/lib/inventory/dosai.d.ts.map +1 -0
- package/types/lib/inventory/dosaiParsers.d.ts +59 -0
- package/types/lib/inventory/dosaiParsers.d.ts.map +1 -0
- package/types/lib/inventory/dynamic.d.ts +25 -0
- package/types/lib/inventory/dynamic.d.ts.map +1 -0
- package/types/lib/inventory/envcontext.d.ts +377 -0
- package/types/lib/inventory/envcontext.d.ts.map +1 -0
- package/types/lib/inventory/evidenceUtils.d.ts +74 -0
- package/types/lib/inventory/evidenceUtils.d.ts.map +1 -0
- package/types/lib/inventory/fetchBatch.d.ts +127 -0
- package/types/lib/inventory/fetchBatch.d.ts.map +1 -0
- package/types/lib/inventory/fetchRate.d.ts +118 -0
- package/types/lib/inventory/fetchRate.d.ts.map +1 -0
- package/types/lib/inventory/forgeEnricher.d.ts +31 -0
- package/types/lib/inventory/forgeEnricher.d.ts.map +1 -0
- package/types/lib/inventory/formulationParsers.d.ts +50 -0
- package/types/lib/inventory/formulationParsers.d.ts.map +1 -0
- package/types/lib/inventory/gtfobins.d.ts +27 -0
- package/types/lib/inventory/gtfobins.d.ts.map +1 -0
- package/types/lib/inventory/hbom.d.ts +58 -0
- package/types/lib/inventory/hbom.d.ts.map +1 -0
- package/types/lib/inventory/hbomAnalysis.d.ts +56 -0
- package/types/lib/inventory/hbomAnalysis.d.ts.map +1 -0
- package/types/lib/inventory/hbomLoader.d.ts +7 -0
- package/types/lib/inventory/hbomLoader.d.ts.map +1 -0
- package/types/lib/inventory/hostTopology.d.ts +47 -0
- package/types/lib/inventory/hostTopology.d.ts.map +1 -0
- package/types/lib/inventory/inventoryStats.d.ts +42 -0
- package/types/lib/inventory/inventoryStats.d.ts.map +1 -0
- package/types/lib/inventory/jsonLike.d.ts +23 -0
- package/types/lib/inventory/jsonLike.d.ts.map +1 -0
- package/types/lib/inventory/licenseEnhancer.d.ts +70 -0
- package/types/lib/inventory/licenseEnhancer.d.ts.map +1 -0
- package/types/lib/inventory/lolbas.d.ts +16 -0
- package/types/lib/inventory/lolbas.d.ts.map +1 -0
- package/types/lib/inventory/mcp.d.ts +29 -0
- package/types/lib/inventory/mcp.d.ts.map +1 -0
- package/types/lib/inventory/mcpConfigParser.d.ts +20 -0
- package/types/lib/inventory/mcpConfigParser.d.ts.map +1 -0
- package/types/lib/inventory/mcpDiscovery.d.ts +33 -0
- package/types/lib/inventory/mcpDiscovery.d.ts.map +1 -0
- package/types/lib/inventory/mcpPinning.d.ts +11 -0
- package/types/lib/inventory/mcpPinning.d.ts.map +1 -0
- package/types/lib/inventory/osPackageResolver.d.ts +49 -0
- package/types/lib/inventory/osPackageResolver.d.ts.map +1 -0
- package/types/lib/inventory/osinfo.d.ts +201 -0
- package/types/lib/inventory/osinfo.d.ts.map +1 -0
- package/types/lib/inventory/osqueryTransform.d.ts +84 -0
- package/types/lib/inventory/osqueryTransform.d.ts.map +1 -0
- package/types/lib/inventory/plugins.d.ts +58 -0
- package/types/lib/inventory/plugins.d.ts.map +1 -0
- package/types/lib/inventory/protobom.d.ts +71 -0
- package/types/lib/inventory/protobom.d.ts.map +1 -0
- package/types/lib/inventory/protobomLoader.d.ts +17 -0
- package/types/lib/inventory/protobomLoader.d.ts.map +1 -0
- package/types/lib/inventory/provenanceUtils.d.ts +98 -0
- package/types/lib/inventory/provenanceUtils.d.ts.map +1 -0
- package/types/lib/inventory/purl.d.ts +313 -0
- package/types/lib/inventory/purl.d.ts.map +1 -0
- package/types/lib/inventory/rustFormulationParser.d.ts +17 -0
- package/types/lib/inventory/rustFormulationParser.d.ts.map +1 -0
- package/types/lib/inventory/sbomDocument.d.ts +59 -0
- package/types/lib/inventory/sbomDocument.d.ts.map +1 -0
- package/types/lib/inventory/source.d.ts +163 -0
- package/types/lib/inventory/source.d.ts.map +1 -0
- package/types/lib/inventory/spdx.d.ts +66 -0
- package/types/lib/inventory/spdx.d.ts.map +1 -0
- package/types/lib/inventory/spdxExpression.d.ts +58 -0
- package/types/lib/inventory/spdxExpression.d.ts.map +1 -0
- package/types/lib/inventory/spdxUtils.d.ts +12 -0
- package/types/lib/inventory/spdxUtils.d.ts.map +1 -0
- package/types/lib/inventory/table.d.ts +22 -0
- package/types/lib/inventory/table.d.ts.map +1 -0
- package/types/lib/inventory/traceRunner.d.ts +80 -0
- package/types/lib/inventory/traceRunner.d.ts.map +1 -0
- package/types/lib/inventory/unicodeScan.d.ts +46 -0
- package/types/lib/inventory/unicodeScan.d.ts.map +1 -0
- package/types/lib/managers/binary.d.ts +147 -0
- package/types/lib/managers/binary.d.ts.map +1 -0
- package/types/lib/managers/containerutils.d.ts +30 -0
- package/types/lib/managers/containerutils.d.ts.map +1 -0
- package/types/lib/managers/docker.d.ts +157 -0
- package/types/lib/managers/docker.d.ts.map +1 -0
- package/types/lib/managers/dockerConnection.d.ts +42 -0
- package/types/lib/managers/dockerConnection.d.ts.map +1 -0
- package/types/lib/managers/oci.d.ts +21 -0
- package/types/lib/managers/oci.d.ts.map +1 -0
- package/types/lib/managers/piptree.d.ts +13 -0
- package/types/lib/managers/piptree.d.ts.map +1 -0
- package/types/lib/parsers/cmakeCache.d.ts +70 -0
- package/types/lib/parsers/cmakeCache.d.ts.map +1 -0
- package/types/lib/parsers/gguf.d.ts +39 -0
- package/types/lib/parsers/gguf.d.ts.map +1 -0
- package/types/lib/parsers/gitAiNotes.d.ts +15 -0
- package/types/lib/parsers/gitAiNotes.d.ts.map +1 -0
- package/types/lib/parsers/gitmodules.d.ts +88 -0
- package/types/lib/parsers/gitmodules.d.ts.map +1 -0
- package/types/lib/parsers/htmlExtract.d.ts +34 -0
- package/types/lib/parsers/htmlExtract.d.ts.map +1 -0
- package/types/lib/parsers/huggingfaceManifest.d.ts +153 -0
- package/types/lib/parsers/huggingfaceManifest.d.ts.map +1 -0
- package/types/lib/parsers/huggingfaceUtils.d.ts +155 -0
- package/types/lib/parsers/huggingfaceUtils.d.ts.map +1 -0
- package/types/lib/parsers/iri.d.ts +68 -0
- package/types/lib/parsers/iri.d.ts.map +1 -0
- package/types/lib/parsers/npmrc.d.ts +33 -0
- package/types/lib/parsers/npmrc.d.ts.map +1 -0
- package/types/lib/parsers/ollama.d.ts +22 -0
- package/types/lib/parsers/ollama.d.ts.map +1 -0
- package/types/lib/parsers/xml.d.ts +47 -0
- package/types/lib/parsers/xml.d.ts.map +1 -0
- package/types/lib/server/server.d.ts +51 -0
- package/types/lib/server/server.d.ts.map +1 -0
- package/types/lib/stages/postgen/annotator.d.ts +36 -0
- package/types/lib/stages/postgen/annotator.d.ts.map +1 -0
- package/types/lib/stages/postgen/auditBom.d.ts +92 -0
- package/types/lib/stages/postgen/auditBom.d.ts.map +1 -0
- package/types/lib/stages/postgen/postgen.d.ts +59 -0
- package/types/lib/stages/postgen/postgen.d.ts.map +1 -0
- package/types/lib/stages/postgen/ruleEngine.d.ts +18 -0
- package/types/lib/stages/postgen/ruleEngine.d.ts.map +1 -0
- package/types/lib/stages/postgen/sortBom.d.ts +34 -0
- package/types/lib/stages/postgen/sortBom.d.ts.map +1 -0
- package/types/lib/stages/postgen/spdxConverter.d.ts +11 -0
- package/types/lib/stages/postgen/spdxConverter.d.ts.map +1 -0
- package/types/lib/stages/postgen/specVersionCompat.d.ts +71 -0
- package/types/lib/stages/postgen/specVersionCompat.d.ts.map +1 -0
- package/types/lib/stages/pregen/envAudit.d.ts +14 -0
- package/types/lib/stages/pregen/envAudit.d.ts.map +1 -0
- package/types/lib/stages/pregen/pregen.d.ts +59 -0
- package/types/lib/stages/pregen/pregen.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/arborist/index.d.ts +47 -0
- package/types/lib/third-party/arborist/lib/arborist/index.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/arborist/load-actual.d.ts +4 -0
- package/types/lib/third-party/arborist/lib/arborist/load-actual.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/arborist/load-virtual.d.ts +4 -0
- package/types/lib/third-party/arborist/lib/arborist/load-virtual.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/bin-links.d.ts +18 -0
- package/types/lib/third-party/arborist/lib/bin-links.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/calc-dep-flags.d.ts +3 -0
- package/types/lib/third-party/arborist/lib/calc-dep-flags.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/case-insensitive-map.d.ts +9 -0
- package/types/lib/third-party/arborist/lib/case-insensitive-map.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/consistent-resolve.d.ts +3 -0
- package/types/lib/third-party/arborist/lib/consistent-resolve.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/debug.d.ts +3 -0
- package/types/lib/third-party/arborist/lib/debug.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/dep-valid.d.ts +3 -0
- package/types/lib/third-party/arborist/lib/dep-valid.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/edge.d.ts +46 -0
- package/types/lib/third-party/arborist/lib/edge.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/from-path.d.ts +3 -0
- package/types/lib/third-party/arborist/lib/from-path.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/gather-dep-set.d.ts +3 -0
- package/types/lib/third-party/arborist/lib/gather-dep-set.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/index.d.ts +3 -0
- package/types/lib/third-party/arborist/lib/index.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/inventory.d.ts +14 -0
- package/types/lib/third-party/arborist/lib/inventory.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/link.d.ts +18 -0
- package/types/lib/third-party/arborist/lib/link.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/node.d.ts +112 -0
- package/types/lib/third-party/arborist/lib/node.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/npm-extension.d.ts +18 -0
- package/types/lib/third-party/arborist/lib/npm-extension.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/override-resolves.d.ts +3 -0
- package/types/lib/third-party/arborist/lib/override-resolves.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/override-set.d.ts +27 -0
- package/types/lib/third-party/arborist/lib/override-set.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/package-extensions.d.ts +36 -0
- package/types/lib/third-party/arborist/lib/package-extensions.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/printable.d.ts +3 -0
- package/types/lib/third-party/arborist/lib/printable.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/proc-log.d.ts +20 -0
- package/types/lib/third-party/arborist/lib/proc-log.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/realpath.d.ts +3 -0
- package/types/lib/third-party/arborist/lib/realpath.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/relpath.d.ts +3 -0
- package/types/lib/third-party/arborist/lib/relpath.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/shrinkwrap.d.ts +54 -0
- package/types/lib/third-party/arborist/lib/shrinkwrap.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/spec-from-lock.d.ts +3 -0
- package/types/lib/third-party/arborist/lib/spec-from-lock.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/tree-check.d.ts +3 -0
- package/types/lib/third-party/arborist/lib/tree-check.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/validate-npm-package-name.d.ts +13 -0
- package/types/lib/third-party/arborist/lib/validate-npm-package-name.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/version-from-tgz.d.ts +6 -0
- package/types/lib/third-party/arborist/lib/version-from-tgz.d.ts.map +1 -0
- package/types/lib/third-party/arborist/lib/yarn-lock.d.ts +35 -0
- package/types/lib/third-party/arborist/lib/yarn-lock.d.ts.map +1 -0
- package/types/lib/validator/bomValidator.d.ts +40 -0
- package/types/lib/validator/bomValidator.d.ts.map +1 -0
- package/types/lib/validator/complianceEngine.d.ts +72 -0
- package/types/lib/validator/complianceEngine.d.ts.map +1 -0
- package/types/lib/validator/complianceRules.d.ts +61 -0
- package/types/lib/validator/complianceRules.d.ts.map +1 -0
- package/types/lib/validator/index.d.ts +101 -0
- package/types/lib/validator/index.d.ts.map +1 -0
- package/types/lib/validator/reporters/annotations.d.ts +37 -0
- package/types/lib/validator/reporters/annotations.d.ts.map +1 -0
- package/types/lib/validator/reporters/console.d.ts +34 -0
- package/types/lib/validator/reporters/console.d.ts.map +1 -0
- package/types/lib/validator/reporters/index.d.ts +30 -0
- package/types/lib/validator/reporters/index.d.ts.map +1 -0
- package/types/lib/validator/reporters/json.d.ts +11 -0
- package/types/lib/validator/reporters/json.d.ts.map +1 -0
- package/types/lib/validator/reporters/sarif.d.ts +22 -0
- package/types/lib/validator/reporters/sarif.d.ts.map +1 -0
- package/mod.d.ts +0 -7
- package/mod.js +0 -22
|
@@ -0,0 +1,1807 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { cpus } from "node:os";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
|
|
5
|
+
import { DEBUG_MODE } from "../core/activity.js";
|
|
6
|
+
import {
|
|
7
|
+
getTmpDir,
|
|
8
|
+
safeExistsSync,
|
|
9
|
+
safeMkdtempSync,
|
|
10
|
+
safeRmSync,
|
|
11
|
+
safeSpawnSync,
|
|
12
|
+
} from "../core/fs.js";
|
|
13
|
+
import { dirNameStr } from "../core/paths.js";
|
|
14
|
+
import { resolvePluginBinary } from "../inventory/plugins.js";
|
|
15
|
+
|
|
16
|
+
const GO_LANGUAGES = new Set(["go", "golang"]);
|
|
17
|
+
const GOLEM_CALLGRAPH_MODES = new Set(["none", "static", "cha", "rta", "vta"]);
|
|
18
|
+
const GOLEM_DATAFLOW_MODES = new Set(["none", "security", "crypto", "all"]);
|
|
19
|
+
const GOLEM_DATAFLOW_CALLGRAPH_MODES = new Set([
|
|
20
|
+
"none",
|
|
21
|
+
"static",
|
|
22
|
+
"cha",
|
|
23
|
+
"rta",
|
|
24
|
+
"vta",
|
|
25
|
+
]);
|
|
26
|
+
const GOLEM_CRYPTO_OIDS = JSON.parse(
|
|
27
|
+
readFileSync(join(dirNameStr, "data", "crypto-oid.json"), "utf-8"),
|
|
28
|
+
);
|
|
29
|
+
const GOLEM_CRYPTO_PRIMITIVES = new Set([
|
|
30
|
+
"drbg",
|
|
31
|
+
"mac",
|
|
32
|
+
"block-cipher",
|
|
33
|
+
"stream-cipher",
|
|
34
|
+
"signature",
|
|
35
|
+
"hash",
|
|
36
|
+
"pke",
|
|
37
|
+
"xof",
|
|
38
|
+
"kdf",
|
|
39
|
+
"key-agree",
|
|
40
|
+
"kem",
|
|
41
|
+
"ae",
|
|
42
|
+
"combiner",
|
|
43
|
+
"other",
|
|
44
|
+
"unknown",
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
function golemBin() {
|
|
48
|
+
return resolvePluginBinary("golem");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function appendUniqueProperty(properties, name, value) {
|
|
52
|
+
if (value === undefined || value === null || value === "") {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const propertyValue = String(value);
|
|
56
|
+
if (
|
|
57
|
+
!properties.some(
|
|
58
|
+
(property) => property.name === name && property.value === propertyValue,
|
|
59
|
+
)
|
|
60
|
+
) {
|
|
61
|
+
properties.push({ name, value: propertyValue });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function addSetValue(map, key, value) {
|
|
66
|
+
if (!key || !value) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
map[key] ??= new Set();
|
|
70
|
+
map[key].add(value);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function addPropertyValue(map, key, name, value) {
|
|
74
|
+
if (!key || value === undefined || value === null || value === "") {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
map[key] ??= [];
|
|
78
|
+
appendUniqueProperty(map[key], name, value);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function rangeLocation(range) {
|
|
82
|
+
const start = range?.start;
|
|
83
|
+
if (!start?.filename) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
if (start.line && start.line > 0) {
|
|
87
|
+
return `${start.filename}#${start.line}`;
|
|
88
|
+
}
|
|
89
|
+
return start.filename;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function positionLocation(position) {
|
|
93
|
+
if (!position?.filename) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
if (position.line && position.line > 0) {
|
|
97
|
+
return `${position.filename}#${position.line}`;
|
|
98
|
+
}
|
|
99
|
+
return position.filename;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function purlWithoutVersion(purl) {
|
|
103
|
+
return purl?.split("?")[0].split("#")[0].split("@")[0];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function modulePurl(module) {
|
|
107
|
+
return module?.purl || module?.PURL;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function createPurlAliasMap(components = []) {
|
|
111
|
+
const purlAliasMap = new Map();
|
|
112
|
+
for (const component of components) {
|
|
113
|
+
if (!component?.purl) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
purlAliasMap.set(component.purl, component.purl);
|
|
117
|
+
const noVersionPurl = purlWithoutVersion(component.purl);
|
|
118
|
+
if (noVersionPurl && !purlAliasMap.has(noVersionPurl)) {
|
|
119
|
+
purlAliasMap.set(noVersionPurl, component.purl);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return purlAliasMap;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function resolveComponentPurl(purl, purlAliasMap) {
|
|
126
|
+
if (!purl) {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
return purlAliasMap.get(purl) || purlAliasMap.get(purlWithoutVersion(purl));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function addResolvedPurl(purls, purl, purlAliasMap) {
|
|
133
|
+
const resolvedPurl = resolveComponentPurl(purl, purlAliasMap);
|
|
134
|
+
if (resolvedPurl) {
|
|
135
|
+
purls.add(resolvedPurl);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function addResolvedPurls(purls, values, purlAliasMap) {
|
|
140
|
+
for (const value of values || []) {
|
|
141
|
+
addResolvedPurl(purls, value, purlAliasMap);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function symbolModule(symbol, modules = []) {
|
|
146
|
+
if (!symbol) {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
let match;
|
|
150
|
+
for (const module of modules) {
|
|
151
|
+
if (
|
|
152
|
+
module?.path &&
|
|
153
|
+
(symbol === module.path || symbol.startsWith(`${module.path}.`)) &&
|
|
154
|
+
(!match || module.path.length > match.path.length)
|
|
155
|
+
) {
|
|
156
|
+
match = module;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return match;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function frameFromUsage(usage) {
|
|
163
|
+
const start = usage?.range?.start;
|
|
164
|
+
if (!start?.filename) {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
package: usage.enclosing?.id?.split("|")[0] || "",
|
|
169
|
+
module: usage.enclosing?.kind || "",
|
|
170
|
+
function: usage.enclosing?.name || "",
|
|
171
|
+
line: start.line || undefined,
|
|
172
|
+
column: start.column || undefined,
|
|
173
|
+
fullFilename: start.filename,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function frameFromEdge(edge) {
|
|
178
|
+
const position = edge?.position;
|
|
179
|
+
if (!position?.filename) {
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
package: edge.sourceId?.split(".").slice(0, -1).join(".") || "",
|
|
184
|
+
module: edge.callType || "",
|
|
185
|
+
function: edge.sourceName || edge.sourceId || "",
|
|
186
|
+
line: position.line || undefined,
|
|
187
|
+
column: position.column || undefined,
|
|
188
|
+
fullFilename: position.filename,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function frameFromCallGraphNode(node, fallbackName = "") {
|
|
193
|
+
const position = node?.position;
|
|
194
|
+
if (!position?.filename) {
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
package: node.packagePath || fallbackName.split(".").slice(0, -1).join("."),
|
|
199
|
+
module: node.kind || "",
|
|
200
|
+
function: node.label || node.name || fallbackName || "",
|
|
201
|
+
line: position.line || undefined,
|
|
202
|
+
column: position.column || undefined,
|
|
203
|
+
fullFilename: position.filename,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function frameLocationKey(frame) {
|
|
208
|
+
if (!frame?.fullFilename) {
|
|
209
|
+
return undefined;
|
|
210
|
+
}
|
|
211
|
+
return `${frame.fullFilename}#${frame.line || ""}#${frame.column || ""}`;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function dedupeFrames(frames = []) {
|
|
215
|
+
const seen = new Set();
|
|
216
|
+
const out = [];
|
|
217
|
+
for (const frame of frames) {
|
|
218
|
+
const key = frameLocationKey(frame);
|
|
219
|
+
if (!key || seen.has(key)) {
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
seen.add(key);
|
|
223
|
+
out.push(frame);
|
|
224
|
+
}
|
|
225
|
+
return out;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function frameFromDataFlowNode(node, fallbackFunction) {
|
|
229
|
+
const position = node?.position;
|
|
230
|
+
if (!position?.filename) {
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
const functionName = node.function || fallbackFunction || "";
|
|
234
|
+
return {
|
|
235
|
+
package: node.packagePath || functionName.split(".").slice(0, -1).join("."),
|
|
236
|
+
module: node.kind || node.category || "",
|
|
237
|
+
function: functionName || node.symbol || node.name || "",
|
|
238
|
+
line: position.line || undefined,
|
|
239
|
+
column: position.column || undefined,
|
|
240
|
+
fullFilename: position.filename,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function addFrame(dataFlowFrames, purl, frame) {
|
|
245
|
+
if (!purl || !frame) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
dataFlowFrames[purl] ??= [];
|
|
249
|
+
dataFlowFrames[purl].push([frame]);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function addCountProperty(properties, name, count) {
|
|
253
|
+
if (count && count > 0) {
|
|
254
|
+
appendUniqueProperty(properties, name, count);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function normalizedPositiveInteger(value) {
|
|
259
|
+
const intValue = Number.parseInt(value, 10);
|
|
260
|
+
if (Number.isFinite(intValue) && intValue > 0) {
|
|
261
|
+
return intValue;
|
|
262
|
+
}
|
|
263
|
+
return undefined;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function sortedCsv(values) {
|
|
267
|
+
const filteredValues = [...new Set((values || []).filter(Boolean))].sort();
|
|
268
|
+
return filteredValues.length ? filteredValues.join(",") : undefined;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function incrementNestedCount(map, key, name) {
|
|
272
|
+
if (!key || !name) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
map[key] ??= {};
|
|
276
|
+
map[key][name] = (map[key][name] || 0) + 1;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function incrementCount(map, key) {
|
|
280
|
+
if (!key) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
map[key] = (map[key] || 0) + 1;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function isCryptoDataFlowSlice(slice) {
|
|
287
|
+
return [
|
|
288
|
+
slice?.sourceCategory,
|
|
289
|
+
slice?.sinkCategory,
|
|
290
|
+
slice?.ruleId,
|
|
291
|
+
slice?.ruleName,
|
|
292
|
+
...(slice?.taintKinds || []),
|
|
293
|
+
]
|
|
294
|
+
.filter(Boolean)
|
|
295
|
+
.some((value) => String(value).toLowerCase().includes("crypto"));
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function cryptoBomRef(kind, name, version) {
|
|
299
|
+
return `crypto/${kind}/${encodeURIComponent(name)}@${encodeURIComponent(version || name)}`;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function safeCryptoPrimitive(primitive) {
|
|
303
|
+
if (GOLEM_CRYPTO_PRIMITIVES.has(primitive)) {
|
|
304
|
+
return primitive;
|
|
305
|
+
}
|
|
306
|
+
return primitive ? "other" : undefined;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function cryptoSourceLocation(item) {
|
|
310
|
+
const start = item?.range?.start;
|
|
311
|
+
if (!start?.filename) {
|
|
312
|
+
return undefined;
|
|
313
|
+
}
|
|
314
|
+
return `${start.filename}:${start.line || 0}:${start.column || 0}`;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function appendCryptoComponentProperty(component, name, value) {
|
|
318
|
+
component.properties ??= [];
|
|
319
|
+
appendUniqueProperty(component.properties, name, value);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function mergeCryptoComponent(componentsByRef, component, item) {
|
|
323
|
+
const existing = componentsByRef.get(component["bom-ref"]);
|
|
324
|
+
if (!existing) {
|
|
325
|
+
componentsByRef.set(component["bom-ref"], component);
|
|
326
|
+
appendCryptoComponentProperty(
|
|
327
|
+
component,
|
|
328
|
+
"cdx:golem:crypto:sourceLocation",
|
|
329
|
+
cryptoSourceLocation(item),
|
|
330
|
+
);
|
|
331
|
+
return component;
|
|
332
|
+
}
|
|
333
|
+
appendCryptoComponentProperty(
|
|
334
|
+
existing,
|
|
335
|
+
"cdx:golem:crypto:sourceLocation",
|
|
336
|
+
cryptoSourceLocation(item),
|
|
337
|
+
);
|
|
338
|
+
return existing;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function cryptoAlgorithmComponent(asset) {
|
|
342
|
+
const algorithmMetadata = GOLEM_CRYPTO_OIDS[asset.name];
|
|
343
|
+
const oid = asset.oid || algorithmMetadata?.oid;
|
|
344
|
+
if (!oid) {
|
|
345
|
+
return undefined;
|
|
346
|
+
}
|
|
347
|
+
const primitive = safeCryptoPrimitive(asset.primitive);
|
|
348
|
+
const component = {
|
|
349
|
+
type: "cryptographic-asset",
|
|
350
|
+
name: asset.name,
|
|
351
|
+
"bom-ref": cryptoBomRef("algorithm", asset.name, oid),
|
|
352
|
+
description:
|
|
353
|
+
algorithmMetadata?.description ||
|
|
354
|
+
`${asset.primitive || "cryptographic"} algorithm detected by golem`,
|
|
355
|
+
cryptoProperties: {
|
|
356
|
+
assetType: "algorithm",
|
|
357
|
+
oid,
|
|
358
|
+
...(primitive ? { algorithmProperties: { primitive } } : {}),
|
|
359
|
+
},
|
|
360
|
+
properties: [],
|
|
361
|
+
};
|
|
362
|
+
appendCryptoComponentProperty(
|
|
363
|
+
component,
|
|
364
|
+
"cdx:golem:crypto:strength",
|
|
365
|
+
asset.strength,
|
|
366
|
+
);
|
|
367
|
+
appendCryptoComponentProperty(
|
|
368
|
+
component,
|
|
369
|
+
"cdx:golem:crypto:symbol",
|
|
370
|
+
asset.symbol,
|
|
371
|
+
);
|
|
372
|
+
appendCryptoComponentProperty(
|
|
373
|
+
component,
|
|
374
|
+
"cdx:golem:crypto:usageScope",
|
|
375
|
+
asset.usageScope,
|
|
376
|
+
);
|
|
377
|
+
return component;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function cryptoCertificateComponent(asset) {
|
|
381
|
+
const component = {
|
|
382
|
+
type: "cryptographic-asset",
|
|
383
|
+
name: asset.name || "X.509 certificate",
|
|
384
|
+
"bom-ref": cryptoBomRef(
|
|
385
|
+
"certificate",
|
|
386
|
+
asset.name || "X.509 certificate",
|
|
387
|
+
"x509",
|
|
388
|
+
),
|
|
389
|
+
description: "Certificate asset detected by golem source analysis",
|
|
390
|
+
cryptoProperties: {
|
|
391
|
+
assetType: "certificate",
|
|
392
|
+
algorithmProperties: { primitive: "unknown" },
|
|
393
|
+
},
|
|
394
|
+
properties: [],
|
|
395
|
+
};
|
|
396
|
+
appendCryptoComponentProperty(
|
|
397
|
+
component,
|
|
398
|
+
"cdx:golem:crypto:symbol",
|
|
399
|
+
asset.symbol,
|
|
400
|
+
);
|
|
401
|
+
appendCryptoComponentProperty(
|
|
402
|
+
component,
|
|
403
|
+
"cdx:golem:crypto:usageScope",
|
|
404
|
+
asset.usageScope,
|
|
405
|
+
);
|
|
406
|
+
return component;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function cryptoProtocolComponent(protocol) {
|
|
410
|
+
const protocolType = protocol.type || "unknown";
|
|
411
|
+
const component = {
|
|
412
|
+
type: "cryptographic-asset",
|
|
413
|
+
name: protocol.name || protocolType.toUpperCase(),
|
|
414
|
+
"bom-ref": cryptoBomRef(
|
|
415
|
+
"protocol",
|
|
416
|
+
protocol.name || protocolType,
|
|
417
|
+
protocol.version || protocolType,
|
|
418
|
+
),
|
|
419
|
+
description: "Cryptographic protocol detected by golem source analysis",
|
|
420
|
+
cryptoProperties: {
|
|
421
|
+
assetType: "protocol",
|
|
422
|
+
protocolProperties: {
|
|
423
|
+
type: ["tls", "ssh", "ipsec", "ike", "sstp", "wpa"].includes(
|
|
424
|
+
protocolType,
|
|
425
|
+
)
|
|
426
|
+
? protocolType
|
|
427
|
+
: "other",
|
|
428
|
+
...(protocol.version ? { version: protocol.version } : {}),
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
properties: [],
|
|
432
|
+
};
|
|
433
|
+
appendCryptoComponentProperty(
|
|
434
|
+
component,
|
|
435
|
+
"cdx:golem:crypto:symbol",
|
|
436
|
+
protocol.symbol,
|
|
437
|
+
);
|
|
438
|
+
appendCryptoComponentProperty(
|
|
439
|
+
component,
|
|
440
|
+
"cdx:golem:crypto:usageScope",
|
|
441
|
+
protocol.usageScope,
|
|
442
|
+
);
|
|
443
|
+
return component;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function cryptoMaterialComponent(material) {
|
|
447
|
+
const materialType = material.type || "unknown";
|
|
448
|
+
const component = {
|
|
449
|
+
type: "cryptographic-asset",
|
|
450
|
+
name: material.name || materialType,
|
|
451
|
+
"bom-ref": cryptoBomRef(
|
|
452
|
+
"material",
|
|
453
|
+
material.name || materialType,
|
|
454
|
+
materialType,
|
|
455
|
+
),
|
|
456
|
+
description:
|
|
457
|
+
"Related cryptographic material indicator detected by golem source analysis; raw values are not emitted",
|
|
458
|
+
cryptoProperties: {
|
|
459
|
+
assetType: "related-crypto-material",
|
|
460
|
+
relatedCryptoMaterialProperties: { type: materialType },
|
|
461
|
+
},
|
|
462
|
+
properties: [],
|
|
463
|
+
};
|
|
464
|
+
appendCryptoComponentProperty(
|
|
465
|
+
component,
|
|
466
|
+
"cdx:golem:crypto:symbol",
|
|
467
|
+
material.symbol,
|
|
468
|
+
);
|
|
469
|
+
appendCryptoComponentProperty(
|
|
470
|
+
component,
|
|
471
|
+
"cdx:golem:crypto:usageScope",
|
|
472
|
+
material.usageScope,
|
|
473
|
+
);
|
|
474
|
+
return component;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
function addScopedProperties(componentPropertiesMap, purl, scopeCounts = {}) {
|
|
478
|
+
const scopes = Object.keys(scopeCounts).filter(
|
|
479
|
+
(scope) => scopeCounts[scope] > 0,
|
|
480
|
+
);
|
|
481
|
+
if (!purl || !scopes.length) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
addPropertyValue(
|
|
485
|
+
componentPropertiesMap,
|
|
486
|
+
purl,
|
|
487
|
+
"cdx:golem:usageScopes",
|
|
488
|
+
sortedCsv(scopes),
|
|
489
|
+
);
|
|
490
|
+
addPropertyValue(
|
|
491
|
+
componentPropertiesMap,
|
|
492
|
+
purl,
|
|
493
|
+
"cdx:golem:testOnly",
|
|
494
|
+
scopes.length > 0 && scopes.every((scope) => scope !== "runtime"),
|
|
495
|
+
);
|
|
496
|
+
for (const [scope, count] of Object.entries(scopeCounts)) {
|
|
497
|
+
addCountProperty(
|
|
498
|
+
(componentPropertiesMap[purl] ??= []),
|
|
499
|
+
`cdx:golem:${scope}UsageCount`,
|
|
500
|
+
count,
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function addOccurrenceKindProperties(
|
|
506
|
+
componentPropertiesMap,
|
|
507
|
+
purl,
|
|
508
|
+
kindCounts = {},
|
|
509
|
+
) {
|
|
510
|
+
const kinds = Object.keys(kindCounts).filter((kind) => kindCounts[kind] > 0);
|
|
511
|
+
if (!purl || !kinds.length) {
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
addPropertyValue(
|
|
515
|
+
componentPropertiesMap,
|
|
516
|
+
purl,
|
|
517
|
+
"cdx:golem:occurrenceEvidenceKinds",
|
|
518
|
+
sortedCsv(kinds),
|
|
519
|
+
);
|
|
520
|
+
for (const [kind, count] of Object.entries(kindCounts)) {
|
|
521
|
+
addCountProperty(
|
|
522
|
+
(componentPropertiesMap[purl] ??= []),
|
|
523
|
+
`cdx:golem:${kind}OccurrenceCount`,
|
|
524
|
+
count,
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function addMetadataProperties(properties, golemReport = {}) {
|
|
530
|
+
appendUniqueProperty(
|
|
531
|
+
properties,
|
|
532
|
+
"cdx:golem:toolVersion",
|
|
533
|
+
golemReport.tool?.version,
|
|
534
|
+
);
|
|
535
|
+
appendUniqueProperty(
|
|
536
|
+
properties,
|
|
537
|
+
"cdx:golem:callGraphMode",
|
|
538
|
+
golemReport.callGraph?.mode || golemReport.options?.callGraphMode,
|
|
539
|
+
);
|
|
540
|
+
appendUniqueProperty(
|
|
541
|
+
properties,
|
|
542
|
+
"cdx:golem:dataFlowMode",
|
|
543
|
+
golemReport.dataFlow?.mode || golemReport.options?.dataFlowMode,
|
|
544
|
+
);
|
|
545
|
+
appendUniqueProperty(
|
|
546
|
+
properties,
|
|
547
|
+
"cdx:golem:dataFlowCallGraphMode",
|
|
548
|
+
golemReport.options?.dataFlowCallGraphMode,
|
|
549
|
+
);
|
|
550
|
+
appendUniqueProperty(
|
|
551
|
+
properties,
|
|
552
|
+
"cdx:golem:noRecurse",
|
|
553
|
+
golemReport.options?.noRecurse,
|
|
554
|
+
);
|
|
555
|
+
appendUniqueProperty(
|
|
556
|
+
properties,
|
|
557
|
+
"cdx:golem:includeAllFlows",
|
|
558
|
+
golemReport.options?.includeAllFlows,
|
|
559
|
+
);
|
|
560
|
+
appendUniqueProperty(
|
|
561
|
+
properties,
|
|
562
|
+
"cdx:golem:dataFlowPacks",
|
|
563
|
+
sortedCsv(golemReport.options?.dataFlowPacks),
|
|
564
|
+
);
|
|
565
|
+
addCountProperty(
|
|
566
|
+
properties,
|
|
567
|
+
"cdx:golem:packageCount",
|
|
568
|
+
golemReport.stats?.packageCount,
|
|
569
|
+
);
|
|
570
|
+
addCountProperty(
|
|
571
|
+
properties,
|
|
572
|
+
"cdx:golem:moduleCount",
|
|
573
|
+
golemReport.stats?.moduleCount,
|
|
574
|
+
);
|
|
575
|
+
addCountProperty(
|
|
576
|
+
properties,
|
|
577
|
+
"cdx:golem:fileCount",
|
|
578
|
+
golemReport.stats?.fileCount,
|
|
579
|
+
);
|
|
580
|
+
addCountProperty(
|
|
581
|
+
properties,
|
|
582
|
+
"cdx:golem:generatedFileCount",
|
|
583
|
+
golemReport.stats?.generatedFileCount,
|
|
584
|
+
);
|
|
585
|
+
addCountProperty(
|
|
586
|
+
properties,
|
|
587
|
+
"cdx:golem:importCount",
|
|
588
|
+
golemReport.stats?.importCount,
|
|
589
|
+
);
|
|
590
|
+
addCountProperty(
|
|
591
|
+
properties,
|
|
592
|
+
"cdx:golem:declarationCount",
|
|
593
|
+
golemReport.stats?.declarationCount,
|
|
594
|
+
);
|
|
595
|
+
addCountProperty(
|
|
596
|
+
properties,
|
|
597
|
+
"cdx:golem:usageCount",
|
|
598
|
+
golemReport.stats?.usageCount,
|
|
599
|
+
);
|
|
600
|
+
for (const scope of ["runtime", "test", "benchmark", "fuzz", "example"]) {
|
|
601
|
+
addCountProperty(
|
|
602
|
+
properties,
|
|
603
|
+
`cdx:golem:${scope}UsageCount`,
|
|
604
|
+
golemReport.stats?.[`${scope}UsageCount`],
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
addCountProperty(
|
|
608
|
+
properties,
|
|
609
|
+
"cdx:golem:buildDirectiveCount",
|
|
610
|
+
golemReport.stats?.buildDirectiveCount,
|
|
611
|
+
);
|
|
612
|
+
addCountProperty(
|
|
613
|
+
properties,
|
|
614
|
+
"cdx:golem:nativeArtifactCount",
|
|
615
|
+
golemReport.stats?.nativeArtifactCount,
|
|
616
|
+
);
|
|
617
|
+
addCountProperty(
|
|
618
|
+
properties,
|
|
619
|
+
"cdx:golem:securitySignalCount",
|
|
620
|
+
golemReport.stats?.securitySignalCount,
|
|
621
|
+
);
|
|
622
|
+
addCountProperty(
|
|
623
|
+
properties,
|
|
624
|
+
"cdx:golem:dataFlowSourceCount",
|
|
625
|
+
golemReport.stats?.dataFlowSourceCount,
|
|
626
|
+
);
|
|
627
|
+
addCountProperty(
|
|
628
|
+
properties,
|
|
629
|
+
"cdx:golem:dataFlowSinkCount",
|
|
630
|
+
golemReport.stats?.dataFlowSinkCount,
|
|
631
|
+
);
|
|
632
|
+
addCountProperty(
|
|
633
|
+
properties,
|
|
634
|
+
"cdx:golem:dataFlowSliceCount",
|
|
635
|
+
golemReport.stats?.dataFlowSliceCount,
|
|
636
|
+
);
|
|
637
|
+
addCountProperty(
|
|
638
|
+
properties,
|
|
639
|
+
"cdx:golem:diagnosticCount",
|
|
640
|
+
golemReport.stats?.diagnosticCount,
|
|
641
|
+
);
|
|
642
|
+
addCountProperty(
|
|
643
|
+
properties,
|
|
644
|
+
"cdx:golem:goModReplaceCount",
|
|
645
|
+
golemReport.stats?.goModReplaceCount,
|
|
646
|
+
);
|
|
647
|
+
addCountProperty(
|
|
648
|
+
properties,
|
|
649
|
+
"cdx:golem:goModExcludeCount",
|
|
650
|
+
golemReport.stats?.goModExcludeCount,
|
|
651
|
+
);
|
|
652
|
+
addCountProperty(
|
|
653
|
+
properties,
|
|
654
|
+
"cdx:golem:vendorModuleCount",
|
|
655
|
+
golemReport.stats?.vendorModuleCount,
|
|
656
|
+
);
|
|
657
|
+
addCountProperty(
|
|
658
|
+
properties,
|
|
659
|
+
"cdx:golem:workspaceModuleCount",
|
|
660
|
+
golemReport.stats?.workspaceModuleCount,
|
|
661
|
+
);
|
|
662
|
+
addCountProperty(
|
|
663
|
+
properties,
|
|
664
|
+
"cdx:golem:privateModuleHintCount",
|
|
665
|
+
golemReport.stats?.privateModuleHintCount,
|
|
666
|
+
);
|
|
667
|
+
addCountProperty(
|
|
668
|
+
properties,
|
|
669
|
+
"cdx:golem:licenseFileModuleCount",
|
|
670
|
+
golemReport.stats?.licenseFileModuleCount,
|
|
671
|
+
);
|
|
672
|
+
addCountProperty(
|
|
673
|
+
properties,
|
|
674
|
+
"cdx:golem:callGraphNodeCount",
|
|
675
|
+
golemReport.callGraph?.stats?.nodeCount,
|
|
676
|
+
);
|
|
677
|
+
addCountProperty(
|
|
678
|
+
properties,
|
|
679
|
+
"cdx:golem:callGraphEdgeCount",
|
|
680
|
+
golemReport.callGraph?.stats?.edgeCount,
|
|
681
|
+
);
|
|
682
|
+
addCountProperty(
|
|
683
|
+
properties,
|
|
684
|
+
"cdx:golem:dataFlowNodeCount",
|
|
685
|
+
golemReport.dataFlow?.stats?.nodeCount,
|
|
686
|
+
);
|
|
687
|
+
addCountProperty(
|
|
688
|
+
properties,
|
|
689
|
+
"cdx:golem:dataFlowEdgeCount",
|
|
690
|
+
golemReport.dataFlow?.stats?.edgeCount,
|
|
691
|
+
);
|
|
692
|
+
addCountProperty(
|
|
693
|
+
properties,
|
|
694
|
+
"cdx:golem:dataFlowSummaryCount",
|
|
695
|
+
golemReport.dataFlow?.stats?.summaryCount,
|
|
696
|
+
);
|
|
697
|
+
addCountProperty(
|
|
698
|
+
properties,
|
|
699
|
+
"cdx:golem:dataFlowCandidateFunctionCount",
|
|
700
|
+
golemReport.dataFlow?.stats?.candidateFunctionCount,
|
|
701
|
+
);
|
|
702
|
+
addCountProperty(
|
|
703
|
+
properties,
|
|
704
|
+
"cdx:golem:dataFlowFunctionCount",
|
|
705
|
+
golemReport.dataFlow?.stats?.functionCount,
|
|
706
|
+
);
|
|
707
|
+
addCountProperty(
|
|
708
|
+
properties,
|
|
709
|
+
"cdx:golem:dataFlowSkippedFunctionCount",
|
|
710
|
+
golemReport.dataFlow?.stats?.skippedFunctionCount,
|
|
711
|
+
);
|
|
712
|
+
addCountProperty(
|
|
713
|
+
properties,
|
|
714
|
+
"cdx:golem:dataFlowInstructionCount",
|
|
715
|
+
golemReport.dataFlow?.stats?.instructionCount,
|
|
716
|
+
);
|
|
717
|
+
addCountProperty(
|
|
718
|
+
properties,
|
|
719
|
+
"cdx:golem:dataFlowWorkerCount",
|
|
720
|
+
golemReport.dataFlow?.stats?.workerCount,
|
|
721
|
+
);
|
|
722
|
+
addCountProperty(
|
|
723
|
+
properties,
|
|
724
|
+
"cdx:golem:dataFlowElapsedMillis",
|
|
725
|
+
golemReport.dataFlow?.stats?.elapsedMillis,
|
|
726
|
+
);
|
|
727
|
+
addCountProperty(
|
|
728
|
+
properties,
|
|
729
|
+
"cdx:golem:dataFlowUniqueFlowCount",
|
|
730
|
+
golemReport.dataFlow?.stats?.uniqueFlowCount,
|
|
731
|
+
);
|
|
732
|
+
addCountProperty(
|
|
733
|
+
properties,
|
|
734
|
+
"cdx:golem:dataFlowDuplicateSliceCount",
|
|
735
|
+
golemReport.dataFlow?.stats?.duplicateSliceCount,
|
|
736
|
+
);
|
|
737
|
+
addCountProperty(
|
|
738
|
+
properties,
|
|
739
|
+
"cdx:golem:dataFlowDuplicateGroupCount",
|
|
740
|
+
golemReport.dataFlow?.stats?.duplicateGroupCount,
|
|
741
|
+
);
|
|
742
|
+
addCountProperty(
|
|
743
|
+
properties,
|
|
744
|
+
"cdx:golem:dataFlowMaxPathLength",
|
|
745
|
+
golemReport.dataFlow?.stats?.maxPathLength,
|
|
746
|
+
);
|
|
747
|
+
addCountProperty(
|
|
748
|
+
properties,
|
|
749
|
+
"cdx:golem:dataFlowSanitizedSliceCount",
|
|
750
|
+
golemReport.dataFlow?.stats?.sanitizedSliceCount,
|
|
751
|
+
);
|
|
752
|
+
appendUniqueProperty(
|
|
753
|
+
properties,
|
|
754
|
+
"cdx:golem:dataFlowTruncated",
|
|
755
|
+
golemReport.dataFlow?.stats?.truncated,
|
|
756
|
+
);
|
|
757
|
+
appendUniqueProperty(
|
|
758
|
+
properties,
|
|
759
|
+
"cdx:golem:dataFlowTruncationReasons",
|
|
760
|
+
sortedCsv(golemReport.dataFlow?.stats?.truncationReasons),
|
|
761
|
+
);
|
|
762
|
+
appendUniqueProperty(
|
|
763
|
+
properties,
|
|
764
|
+
"cdx:golem:buildDirectiveKinds",
|
|
765
|
+
sortedCsv(
|
|
766
|
+
(golemReport.buildDirectives || []).map((directive) => directive.kind),
|
|
767
|
+
),
|
|
768
|
+
);
|
|
769
|
+
appendUniqueProperty(
|
|
770
|
+
properties,
|
|
771
|
+
"cdx:golem:nativeArtifactKinds",
|
|
772
|
+
sortedCsv(
|
|
773
|
+
(golemReport.nativeArtifacts || []).map((artifact) => artifact.kind),
|
|
774
|
+
),
|
|
775
|
+
);
|
|
776
|
+
appendUniqueProperty(
|
|
777
|
+
properties,
|
|
778
|
+
"cdx:golem:securitySignalCategories",
|
|
779
|
+
sortedCsv(
|
|
780
|
+
(golemReport.securitySignals || []).map((signal) => signal.category),
|
|
781
|
+
),
|
|
782
|
+
);
|
|
783
|
+
appendUniqueProperty(
|
|
784
|
+
properties,
|
|
785
|
+
"cdx:golem:securitySignalSeverities",
|
|
786
|
+
sortedCsv(
|
|
787
|
+
(golemReport.securitySignals || []).map((signal) => signal.severity),
|
|
788
|
+
),
|
|
789
|
+
);
|
|
790
|
+
appendUniqueProperty(
|
|
791
|
+
properties,
|
|
792
|
+
"cdx:golem:generatorKinds",
|
|
793
|
+
sortedCsv((golemReport.files || []).map((file) => file.generatedBy)),
|
|
794
|
+
);
|
|
795
|
+
appendUniqueProperty(
|
|
796
|
+
properties,
|
|
797
|
+
"cdx:golem:goDirectiveVersion",
|
|
798
|
+
golemReport.supplyChain?.goDirectiveVersion,
|
|
799
|
+
);
|
|
800
|
+
appendUniqueProperty(
|
|
801
|
+
properties,
|
|
802
|
+
"cdx:golem:toolchainDirective",
|
|
803
|
+
golemReport.supplyChain?.toolchainDirective,
|
|
804
|
+
);
|
|
805
|
+
appendUniqueProperty(
|
|
806
|
+
properties,
|
|
807
|
+
"cdx:golem:goWorkPresent",
|
|
808
|
+
golemReport.supplyChain?.goWorkPresent,
|
|
809
|
+
);
|
|
810
|
+
appendUniqueProperty(
|
|
811
|
+
properties,
|
|
812
|
+
"cdx:golem:vendorDirectoryPresent",
|
|
813
|
+
golemReport.supplyChain?.vendorDirectoryPresent,
|
|
814
|
+
);
|
|
815
|
+
addCountProperty(
|
|
816
|
+
properties,
|
|
817
|
+
"cdx:golem:goGenerateCount",
|
|
818
|
+
(golemReport.buildDirectives || []).filter(
|
|
819
|
+
(directive) => directive.kind === "go-generate",
|
|
820
|
+
).length,
|
|
821
|
+
);
|
|
822
|
+
addCountProperty(
|
|
823
|
+
properties,
|
|
824
|
+
"cdx:golem:goEmbedCount",
|
|
825
|
+
(golemReport.buildDirectives || []).filter(
|
|
826
|
+
(directive) => directive.kind === "go-embed",
|
|
827
|
+
).length,
|
|
828
|
+
);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
function addSupplyChainProperties(
|
|
832
|
+
componentPropertiesMap,
|
|
833
|
+
metadataProperties,
|
|
834
|
+
purlAliasMap,
|
|
835
|
+
supplyChain = {},
|
|
836
|
+
) {
|
|
837
|
+
for (const directive of supplyChain.replaces || []) {
|
|
838
|
+
appendUniqueProperty(
|
|
839
|
+
metadataProperties,
|
|
840
|
+
"cdx:golem:replaceModule",
|
|
841
|
+
directive.modulePath,
|
|
842
|
+
);
|
|
843
|
+
appendUniqueProperty(
|
|
844
|
+
metadataProperties,
|
|
845
|
+
"cdx:golem:replaceTargetPathKind",
|
|
846
|
+
directive.targetPathKind,
|
|
847
|
+
);
|
|
848
|
+
appendUniqueProperty(
|
|
849
|
+
metadataProperties,
|
|
850
|
+
"cdx:golem:localReplacementPresent",
|
|
851
|
+
directive.localReplacement,
|
|
852
|
+
);
|
|
853
|
+
}
|
|
854
|
+
for (const directive of supplyChain.excludes || []) {
|
|
855
|
+
appendUniqueProperty(
|
|
856
|
+
metadataProperties,
|
|
857
|
+
"cdx:golem:excludeModule",
|
|
858
|
+
directive.modulePath,
|
|
859
|
+
);
|
|
860
|
+
}
|
|
861
|
+
for (const module of supplyChain.modules || []) {
|
|
862
|
+
const purl = resolveComponentPurl(module.purl || module.PURL, purlAliasMap);
|
|
863
|
+
if (!purl) {
|
|
864
|
+
continue;
|
|
865
|
+
}
|
|
866
|
+
addPropertyValue(
|
|
867
|
+
componentPropertiesMap,
|
|
868
|
+
purl,
|
|
869
|
+
"cdx:golem:vendored",
|
|
870
|
+
module.vendored,
|
|
871
|
+
);
|
|
872
|
+
addPropertyValue(
|
|
873
|
+
componentPropertiesMap,
|
|
874
|
+
purl,
|
|
875
|
+
"cdx:golem:privateModuleCandidate",
|
|
876
|
+
module.privateModuleCandidate,
|
|
877
|
+
);
|
|
878
|
+
addCountProperty(
|
|
879
|
+
(componentPropertiesMap[purl] ??= []),
|
|
880
|
+
"cdx:golem:licenseFileCount",
|
|
881
|
+
module.licenseFiles?.length,
|
|
882
|
+
);
|
|
883
|
+
addPropertyValue(
|
|
884
|
+
componentPropertiesMap,
|
|
885
|
+
purl,
|
|
886
|
+
"cdx:golem:licenseFiles",
|
|
887
|
+
sortedCsv(module.licenseFiles),
|
|
888
|
+
);
|
|
889
|
+
addPropertyValue(
|
|
890
|
+
componentPropertiesMap,
|
|
891
|
+
purl,
|
|
892
|
+
"cdx:golem:replacementModule",
|
|
893
|
+
module.properties?.replacementModule,
|
|
894
|
+
);
|
|
895
|
+
addPropertyValue(
|
|
896
|
+
componentPropertiesMap,
|
|
897
|
+
purl,
|
|
898
|
+
"cdx:golem:localReplacement",
|
|
899
|
+
module.properties?.localReplacement,
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
function addModuleProperties(
|
|
905
|
+
componentPropertiesMap,
|
|
906
|
+
purlAliasMap,
|
|
907
|
+
modules = [],
|
|
908
|
+
) {
|
|
909
|
+
for (const module of modules) {
|
|
910
|
+
const purl = resolveComponentPurl(modulePurl(module), purlAliasMap);
|
|
911
|
+
if (!purl) {
|
|
912
|
+
continue;
|
|
913
|
+
}
|
|
914
|
+
addPropertyValue(
|
|
915
|
+
componentPropertiesMap,
|
|
916
|
+
purl,
|
|
917
|
+
"cdx:golem:modulePath",
|
|
918
|
+
module.path,
|
|
919
|
+
);
|
|
920
|
+
addPropertyValue(
|
|
921
|
+
componentPropertiesMap,
|
|
922
|
+
purl,
|
|
923
|
+
"cdx:golem:goVersion",
|
|
924
|
+
module.goVersion,
|
|
925
|
+
);
|
|
926
|
+
addPropertyValue(
|
|
927
|
+
componentPropertiesMap,
|
|
928
|
+
purl,
|
|
929
|
+
"cdx:golem:mainModule",
|
|
930
|
+
module.main,
|
|
931
|
+
);
|
|
932
|
+
addPropertyValue(
|
|
933
|
+
componentPropertiesMap,
|
|
934
|
+
purl,
|
|
935
|
+
"cdx:golem:replacementModule",
|
|
936
|
+
module.replace?.path,
|
|
937
|
+
);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
function addSignalProperties(
|
|
942
|
+
componentPropertiesMap,
|
|
943
|
+
purlAliasMap,
|
|
944
|
+
golemReport = {},
|
|
945
|
+
) {
|
|
946
|
+
const modules = golemReport.modules || [];
|
|
947
|
+
for (const signal of golemReport.securitySignals || []) {
|
|
948
|
+
const module = symbolModule(signal.packagePath, modules);
|
|
949
|
+
const purl = resolveComponentPurl(modulePurl(module), purlAliasMap);
|
|
950
|
+
if (!purl) {
|
|
951
|
+
continue;
|
|
952
|
+
}
|
|
953
|
+
addPropertyValue(
|
|
954
|
+
componentPropertiesMap,
|
|
955
|
+
purl,
|
|
956
|
+
"cdx:golem:securitySignalCategory",
|
|
957
|
+
signal.category,
|
|
958
|
+
);
|
|
959
|
+
addPropertyValue(
|
|
960
|
+
componentPropertiesMap,
|
|
961
|
+
purl,
|
|
962
|
+
"cdx:golem:securitySignalSeverity",
|
|
963
|
+
signal.severity,
|
|
964
|
+
);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
function addCryptoEvidence(
|
|
969
|
+
componentPropertiesMap,
|
|
970
|
+
metadataProperties,
|
|
971
|
+
purlAliasMap,
|
|
972
|
+
golemReport,
|
|
973
|
+
cryptoComponentsByRef,
|
|
974
|
+
cryptoGeneratePurls,
|
|
975
|
+
) {
|
|
976
|
+
const crypto = golemReport?.crypto;
|
|
977
|
+
if (!crypto) {
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
addCountProperty(
|
|
981
|
+
metadataProperties,
|
|
982
|
+
"cdx:golem:cryptoLibraryCount",
|
|
983
|
+
crypto.libraries?.length,
|
|
984
|
+
);
|
|
985
|
+
addCountProperty(
|
|
986
|
+
metadataProperties,
|
|
987
|
+
"cdx:golem:cryptoAssetCount",
|
|
988
|
+
crypto.assets?.length,
|
|
989
|
+
);
|
|
990
|
+
addCountProperty(
|
|
991
|
+
metadataProperties,
|
|
992
|
+
"cdx:golem:cryptoOperationCount",
|
|
993
|
+
crypto.operations?.length,
|
|
994
|
+
);
|
|
995
|
+
addCountProperty(
|
|
996
|
+
metadataProperties,
|
|
997
|
+
"cdx:golem:cryptoMaterialCount",
|
|
998
|
+
crypto.materials?.length,
|
|
999
|
+
);
|
|
1000
|
+
addCountProperty(
|
|
1001
|
+
metadataProperties,
|
|
1002
|
+
"cdx:golem:cryptoProtocolCount",
|
|
1003
|
+
crypto.protocols?.length,
|
|
1004
|
+
);
|
|
1005
|
+
addCountProperty(
|
|
1006
|
+
metadataProperties,
|
|
1007
|
+
"cdx:golem:cryptoFindingCount",
|
|
1008
|
+
crypto.findings?.length,
|
|
1009
|
+
);
|
|
1010
|
+
appendUniqueProperty(
|
|
1011
|
+
metadataProperties,
|
|
1012
|
+
"cdx:golem:cryptoAlgorithms",
|
|
1013
|
+
sortedCsv(
|
|
1014
|
+
(crypto.assets || []).map((asset) =>
|
|
1015
|
+
asset.assetType === "algorithm" ? asset.name : undefined,
|
|
1016
|
+
),
|
|
1017
|
+
),
|
|
1018
|
+
);
|
|
1019
|
+
appendUniqueProperty(
|
|
1020
|
+
metadataProperties,
|
|
1021
|
+
"cdx:golem:cryptoMaterialTypes",
|
|
1022
|
+
sortedCsv((crypto.materials || []).map((material) => material.type)),
|
|
1023
|
+
);
|
|
1024
|
+
appendUniqueProperty(
|
|
1025
|
+
metadataProperties,
|
|
1026
|
+
"cdx:golem:cryptoProtocols",
|
|
1027
|
+
sortedCsv((crypto.protocols || []).map((protocol) => protocol.type)),
|
|
1028
|
+
);
|
|
1029
|
+
for (const asset of crypto.assets || []) {
|
|
1030
|
+
let component;
|
|
1031
|
+
if (asset.assetType === "algorithm") {
|
|
1032
|
+
component = cryptoAlgorithmComponent(asset);
|
|
1033
|
+
} else if (asset.assetType === "certificate") {
|
|
1034
|
+
component = cryptoCertificateComponent(asset);
|
|
1035
|
+
}
|
|
1036
|
+
if (component) {
|
|
1037
|
+
mergeCryptoComponent(cryptoComponentsByRef, component, asset);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
for (const protocol of crypto.protocols || []) {
|
|
1041
|
+
mergeCryptoComponent(
|
|
1042
|
+
cryptoComponentsByRef,
|
|
1043
|
+
cryptoProtocolComponent(protocol),
|
|
1044
|
+
protocol,
|
|
1045
|
+
);
|
|
1046
|
+
}
|
|
1047
|
+
for (const material of crypto.materials || []) {
|
|
1048
|
+
mergeCryptoComponent(
|
|
1049
|
+
cryptoComponentsByRef,
|
|
1050
|
+
cryptoMaterialComponent(material),
|
|
1051
|
+
material,
|
|
1052
|
+
);
|
|
1053
|
+
}
|
|
1054
|
+
const componentRefByAssetId = new Map();
|
|
1055
|
+
for (const asset of crypto.assets || []) {
|
|
1056
|
+
const component =
|
|
1057
|
+
asset.assetType === "algorithm"
|
|
1058
|
+
? cryptoAlgorithmComponent(asset)
|
|
1059
|
+
: asset.assetType === "certificate"
|
|
1060
|
+
? cryptoCertificateComponent(asset)
|
|
1061
|
+
: undefined;
|
|
1062
|
+
if (component) {
|
|
1063
|
+
componentRefByAssetId.set(asset.id, component["bom-ref"]);
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
const modules = golemReport.modules || [];
|
|
1067
|
+
for (const operation of crypto.operations || []) {
|
|
1068
|
+
const module = symbolModule(operation.packagePath, modules);
|
|
1069
|
+
const purl = resolveComponentPurl(modulePurl(module), purlAliasMap);
|
|
1070
|
+
if (!purl) {
|
|
1071
|
+
continue;
|
|
1072
|
+
}
|
|
1073
|
+
addPropertyValue(
|
|
1074
|
+
componentPropertiesMap,
|
|
1075
|
+
purl,
|
|
1076
|
+
"cdx:golem:cryptoOperationType",
|
|
1077
|
+
operation.operationType,
|
|
1078
|
+
);
|
|
1079
|
+
addPropertyValue(
|
|
1080
|
+
componentPropertiesMap,
|
|
1081
|
+
purl,
|
|
1082
|
+
"cdx:golem:cryptoAlgorithm",
|
|
1083
|
+
operation.algorithm,
|
|
1084
|
+
);
|
|
1085
|
+
const assetRef = componentRefByAssetId.get(operation.assetId);
|
|
1086
|
+
if (assetRef) {
|
|
1087
|
+
cryptoGeneratePurls[purl] ??= new Set();
|
|
1088
|
+
cryptoGeneratePurls[purl].add(assetRef);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
for (const finding of crypto.findings || []) {
|
|
1092
|
+
const module = symbolModule(finding.packagePath, modules);
|
|
1093
|
+
const purl = resolveComponentPurl(modulePurl(module), purlAliasMap);
|
|
1094
|
+
if (!purl) {
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1097
|
+
addPropertyValue(
|
|
1098
|
+
componentPropertiesMap,
|
|
1099
|
+
purl,
|
|
1100
|
+
"cdx:golem:cryptoFinding",
|
|
1101
|
+
finding.ruleId,
|
|
1102
|
+
);
|
|
1103
|
+
addPropertyValue(
|
|
1104
|
+
componentPropertiesMap,
|
|
1105
|
+
purl,
|
|
1106
|
+
"cdx:golem:cryptoFindingSeverity",
|
|
1107
|
+
finding.severity,
|
|
1108
|
+
);
|
|
1109
|
+
}
|
|
1110
|
+
for (const slice of golemReport.dataFlow?.slices || []) {
|
|
1111
|
+
if (!isCryptoDataFlowSlice(slice)) {
|
|
1112
|
+
continue;
|
|
1113
|
+
}
|
|
1114
|
+
const module = symbolModule(slice.sinkPackagePath, modules);
|
|
1115
|
+
const purl =
|
|
1116
|
+
resolveComponentPurl(slice.sinkPurl, purlAliasMap) ||
|
|
1117
|
+
resolveComponentPurl(modulePurl(module), purlAliasMap);
|
|
1118
|
+
if (!purl) {
|
|
1119
|
+
continue;
|
|
1120
|
+
}
|
|
1121
|
+
const asset = (crypto.assets || []).find(
|
|
1122
|
+
(item) =>
|
|
1123
|
+
item.symbol === slice.sinkSymbol ||
|
|
1124
|
+
(item.name && slice.sinkSymbol?.toLowerCase().includes(item.name)),
|
|
1125
|
+
);
|
|
1126
|
+
const assetRef = componentRefByAssetId.get(asset?.id);
|
|
1127
|
+
if (assetRef) {
|
|
1128
|
+
cryptoGeneratePurls[purl] ??= new Set();
|
|
1129
|
+
cryptoGeneratePurls[purl].add(assetRef);
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
function dataFlowNodeCache(golemReport = {}) {
|
|
1135
|
+
const nodeCache = new Map();
|
|
1136
|
+
for (const node of golemReport.dataFlow?.nodes || []) {
|
|
1137
|
+
nodeCache.set(node.id, node);
|
|
1138
|
+
}
|
|
1139
|
+
return nodeCache;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
function resolveDataFlowSlicePurls(slice, nodeCache, modules, purlAliasMap) {
|
|
1143
|
+
const purls = new Set();
|
|
1144
|
+
addResolvedPurls(purls, slice.purls, purlAliasMap);
|
|
1145
|
+
addResolvedPurls(purls, [slice.sourcePurl, slice.sinkPurl], purlAliasMap);
|
|
1146
|
+
for (const packagePath of [slice.sourcePackagePath, slice.sinkPackagePath]) {
|
|
1147
|
+
const resolvedPurl = resolveComponentPurl(
|
|
1148
|
+
modulePurl(symbolModule(packagePath, modules)),
|
|
1149
|
+
purlAliasMap,
|
|
1150
|
+
);
|
|
1151
|
+
if (resolvedPurl) {
|
|
1152
|
+
purls.add(resolvedPurl);
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
for (const nodeId of slice.nodeIds || []) {
|
|
1156
|
+
const node = nodeCache.get(nodeId);
|
|
1157
|
+
const resolvedPurl =
|
|
1158
|
+
resolveComponentPurl(node?.purl, purlAliasMap) ||
|
|
1159
|
+
resolveComponentPurl(modulePurl(node?.module), purlAliasMap) ||
|
|
1160
|
+
resolveComponentPurl(
|
|
1161
|
+
modulePurl(symbolModule(node?.packagePath, modules)),
|
|
1162
|
+
purlAliasMap,
|
|
1163
|
+
);
|
|
1164
|
+
if (resolvedPurl) {
|
|
1165
|
+
purls.add(resolvedPurl);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
return purls;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
function dataFlowSliceFrames(slice, nodeCache) {
|
|
1172
|
+
const frames = [];
|
|
1173
|
+
for (const nodeId of slice.nodeIds || []) {
|
|
1174
|
+
const node = nodeCache.get(nodeId);
|
|
1175
|
+
const frame = frameFromDataFlowNode(node, slice.sinkFunction);
|
|
1176
|
+
if (frame) {
|
|
1177
|
+
frames.push(frame);
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
if (!frames.length) {
|
|
1181
|
+
for (const nodeId of [slice.sourceId, slice.sinkId]) {
|
|
1182
|
+
const node = nodeCache.get(nodeId);
|
|
1183
|
+
const frame = frameFromDataFlowNode(node, slice.sinkFunction);
|
|
1184
|
+
if (frame) {
|
|
1185
|
+
frames.push(frame);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
return frames;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
function addDataFlowEvidence(
|
|
1193
|
+
golemReport,
|
|
1194
|
+
purlAliasMap,
|
|
1195
|
+
purlLocationMap,
|
|
1196
|
+
dataFlowFrames,
|
|
1197
|
+
componentPropertiesMap,
|
|
1198
|
+
scopeCountsMap,
|
|
1199
|
+
occurrenceKindCountsMap,
|
|
1200
|
+
metadataProperties,
|
|
1201
|
+
) {
|
|
1202
|
+
const dataFlow = golemReport.dataFlow;
|
|
1203
|
+
if (!dataFlow) {
|
|
1204
|
+
return;
|
|
1205
|
+
}
|
|
1206
|
+
const nodeCache = dataFlowNodeCache(golemReport);
|
|
1207
|
+
const modules = golemReport.modules || [];
|
|
1208
|
+
const dataFlowCounts = {};
|
|
1209
|
+
const cryptoDataFlowCounts = {};
|
|
1210
|
+
const slices = [...(dataFlow.slices || [])].sort(
|
|
1211
|
+
(left, right) =>
|
|
1212
|
+
Number(isCryptoDataFlowSlice(right)) -
|
|
1213
|
+
Number(isCryptoDataFlowSlice(left)),
|
|
1214
|
+
);
|
|
1215
|
+
for (const slice of slices) {
|
|
1216
|
+
const purls = resolveDataFlowSlicePurls(
|
|
1217
|
+
slice,
|
|
1218
|
+
nodeCache,
|
|
1219
|
+
modules,
|
|
1220
|
+
purlAliasMap,
|
|
1221
|
+
);
|
|
1222
|
+
if (!purls.size) {
|
|
1223
|
+
continue;
|
|
1224
|
+
}
|
|
1225
|
+
const frames = dataFlowSliceFrames(slice, nodeCache);
|
|
1226
|
+
const category = [slice.sourceCategory, slice.sinkCategory]
|
|
1227
|
+
.filter(Boolean)
|
|
1228
|
+
.join("->");
|
|
1229
|
+
const taintKinds = sortedCsv(slice.taintKinds);
|
|
1230
|
+
const sourceNode = nodeCache.get(slice.sourceId);
|
|
1231
|
+
const sinkNode = nodeCache.get(slice.sinkId);
|
|
1232
|
+
for (const purl of purls) {
|
|
1233
|
+
incrementCount(dataFlowCounts, purl);
|
|
1234
|
+
incrementNestedCount(occurrenceKindCountsMap, purl, "dataFlowSlice");
|
|
1235
|
+
incrementNestedCount(scopeCountsMap, purl, slice.sinkScope || "runtime");
|
|
1236
|
+
addSetValue(
|
|
1237
|
+
purlLocationMap,
|
|
1238
|
+
purl,
|
|
1239
|
+
positionLocation(sourceNode?.position),
|
|
1240
|
+
);
|
|
1241
|
+
addSetValue(purlLocationMap, purl, positionLocation(sinkNode?.position));
|
|
1242
|
+
if (frames.length) {
|
|
1243
|
+
dataFlowFrames[purl] ??= [];
|
|
1244
|
+
dataFlowFrames[purl].push(frames);
|
|
1245
|
+
}
|
|
1246
|
+
addPropertyValue(
|
|
1247
|
+
componentPropertiesMap,
|
|
1248
|
+
purl,
|
|
1249
|
+
"cdx:golem:dataFlowCategories",
|
|
1250
|
+
category,
|
|
1251
|
+
);
|
|
1252
|
+
addPropertyValue(
|
|
1253
|
+
componentPropertiesMap,
|
|
1254
|
+
purl,
|
|
1255
|
+
"cdx:golem:dataFlowRuleId",
|
|
1256
|
+
slice.ruleId,
|
|
1257
|
+
);
|
|
1258
|
+
addPropertyValue(
|
|
1259
|
+
componentPropertiesMap,
|
|
1260
|
+
purl,
|
|
1261
|
+
"cdx:golem:dataFlowSeverity",
|
|
1262
|
+
slice.severity,
|
|
1263
|
+
);
|
|
1264
|
+
addPropertyValue(
|
|
1265
|
+
componentPropertiesMap,
|
|
1266
|
+
purl,
|
|
1267
|
+
"cdx:golem:dataFlowConfidence",
|
|
1268
|
+
slice.confidence,
|
|
1269
|
+
);
|
|
1270
|
+
addPropertyValue(
|
|
1271
|
+
componentPropertiesMap,
|
|
1272
|
+
purl,
|
|
1273
|
+
"cdx:golem:dataFlowTaintKinds",
|
|
1274
|
+
taintKinds,
|
|
1275
|
+
);
|
|
1276
|
+
if (isCryptoDataFlowSlice(slice)) {
|
|
1277
|
+
incrementCount(cryptoDataFlowCounts, purl);
|
|
1278
|
+
addPropertyValue(
|
|
1279
|
+
componentPropertiesMap,
|
|
1280
|
+
purl,
|
|
1281
|
+
"cdx:golem:cryptoDataFlow",
|
|
1282
|
+
true,
|
|
1283
|
+
);
|
|
1284
|
+
addPropertyValue(
|
|
1285
|
+
componentPropertiesMap,
|
|
1286
|
+
purl,
|
|
1287
|
+
"cdx:golem:cryptoDataFlowCategories",
|
|
1288
|
+
category,
|
|
1289
|
+
);
|
|
1290
|
+
addPropertyValue(
|
|
1291
|
+
componentPropertiesMap,
|
|
1292
|
+
purl,
|
|
1293
|
+
"cdx:golem:cryptoDataFlowRuleId",
|
|
1294
|
+
slice.ruleId,
|
|
1295
|
+
);
|
|
1296
|
+
addPropertyValue(
|
|
1297
|
+
componentPropertiesMap,
|
|
1298
|
+
purl,
|
|
1299
|
+
"cdx:golem:cryptoDataFlowTaintKinds",
|
|
1300
|
+
taintKinds,
|
|
1301
|
+
);
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
addCountProperty(
|
|
1306
|
+
metadataProperties,
|
|
1307
|
+
"cdx:golem:cryptoDataFlowCount",
|
|
1308
|
+
Object.values(cryptoDataFlowCounts).reduce((sum, count) => sum + count, 0),
|
|
1309
|
+
);
|
|
1310
|
+
for (const [purl, count] of Object.entries(dataFlowCounts)) {
|
|
1311
|
+
addCountProperty(
|
|
1312
|
+
(componentPropertiesMap[purl] ??= []),
|
|
1313
|
+
"cdx:golem:dataFlowSliceCount",
|
|
1314
|
+
count,
|
|
1315
|
+
);
|
|
1316
|
+
}
|
|
1317
|
+
for (const [purl, count] of Object.entries(cryptoDataFlowCounts)) {
|
|
1318
|
+
addCountProperty(
|
|
1319
|
+
(componentPropertiesMap[purl] ??= []),
|
|
1320
|
+
"cdx:golem:cryptoDataFlowCount",
|
|
1321
|
+
count,
|
|
1322
|
+
);
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
function normalizedGolemDataFlowMode(options = {}) {
|
|
1327
|
+
let dataFlowMode = String(
|
|
1328
|
+
options.golemDataflow || options.golemDataFlow || "",
|
|
1329
|
+
).toLowerCase();
|
|
1330
|
+
if (!dataFlowMode) {
|
|
1331
|
+
if (options.withDataFlow || options.profile === "research") {
|
|
1332
|
+
dataFlowMode = "all";
|
|
1333
|
+
} else if (options.deep) {
|
|
1334
|
+
dataFlowMode = "all";
|
|
1335
|
+
} else {
|
|
1336
|
+
dataFlowMode = "none";
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
if (!GOLEM_DATAFLOW_MODES.has(dataFlowMode)) {
|
|
1340
|
+
return "none";
|
|
1341
|
+
}
|
|
1342
|
+
return dataFlowMode;
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
function normalizedGolemCallGraphMode(dataFlowMode, options = {}) {
|
|
1346
|
+
let callgraphMode = String(options.golemCallgraph || "static").toLowerCase();
|
|
1347
|
+
if (!GOLEM_CALLGRAPH_MODES.has(callgraphMode)) {
|
|
1348
|
+
callgraphMode = dataFlowMode || "static";
|
|
1349
|
+
}
|
|
1350
|
+
return callgraphMode;
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
function normalizedGolemDataFlowCallGraphMode(options = {}) {
|
|
1354
|
+
let callgraphMode = String(
|
|
1355
|
+
options.golemDataflowCallgraph || "static",
|
|
1356
|
+
).toLowerCase();
|
|
1357
|
+
if (!GOLEM_DATAFLOW_CALLGRAPH_MODES.has(callgraphMode)) {
|
|
1358
|
+
callgraphMode = "static";
|
|
1359
|
+
}
|
|
1360
|
+
return callgraphMode;
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
function appendGolemDataFlowArgs(args, dataFlowMode, options = {}) {
|
|
1364
|
+
if (dataFlowMode === "none") {
|
|
1365
|
+
return;
|
|
1366
|
+
}
|
|
1367
|
+
const cpuCount = cpus()?.length || 1;
|
|
1368
|
+
const performanceWorkerCount = Math.max(1, Math.min(cpuCount, 4));
|
|
1369
|
+
const dataFlowCallgraph = normalizedGolemDataFlowCallGraphMode(options);
|
|
1370
|
+
const dataFlowPacks =
|
|
1371
|
+
options.golemDataflowPatternPacks ||
|
|
1372
|
+
(dataFlowMode === "crypto" ? "crypto" : "all");
|
|
1373
|
+
const dataFlowMaxSlices =
|
|
1374
|
+
normalizedPositiveInteger(options.golemDataflowMaxSlices) ||
|
|
1375
|
+
(options.deep ? 250 : 1000);
|
|
1376
|
+
const dataFlowWorkers =
|
|
1377
|
+
normalizedPositiveInteger(options.golemDataflowWorkers) ||
|
|
1378
|
+
performanceWorkerCount;
|
|
1379
|
+
const maxProcs =
|
|
1380
|
+
normalizedPositiveInteger(options.golemMaxProcs) || performanceWorkerCount;
|
|
1381
|
+
args.push("--dataflow", dataFlowMode);
|
|
1382
|
+
args.push("--dataflow-callgraph", dataFlowCallgraph);
|
|
1383
|
+
args.push("--dataflow-pattern-packs", String(dataFlowPacks));
|
|
1384
|
+
args.push("--dataflow-max-slices", String(dataFlowMaxSlices));
|
|
1385
|
+
args.push("--dataflow-workers", String(dataFlowWorkers));
|
|
1386
|
+
args.push("--max-procs", String(maxProcs));
|
|
1387
|
+
args.push(
|
|
1388
|
+
"--dataflow-large-repo-functions",
|
|
1389
|
+
String(
|
|
1390
|
+
normalizedPositiveInteger(options.golemDataflowLargeRepoFunctions) ||
|
|
1391
|
+
1000,
|
|
1392
|
+
),
|
|
1393
|
+
);
|
|
1394
|
+
args.push(
|
|
1395
|
+
"--dataflow-max-function-instructions",
|
|
1396
|
+
String(
|
|
1397
|
+
normalizedPositiveInteger(options.golemDataflowMaxFunctionInstructions) ||
|
|
1398
|
+
200,
|
|
1399
|
+
),
|
|
1400
|
+
);
|
|
1401
|
+
args.push(
|
|
1402
|
+
"--dataflow-max-trace-nodes",
|
|
1403
|
+
String(normalizedPositiveInteger(options.golemDataflowMaxTraceNodes) || 64),
|
|
1404
|
+
);
|
|
1405
|
+
args.push(
|
|
1406
|
+
"--dataflow-max-trace-edges",
|
|
1407
|
+
String(
|
|
1408
|
+
normalizedPositiveInteger(options.golemDataflowMaxTraceEdges) || 128,
|
|
1409
|
+
),
|
|
1410
|
+
);
|
|
1411
|
+
if (options.golemDataflowPatterns) {
|
|
1412
|
+
args.push("--dataflow-patterns", String(options.golemDataflowPatterns));
|
|
1413
|
+
}
|
|
1414
|
+
if (options.golemMemoryLimit) {
|
|
1415
|
+
args.push("--memory-limit", String(options.golemMemoryLimit));
|
|
1416
|
+
}
|
|
1417
|
+
if (options.golemDataflowSkipGenerated ?? true) {
|
|
1418
|
+
args.push("--dataflow-skip-generated");
|
|
1419
|
+
}
|
|
1420
|
+
if (options.golemDataflowSkipTests ?? !options.golemTests) {
|
|
1421
|
+
args.push("--dataflow-skip-tests");
|
|
1422
|
+
}
|
|
1423
|
+
if (options.golemProgress) {
|
|
1424
|
+
args.push("--progress");
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
function addImportEvidence(
|
|
1429
|
+
golemReport,
|
|
1430
|
+
purlAliasMap,
|
|
1431
|
+
purlLocationMap,
|
|
1432
|
+
componentPropertiesMap,
|
|
1433
|
+
scopeCountsMap,
|
|
1434
|
+
occurrenceKindCountsMap,
|
|
1435
|
+
) {
|
|
1436
|
+
for (const importUsage of golemReport.imports || []) {
|
|
1437
|
+
const purl = resolveComponentPurl(
|
|
1438
|
+
modulePurl(importUsage.module),
|
|
1439
|
+
purlAliasMap,
|
|
1440
|
+
);
|
|
1441
|
+
if (!purl) {
|
|
1442
|
+
continue;
|
|
1443
|
+
}
|
|
1444
|
+
addSetValue(purlLocationMap, purl, rangeLocation(importUsage.range));
|
|
1445
|
+
incrementNestedCount(
|
|
1446
|
+
scopeCountsMap,
|
|
1447
|
+
purl,
|
|
1448
|
+
importUsage.usageScope || "runtime",
|
|
1449
|
+
);
|
|
1450
|
+
incrementNestedCount(occurrenceKindCountsMap, purl, "import");
|
|
1451
|
+
addPropertyValue(
|
|
1452
|
+
componentPropertiesMap,
|
|
1453
|
+
purl,
|
|
1454
|
+
"cdx:golem:importDirect",
|
|
1455
|
+
importUsage.direct,
|
|
1456
|
+
);
|
|
1457
|
+
addPropertyValue(
|
|
1458
|
+
componentPropertiesMap,
|
|
1459
|
+
purl,
|
|
1460
|
+
"cdx:golem:importAliasKind",
|
|
1461
|
+
importUsage.aliasKind,
|
|
1462
|
+
);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
function addUsageEvidence(
|
|
1467
|
+
golemReport,
|
|
1468
|
+
purlAliasMap,
|
|
1469
|
+
purlLocationMap,
|
|
1470
|
+
dataFlowFrames,
|
|
1471
|
+
componentPropertiesMap,
|
|
1472
|
+
scopeCountsMap,
|
|
1473
|
+
occurrenceKindCountsMap,
|
|
1474
|
+
) {
|
|
1475
|
+
for (const usage of golemReport.usages || []) {
|
|
1476
|
+
const purl = resolveComponentPurl(modulePurl(usage.module), purlAliasMap);
|
|
1477
|
+
if (!purl) {
|
|
1478
|
+
continue;
|
|
1479
|
+
}
|
|
1480
|
+
addSetValue(purlLocationMap, purl, rangeLocation(usage.range));
|
|
1481
|
+
addFrame(dataFlowFrames, purl, frameFromUsage(usage));
|
|
1482
|
+
incrementNestedCount(scopeCountsMap, purl, usage.usageScope || "runtime");
|
|
1483
|
+
incrementNestedCount(
|
|
1484
|
+
occurrenceKindCountsMap,
|
|
1485
|
+
purl,
|
|
1486
|
+
usage.call ? "symbolCall" : "symbolReference",
|
|
1487
|
+
);
|
|
1488
|
+
addPropertyValue(
|
|
1489
|
+
componentPropertiesMap,
|
|
1490
|
+
purl,
|
|
1491
|
+
"cdx:golem:symbolKind",
|
|
1492
|
+
usage.symbolKind,
|
|
1493
|
+
);
|
|
1494
|
+
addPropertyValue(
|
|
1495
|
+
componentPropertiesMap,
|
|
1496
|
+
purl,
|
|
1497
|
+
"cdx:golem:usageKind",
|
|
1498
|
+
usage.kind,
|
|
1499
|
+
);
|
|
1500
|
+
addPropertyValue(
|
|
1501
|
+
componentPropertiesMap,
|
|
1502
|
+
purl,
|
|
1503
|
+
"cdx:golem:usageScope",
|
|
1504
|
+
usage.usageScope || "runtime",
|
|
1505
|
+
);
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
function addCallGraphEvidence(
|
|
1510
|
+
golemReport,
|
|
1511
|
+
purlAliasMap,
|
|
1512
|
+
purlLocationMap,
|
|
1513
|
+
dataFlowFrames,
|
|
1514
|
+
) {
|
|
1515
|
+
const modules = golemReport.modules || [];
|
|
1516
|
+
const callGraphNodeMap = new Map();
|
|
1517
|
+
for (const node of golemReport.callGraph?.nodes || []) {
|
|
1518
|
+
if (node?.id) {
|
|
1519
|
+
callGraphNodeMap.set(node.id, node);
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
const localModules = new Set(
|
|
1523
|
+
modules.filter((module) => module.main).map((module) => module.path),
|
|
1524
|
+
);
|
|
1525
|
+
const localPurls = new Set(
|
|
1526
|
+
modules
|
|
1527
|
+
.filter((module) => module.main)
|
|
1528
|
+
.map((module) => resolveComponentPurl(modulePurl(module), purlAliasMap))
|
|
1529
|
+
.filter(Boolean),
|
|
1530
|
+
);
|
|
1531
|
+
for (const edge of golemReport.callGraph?.edges || []) {
|
|
1532
|
+
const sourceModule = symbolModule(edge.sourceId, modules);
|
|
1533
|
+
const targetModule = symbolModule(edge.targetId, modules);
|
|
1534
|
+
const sourcePurl = resolveComponentPurl(edge.sourcePurl, purlAliasMap);
|
|
1535
|
+
const resolvedSourcePurl =
|
|
1536
|
+
sourcePurl ||
|
|
1537
|
+
resolveComponentPurl(modulePurl(sourceModule), purlAliasMap);
|
|
1538
|
+
if (
|
|
1539
|
+
resolvedSourcePurl
|
|
1540
|
+
? !localPurls.has(resolvedSourcePurl)
|
|
1541
|
+
: !sourceModule?.path || !localModules.has(sourceModule.path)
|
|
1542
|
+
) {
|
|
1543
|
+
continue;
|
|
1544
|
+
}
|
|
1545
|
+
const purls = new Set();
|
|
1546
|
+
addResolvedPurls(
|
|
1547
|
+
purls,
|
|
1548
|
+
[edge.sinkPurl, edge.targetPurl, modulePurl(targetModule)],
|
|
1549
|
+
purlAliasMap,
|
|
1550
|
+
);
|
|
1551
|
+
addResolvedPurls(purls, edge.purls, purlAliasMap);
|
|
1552
|
+
purls.delete(resolvedSourcePurl);
|
|
1553
|
+
if (!purls.size && resolvedSourcePurl) {
|
|
1554
|
+
purls.add(resolvedSourcePurl);
|
|
1555
|
+
}
|
|
1556
|
+
if (!purls.size) {
|
|
1557
|
+
continue;
|
|
1558
|
+
}
|
|
1559
|
+
for (const purl of purls) {
|
|
1560
|
+
addSetValue(
|
|
1561
|
+
purlLocationMap,
|
|
1562
|
+
purl,
|
|
1563
|
+
rangeLocation({ start: edge.position }),
|
|
1564
|
+
);
|
|
1565
|
+
const sourceFrame =
|
|
1566
|
+
frameFromEdge(edge) ||
|
|
1567
|
+
frameFromCallGraphNode(
|
|
1568
|
+
callGraphNodeMap.get(edge.sourceId),
|
|
1569
|
+
edge.sourceName,
|
|
1570
|
+
);
|
|
1571
|
+
const targetFrame = frameFromCallGraphNode(
|
|
1572
|
+
callGraphNodeMap.get(edge.targetId),
|
|
1573
|
+
edge.targetName,
|
|
1574
|
+
);
|
|
1575
|
+
const edgeFrames = dedupeFrames([sourceFrame, targetFrame]);
|
|
1576
|
+
if (edgeFrames.length) {
|
|
1577
|
+
dataFlowFrames[purl] ??= [];
|
|
1578
|
+
dataFlowFrames[purl].push(edgeFrames);
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
/**
|
|
1585
|
+
* Determine whether a project language is a Go variant that should trigger golem analysis.
|
|
1586
|
+
*
|
|
1587
|
+
* @param {string} language Project language identifier.
|
|
1588
|
+
* @returns {boolean} True when the language maps to a Go variant.
|
|
1589
|
+
*/
|
|
1590
|
+
export function isGolemGoLanguage(language) {
|
|
1591
|
+
return GO_LANGUAGES.has(String(language || "").toLowerCase());
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
/**
|
|
1595
|
+
* Read and parse a golem analysis JSON report file.
|
|
1596
|
+
*
|
|
1597
|
+
* @param {string} jsonFile Path to the golem JSON report.
|
|
1598
|
+
* @returns {object|undefined} Parsed report object, or undefined when the file
|
|
1599
|
+
* is missing or cannot be parsed.
|
|
1600
|
+
*/
|
|
1601
|
+
export function readGolemJsonFile(jsonFile) {
|
|
1602
|
+
if (!jsonFile || !safeExistsSync(jsonFile)) {
|
|
1603
|
+
return undefined;
|
|
1604
|
+
}
|
|
1605
|
+
try {
|
|
1606
|
+
return JSON.parse(readFileSync(jsonFile, "utf-8"));
|
|
1607
|
+
} catch (_err) {
|
|
1608
|
+
return undefined;
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
/**
|
|
1613
|
+
* Invoke the golem analyzer binary over a source directory to produce a JSON report.
|
|
1614
|
+
*
|
|
1615
|
+
* Assembles the analyze invocation (callgraph mode, data-flow mode, patterns,
|
|
1616
|
+
* tags, tests, stdlib flags) from the options and writes the result to
|
|
1617
|
+
* `outputFile`.
|
|
1618
|
+
*
|
|
1619
|
+
* @param {string} src Source directory to analyze.
|
|
1620
|
+
* @param {string} outputFile Destination path for the JSON report.
|
|
1621
|
+
* @param {object} [options={}] Options controlling golem behavior.
|
|
1622
|
+
* @returns {boolean} True when the analysis succeeded and the report was written.
|
|
1623
|
+
*/
|
|
1624
|
+
export function runGolemAnalysis(src, outputFile, options = {}) {
|
|
1625
|
+
const executable = options.golemCommand || golemBin();
|
|
1626
|
+
if (!executable || !src || !outputFile) {
|
|
1627
|
+
return false;
|
|
1628
|
+
}
|
|
1629
|
+
const dataFlowMode = normalizedGolemDataFlowMode(options);
|
|
1630
|
+
const callgraphMode = normalizedGolemCallGraphMode(dataFlowMode, options);
|
|
1631
|
+
const args = [
|
|
1632
|
+
"analyze",
|
|
1633
|
+
"--dir",
|
|
1634
|
+
resolve(src),
|
|
1635
|
+
"--format",
|
|
1636
|
+
"json",
|
|
1637
|
+
"--callgraph",
|
|
1638
|
+
callgraphMode,
|
|
1639
|
+
"--out",
|
|
1640
|
+
resolve(outputFile),
|
|
1641
|
+
];
|
|
1642
|
+
appendGolemDataFlowArgs(args, dataFlowMode, options);
|
|
1643
|
+
if (options.golemPatterns) {
|
|
1644
|
+
args.push("--patterns", String(options.golemPatterns));
|
|
1645
|
+
}
|
|
1646
|
+
if (options.golemTags || options.tags) {
|
|
1647
|
+
args.push("--tags", String(options.golemTags || options.tags));
|
|
1648
|
+
}
|
|
1649
|
+
if (options.golemTests || options.tests) {
|
|
1650
|
+
args.push("--tests");
|
|
1651
|
+
}
|
|
1652
|
+
if (options.golemIncludeStdlib) {
|
|
1653
|
+
args.push("--include-stdlib");
|
|
1654
|
+
}
|
|
1655
|
+
if (DEBUG_MODE) {
|
|
1656
|
+
console.log("Executing", executable, args.join(" "));
|
|
1657
|
+
}
|
|
1658
|
+
const result = safeSpawnSync(executable, args, {
|
|
1659
|
+
cwd: resolve(src),
|
|
1660
|
+
shell: false,
|
|
1661
|
+
});
|
|
1662
|
+
if (result?.status !== 0 || result?.error || !safeExistsSync(outputFile)) {
|
|
1663
|
+
if (DEBUG_MODE) {
|
|
1664
|
+
if (result?.stdout || result?.stderr) {
|
|
1665
|
+
console.error(result.stdout, result.stderr);
|
|
1666
|
+
} else {
|
|
1667
|
+
console.log("Check if the golem plugin was installed successfully.");
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
return false;
|
|
1671
|
+
}
|
|
1672
|
+
return true;
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
/**
|
|
1676
|
+
* Orchestrate a full golem run: execute the analyzer, read the report, and clean up.
|
|
1677
|
+
*
|
|
1678
|
+
* When `options.semanticsSlicesFile` is set the report is persisted there;
|
|
1679
|
+
* otherwise it is written to a temporary directory that is removed after parsing.
|
|
1680
|
+
*
|
|
1681
|
+
* @param {string} src Source directory to analyze.
|
|
1682
|
+
* @param {object} [options={}] Options forwarded to {@link runGolemAnalysis}.
|
|
1683
|
+
* @returns {object|undefined} Parsed golem report, or undefined on failure.
|
|
1684
|
+
*/
|
|
1685
|
+
export function analyzeGolemProject(src, options = {}) {
|
|
1686
|
+
// When a semantics-slices path is provided (--semantics-slices-file), persist
|
|
1687
|
+
// the full raw golem report there and keep it. Downstream tools (e.g. depscan)
|
|
1688
|
+
// can then consume the complete report - call graph, data-flow slices,
|
|
1689
|
+
// security signals, usages - which cdxgen only projects a subset of into the
|
|
1690
|
+
// SBOM evidence. go does not otherwise use the semantics slice (atom is never
|
|
1691
|
+
// run for go), so the path is free to carry the golem report. Without it,
|
|
1692
|
+
// the report is written to a temp dir and deleted after parsing (default).
|
|
1693
|
+
const durablePath = options.semanticsSlicesFile
|
|
1694
|
+
? resolve(options.semanticsSlicesFile)
|
|
1695
|
+
: undefined;
|
|
1696
|
+
const tempDir = durablePath
|
|
1697
|
+
? undefined
|
|
1698
|
+
: safeMkdtempSync(join(getTmpDir(), "golem-"));
|
|
1699
|
+
const outputFile = durablePath || join(tempDir, "golem.json");
|
|
1700
|
+
try {
|
|
1701
|
+
if (!runGolemAnalysis(src, outputFile, options)) {
|
|
1702
|
+
return undefined;
|
|
1703
|
+
}
|
|
1704
|
+
return readGolemJsonFile(outputFile);
|
|
1705
|
+
} finally {
|
|
1706
|
+
if (tempDir?.startsWith(getTmpDir())) {
|
|
1707
|
+
safeRmSync(tempDir, { recursive: true, force: true });
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
/**
|
|
1713
|
+
* Project a golem report into CycloneDX component evidence, properties, and crypto assets.
|
|
1714
|
+
*
|
|
1715
|
+
* Aggregates import/usage/call-graph/data-flow evidence and crypto signals from
|
|
1716
|
+
* the report, attaching per-component properties and occurrence evidence while
|
|
1717
|
+
* collecting any derived cryptographic-asset components.
|
|
1718
|
+
*
|
|
1719
|
+
* @param {object} [golemReport={}] Parsed golem analysis report.
|
|
1720
|
+
* @param {Array<object>} [components=[]] Existing BOM components to match against.
|
|
1721
|
+
* @returns {{componentPropertiesMap: Object<string, Array<object>>, cryptoComponents: Array<object>, cryptoGeneratePurls: Object<string, boolean>, dataFlowFrames: Object<string, Array>, metadataProperties: Array<object>, purlLocationMap: Object<string, Array>}}
|
|
1722
|
+
* Projected evidence maps and crypto components.
|
|
1723
|
+
*/
|
|
1724
|
+
export function collectGolemEvidence(golemReport = {}, components = []) {
|
|
1725
|
+
const purlAliasMap = createPurlAliasMap(components);
|
|
1726
|
+
const purlLocationMap = {};
|
|
1727
|
+
const dataFlowFrames = {};
|
|
1728
|
+
const componentPropertiesMap = {};
|
|
1729
|
+
const metadataProperties = [];
|
|
1730
|
+
const scopeCountsMap = {};
|
|
1731
|
+
const occurrenceKindCountsMap = {};
|
|
1732
|
+
const cryptoComponentsByRef = new Map();
|
|
1733
|
+
const cryptoGeneratePurls = {};
|
|
1734
|
+
addMetadataProperties(metadataProperties, golemReport);
|
|
1735
|
+
addSupplyChainProperties(
|
|
1736
|
+
componentPropertiesMap,
|
|
1737
|
+
metadataProperties,
|
|
1738
|
+
purlAliasMap,
|
|
1739
|
+
golemReport.supplyChain,
|
|
1740
|
+
);
|
|
1741
|
+
addModuleProperties(
|
|
1742
|
+
componentPropertiesMap,
|
|
1743
|
+
purlAliasMap,
|
|
1744
|
+
golemReport.modules || [],
|
|
1745
|
+
);
|
|
1746
|
+
addImportEvidence(
|
|
1747
|
+
golemReport,
|
|
1748
|
+
purlAliasMap,
|
|
1749
|
+
purlLocationMap,
|
|
1750
|
+
componentPropertiesMap,
|
|
1751
|
+
scopeCountsMap,
|
|
1752
|
+
occurrenceKindCountsMap,
|
|
1753
|
+
);
|
|
1754
|
+
addUsageEvidence(
|
|
1755
|
+
golemReport,
|
|
1756
|
+
purlAliasMap,
|
|
1757
|
+
purlLocationMap,
|
|
1758
|
+
dataFlowFrames,
|
|
1759
|
+
componentPropertiesMap,
|
|
1760
|
+
scopeCountsMap,
|
|
1761
|
+
occurrenceKindCountsMap,
|
|
1762
|
+
);
|
|
1763
|
+
addCallGraphEvidence(
|
|
1764
|
+
golemReport,
|
|
1765
|
+
purlAliasMap,
|
|
1766
|
+
purlLocationMap,
|
|
1767
|
+
dataFlowFrames,
|
|
1768
|
+
);
|
|
1769
|
+
addDataFlowEvidence(
|
|
1770
|
+
golemReport,
|
|
1771
|
+
purlAliasMap,
|
|
1772
|
+
purlLocationMap,
|
|
1773
|
+
dataFlowFrames,
|
|
1774
|
+
componentPropertiesMap,
|
|
1775
|
+
scopeCountsMap,
|
|
1776
|
+
occurrenceKindCountsMap,
|
|
1777
|
+
metadataProperties,
|
|
1778
|
+
);
|
|
1779
|
+
addSignalProperties(componentPropertiesMap, purlAliasMap, golemReport);
|
|
1780
|
+
addCryptoEvidence(
|
|
1781
|
+
componentPropertiesMap,
|
|
1782
|
+
metadataProperties,
|
|
1783
|
+
purlAliasMap,
|
|
1784
|
+
golemReport,
|
|
1785
|
+
cryptoComponentsByRef,
|
|
1786
|
+
cryptoGeneratePurls,
|
|
1787
|
+
);
|
|
1788
|
+
for (const [purl, scopeCounts] of Object.entries(scopeCountsMap)) {
|
|
1789
|
+
addScopedProperties(componentPropertiesMap, purl, scopeCounts);
|
|
1790
|
+
}
|
|
1791
|
+
for (const [purl, kindCounts] of Object.entries(occurrenceKindCountsMap)) {
|
|
1792
|
+
addOccurrenceKindProperties(componentPropertiesMap, purl, kindCounts);
|
|
1793
|
+
}
|
|
1794
|
+
return {
|
|
1795
|
+
componentPropertiesMap,
|
|
1796
|
+
cryptoComponents: Array.from(cryptoComponentsByRef.values()).sort(
|
|
1797
|
+
(left, right) =>
|
|
1798
|
+
`${left.name}:${left["bom-ref"]}`.localeCompare(
|
|
1799
|
+
`${right.name}:${right["bom-ref"]}`,
|
|
1800
|
+
),
|
|
1801
|
+
),
|
|
1802
|
+
cryptoGeneratePurls,
|
|
1803
|
+
dataFlowFrames,
|
|
1804
|
+
metadataProperties,
|
|
1805
|
+
purlLocationMap,
|
|
1806
|
+
};
|
|
1807
|
+
}
|