@cdxgen/cdxgen 0.0.1 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +921 -87
- package/bin/audit.js +239 -0
- package/bin/cdxgen.js +2324 -0
- package/bin/convert.js +213 -0
- package/bin/evinse.js +353 -0
- package/bin/hbom.js +495 -0
- package/bin/repl.js +2224 -0
- package/bin/sign.js +195 -0
- package/bin/tracebom.js +295 -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 +1833 -0
- package/lib/cli/cliOptions.js +513 -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 +142 -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 +876 -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 +575 -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 +1789 -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 +277 -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 +263 -0
- package/lib/inventory/traceRunner.js +439 -0
- package/lib/inventory/unicodeScan.js +147 -0
- package/lib/managers/binary.js +3307 -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 +315 -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 +28 -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 +120 -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 +19 -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 +76 -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,1174 @@
|
|
|
1
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
4
|
+
|
|
5
|
+
import { build } from "@cdxgen/cdx-purl";
|
|
6
|
+
|
|
7
|
+
import { readEnvironmentVariable } from "../core/activity.js";
|
|
8
|
+
import { safeExistsSync } from "../core/fs.js";
|
|
9
|
+
import { isMac, isWin } from "../core/paths.js";
|
|
10
|
+
import { sanitizeBomPropertyValue } from "../core/propertySanitizer.js";
|
|
11
|
+
import {
|
|
12
|
+
CHROMIUM_EXTENSION_CAPABILITY_CATEGORIES,
|
|
13
|
+
detectExtensionCapabilities,
|
|
14
|
+
} from "../inventory/analyzer.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The purl type for Chrome extensions as defined by the packageurl spec.
|
|
18
|
+
*/
|
|
19
|
+
export const CHROME_EXTENSION_PURL_TYPE = "chrome-extension";
|
|
20
|
+
|
|
21
|
+
const CHROME_EXTENSION_ID_REGEX = /^[a-z]{32}$/i;
|
|
22
|
+
const BRAVE_SPECIFIC_PERMISSIONS = ["webDiscovery", "settingsPrivate"];
|
|
23
|
+
/**
|
|
24
|
+
* Per-process cache for extension source capability scans.
|
|
25
|
+
*
|
|
26
|
+
* Entries are keyed by resolved extension directory and populated on first scan.
|
|
27
|
+
* Values are reused during a single cdxgen run to avoid repeated Babel AST scans
|
|
28
|
+
* for the same extension directory. The cache is intentionally process-local and
|
|
29
|
+
* naturally discarded when the process exits.
|
|
30
|
+
*/
|
|
31
|
+
const extensionDirCapabilityCache = new Map();
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Infer high-risk extension capabilities from manifest fields and permission hints.
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} manifestData Parsed manifest-derived data
|
|
37
|
+
* @returns {Object<string, boolean>} Capability booleans keyed by
|
|
38
|
+
* CHROMIUM_EXTENSION_CAPABILITY_CATEGORIES entries; unknown/extra keys are ignored.
|
|
39
|
+
*/
|
|
40
|
+
function inferChromiumCapabilitySignals(manifestData) {
|
|
41
|
+
const permissions = [
|
|
42
|
+
...(manifestData?.permissions || []),
|
|
43
|
+
...(manifestData?.optionalPermissions || []),
|
|
44
|
+
]
|
|
45
|
+
.filter(Boolean)
|
|
46
|
+
.map((permission) => permission.toLowerCase());
|
|
47
|
+
const hostPermissions = [
|
|
48
|
+
...(manifestData?.hostPermissions || []),
|
|
49
|
+
...(manifestData?.optionalHostPermissions || []),
|
|
50
|
+
]
|
|
51
|
+
.filter(Boolean)
|
|
52
|
+
.map((permission) => permission.toLowerCase());
|
|
53
|
+
const commandNames = (manifestData?.commands || [])
|
|
54
|
+
.filter(Boolean)
|
|
55
|
+
.map((commandName) => commandName.toLowerCase());
|
|
56
|
+
const contentScripts = Array.isArray(manifestData?.contentScripts)
|
|
57
|
+
? manifestData.contentScripts
|
|
58
|
+
: [];
|
|
59
|
+
const contentScriptPaths = contentScripts
|
|
60
|
+
.flatMap((script) => [
|
|
61
|
+
...(Array.isArray(script?.js) ? script.js : []),
|
|
62
|
+
...(Array.isArray(script?.css) ? script.css : []),
|
|
63
|
+
])
|
|
64
|
+
.filter((entry) => typeof entry === "string")
|
|
65
|
+
.map((entry) => entry.toLowerCase());
|
|
66
|
+
const allSignals = [
|
|
67
|
+
...permissions,
|
|
68
|
+
...hostPermissions,
|
|
69
|
+
...commandNames,
|
|
70
|
+
...contentScriptPaths,
|
|
71
|
+
];
|
|
72
|
+
const hasBroadHosts = hostPermissions.some(
|
|
73
|
+
(permission) =>
|
|
74
|
+
permission === "<all_urls>" ||
|
|
75
|
+
permission === "*://*/*" ||
|
|
76
|
+
permission.startsWith("file://"),
|
|
77
|
+
);
|
|
78
|
+
const hasContentScripts = contentScripts.length > 0;
|
|
79
|
+
const hasWebAccessibleResources = Array.isArray(
|
|
80
|
+
manifestData?.webAccessibleResources,
|
|
81
|
+
)
|
|
82
|
+
? manifestData.webAccessibleResources.length > 0
|
|
83
|
+
: false;
|
|
84
|
+
return {
|
|
85
|
+
fileAccess:
|
|
86
|
+
allSignals.some((signal) =>
|
|
87
|
+
[
|
|
88
|
+
"filesystem",
|
|
89
|
+
"downloads",
|
|
90
|
+
"filebrowserhandler",
|
|
91
|
+
"filemanagerprivate",
|
|
92
|
+
"file://",
|
|
93
|
+
].some((token) => signal.includes(token)),
|
|
94
|
+
) || Boolean(manifestData?.fileBrowserHandlers),
|
|
95
|
+
deviceAccess: allSignals.some((signal) =>
|
|
96
|
+
["usb", "hid", "serial", "nfc", "mediagalleries", "bluetooth"].some(
|
|
97
|
+
(token) => signal.includes(token),
|
|
98
|
+
),
|
|
99
|
+
),
|
|
100
|
+
network:
|
|
101
|
+
allSignals.some((signal) =>
|
|
102
|
+
[
|
|
103
|
+
"webrequest",
|
|
104
|
+
"declarativenetrequest",
|
|
105
|
+
"proxy",
|
|
106
|
+
"webnavigation",
|
|
107
|
+
"socket",
|
|
108
|
+
"cookies",
|
|
109
|
+
].some((token) => signal.includes(token)),
|
|
110
|
+
) ||
|
|
111
|
+
hasBroadHosts ||
|
|
112
|
+
hasWebAccessibleResources,
|
|
113
|
+
bluetooth: allSignals.some((signal) => signal.includes("bluetooth")),
|
|
114
|
+
accessibility: allSignals.some((signal) =>
|
|
115
|
+
["accessibility", "automation", "screenreader"].some((token) =>
|
|
116
|
+
signal.includes(token),
|
|
117
|
+
),
|
|
118
|
+
),
|
|
119
|
+
codeInjection:
|
|
120
|
+
allSignals.some((signal) =>
|
|
121
|
+
[
|
|
122
|
+
"scripting",
|
|
123
|
+
"userscripts",
|
|
124
|
+
"debugger",
|
|
125
|
+
"tabs",
|
|
126
|
+
"execute",
|
|
127
|
+
"inject",
|
|
128
|
+
].some((token) => signal.includes(token)),
|
|
129
|
+
) || hasContentScripts,
|
|
130
|
+
fingerprinting: allSignals.some((signal) =>
|
|
131
|
+
["history", "fonts", "fontsettings", "webgl", "canvas", "cookies"].some(
|
|
132
|
+
(token) => signal.includes(token),
|
|
133
|
+
),
|
|
134
|
+
),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Merge one or more capability maps into a normalized set of boolean flags.
|
|
140
|
+
*
|
|
141
|
+
* Performs logical OR across known capability keys only; unknown keys are ignored.
|
|
142
|
+
*
|
|
143
|
+
* @param {...Object<string, boolean>} capabilityMaps Capability maps from manifest/code analysis
|
|
144
|
+
* @returns {Object<string, boolean>} Merged capability map
|
|
145
|
+
*/
|
|
146
|
+
function mergeCapabilitySignals(...capabilityMaps) {
|
|
147
|
+
const merged = {};
|
|
148
|
+
for (const capabilityName of CHROMIUM_EXTENSION_CAPABILITY_CATEGORIES) {
|
|
149
|
+
merged[capabilityName] = false;
|
|
150
|
+
}
|
|
151
|
+
for (const capabilityMap of capabilityMaps) {
|
|
152
|
+
for (const capabilityName of CHROMIUM_EXTENSION_CAPABILITY_CATEGORIES) {
|
|
153
|
+
if (capabilityMap?.[capabilityName]) {
|
|
154
|
+
merged[capabilityName] = true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return merged;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Detect extension capabilities from source code with per-directory caching.
|
|
163
|
+
*
|
|
164
|
+
* @param {string} extensionDir Extension directory
|
|
165
|
+
* @returns {Object<string, boolean>} Capability signal map for
|
|
166
|
+
* CHROMIUM_EXTENSION_CAPABILITY_CATEGORIES where each value is boolean.
|
|
167
|
+
* Uses detectExtensionCapabilities(extensionDir, false), where false excludes
|
|
168
|
+
* node_modules/deep scanning for performance.
|
|
169
|
+
*/
|
|
170
|
+
function detectCachedExtensionCapabilities(extensionDir) {
|
|
171
|
+
const cacheKey = resolve(extensionDir);
|
|
172
|
+
if (extensionDirCapabilityCache.has(cacheKey)) {
|
|
173
|
+
return extensionDirCapabilityCache.get(cacheKey);
|
|
174
|
+
}
|
|
175
|
+
const codeCapabilityScan = detectExtensionCapabilities(cacheKey, false);
|
|
176
|
+
const codeCapabilities = {};
|
|
177
|
+
for (const capabilityName of CHROMIUM_EXTENSION_CAPABILITY_CATEGORIES) {
|
|
178
|
+
codeCapabilities[capabilityName] =
|
|
179
|
+
codeCapabilityScan.capabilities.includes(capabilityName);
|
|
180
|
+
}
|
|
181
|
+
extensionDirCapabilityCache.set(cacheKey, codeCapabilities);
|
|
182
|
+
return codeCapabilities;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Discover known Chromium-based browser user-data directories.
|
|
187
|
+
*
|
|
188
|
+
* @returns {Array<{browser: string, channel: string, dir: string}>}
|
|
189
|
+
*/
|
|
190
|
+
export function getChromiumExtensionDirs() {
|
|
191
|
+
const home = homedir();
|
|
192
|
+
const localAppData =
|
|
193
|
+
readEnvironmentVariable("LOCALAPPDATA") || join(home, "AppData", "Local");
|
|
194
|
+
const xdgConfigHome =
|
|
195
|
+
readEnvironmentVariable("XDG_CONFIG_HOME") || join(home, ".config");
|
|
196
|
+
const dirs = [
|
|
197
|
+
// Google Chrome
|
|
198
|
+
{
|
|
199
|
+
browser: "Google Chrome",
|
|
200
|
+
channel: "stable",
|
|
201
|
+
dir: isWin
|
|
202
|
+
? join(localAppData, "Google", "Chrome", "User Data")
|
|
203
|
+
: isMac
|
|
204
|
+
? join(home, "Library", "Application Support", "Google", "Chrome")
|
|
205
|
+
: join(xdgConfigHome, "google-chrome"),
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
browser: "Google Chrome",
|
|
209
|
+
channel: "beta",
|
|
210
|
+
dir: isWin
|
|
211
|
+
? join(localAppData, "Google", "Chrome Beta", "User Data")
|
|
212
|
+
: isMac
|
|
213
|
+
? join(
|
|
214
|
+
home,
|
|
215
|
+
"Library",
|
|
216
|
+
"Application Support",
|
|
217
|
+
"Google",
|
|
218
|
+
"Chrome Beta",
|
|
219
|
+
)
|
|
220
|
+
: join(xdgConfigHome, "google-chrome-beta"),
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
browser: "Google Chrome",
|
|
224
|
+
channel: "dev",
|
|
225
|
+
dir: isWin
|
|
226
|
+
? join(localAppData, "Google", "Chrome Dev", "User Data")
|
|
227
|
+
: isMac
|
|
228
|
+
? join(home, "Library", "Application Support", "Google", "Chrome Dev")
|
|
229
|
+
: join(xdgConfigHome, "google-chrome-unstable"),
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
browser: "Google Chrome",
|
|
233
|
+
channel: "canary",
|
|
234
|
+
dir: isWin
|
|
235
|
+
? join(localAppData, "Google", "Chrome SxS", "User Data")
|
|
236
|
+
: isMac
|
|
237
|
+
? join(
|
|
238
|
+
home,
|
|
239
|
+
"Library",
|
|
240
|
+
"Application Support",
|
|
241
|
+
"Google",
|
|
242
|
+
"Chrome Canary",
|
|
243
|
+
)
|
|
244
|
+
: "",
|
|
245
|
+
},
|
|
246
|
+
// Chromium
|
|
247
|
+
{
|
|
248
|
+
browser: "Chromium",
|
|
249
|
+
channel: "stable",
|
|
250
|
+
dir: isWin
|
|
251
|
+
? join(localAppData, "Chromium", "User Data")
|
|
252
|
+
: isMac
|
|
253
|
+
? join(home, "Library", "Application Support", "Chromium")
|
|
254
|
+
: join(xdgConfigHome, "chromium"),
|
|
255
|
+
},
|
|
256
|
+
// Microsoft Edge
|
|
257
|
+
{
|
|
258
|
+
browser: "Microsoft Edge",
|
|
259
|
+
channel: "stable",
|
|
260
|
+
dir: isWin
|
|
261
|
+
? join(localAppData, "Microsoft", "Edge", "User Data")
|
|
262
|
+
: isMac
|
|
263
|
+
? join(home, "Library", "Application Support", "Microsoft Edge")
|
|
264
|
+
: join(xdgConfigHome, "microsoft-edge"),
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
browser: "Microsoft Edge",
|
|
268
|
+
channel: "beta",
|
|
269
|
+
dir: isWin
|
|
270
|
+
? join(localAppData, "Microsoft", "Edge Beta", "User Data")
|
|
271
|
+
: isMac
|
|
272
|
+
? join(home, "Library", "Application Support", "Microsoft Edge Beta")
|
|
273
|
+
: join(xdgConfigHome, "microsoft-edge-beta"),
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
browser: "Microsoft Edge",
|
|
277
|
+
channel: "dev",
|
|
278
|
+
dir: isWin
|
|
279
|
+
? join(localAppData, "Microsoft", "Edge Dev", "User Data")
|
|
280
|
+
: isMac
|
|
281
|
+
? join(home, "Library", "Application Support", "Microsoft Edge Dev")
|
|
282
|
+
: join(xdgConfigHome, "microsoft-edge-dev"),
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
browser: "Microsoft Edge",
|
|
286
|
+
channel: "canary",
|
|
287
|
+
dir: isWin
|
|
288
|
+
? join(localAppData, "Microsoft", "Edge SxS", "User Data")
|
|
289
|
+
: isMac
|
|
290
|
+
? join(
|
|
291
|
+
home,
|
|
292
|
+
"Library",
|
|
293
|
+
"Application Support",
|
|
294
|
+
"Microsoft Edge Canary",
|
|
295
|
+
)
|
|
296
|
+
: "",
|
|
297
|
+
},
|
|
298
|
+
// Brave
|
|
299
|
+
{
|
|
300
|
+
browser: "Brave",
|
|
301
|
+
channel: "stable",
|
|
302
|
+
dir: isWin
|
|
303
|
+
? join(localAppData, "BraveSoftware", "Brave-Browser", "User Data")
|
|
304
|
+
: isMac
|
|
305
|
+
? join(
|
|
306
|
+
home,
|
|
307
|
+
"Library",
|
|
308
|
+
"Application Support",
|
|
309
|
+
"BraveSoftware",
|
|
310
|
+
"Brave-Browser",
|
|
311
|
+
)
|
|
312
|
+
: join(xdgConfigHome, "BraveSoftware", "Brave-Browser"),
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
browser: "Brave",
|
|
316
|
+
channel: "beta",
|
|
317
|
+
dir: isWin
|
|
318
|
+
? join(localAppData, "BraveSoftware", "Brave-Browser-Beta", "User Data")
|
|
319
|
+
: isMac
|
|
320
|
+
? join(
|
|
321
|
+
home,
|
|
322
|
+
"Library",
|
|
323
|
+
"Application Support",
|
|
324
|
+
"BraveSoftware",
|
|
325
|
+
"Brave-Browser-Beta",
|
|
326
|
+
)
|
|
327
|
+
: join(xdgConfigHome, "BraveSoftware", "Brave-Browser-Beta"),
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
browser: "Brave",
|
|
331
|
+
channel: "dev",
|
|
332
|
+
dir: isWin
|
|
333
|
+
? join(localAppData, "BraveSoftware", "Brave-Browser-Dev", "User Data")
|
|
334
|
+
: isMac
|
|
335
|
+
? join(
|
|
336
|
+
home,
|
|
337
|
+
"Library",
|
|
338
|
+
"Application Support",
|
|
339
|
+
"BraveSoftware",
|
|
340
|
+
"Brave-Browser-Dev",
|
|
341
|
+
)
|
|
342
|
+
: join(xdgConfigHome, "BraveSoftware", "Brave-Browser-Dev"),
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
browser: "Brave",
|
|
346
|
+
channel: "nightly",
|
|
347
|
+
dir: isWin
|
|
348
|
+
? join(
|
|
349
|
+
localAppData,
|
|
350
|
+
"BraveSoftware",
|
|
351
|
+
"Brave-Browser-Nightly",
|
|
352
|
+
"User Data",
|
|
353
|
+
)
|
|
354
|
+
: isMac
|
|
355
|
+
? join(
|
|
356
|
+
home,
|
|
357
|
+
"Library",
|
|
358
|
+
"Application Support",
|
|
359
|
+
"BraveSoftware",
|
|
360
|
+
"Brave-Browser-Nightly",
|
|
361
|
+
)
|
|
362
|
+
: join(xdgConfigHome, "BraveSoftware", "Brave-Browser-Nightly"),
|
|
363
|
+
},
|
|
364
|
+
// Vivaldi
|
|
365
|
+
{
|
|
366
|
+
browser: "Vivaldi",
|
|
367
|
+
channel: "stable",
|
|
368
|
+
dir: isWin
|
|
369
|
+
? join(localAppData, "Vivaldi", "User Data")
|
|
370
|
+
: isMac
|
|
371
|
+
? join(home, "Library", "Application Support", "Vivaldi")
|
|
372
|
+
: join(xdgConfigHome, "vivaldi"),
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
browser: "Vivaldi",
|
|
376
|
+
channel: "snapshot",
|
|
377
|
+
dir: isWin
|
|
378
|
+
? join(localAppData, "Vivaldi Snapshot", "User Data")
|
|
379
|
+
: isMac
|
|
380
|
+
? join(home, "Library", "Application Support", "Vivaldi Snapshot")
|
|
381
|
+
: join(xdgConfigHome, "vivaldi-snapshot"),
|
|
382
|
+
},
|
|
383
|
+
];
|
|
384
|
+
return dirs.filter((entry) => entry.dir);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Discover existing Chromium-based browser user-data directories.
|
|
389
|
+
*
|
|
390
|
+
* @returns {Array<{browser: string, channel: string, dir: string}>}
|
|
391
|
+
*/
|
|
392
|
+
export function discoverChromiumExtensionDirs() {
|
|
393
|
+
const found = [];
|
|
394
|
+
const seen = new Set();
|
|
395
|
+
for (const browserDir of getChromiumExtensionDirs()) {
|
|
396
|
+
if (safeExistsSync(browserDir.dir) && !seen.has(browserDir.dir)) {
|
|
397
|
+
seen.add(browserDir.dir);
|
|
398
|
+
found.push(browserDir);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return found;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Compare Chromium extension versions with numeric dot-separated semantics.
|
|
406
|
+
*
|
|
407
|
+
* @param {string} leftVersion Left version
|
|
408
|
+
* @param {string} rightVersion Right version
|
|
409
|
+
* @returns {number} Negative when left<right, positive when left>right, zero when equal
|
|
410
|
+
*/
|
|
411
|
+
export function compareChromiumExtensionVersions(leftVersion, rightVersion) {
|
|
412
|
+
const leftParts = String(leftVersion || "")
|
|
413
|
+
.split(".")
|
|
414
|
+
.map((part) => Number.parseInt(part, 10));
|
|
415
|
+
const rightParts = String(rightVersion || "")
|
|
416
|
+
.split(".")
|
|
417
|
+
.map((part) => Number.parseInt(part, 10));
|
|
418
|
+
const maxLength = Math.max(leftParts.length, rightParts.length);
|
|
419
|
+
for (let i = 0; i < maxLength; i++) {
|
|
420
|
+
const leftRawPart = leftParts[i];
|
|
421
|
+
const rightRawPart = rightParts[i];
|
|
422
|
+
const leftPart =
|
|
423
|
+
leftRawPart === undefined || Number.isNaN(leftRawPart) ? 0 : leftRawPart;
|
|
424
|
+
const rightPart =
|
|
425
|
+
rightRawPart === undefined || Number.isNaN(rightRawPart)
|
|
426
|
+
? 0
|
|
427
|
+
: rightRawPart;
|
|
428
|
+
if (leftPart !== rightPart) {
|
|
429
|
+
return leftPart - rightPart;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return 0;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Read profile names from Chromium user-data directory.
|
|
437
|
+
*
|
|
438
|
+
* @param {string} userDataDir Browser user-data directory
|
|
439
|
+
* @returns {string[]} Profile directory names
|
|
440
|
+
*/
|
|
441
|
+
export function getChromiumProfiles(userDataDir) {
|
|
442
|
+
const profiles = [];
|
|
443
|
+
const localStateFile = join(userDataDir, "Local State");
|
|
444
|
+
if (safeExistsSync(localStateFile)) {
|
|
445
|
+
try {
|
|
446
|
+
const localState = JSON.parse(readFileSync(localStateFile, "utf-8"));
|
|
447
|
+
const infoCache = localState?.profile?.info_cache;
|
|
448
|
+
if (infoCache && typeof infoCache === "object") {
|
|
449
|
+
for (const profileName of Object.keys(infoCache)) {
|
|
450
|
+
if (safeExistsSync(join(userDataDir, profileName, "Extensions"))) {
|
|
451
|
+
profiles.push(profileName);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
const lastUsed = localState?.profile?.last_used;
|
|
456
|
+
if (
|
|
457
|
+
lastUsed &&
|
|
458
|
+
safeExistsSync(join(userDataDir, lastUsed, "Extensions")) &&
|
|
459
|
+
!profiles.includes(lastUsed)
|
|
460
|
+
) {
|
|
461
|
+
profiles.push(lastUsed);
|
|
462
|
+
}
|
|
463
|
+
} catch (_err) {
|
|
464
|
+
// Ignore malformed Local State and fallback to directory scan
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if (profiles.length) {
|
|
468
|
+
return profiles;
|
|
469
|
+
}
|
|
470
|
+
try {
|
|
471
|
+
const profileDirs = readdirSync(userDataDir, { withFileTypes: true })
|
|
472
|
+
.filter((entry) => entry.isDirectory())
|
|
473
|
+
.map((entry) => entry.name)
|
|
474
|
+
.filter((name) => name === "Default" || /^Profile \d+$/.test(name))
|
|
475
|
+
.filter((name) => safeExistsSync(join(userDataDir, name, "Extensions")));
|
|
476
|
+
if (profileDirs.length) {
|
|
477
|
+
return profileDirs;
|
|
478
|
+
}
|
|
479
|
+
} catch (_err) {
|
|
480
|
+
// Ignore directory scan errors
|
|
481
|
+
}
|
|
482
|
+
return safeExistsSync(join(userDataDir, "Default", "Extensions"))
|
|
483
|
+
? ["Default"]
|
|
484
|
+
: [];
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Parse a Chromium extension manifest file.
|
|
489
|
+
*
|
|
490
|
+
* @param {string} manifestFile Absolute path to manifest.json
|
|
491
|
+
* @returns {Object|undefined} Parsed manifest metadata
|
|
492
|
+
*/
|
|
493
|
+
export function parseChromiumExtensionManifest(manifestFile) {
|
|
494
|
+
if (!safeExistsSync(manifestFile)) {
|
|
495
|
+
return undefined;
|
|
496
|
+
}
|
|
497
|
+
try {
|
|
498
|
+
const manifest = JSON.parse(readFileSync(manifestFile, "utf-8"));
|
|
499
|
+
const permissions = Array.isArray(manifest.permissions)
|
|
500
|
+
? manifest.permissions.filter((value) => typeof value === "string")
|
|
501
|
+
: [];
|
|
502
|
+
const optionalPermissions = Array.isArray(manifest.optional_permissions)
|
|
503
|
+
? manifest.optional_permissions.filter(
|
|
504
|
+
(value) => typeof value === "string",
|
|
505
|
+
)
|
|
506
|
+
: [];
|
|
507
|
+
const declaredHostPermissions = Array.isArray(manifest.host_permissions)
|
|
508
|
+
? manifest.host_permissions.filter((value) => typeof value === "string")
|
|
509
|
+
: [];
|
|
510
|
+
const optionalHostPermissions = Array.isArray(
|
|
511
|
+
manifest.optional_host_permissions,
|
|
512
|
+
)
|
|
513
|
+
? manifest.optional_host_permissions.filter(
|
|
514
|
+
(value) => typeof value === "string",
|
|
515
|
+
)
|
|
516
|
+
: [];
|
|
517
|
+
const commands =
|
|
518
|
+
manifest.commands && typeof manifest.commands === "object"
|
|
519
|
+
? Object.keys(manifest.commands).filter(Boolean)
|
|
520
|
+
: [];
|
|
521
|
+
const contentScriptsRunAt = Array.isArray(manifest.content_scripts)
|
|
522
|
+
? [
|
|
523
|
+
...new Set(
|
|
524
|
+
manifest.content_scripts
|
|
525
|
+
.map((script) => script?.run_at)
|
|
526
|
+
.filter((value) => typeof value === "string"),
|
|
527
|
+
),
|
|
528
|
+
]
|
|
529
|
+
: [];
|
|
530
|
+
const contentScriptsMatches = Array.isArray(manifest.content_scripts)
|
|
531
|
+
? [
|
|
532
|
+
...new Set(
|
|
533
|
+
manifest.content_scripts
|
|
534
|
+
.flatMap((script) =>
|
|
535
|
+
Array.isArray(script?.matches) ? script.matches : [],
|
|
536
|
+
)
|
|
537
|
+
.filter((value) => typeof value === "string"),
|
|
538
|
+
),
|
|
539
|
+
]
|
|
540
|
+
: [];
|
|
541
|
+
const hostPermissions = [
|
|
542
|
+
...new Set([...declaredHostPermissions, ...contentScriptsMatches]),
|
|
543
|
+
];
|
|
544
|
+
const hasAutofillInContentScripts = Array.isArray(manifest.content_scripts)
|
|
545
|
+
? manifest.content_scripts.some((script) => {
|
|
546
|
+
if (!script || typeof script !== "object") {
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
549
|
+
const jsEntries = Array.isArray(script.js) ? script.js : [];
|
|
550
|
+
const cssEntries = Array.isArray(script.css) ? script.css : [];
|
|
551
|
+
const hasAutofillInJs = jsEntries.some(
|
|
552
|
+
(entry) =>
|
|
553
|
+
typeof entry === "string" &&
|
|
554
|
+
entry.toLowerCase().includes("autofill"),
|
|
555
|
+
);
|
|
556
|
+
const hasAutofillInCss = cssEntries.some(
|
|
557
|
+
(entry) =>
|
|
558
|
+
typeof entry === "string" &&
|
|
559
|
+
entry.toLowerCase().includes("autofill"),
|
|
560
|
+
);
|
|
561
|
+
return hasAutofillInJs || hasAutofillInCss;
|
|
562
|
+
})
|
|
563
|
+
: false;
|
|
564
|
+
const hasAutofill =
|
|
565
|
+
permissions.some((permission) =>
|
|
566
|
+
permission.toLowerCase().includes("autofill"),
|
|
567
|
+
) ||
|
|
568
|
+
optionalPermissions.some((permission) =>
|
|
569
|
+
permission.toLowerCase().includes("autofill"),
|
|
570
|
+
) ||
|
|
571
|
+
hasAutofillInContentScripts ||
|
|
572
|
+
commands.some((commandName) =>
|
|
573
|
+
commandName.toLowerCase().includes("autofill"),
|
|
574
|
+
);
|
|
575
|
+
let contentSecurityPolicy = "";
|
|
576
|
+
if (typeof manifest.content_security_policy === "string") {
|
|
577
|
+
contentSecurityPolicy = manifest.content_security_policy;
|
|
578
|
+
} else if (
|
|
579
|
+
manifest.content_security_policy &&
|
|
580
|
+
typeof manifest.content_security_policy === "object"
|
|
581
|
+
) {
|
|
582
|
+
contentSecurityPolicy = JSON.stringify(manifest.content_security_policy);
|
|
583
|
+
}
|
|
584
|
+
const webAccessibleResourceMatches = Array.isArray(
|
|
585
|
+
manifest.web_accessible_resources,
|
|
586
|
+
)
|
|
587
|
+
? [
|
|
588
|
+
...new Set(
|
|
589
|
+
manifest.web_accessible_resources
|
|
590
|
+
.flatMap((entry) => {
|
|
591
|
+
if (typeof entry === "string") {
|
|
592
|
+
return [];
|
|
593
|
+
}
|
|
594
|
+
const matches = Array.isArray(entry?.matches)
|
|
595
|
+
? entry.matches
|
|
596
|
+
: [];
|
|
597
|
+
return matches.filter((value) => typeof value === "string");
|
|
598
|
+
})
|
|
599
|
+
.filter(Boolean),
|
|
600
|
+
),
|
|
601
|
+
]
|
|
602
|
+
: [];
|
|
603
|
+
const externallyConnectableMatches = Array.isArray(
|
|
604
|
+
manifest.externally_connectable?.matches,
|
|
605
|
+
)
|
|
606
|
+
? manifest.externally_connectable.matches.filter(
|
|
607
|
+
(value) => typeof value === "string",
|
|
608
|
+
)
|
|
609
|
+
: [];
|
|
610
|
+
const capabilities = inferChromiumCapabilitySignals({
|
|
611
|
+
permissions,
|
|
612
|
+
optionalPermissions,
|
|
613
|
+
hostPermissions,
|
|
614
|
+
optionalHostPermissions,
|
|
615
|
+
commands,
|
|
616
|
+
contentScripts: manifest.content_scripts,
|
|
617
|
+
fileBrowserHandlers: manifest.file_browser_handlers,
|
|
618
|
+
webAccessibleResources: manifest.web_accessible_resources,
|
|
619
|
+
});
|
|
620
|
+
return {
|
|
621
|
+
name: manifest.name || "",
|
|
622
|
+
description: manifest.description || "",
|
|
623
|
+
version: manifest.version || "",
|
|
624
|
+
versionName: manifest.version_name || "",
|
|
625
|
+
manifestVersion: manifest.manifest_version,
|
|
626
|
+
updateUrl: manifest.update_url || "",
|
|
627
|
+
minimumChromeVersion: manifest.minimum_chrome_version || "",
|
|
628
|
+
minimumEdgeVersion: manifest.minimum_edge_version || "",
|
|
629
|
+
incognito: manifest.incognito || "",
|
|
630
|
+
offlineEnabled:
|
|
631
|
+
typeof manifest.offline_enabled === "boolean"
|
|
632
|
+
? manifest.offline_enabled
|
|
633
|
+
: undefined,
|
|
634
|
+
permissions,
|
|
635
|
+
optionalPermissions,
|
|
636
|
+
hostPermissions,
|
|
637
|
+
optionalHostPermissions,
|
|
638
|
+
commands,
|
|
639
|
+
contentScriptsRunAt,
|
|
640
|
+
contentScriptsMatches,
|
|
641
|
+
contentSecurityPolicy,
|
|
642
|
+
storageManagedSchema: manifest?.storage?.managed_schema || "",
|
|
643
|
+
webAccessibleResourceMatches,
|
|
644
|
+
externallyConnectableMatches,
|
|
645
|
+
edgeUrlOverrides: manifest.edge_url_overrides || undefined,
|
|
646
|
+
braveMaybeBackground:
|
|
647
|
+
manifest.MAYBE_background &&
|
|
648
|
+
typeof manifest.MAYBE_background === "object",
|
|
649
|
+
bravePermissions: permissions.filter((permission) =>
|
|
650
|
+
BRAVE_SPECIFIC_PERMISSIONS.includes(permission),
|
|
651
|
+
),
|
|
652
|
+
capabilities,
|
|
653
|
+
hasAutofill,
|
|
654
|
+
};
|
|
655
|
+
} catch (_err) {
|
|
656
|
+
return undefined;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Infer browser context from a resolved Chromium extension manifest path.
|
|
662
|
+
*
|
|
663
|
+
* @param {string} manifestFile Absolute path to manifest.json
|
|
664
|
+
* @returns {{browser?: string, channel?: string, profile?: string, profilePath?: string}}
|
|
665
|
+
*/
|
|
666
|
+
export function inferChromiumContextFromManifest(manifestFile) {
|
|
667
|
+
const resolvedManifest = resolve(manifestFile);
|
|
668
|
+
for (const browserDir of getChromiumExtensionDirs()) {
|
|
669
|
+
const resolvedBrowserDir = resolve(browserDir.dir);
|
|
670
|
+
const browserRootPrefix = `${resolvedBrowserDir}${sep}`;
|
|
671
|
+
if (!resolvedManifest.startsWith(browserRootPrefix)) {
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
const rel = relative(resolvedBrowserDir, resolvedManifest);
|
|
675
|
+
const relParts = rel.split(sep);
|
|
676
|
+
if (
|
|
677
|
+
relParts.length >= 5 &&
|
|
678
|
+
relParts[0] &&
|
|
679
|
+
relParts[1] === "Extensions" &&
|
|
680
|
+
CHROME_EXTENSION_ID_REGEX.test(relParts[2]) &&
|
|
681
|
+
relParts[4] === "manifest.json"
|
|
682
|
+
) {
|
|
683
|
+
return {
|
|
684
|
+
browser: browserDir.browser,
|
|
685
|
+
channel: browserDir.channel,
|
|
686
|
+
profile: relParts[0],
|
|
687
|
+
profilePath: join(resolvedBrowserDir, relParts[0]),
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
return {};
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Pick the latest installed version directory for an extension-id directory.
|
|
696
|
+
*
|
|
697
|
+
* @param {string} extensionIdDir Path to `<...>/Extensions/<extension-id>`
|
|
698
|
+
* @returns {string|undefined} Absolute path to the latest version directory
|
|
699
|
+
*/
|
|
700
|
+
function getLatestExtensionVersionDir(extensionIdDir) {
|
|
701
|
+
if (!safeExistsSync(extensionIdDir)) {
|
|
702
|
+
return undefined;
|
|
703
|
+
}
|
|
704
|
+
let versionDirs;
|
|
705
|
+
try {
|
|
706
|
+
versionDirs = readdirSync(extensionIdDir, { withFileTypes: true })
|
|
707
|
+
.filter((entry) => entry.isDirectory())
|
|
708
|
+
.map((entry) => entry.name);
|
|
709
|
+
} catch (_err) {
|
|
710
|
+
return undefined;
|
|
711
|
+
}
|
|
712
|
+
if (!versionDirs.length) {
|
|
713
|
+
return undefined;
|
|
714
|
+
}
|
|
715
|
+
versionDirs.sort(compareChromiumExtensionVersions);
|
|
716
|
+
return join(extensionIdDir, versionDirs[versionDirs.length - 1]);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Convert a manifest file path into a CycloneDX component and extension dir.
|
|
721
|
+
*
|
|
722
|
+
* @param {string} manifestFile Absolute path to manifest.json
|
|
723
|
+
* @returns {{component?: Object, extensionDir?: string}}
|
|
724
|
+
*/
|
|
725
|
+
function parseChromeExtensionFromManifestPath(manifestFile) {
|
|
726
|
+
if (!safeExistsSync(manifestFile)) {
|
|
727
|
+
return {};
|
|
728
|
+
}
|
|
729
|
+
const extensionDir = dirname(manifestFile);
|
|
730
|
+
const extensionId = basename(dirname(extensionDir)).toLowerCase();
|
|
731
|
+
if (!CHROME_EXTENSION_ID_REGEX.test(extensionId)) {
|
|
732
|
+
return {};
|
|
733
|
+
}
|
|
734
|
+
const versionFromPath = basename(extensionDir);
|
|
735
|
+
const manifest = parseChromiumExtensionManifest(manifestFile);
|
|
736
|
+
const codeCapabilities = detectCachedExtensionCapabilities(extensionDir);
|
|
737
|
+
const context = inferChromiumContextFromManifest(manifestFile);
|
|
738
|
+
return {
|
|
739
|
+
component: toComponent({
|
|
740
|
+
extensionId,
|
|
741
|
+
version: manifest?.version || versionFromPath,
|
|
742
|
+
displayName: manifest?.name || "",
|
|
743
|
+
description: manifest?.description || "",
|
|
744
|
+
manifestVersion: manifest?.manifestVersion,
|
|
745
|
+
updateUrl: manifest?.updateUrl || "",
|
|
746
|
+
permissions: manifest?.permissions || [],
|
|
747
|
+
optionalPermissions: manifest?.optionalPermissions || [],
|
|
748
|
+
hostPermissions: manifest?.hostPermissions || [],
|
|
749
|
+
optionalHostPermissions: manifest?.optionalHostPermissions || [],
|
|
750
|
+
commands: manifest?.commands || [],
|
|
751
|
+
contentScriptsRunAt: manifest?.contentScriptsRunAt || [],
|
|
752
|
+
contentScriptsMatches: manifest?.contentScriptsMatches || [],
|
|
753
|
+
contentSecurityPolicy: manifest?.contentSecurityPolicy || "",
|
|
754
|
+
storageManagedSchema: manifest?.storageManagedSchema || "",
|
|
755
|
+
minimumChromeVersion: manifest?.minimumChromeVersion || "",
|
|
756
|
+
minimumEdgeVersion: manifest?.minimumEdgeVersion || "",
|
|
757
|
+
versionName: manifest?.versionName || "",
|
|
758
|
+
incognito: manifest?.incognito || "",
|
|
759
|
+
offlineEnabled: manifest?.offlineEnabled,
|
|
760
|
+
webAccessibleResourceMatches:
|
|
761
|
+
manifest?.webAccessibleResourceMatches || [],
|
|
762
|
+
externallyConnectableMatches:
|
|
763
|
+
manifest?.externallyConnectableMatches || [],
|
|
764
|
+
edgeUrlOverrides: manifest?.edgeUrlOverrides,
|
|
765
|
+
braveMaybeBackground: manifest?.braveMaybeBackground || false,
|
|
766
|
+
bravePermissions: manifest?.bravePermissions || [],
|
|
767
|
+
capabilities: mergeCapabilitySignals(
|
|
768
|
+
manifest?.capabilities || {},
|
|
769
|
+
codeCapabilities,
|
|
770
|
+
),
|
|
771
|
+
hasAutofill: manifest?.hasAutofill || false,
|
|
772
|
+
srcPath: manifestFile,
|
|
773
|
+
...context,
|
|
774
|
+
}),
|
|
775
|
+
extensionDir,
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Collect one directly specified extension from a path.
|
|
781
|
+
*
|
|
782
|
+
* Supported path forms:
|
|
783
|
+
* - `<...>/manifest.json`
|
|
784
|
+
* - `<...>/<extension-id>/<version>/manifest.json`
|
|
785
|
+
* - `<...>/<version>/` (contains manifest.json)
|
|
786
|
+
* - `<...>/<extension-id>/` (contains version subdirectories)
|
|
787
|
+
*
|
|
788
|
+
* Note: a standalone `<...>/<version>/` directory is not sufficient unless its
|
|
789
|
+
* parent directory name is the extension id, because the parser derives the
|
|
790
|
+
* extension id from the version directory's parent path.
|
|
791
|
+
*
|
|
792
|
+
* @param {string} extensionPath Candidate extension path
|
|
793
|
+
* @returns {{components: Object[], extensionDirs: string[]}}
|
|
794
|
+
*/
|
|
795
|
+
export function collectChromeExtensionsFromPath(extensionPath) {
|
|
796
|
+
if (!extensionPath || !safeExistsSync(extensionPath)) {
|
|
797
|
+
return { components: [], extensionDirs: [] };
|
|
798
|
+
}
|
|
799
|
+
const resolvedPath = resolve(extensionPath);
|
|
800
|
+
const manifestCandidates = [];
|
|
801
|
+
const extensionDirs = [];
|
|
802
|
+
const seenManifestFiles = new Set();
|
|
803
|
+
const name = basename(resolvedPath);
|
|
804
|
+
if (name === "manifest.json") {
|
|
805
|
+
manifestCandidates.push(resolvedPath);
|
|
806
|
+
} else if (safeExistsSync(join(resolvedPath, "manifest.json"))) {
|
|
807
|
+
manifestCandidates.push(join(resolvedPath, "manifest.json"));
|
|
808
|
+
} else if (CHROME_EXTENSION_ID_REGEX.test(name)) {
|
|
809
|
+
const latestVersionDir = getLatestExtensionVersionDir(resolvedPath);
|
|
810
|
+
if (latestVersionDir) {
|
|
811
|
+
manifestCandidates.push(join(latestVersionDir, "manifest.json"));
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
const components = [];
|
|
815
|
+
const seenBomRefs = new Set();
|
|
816
|
+
for (const manifestFile of manifestCandidates) {
|
|
817
|
+
if (seenManifestFiles.has(manifestFile)) {
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
820
|
+
seenManifestFiles.add(manifestFile);
|
|
821
|
+
const { component, extensionDir } =
|
|
822
|
+
parseChromeExtensionFromManifestPath(manifestFile);
|
|
823
|
+
if (extensionDir && !extensionDirs.includes(extensionDir)) {
|
|
824
|
+
extensionDirs.push(extensionDir);
|
|
825
|
+
}
|
|
826
|
+
if (component?.["bom-ref"] && !seenBomRefs.has(component["bom-ref"])) {
|
|
827
|
+
seenBomRefs.add(component["bom-ref"]);
|
|
828
|
+
components.push(component);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
return { components, extensionDirs };
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Convert parsed Chromium extension metadata into a CycloneDX component object.
|
|
836
|
+
*
|
|
837
|
+
* @param {Object} extInfo Extension metadata
|
|
838
|
+
* @returns {Object|undefined} CycloneDX component object or undefined
|
|
839
|
+
*/
|
|
840
|
+
export function toComponent(extInfo) {
|
|
841
|
+
if (!extInfo?.extensionId) {
|
|
842
|
+
return undefined;
|
|
843
|
+
}
|
|
844
|
+
const extensionId = extInfo.extensionId.toLowerCase();
|
|
845
|
+
const purl = build({
|
|
846
|
+
type: CHROME_EXTENSION_PURL_TYPE,
|
|
847
|
+
name: extensionId,
|
|
848
|
+
version: extInfo.version || null || null,
|
|
849
|
+
});
|
|
850
|
+
const component = {
|
|
851
|
+
name: extensionId,
|
|
852
|
+
version: extInfo.version || "",
|
|
853
|
+
description: String(
|
|
854
|
+
sanitizeBomPropertyValue(
|
|
855
|
+
"cdx:chrome-extension:description",
|
|
856
|
+
extInfo.displayName || extInfo.description || "",
|
|
857
|
+
) || "",
|
|
858
|
+
),
|
|
859
|
+
purl,
|
|
860
|
+
"bom-ref": decodeURIComponent(purl),
|
|
861
|
+
type: "application",
|
|
862
|
+
};
|
|
863
|
+
const properties = [];
|
|
864
|
+
if (extInfo.browser) {
|
|
865
|
+
properties.push({
|
|
866
|
+
name: "cdx:chrome-extension:browser",
|
|
867
|
+
value: extInfo.browser,
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
if (extInfo.channel) {
|
|
871
|
+
properties.push({
|
|
872
|
+
name: "cdx:chrome-extension:channel",
|
|
873
|
+
value: extInfo.channel,
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
if (extInfo.profile) {
|
|
877
|
+
properties.push({
|
|
878
|
+
name: "cdx:chrome-extension:profile",
|
|
879
|
+
value: extInfo.profile,
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
if (extInfo.profilePath) {
|
|
883
|
+
properties.push({
|
|
884
|
+
name: "cdx:chrome-extension:profilePath",
|
|
885
|
+
value: extInfo.profilePath,
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
if (extInfo.manifestVersion !== undefined) {
|
|
889
|
+
properties.push({
|
|
890
|
+
name: "cdx:chrome-extension:manifestVersion",
|
|
891
|
+
value: String(extInfo.manifestVersion),
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
if (extInfo.updateUrl) {
|
|
895
|
+
properties.push({
|
|
896
|
+
name: "cdx:chrome-extension:updateUrl",
|
|
897
|
+
value: extInfo.updateUrl,
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
if (extInfo.permissions?.length) {
|
|
901
|
+
properties.push({
|
|
902
|
+
name: "cdx:chrome-extension:permissions",
|
|
903
|
+
value: extInfo.permissions.join(", "),
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
if (extInfo.optionalPermissions?.length) {
|
|
907
|
+
properties.push({
|
|
908
|
+
name: "cdx:chrome-extension:optionalPermissions",
|
|
909
|
+
value: extInfo.optionalPermissions.join(", "),
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
if (extInfo.hostPermissions?.length) {
|
|
913
|
+
properties.push({
|
|
914
|
+
name: "cdx:chrome-extension:hostPermissions",
|
|
915
|
+
value: extInfo.hostPermissions.join(", "),
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
if (extInfo.optionalHostPermissions?.length) {
|
|
919
|
+
properties.push({
|
|
920
|
+
name: "cdx:chrome-extension:optionalHostPermissions",
|
|
921
|
+
value: extInfo.optionalHostPermissions.join(", "),
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
if (extInfo.commands?.length) {
|
|
925
|
+
properties.push({
|
|
926
|
+
name: "cdx:chrome-extension:commands",
|
|
927
|
+
value: extInfo.commands.join(", "),
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
if (extInfo.contentScriptsRunAt?.length) {
|
|
931
|
+
properties.push({
|
|
932
|
+
name: "cdx:chrome-extension:contentScriptsRunAt",
|
|
933
|
+
value: extInfo.contentScriptsRunAt.join(", "),
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
if (extInfo.contentScriptsMatches?.length) {
|
|
937
|
+
properties.push({
|
|
938
|
+
name: "cdx:chrome-extension:contentScriptsMatches",
|
|
939
|
+
value: extInfo.contentScriptsMatches.join(", "),
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
if (extInfo.contentSecurityPolicy) {
|
|
943
|
+
properties.push({
|
|
944
|
+
name: "cdx:chrome-extension:contentSecurityPolicy",
|
|
945
|
+
value: extInfo.contentSecurityPolicy,
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
if (extInfo.storageManagedSchema) {
|
|
949
|
+
properties.push({
|
|
950
|
+
name: "cdx:chrome-extension:storageManagedSchema",
|
|
951
|
+
value: extInfo.storageManagedSchema,
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
if (extInfo.minimumChromeVersion) {
|
|
955
|
+
properties.push({
|
|
956
|
+
name: "cdx:chrome-extension:minimumChromeVersion",
|
|
957
|
+
value: extInfo.minimumChromeVersion,
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
if (extInfo.versionName) {
|
|
961
|
+
properties.push({
|
|
962
|
+
name: "cdx:chrome-extension:versionName",
|
|
963
|
+
value: extInfo.versionName,
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
if (extInfo.incognito) {
|
|
967
|
+
properties.push({
|
|
968
|
+
name: "cdx:chrome-extension:incognito",
|
|
969
|
+
value: extInfo.incognito,
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
if (typeof extInfo.offlineEnabled === "boolean") {
|
|
973
|
+
properties.push({
|
|
974
|
+
name: "cdx:chrome-extension:offlineEnabled",
|
|
975
|
+
value: String(extInfo.offlineEnabled),
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
if (extInfo.webAccessibleResourceMatches?.length) {
|
|
979
|
+
properties.push({
|
|
980
|
+
name: "cdx:chrome-extension:webAccessibleResourceMatches",
|
|
981
|
+
value: extInfo.webAccessibleResourceMatches.join(", "),
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
if (extInfo.externallyConnectableMatches?.length) {
|
|
985
|
+
properties.push({
|
|
986
|
+
name: "cdx:chrome-extension:externallyConnectableMatches",
|
|
987
|
+
value: extInfo.externallyConnectableMatches.join(", "),
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
if (extInfo.minimumEdgeVersion) {
|
|
991
|
+
properties.push({
|
|
992
|
+
name: "cdx:chrome-extension:edge:minimumVersion",
|
|
993
|
+
value: extInfo.minimumEdgeVersion,
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
if (extInfo.edgeUrlOverrides) {
|
|
997
|
+
properties.push({
|
|
998
|
+
name: "cdx:chrome-extension:edge:urlOverrides",
|
|
999
|
+
value:
|
|
1000
|
+
typeof extInfo.edgeUrlOverrides === "string"
|
|
1001
|
+
? extInfo.edgeUrlOverrides
|
|
1002
|
+
: JSON.stringify(extInfo.edgeUrlOverrides),
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
if (extInfo.braveMaybeBackground) {
|
|
1006
|
+
properties.push({
|
|
1007
|
+
name: "cdx:chrome-extension:brave:maybeBackground",
|
|
1008
|
+
value: "true",
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
if (extInfo.bravePermissions?.length) {
|
|
1012
|
+
properties.push({
|
|
1013
|
+
name: "cdx:chrome-extension:brave:permissions",
|
|
1014
|
+
value: extInfo.bravePermissions.join(", "),
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
if (extInfo.capabilities) {
|
|
1018
|
+
const capabilityNames = CHROMIUM_EXTENSION_CAPABILITY_CATEGORIES.filter(
|
|
1019
|
+
(capabilityName) => extInfo.capabilities?.[capabilityName],
|
|
1020
|
+
);
|
|
1021
|
+
if (capabilityNames.length) {
|
|
1022
|
+
properties.push({
|
|
1023
|
+
name: "cdx:chrome-extension:capabilities",
|
|
1024
|
+
value: capabilityNames.join(", "),
|
|
1025
|
+
});
|
|
1026
|
+
for (const capabilityName of capabilityNames) {
|
|
1027
|
+
properties.push({
|
|
1028
|
+
name: `cdx:chrome-extension:capability:${capabilityName}`,
|
|
1029
|
+
value: "true",
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
if (extInfo.hasAutofill) {
|
|
1035
|
+
properties.push({
|
|
1036
|
+
name: "cdx:chrome-extension:hasAutofill",
|
|
1037
|
+
value: "true",
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
if (extInfo.srcPath) {
|
|
1041
|
+
properties.push({ name: "internal:SrcFile", value: extInfo.srcPath });
|
|
1042
|
+
}
|
|
1043
|
+
const sanitizedProperties = properties
|
|
1044
|
+
.map((property) => {
|
|
1045
|
+
const sanitizedValue = sanitizeBomPropertyValue(
|
|
1046
|
+
property.name,
|
|
1047
|
+
property.value,
|
|
1048
|
+
);
|
|
1049
|
+
if (
|
|
1050
|
+
sanitizedValue === undefined ||
|
|
1051
|
+
sanitizedValue === null ||
|
|
1052
|
+
sanitizedValue === ""
|
|
1053
|
+
) {
|
|
1054
|
+
return undefined;
|
|
1055
|
+
}
|
|
1056
|
+
return { name: property.name, value: String(sanitizedValue) };
|
|
1057
|
+
})
|
|
1058
|
+
.filter(Boolean);
|
|
1059
|
+
if (sanitizedProperties.length) {
|
|
1060
|
+
component.properties = sanitizedProperties;
|
|
1061
|
+
}
|
|
1062
|
+
return component;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* Collect installed Chromium extension components from discovered browser directories.
|
|
1067
|
+
*
|
|
1068
|
+
* @param {Array<{browser: string, channel: string, dir: string}>} browserDirs Browser directories
|
|
1069
|
+
* @returns {Object[]} Array of CycloneDX component objects
|
|
1070
|
+
*/
|
|
1071
|
+
export function collectInstalledChromeExtensions(browserDirs) {
|
|
1072
|
+
const installMap = new Map();
|
|
1073
|
+
for (const browserDir of browserDirs) {
|
|
1074
|
+
const profiles = getChromiumProfiles(browserDir.dir);
|
|
1075
|
+
for (const profileName of profiles) {
|
|
1076
|
+
const profilePath = join(browserDir.dir, profileName);
|
|
1077
|
+
const extensionsDir = join(profilePath, "Extensions");
|
|
1078
|
+
if (!safeExistsSync(extensionsDir)) {
|
|
1079
|
+
continue;
|
|
1080
|
+
}
|
|
1081
|
+
let extensionEntries;
|
|
1082
|
+
try {
|
|
1083
|
+
extensionEntries = readdirSync(extensionsDir, { withFileTypes: true });
|
|
1084
|
+
} catch (_err) {
|
|
1085
|
+
continue;
|
|
1086
|
+
}
|
|
1087
|
+
for (const extensionEntry of extensionEntries) {
|
|
1088
|
+
if (!extensionEntry.isDirectory()) {
|
|
1089
|
+
continue;
|
|
1090
|
+
}
|
|
1091
|
+
const extensionId = extensionEntry.name.toLowerCase();
|
|
1092
|
+
if (!CHROME_EXTENSION_ID_REGEX.test(extensionId)) {
|
|
1093
|
+
continue;
|
|
1094
|
+
}
|
|
1095
|
+
const versionRoot = join(extensionsDir, extensionEntry.name);
|
|
1096
|
+
let versionEntries;
|
|
1097
|
+
try {
|
|
1098
|
+
versionEntries = readdirSync(versionRoot, { withFileTypes: true })
|
|
1099
|
+
.filter((entry) => entry.isDirectory())
|
|
1100
|
+
.map((entry) => entry.name);
|
|
1101
|
+
} catch (_err) {
|
|
1102
|
+
continue;
|
|
1103
|
+
}
|
|
1104
|
+
if (!versionEntries.length) {
|
|
1105
|
+
continue;
|
|
1106
|
+
}
|
|
1107
|
+
versionEntries.sort(compareChromiumExtensionVersions);
|
|
1108
|
+
const version = versionEntries[versionEntries.length - 1];
|
|
1109
|
+
const manifestPath = join(versionRoot, version, "manifest.json");
|
|
1110
|
+
const manifest = parseChromiumExtensionManifest(manifestPath);
|
|
1111
|
+
const extensionDir = join(versionRoot, version);
|
|
1112
|
+
const codeCapabilities =
|
|
1113
|
+
detectCachedExtensionCapabilities(extensionDir);
|
|
1114
|
+
const extInfo = {
|
|
1115
|
+
extensionId,
|
|
1116
|
+
version: manifest?.version || version,
|
|
1117
|
+
displayName: manifest?.name || "",
|
|
1118
|
+
description: manifest?.description || "",
|
|
1119
|
+
manifestVersion: manifest?.manifestVersion,
|
|
1120
|
+
updateUrl: manifest?.updateUrl || "",
|
|
1121
|
+
permissions: manifest?.permissions || [],
|
|
1122
|
+
optionalPermissions: manifest?.optionalPermissions || [],
|
|
1123
|
+
hostPermissions: manifest?.hostPermissions || [],
|
|
1124
|
+
optionalHostPermissions: manifest?.optionalHostPermissions || [],
|
|
1125
|
+
commands: manifest?.commands || [],
|
|
1126
|
+
contentScriptsRunAt: manifest?.contentScriptsRunAt || [],
|
|
1127
|
+
contentSecurityPolicy: manifest?.contentSecurityPolicy || "",
|
|
1128
|
+
storageManagedSchema: manifest?.storageManagedSchema || "",
|
|
1129
|
+
minimumChromeVersion: manifest?.minimumChromeVersion || "",
|
|
1130
|
+
minimumEdgeVersion: manifest?.minimumEdgeVersion || "",
|
|
1131
|
+
versionName: manifest?.versionName || "",
|
|
1132
|
+
incognito: manifest?.incognito || "",
|
|
1133
|
+
offlineEnabled: manifest?.offlineEnabled,
|
|
1134
|
+
webAccessibleResourceMatches:
|
|
1135
|
+
manifest?.webAccessibleResourceMatches || [],
|
|
1136
|
+
externallyConnectableMatches:
|
|
1137
|
+
manifest?.externallyConnectableMatches || [],
|
|
1138
|
+
edgeUrlOverrides: manifest?.edgeUrlOverrides,
|
|
1139
|
+
braveMaybeBackground: manifest?.braveMaybeBackground || false,
|
|
1140
|
+
bravePermissions: manifest?.bravePermissions || [],
|
|
1141
|
+
capabilities: mergeCapabilitySignals(
|
|
1142
|
+
manifest?.capabilities || {},
|
|
1143
|
+
codeCapabilities,
|
|
1144
|
+
),
|
|
1145
|
+
hasAutofill: manifest?.hasAutofill || false,
|
|
1146
|
+
browser: browserDir.browser,
|
|
1147
|
+
channel: browserDir.channel,
|
|
1148
|
+
profile: profileName,
|
|
1149
|
+
profilePath,
|
|
1150
|
+
srcPath: manifestPath,
|
|
1151
|
+
};
|
|
1152
|
+
const key = `${browserDir.browser}|${browserDir.channel}|${profileName}|${extensionId}`;
|
|
1153
|
+
const existing = installMap.get(key);
|
|
1154
|
+
if (
|
|
1155
|
+
!existing ||
|
|
1156
|
+
compareChromiumExtensionVersions(existing.version, extInfo.version) <
|
|
1157
|
+
0
|
|
1158
|
+
) {
|
|
1159
|
+
installMap.set(key, extInfo);
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
const components = [];
|
|
1165
|
+
const seen = new Set();
|
|
1166
|
+
for (const extInfo of installMap.values()) {
|
|
1167
|
+
const component = toComponent(extInfo);
|
|
1168
|
+
if (component && !seen.has(component["bom-ref"])) {
|
|
1169
|
+
seen.add(component["bom-ref"]);
|
|
1170
|
+
components.push(component);
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
return components;
|
|
1174
|
+
}
|