vigievuln 1.3.2 → 1.4.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/CHANGELOG.md +63 -0
- package/README.md +34 -19
- package/completions/vigievuln.bash +14 -3
- package/completions/vigievuln.zsh +11 -8
- package/data/fingerprints/index.js +80 -0
- package/data/fingerprints/interpreters/javascript/bun.json +23 -0
- package/data/fingerprints/interpreters/javascript/deno.json +10 -0
- package/data/fingerprints/interpreters/javascript/electron.json +20 -0
- package/data/fingerprints/interpreters/javascript/gjs.json +8 -0
- package/data/fingerprints/interpreters/javascript/javascriptcore.json +14 -0
- package/data/fingerprints/interpreters/javascript/jscgtk.json +10 -0
- package/data/fingerprints/interpreters/javascript/node.json +26 -0
- package/data/fingerprints/interpreters/javascript/nwjs.json +8 -0
- package/data/fingerprints/interpreters/javascript/webkitgtk.json +10 -0
- package/data/fingerprints/interpreters/javascript/wpewebkit.json +10 -0
- package/data/fingerprints/interpreters/languages/dotnet.json +8 -0
- package/data/fingerprints/interpreters/languages/erlang.json +9 -0
- package/data/fingerprints/interpreters/languages/gawk.json +10 -0
- package/data/fingerprints/interpreters/languages/guile.json +9 -0
- package/data/fingerprints/interpreters/languages/java.json +8 -0
- package/data/fingerprints/interpreters/languages/julia.json +9 -0
- package/data/fingerprints/interpreters/languages/lua.json +11 -0
- package/data/fingerprints/interpreters/languages/luajit.json +10 -0
- package/data/fingerprints/interpreters/languages/perl.json +11 -0
- package/data/fingerprints/interpreters/languages/php.json +22 -0
- package/data/fingerprints/interpreters/languages/powershell.json +17 -0
- package/data/fingerprints/interpreters/languages/pypy.json +8 -0
- package/data/fingerprints/interpreters/languages/python.json +24 -0
- package/data/fingerprints/interpreters/languages/r.json +9 -0
- package/data/fingerprints/interpreters/languages/racket.json +9 -0
- package/data/fingerprints/interpreters/languages/raku.json +8 -0
- package/data/fingerprints/interpreters/languages/ruby.json +21 -0
- package/data/fingerprints/interpreters/languages/tcl.json +9 -0
- package/data/fingerprints/interpreters/shells/bash.json +10 -0
- package/data/fingerprints/interpreters/shells/dash.json +8 -0
- package/data/fingerprints/interpreters/shells/fish.json +9 -0
- package/data/fingerprints/interpreters/shells/ksh.json +8 -0
- package/data/fingerprints/interpreters/shells/zsh.json +9 -0
- package/data/fingerprints/services/databases/clickhouse.json +8 -0
- package/data/fingerprints/services/databases/elasticsearch.json +8 -0
- package/data/fingerprints/services/databases/etcd.json +9 -0
- package/data/fingerprints/services/databases/mariadb.json +9 -0
- package/data/fingerprints/services/databases/memcached.json +9 -0
- package/data/fingerprints/services/databases/mongo.json +8 -0
- package/data/fingerprints/services/databases/mysql.json +9 -0
- package/data/fingerprints/services/databases/opensearch.json +8 -0
- package/data/fingerprints/services/databases/postgres.json +18 -0
- package/data/fingerprints/services/databases/redis.json +9 -0
- package/data/fingerprints/services/databases/valkey.json +8 -0
- package/data/fingerprints/services/dns-directory/bind.json +8 -0
- package/data/fingerprints/services/dns-directory/dnsmasq.json +8 -0
- package/data/fingerprints/services/dns-directory/slapd.json +8 -0
- package/data/fingerprints/services/dns-directory/unbound.json +8 -0
- package/data/fingerprints/services/mail/cyrus.json +8 -0
- package/data/fingerprints/services/mail/dovecot.json +8 -0
- package/data/fingerprints/services/mail/exim.json +9 -0
- package/data/fingerprints/services/mail/opendkim.json +8 -0
- package/data/fingerprints/services/mail/opensmtpd.json +8 -0
- package/data/fingerprints/services/mail/postfix.json +8 -0
- package/data/fingerprints/services/mail/rspamd.json +8 -0
- package/data/fingerprints/services/mail/sendmail.json +8 -0
- package/data/fingerprints/services/messaging/kafka.json +8 -0
- package/data/fingerprints/services/messaging/mosquitto.json +8 -0
- package/data/fingerprints/services/messaging/nats.json +9 -0
- package/data/fingerprints/services/messaging/rabbitmq.json +8 -0
- package/data/fingerprints/services/remote-access/dropbear.json +8 -0
- package/data/fingerprints/services/remote-access/openssh.json +10 -0
- package/data/fingerprints/services/remote-access/proftpd.json +8 -0
- package/data/fingerprints/services/remote-access/samba.json +8 -0
- package/data/fingerprints/services/remote-access/vsftpd.json +8 -0
- package/data/fingerprints/services/web-proxies/apache.json +18 -0
- package/data/fingerprints/services/web-proxies/caddy.json +9 -0
- package/data/fingerprints/services/web-proxies/envoy.json +8 -0
- package/data/fingerprints/services/web-proxies/haproxy.json +10 -0
- package/data/fingerprints/services/web-proxies/lighttpd.json +8 -0
- package/data/fingerprints/services/web-proxies/nginx.json +14 -0
- package/data/fingerprints/services/web-proxies/squid.json +8 -0
- package/data/fingerprints/services/web-proxies/tomcat.json +8 -0
- package/data/fingerprints/services/web-proxies/traefik.json +9 -0
- package/data/fingerprints/services/web-proxies/varnish.json +8 -0
- package/lib/README.md +51 -0
- package/lib/{coverage-diagnostics.js → advisories/coverage-diagnostics.js} +1 -1
- package/lib/{cve-match.js → advisories/cve-match.js} +17 -12
- package/lib/{advisory-fixes.js → advisories/fixes.js} +1 -1
- package/lib/{advisory-freshness.js → advisories/freshness.js} +5 -1
- package/lib/{gap-adjudicate.js → advisories/gap-adjudicate.js} +3 -3
- package/lib/{native-package-match.js → advisories/native-package-match.js} +20 -11
- package/lib/{native-source-prepare.js → advisories/native-source-prepare.js} +15 -12
- package/lib/{native-advisories.js → advisories/native.js} +15 -13
- package/lib/{advisory-store-sqlite.js → advisories/store-sqlite.js} +5 -5
- package/lib/{advisory-store.js → advisories/store.js} +2 -2
- package/lib/{application-exports.js → applications/exports.js} +1 -1
- package/lib/{application-inventory.js → applications/inventory.js} +3 -1
- package/lib/applications/layout.js +199 -0
- package/lib/{application-providers → applications}/live-snapshot.js +10 -10
- package/lib/{application-plugins → applications/plugins}/drupal.js +2 -2
- package/lib/applications/plugins/ghost.js +36 -0
- package/lib/{application-plugins → applications/plugins}/index.js +1 -1
- package/lib/{application-plugins → applications/plugins}/prestashop.js +73 -15
- package/lib/applications/plugins/redmine.js +24 -0
- package/lib/{application-plugins → applications/plugins}/runner.js +89 -59
- package/lib/{application-plugins → applications/plugins}/spip.js +4 -4
- package/lib/{application-plugins → applications/plugins}/symfony.js +1 -1
- package/lib/{application-plugins → applications/plugins}/typo3.js +2 -2
- package/lib/{application-plugins → applications/plugins}/wave2-common.js +1 -1
- package/lib/{application-plugins → applications/plugins}/wordpress.js +52 -18
- package/lib/{application-providers → applications}/snapshot-cache.js +1 -1
- package/lib/{cms-snapshot-warm.js → applications/snapshot-warm.js} +21 -8
- package/lib/artifacts/access-warnings.js +24 -0
- package/lib/artifacts/applications.js +39 -8
- package/lib/artifacts/component-scope.js +12 -3
- package/lib/artifacts/cve-view.js +8 -5
- package/lib/artifacts/disk-wasm.mjs +3 -0
- package/lib/artifacts/disk.js +188 -0
- package/lib/artifacts/elf-product.js +215 -0
- package/lib/artifacts/enrichment.js +31 -17
- package/lib/artifacts/go-main-identity.js +135 -36
- package/lib/artifacts/go-publisher-advisories.js +4 -3
- package/lib/artifacts/image-products.js +181 -0
- package/lib/artifacts/index.js +36 -13
- package/lib/artifacts/install-version.js +44 -0
- package/lib/artifacts/inventory-scope.js +53 -3
- package/lib/artifacts/pe-product.js +28 -0
- package/lib/artifacts/product-advisories.js +212 -0
- package/lib/artifacts/product-catalog.js +67 -0
- package/lib/artifacts/release-catalogues.js +149 -0
- package/lib/artifacts/release-versions.js +101 -0
- package/lib/artifacts/remediation-report.js +1 -1
- package/lib/artifacts/report-inventory.js +17 -2
- package/lib/artifacts/report-path.js +29 -0
- package/lib/artifacts/report.js +85 -32
- package/lib/artifacts/retire.js +3 -3
- package/lib/artifacts/risk-report.js +12 -8
- package/lib/artifacts/sbom.js +33 -4
- package/lib/artifacts/scan.js +316 -69
- package/lib/artifacts/system-apps.js +98 -0
- package/lib/artifacts/system-maintenance.js +101 -0
- package/lib/artifacts/system-module-updates.js +104 -0
- package/lib/artifacts/system-report.js +232 -0
- package/lib/{airgap-project.js → cache/airgap-project.js} +25 -10
- package/lib/{cache-archive-sqlite.js → cache/archive.js} +6 -5
- package/lib/{cache-db.js → cache/db.js} +1 -1
- package/lib/{dump-format.js → cache/dump-format.js} +2 -2
- package/lib/{json-cache.js → cache/json.js} +1 -1
- package/lib/{proxy-cache.js → cache/proxy-cache.js} +9 -9
- package/lib/{proxy-scope.js → cache/proxy-scope.js} +1 -1
- package/lib/{record-freshness.js → cache/record-freshness.js} +1 -1
- package/lib/{cache-repository.js → cache/repository.js} +1 -1
- package/lib/{resource-cache → cache/resource}/engine.js +23 -16
- package/lib/{resource-cache → cache/resource}/fs-store.js +2 -2
- package/lib/{resource-cache → cache/resource}/sqlite-store.js +3 -3
- package/lib/{resource-cache → cache/resource}/validate.js +20 -5
- package/lib/{sqlite-driver.js → cache/sqlite-driver.js} +7 -5
- package/lib/certs/scan.js +17 -11
- package/lib/cli-collect.js +262 -0
- package/lib/cli-command-routing.js +30 -13
- package/lib/cli-groups.js +1 -1
- package/lib/cli-image.js +158 -47
- package/lib/cli-project-commands.js +10 -10
- package/lib/cli-setup.js +8 -8
- package/lib/cli-watch.js +3 -3
- package/lib/codecs/binary/elf-metadata.js +6 -0
- package/lib/codecs/binary/metadata.js +1 -1
- package/lib/codecs/binary/pe-metadata.js +47 -11
- package/lib/codecs/binary/scan.js +12 -4
- package/lib/codecs/binary.codec.js +1 -1
- package/lib/codecs/composer/platform.js +2 -2
- package/lib/codecs/composer/registry.js +12 -18
- package/lib/codecs/composer.codec.js +6 -5
- package/lib/codecs/go/parse.js +1 -1
- package/lib/codecs/go/registry.js +7 -7
- package/lib/codecs/go.codec.js +2 -2
- package/lib/codecs/gradle/parse.js +1 -1
- package/lib/codecs/gradle/versionless.js +2 -2
- package/lib/codecs/gradle.codec.js +7 -7
- package/lib/codecs/index.js +1 -1
- package/lib/{maven-airgap.js → codecs/maven/airgap.js} +4 -4
- package/lib/{maven-bom.js → codecs/maven/bom.js} +3 -3
- package/lib/codecs/maven/jar-scan.js +4 -4
- package/lib/{maven-license.js → codecs/maven/license.js} +2 -2
- package/lib/{core.js → codecs/maven/pom.js} +22 -11
- package/lib/{maven-reactor.js → codecs/maven/reactor.js} +18 -12
- package/lib/{transitive.js → codecs/maven/transitive.js} +79 -34
- package/lib/{maven-version.js → codecs/maven/version.js} +1 -1
- package/lib/codecs/maven.codec.js +18 -14
- package/lib/codecs/npm/collect.js +55 -8
- package/lib/codecs/npm/manifest-kind.js +16 -0
- package/lib/codecs/npm/parse.js +23 -7
- package/lib/codecs/npm/registry.js +28 -14
- package/lib/codecs/npm.codec.js +5 -5
- package/lib/codecs/nuget/registry.js +7 -7
- package/lib/codecs/nuget.codec.js +4 -4
- package/lib/codecs/pypi/registry.js +7 -7
- package/lib/codecs/pypi.codec.js +4 -4
- package/lib/codecs/recipes.js +2 -2
- package/lib/codecs/ruby/registry.js +7 -7
- package/lib/codecs/ruby.codec.js +2 -2
- package/lib/config.js +1 -1
- package/lib/{attribution.js → findings/attribution.js} +3 -3
- package/lib/findings/cve-descriptions.js +144 -0
- package/lib/{cve-record-coverage.js → findings/cve-record-coverage.js} +46 -41
- package/lib/{diff.js → findings/diff.js} +0 -0
- package/lib/{finding-enrichment.js → findings/enrichment.js} +45 -32
- package/lib/{eu-refs.js → findings/eu-refs.js} +3 -3
- package/lib/{gate.js → findings/gate.js} +1 -1
- package/lib/{malware.js → findings/malware.js} +30 -7
- package/lib/{merge-sources.js → findings/merge.js} +57 -9
- package/lib/{priority.js → findings/priority.js} +3 -3
- package/lib/findings/risk-evidence.js +24 -0
- package/lib/findings/severity.js +16 -0
- package/lib/{finding-summary.js → findings/summary.js} +5 -2
- package/lib/{suppress.js → findings/suppress.js} +2 -2
- package/lib/images/local-docker.js +72 -0
- package/lib/{image-network.js → images/network.js} +26 -16
- package/lib/{image-references.js → images/references.js} +29 -11
- package/lib/{image-registry.js → images/registry.js} +18 -9
- package/lib/{source-image-scan.js → images/source-scan.js} +3 -3
- package/lib/images/temp-roots.js +23 -0
- package/lib/{image-update.js → images/update.js} +3 -3
- package/lib/{dep-record.js → inventory/dep-record.js} +2 -2
- package/lib/{deps-descriptor.js → inventory/deps-descriptor.js} +3 -3
- package/lib/{descriptor-refs.js → inventory/descriptor-refs.js} +1 -1
- package/lib/{embedded.js → inventory/embedded.js} +4 -3
- package/lib/{license-policy.js → inventory/license-policy.js} +2 -2
- package/lib/{manifest-copy.js → inventory/manifest-copy.js} +2 -2
- package/lib/{module-names.js → inventory/module-names.js} +1 -1
- package/lib/{package-versions.js → inventory/package-versions.js} +2 -2
- package/lib/{parallel-walk.js → inventory/parallel-walk.js} +1 -1
- package/lib/{path-filter.js → inventory/path-filter.js} +1 -1
- package/lib/{private-deps.js → inventory/private-deps.js} +1 -1
- package/lib/{project-descriptor.js → inventory/project-descriptor.js} +3 -0
- package/lib/{purl.js → inventory/purl.js} +2 -2
- package/lib/{unmanaged.js → inventory/unmanaged.js} +6 -3
- package/lib/{commercial-support.js → maintenance/commercial-support.js} +5 -5
- package/lib/{outdated.js → maintenance/outdated.js} +20 -20
- package/lib/options-env.js +1 -1
- package/lib/{system-inventory/alpine-tracker.js → providers/alpine/tracker.js} +27 -7
- package/lib/{certfr.js → providers/certfr/enrich.js} +9 -9
- package/lib/{cve-download.js → providers/cveproject/download.js} +56 -36
- package/lib/{cve-legacy-ranges.js → providers/cveproject/legacy-ranges.js} +1 -1
- package/lib/{cve-npm-proxy.js → providers/cveproject/npm-proxy.js} +5 -5
- package/lib/{cve-packages-proxy.js → providers/cveproject/packages-proxy.js} +6 -6
- package/lib/{cve-version-verdict.js → providers/cveproject/version-verdict.js} +2 -2
- package/lib/{system-inventory/current-debian.js → providers/debian/current.js} +6 -6
- package/lib/{system-inventory/historical-debian.js → providers/debian/historical.js} +6 -6
- package/lib/providers/{debian.js → debian/index.js} +1 -0
- package/lib/{application-providers/drupal-advisories.js → providers/drupal/advisories.js} +13 -36
- package/lib/providers/{drupal.js → drupal/index.js} +4 -0
- package/lib/providers/{eol.js → eol/index.js} +1 -1
- package/lib/{epss.js → providers/epss/enrich.js} +16 -13
- package/lib/providers/{epss.js → epss/index.js} +2 -2
- package/lib/{euvd.js → providers/euvd/enrich.js} +13 -13
- package/lib/{system-inventory/freexian-ela.js → providers/freexian/ela.js} +6 -6
- package/lib/providers/{freexian.js → freexian/index.js} +3 -3
- package/lib/{system-inventory/freexian-release-evidence.js → providers/freexian/release-evidence.js} +8 -5
- package/lib/{system-inventory/freexian-tracker.js → providers/freexian/tracker.js} +33 -9
- package/lib/{gcve-feed.js → providers/gcve/feed.js} +4 -4
- package/lib/{gcve.js → providers/gcve/id.js} +1 -1
- package/lib/{gcve-index.js → providers/gcve/local-index.js} +4 -4
- package/lib/{application-providers/github-advisories.js → providers/github/advisories.js} +6 -2
- package/lib/providers/{github.js → github/index.js} +3 -1
- package/lib/{github-publisher-maven.js → providers/github/publisher-maven.js} +1 -1
- package/lib/providers/{go.js → go/index.js} +1 -1
- package/lib/{hash-id.js → providers/hashid/identify.js} +7 -7
- package/lib/providers/{hashid.js → hashid/index.js} +1 -1
- package/lib/providers/index.js +18 -13
- package/lib/{kev.js → providers/kev/enrich.js} +12 -9
- package/lib/{maven-cache.js → providers/maven/cache.js} +3 -3
- package/lib/providers/{maven.js → maven/index.js} +5 -3
- package/lib/{maven-presence.js → providers/maven/presence.js} +5 -5
- package/lib/{maven-repo.js → providers/maven/repo.js} +38 -21
- package/lib/providers/mit-kerberos/index.js +6 -0
- package/lib/{system-inventory/nginx-advisories.js → providers/nginx/advisories.js} +3 -3
- package/lib/providers/{npm.js → npm/index.js} +1 -1
- package/lib/providers/{nuget.js → nuget/index.js} +1 -1
- package/lib/{cpe.js → providers/nvd/cpe.js} +35 -47
- package/lib/{nvd.js → providers/nvd/enrich.js} +41 -40
- package/lib/providers/{nvd.js → nvd/index.js} +18 -4
- package/lib/{nvd-package-ranges.js → providers/nvd/package-ranges.js} +38 -22
- package/lib/{osv-db.js → providers/osv/db.js} +18 -16
- package/lib/providers/{osv.js → osv/index.js} +1 -1
- package/lib/{osv.js → providers/osv/query.js} +150 -80
- package/lib/providers/package-releases/index.js +26 -0
- package/lib/{packagist-audit.js → providers/packagist/audit.js} +31 -11
- package/lib/providers/{packagist.js → packagist/index.js} +1 -1
- package/lib/{proxy-throttle.js → providers/proxy-throttle.js} +17 -9
- package/lib/providers/{pypi.js → pypi/index.js} +1 -1
- package/lib/providers/redhat/bzip2.js +167 -0
- package/lib/providers/redhat/errata.js +75 -0
- package/lib/providers/redhat/index.js +10 -0
- package/lib/providers/redhat/oval.js +70 -0
- package/lib/providers/redhat/unfixed.js +127 -0
- package/lib/{registries.js → providers/registries.js} +4 -4
- package/lib/{retire.js → providers/retire/scan.js} +18 -18
- package/lib/providers/{ruby.js → ruby/index.js} +1 -1
- package/lib/providers/rubysec/advisories.js +177 -0
- package/lib/providers/rubysec/index.js +9 -0
- package/lib/{snyk.js → providers/snyk/client.js} +2 -2
- package/lib/{application-providers/spip-advisories.js → providers/spip/advisories.js} +5 -13
- package/lib/{vigievuln-advisories.js → providers/vigievuln/advisories.js} +4 -4
- package/lib/providers/wolfi/index.js +10 -0
- package/lib/providers/wolfi/secdb.js +47 -0
- package/lib/{application-providers/wordfence-client.js → providers/wordfence/client.js} +4 -4
- package/lib/providers/{wordfence.js → wordfence/index.js} +1 -1
- package/lib/{application-providers/wordfence-projection.js → providers/wordfence/projection.js} +14 -5
- package/lib/{resource-cache/wordfence.js → providers/wordfence/resource-cache.js} +2 -2
- package/lib/{application-providers/wordfence-v3.js → providers/wordfence/v3.js} +4 -5
- package/lib/providers/{wordpress.js → wordpress/index.js} +5 -0
- package/lib/providers/wpvulnerability/assess.js +181 -0
- package/lib/providers/wpvulnerability/index.js +12 -0
- package/lib/{charts.js → reports/charts.js} +25 -18
- package/lib/{csaf-export.js → reports/csaf-export.js} +16 -11
- package/lib/{cve-report.js → reports/cve-report.js} +453 -228
- package/lib/reports/detail.js +55 -0
- package/lib/{i18n.js → reports/i18n.js} +38 -2
- package/lib/{report-integrity.js → reports/integrity.js} +1 -1
- package/lib/{json-export.js → reports/json-export.js} +95 -24
- package/lib/{report-notices.js → reports/notices.js} +11 -6
- package/lib/{sarif-export.js → reports/sarif-export.js} +15 -10
- package/lib/{sbom-export.js → reports/sbom-export.js} +16 -11
- package/lib/{scan-completeness.js → scan/completeness.js} +1 -1
- package/lib/scan/coverage.js +114 -0
- package/lib/{provenance.js → scan/provenance.js} +12 -5
- package/lib/scan/reliability.js +157 -0
- package/lib/{source-health.js → scan/source-health.js} +52 -20
- package/lib/{source-profile.js → scan/source-profile.js} +3 -3
- package/lib/{hosted-proxy.js → service/hosted-proxy.js} +3 -3
- package/lib/{project-client.js → service/project-client.js} +20 -2
- package/lib/source-input.js +58 -0
- package/lib/system-inventory/advisories.js +89 -16
- package/lib/system-inventory/collect.js +33 -10
- package/lib/system-inventory/distribution-sources.js +32 -15
- package/lib/system-inventory/package-applicability.js +51 -0
- package/lib/system-inventory/targeted.js +8 -5
- package/lib/ui.js +11 -0
- package/package.json +49 -2
- package/vigievuln.js +483 -352
- package/lib/cache-archive.js +0 -676
- package/lib/osv-legacy.js +0 -57
- package/lib/risk-evidence.js +0 -18
- package/lib/scan-coverage.js +0 -61
- /package/lib/{application-plugins → applications/plugins}/joomla.js +0 -0
- /package/lib/{application-plugins → applications/plugins}/laravel.js +0 -0
- /package/lib/{application-plugins → applications/plugins}/magento.js +0 -0
- /package/lib/{application-plugins → applications/plugins}/plugin.interface.js +0 -0
- /package/lib/{application-plugins → applications/plugins}/select.js +0 -0
- /package/lib/{advisory-compression.js → cache/advisory-compression.js} +0 -0
- /package/lib/{compression-dictionary.js → cache/compression-dictionary.js} +0 -0
- /package/lib/{cache-directory.js → cache/directory.js} +0 -0
- /package/lib/{cache-policy.js → cache/policy.js} +0 -0
- /package/lib/{resource-cache → cache/resource}/snapshot-projection.js +0 -0
- /package/lib/{cache-startup.js → cache/startup.js} +0 -0
- /package/lib/{ruby-version.js → codecs/ruby/version.js} +0 -0
- /package/lib/{applicability-evidence.js → findings/applicability-evidence.js} +0 -0
- /package/lib/{line-stream.js → inventory/line-stream.js} +0 -0
- /package/lib/{package-metadata.js → inventory/package-metadata.js} +0 -0
- /package/lib/providers/{alpine.js → alpine/index.js} +0 -0
- /package/lib/providers/{certfr.js → certfr/index.js} +0 -0
- /package/lib/{native-cna-identities.js → providers/cveproject/cna-identities.js} +0 -0
- /package/lib/providers/{euvd.js → euvd/index.js} +0 -0
- /package/lib/providers/{gcve.js → gcve/index.js} +0 -0
- /package/lib/providers/{kev.js → kev/index.js} +0 -0
- /package/lib/providers/{nginx.js → nginx/index.js} +0 -0
- /package/lib/{nvd-bulk.js → providers/nvd/bulk.js} +0 -0
- /package/lib/providers/{osvdb.js → osvdb/index.js} +0 -0
- /package/lib/{request-failure.js → providers/request-failure.js} +0 -0
- /package/lib/providers/{retire.js → retire/index.js} +0 -0
- /package/lib/providers/{vigievuln.js → vigievuln/index.js} +0 -0
- /package/lib/{application-providers/wp-checksums.js → providers/wordpress/checksums.js} +0 -0
- /package/lib/{report-time.js → reports/time.js} +0 -0
- /package/lib/{xlsx-export.js → reports/xlsx-export.js} +0 -0
- /package/lib/{diagnostics.js → scan/diagnostics.js} +0 -0
- /package/lib/{account-client.js → service/account-client.js} +0 -0
- /package/lib/{account-session.js → service/account-session.js} +0 -0
- /package/lib/{account-terms.js → service/account-terms.js} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Installed application metadata in an extracted image. Never execute package code.
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require('path');
|
|
4
|
-
const {makeDepRecord} = require('../dep-record');
|
|
4
|
+
const {makeDepRecord} = require('../inventory/dep-record');
|
|
5
5
|
const {isNpmPackageDescriptor,isProjectDescriptor} = require('./component-scope');
|
|
6
6
|
const MAX_METADATA = 16 * 1024 * 1024;
|
|
7
7
|
const handlers = [
|
|
8
|
-
{id:'npm', matches:(n,fp)=>n==='package.json' && isNpmPackageDescriptor(fp), parse:(text)=>{const j=JSON.parse(text);return j.name || j.version ? [{ecosystem:'npm',name:j.name,version:j.version}] : [];}},
|
|
8
|
+
{id:'npm', matches:(n,fp)=>n==='package.json' && isNpmPackageDescriptor(fp), parse:(text)=>{const j=JSON.parse(text);if(require('../codecs/npm/manifest-kind').isClibManifest(j))return [];return j.name || j.version ? [{ecosystem:'npm',name:j.name,version:j.version}] : [];}},
|
|
9
9
|
{id:'composer-project', matches:(n,fp)=>n==='composer.json' && isProjectDescriptor(fp), parse:(text)=>{const j=JSON.parse(text);return j.name || j.version ? [{ecosystem:'composer',name:j.name,version:j.version}] : [];}},
|
|
10
10
|
{id:'pypi-project', matches:(n,fp)=>n==='pyproject.toml' && isProjectDescriptor(fp), parse:(text)=>{const j=require('smol-toml').parse(text),p=j.project || j.tool?.poetry || {};return p.name || p.version ? [{ecosystem:'pypi',name:p.name,version:p.version}] : [];}},
|
|
11
11
|
{id:'maven-project', matches:(n,fp)=>n==='pom.xml' && isProjectDescriptor(fp), async parse(text){const j=await require('xml2js').parseStringPromise(text),p=j.project;if(!p)return [];const parent=p.parent?.[0]||{},name=p.artifactId?.[0],namespace=p.groupId?.[0]||parent.groupId?.[0],version=p.version?.[0]||parent.version?.[0];if(!name)return [];if(!namespace || /\$\{/.test(String(namespace)+String(version)))throw Error('project coordinates are not literal');return [{ecosystem:'maven',namespace,name,version}];}},
|
|
@@ -22,16 +22,23 @@ const handlers = [
|
|
|
22
22
|
{id:'nuget', matches:n=>n.endsWith('.deps.json'), parse:(text)=>{const j=JSON.parse(text);return Object.entries(j.libraries||{}).filter(([,v])=>v?.type==='package').map(([key])=>{const i=key.lastIndexOf('/');return {ecosystem:'nuget',name:key.slice(0,i),version:key.slice(i+1)};});}},
|
|
23
23
|
];
|
|
24
24
|
function valid(x) {return x && typeof x.name==='string' && x.name.trim() && typeof x.version==='string' && x.version.trim() && !/[\r\n\0]/.test(x.name+x.version);}
|
|
25
|
-
const archiveCollectors = [{id:'jar', async collect(root) {return require('../codecs/maven/jar-scan').scanEmbeddedJars(root,{defaultExcludes:false});}}];
|
|
25
|
+
const archiveCollectors = [{id:'jar', async collect(root, opts) {return require('../codecs/maven/jar-scan').scanEmbeddedJars(root,{defaultExcludes:false,skipInventoryDir:opts.skipInventoryDir});}}];
|
|
26
26
|
async function collectInstalledApplications(root,opts={}) {
|
|
27
27
|
const activeHandlers=opts.handlers || handlers, archives=opts.archiveCollectors || archiveCollectors;
|
|
28
28
|
for(const h of activeHandlers) if(!h || typeof h.id!=='string' || typeof h.matches!=='function' || typeof h.parse!=='function') throw Error('Invalid installed metadata handler');
|
|
29
29
|
for(const h of archives) if(!h || typeof h.id!=='string' || typeof h.collect!=='function') throw Error('Invalid installed archive collector');
|
|
30
30
|
const deps=new Map(),warnings=[], coverage={files:0,records:0,handlers:{}}; const stack=[root], max=opts.maxMetadataBytes ?? MAX_METADATA;
|
|
31
|
-
function warning(fp,error) {warnings.push({type:'dependency-coverage',reason:'installed-metadata-error',manifestPath:fp,message
|
|
32
|
-
function add(item,fp,source) {if(item.ecosystem==='composer' && typeof item.name==='string' && !item.namespace) {const slash=item.name.indexOf('/');if(slash>0)item={...item,namespace:item.name.slice(0,slash),name:item.name.slice(slash+1)};}if(!valid(item)){
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
function warning(fp,error) {warnings.push({type:'dependency-coverage',reason:'installed-metadata-error',...(error?.code?{code:error.code}:{}),manifestPath:fp,message:opts.redactParseErrors && error.message !== 'archive has no complete Maven coordinate' ? `Installed metadata could not be inventoried: ${fp}` : `installed metadata incomplete for ${fp}: ${error.message}`});}
|
|
32
|
+
function add(item,fp,source) {if(item.ecosystem==='composer' && typeof item.name==='string' && !item.namespace) {const slash=item.name.indexOf('/');if(slash>0)item={...item,namespace:item.name.slice(0,slash),name:item.name.slice(slash+1)};}if(!valid(item)){
|
|
33
|
+
if(item.name && !item.version && ['composer-project','pypi-project'].includes(source)){
|
|
34
|
+
warnings.push({type:'component-metadata',severity:'info',reason:'installed-version-not-declared',manifestPath:fp,
|
|
35
|
+
message:'The installed metadata declares '+(item.namespace?item.namespace+'/':'')+item.name+' without a version. No package/version query can be constructed from this file.'});
|
|
36
|
+
}else warning(fp,Error('missing package name or version'));
|
|
37
|
+
return;
|
|
38
|
+
} const dep=makeDepRecord({...item,manifestPath:fp,provenance:'installed',scope:'transitive'});dep.coordKey=`installed:${fp}:${item.ecosystem}:${item.name}@${item.version}`;dep.installEvidence={path:fp,source};deps.set(dep.coordKey,dep);}
|
|
39
|
+
while(stack.length) {const dir=stack.pop();let entries;try{entries=fs.readdirSync(dir,{withFileTypes:true})}catch(e){warning(dir,e);continue}for(const entry of entries){const fp=path.join(dir,entry.name);if(entry.isDirectory()){if (!opts.skipInventoryDir?.(fp)) stack.push(fp);continue}if(!entry.isFile())continue;if(opts.onInventoryFile)await opts.onInventoryFile(fp,entry.name,deps);if(entry.name==='installed.php' && entries.some(e=>e.name==='installed.json' && e.isFile()))continue;for(const h of activeHandlers){if(!h.matches(entry.name,fp))continue;coverage.files++;coverage.handlers[h.id]=(coverage.handlers[h.id]||0)+1;try{const st=fs.statSync(fp);if(st.size>max)throw Error(`metadata exceeds ${max} bytes`);const parsed=await h.parse(fs.readFileSync(fp,'utf8'));for(const item of parsed)add(item,fp,h.id)}catch(e){warning(fp,e)}break;}}}
|
|
40
|
+
for(const collector of archives){try{const result=await collector.collect(root,opts);warnings.push(...(result.warnings||[]).map(w=>/^embedded archive with no resolvable Maven coordinate \(not scanned\):/.test(w.message||'') ?
|
|
41
|
+
{...w,type:'component-metadata',severity:'info',reason:'archive-coordinate-undeclared',message:'This installed archive exposes no Maven coordinate for advisory queries: '+w.message.split('(not scanned): ')[1]}:w));coverage.handlers[collector.id]=(result.deps||[]).length;for(const item of result.deps||[]){const fp=item.manifestPaths?.[0]||root;if(!item.namespace && item.ecosystem==='maven'){warning(fp,Error('archive has no complete Maven coordinate'));continue}add({ecosystem:item.ecosystem,namespace:item.namespace,name:item.name,version:item.version},fp,collector.id);}}catch(e){warning(root,e)}}coverage.records=deps.size;coverage.complete=warnings.every(require('../scan/diagnostics').isInformational);return {deps,warnings,coverage};
|
|
35
42
|
}
|
|
36
43
|
// Reclassify only an unidentifiable top-level JAR whose exact installed owner
|
|
37
44
|
// has itself been assessed. Corrupt archives and nested contents remain gaps.
|
|
@@ -55,4 +62,28 @@ function classifyOwnedArchiveWarnings(warnings, packages, assessedPackages) {
|
|
|
55
62
|
}
|
|
56
63
|
return {warnings:remaining,informational};
|
|
57
64
|
}
|
|
58
|
-
|
|
65
|
+
// An upstream version match alone cannot determine the state of a distro build.
|
|
66
|
+
function upstreamPackageObservations(matches, distroMatches, observations) {
|
|
67
|
+
const known = new Set();
|
|
68
|
+
const key = (owner,id) => JSON.stringify([owner.name,owner.version,id]);
|
|
69
|
+
for (const {dep,cve} of distroMatches) {
|
|
70
|
+
if (dep.ecosystem !== 'system') continue;
|
|
71
|
+
for (const id of [cve.id,...(cve.aliases || []),...(cve.upstream || [])]) known.add(key(dep,id));
|
|
72
|
+
}
|
|
73
|
+
const result = [];
|
|
74
|
+
for (const {dep,cve} of matches) {
|
|
75
|
+
for (const owner of dep.osPackageOwners) {
|
|
76
|
+
const ids = [cve.id,...(cve.aliases || [])];
|
|
77
|
+
if (ids.some(id=>known.has(key(owner,id)))) continue;
|
|
78
|
+
const resolved = observations.some(o=>ids.includes(o.id || o.cveId) &&
|
|
79
|
+
['fixed','not-affected'].includes(o.status) && (o.dep?.name===owner.name && o.dep.version===owner.version ||
|
|
80
|
+
o.source==='alpine-tracker' && o.repositoryVerified && o.sourceVersion===owner.version && o.packages?.includes(owner.name)));
|
|
81
|
+
if (resolved) continue;
|
|
82
|
+
result.push({id:cve.id, source:'osv-upstream', status:'possible', sourceName:dep.name, sourceVersion:dep.version,
|
|
83
|
+
packages:[owner.name+'@'+owner.version], sourceUrl:'https://osv.dev/vulnerability/'+encodeURIComponent(cve.sourceAdvisoryId || cve.id),
|
|
84
|
+
evidence:{kind:'upstream-version', ecosystem:dep.ecosystem, ...(cve.fixVersion ? {upstreamFixVersion:cve.fixVersion} : {}), packageOwner:owner, path:dep.artifactPath}});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
module.exports={upstreamPackageObservations,collectInstalledApplications,handlers,archiveCollectors,classifyOwnedArchiveWarnings,MAX_METADATA};
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const IMAGE_COMPONENT_SCOPE='image-components/
|
|
3
|
+
const IMAGE_COMPONENT_SCOPE='image-components/2';
|
|
4
4
|
const parts=value=>String(value||'').replace(/\\/g,'/').split('/').filter(Boolean);
|
|
5
5
|
const stores=new Set(['node_modules','vendor','site-packages','dist-packages','specifications','__pypackages__','.cache','.npm','.yarn','.m2','.gradle','.nuget']);
|
|
6
6
|
// Installed metadata is authoritative inside package stores; source manifests
|
|
7
7
|
// bundled there can be examples or fixtures belonging to the enclosing library.
|
|
8
8
|
const isProjectDescriptor=value=>!parts(value).some(n=>stores.has(n));
|
|
9
9
|
|
|
10
|
+
// Linux distributions and language runtimes also use unbundled package stores.
|
|
11
|
+
function isSystemProjectPath(value) {
|
|
12
|
+
const p=String(value || '').replace(/\\/g,'/').replace(/^\/+/,'');
|
|
13
|
+
return isProjectDescriptor(p) && !/^(?:usr\/share\/nodejs|var\/lib\/gems|usr\/(?:local\/)?lib\/ruby\/\d+(?:\.\d+)+)(?:\/|$)/.test(p)
|
|
14
|
+
&& !/(?:^|\/)(?:lib\/ruby\/gems|share\/gems|bundle\/(?:ruby\/[^/]+\/)?gems|pkg\/mod)(?:\/|$)/.test(p);
|
|
15
|
+
}
|
|
16
|
+
|
|
10
17
|
// Only a package root describes an installed npm component. Files such as
|
|
11
18
|
// pkg/dist/mjs/package.json set module-loading rules, not another package.
|
|
12
19
|
function isNpmPackageDescriptor(value) {
|
|
@@ -19,6 +26,7 @@ function isNpmPackageDescriptor(value) {
|
|
|
19
26
|
}
|
|
20
27
|
|
|
21
28
|
function imageComponentRole(dep={}) {
|
|
29
|
+
if(dep.provenance==='lockfile')return dep.ecosystem==='composer'?'unknown':dep.scope==='transitive'?'transitive':'direct';
|
|
22
30
|
if(imageComponentSource(dep).category==='global')return 'direct';
|
|
23
31
|
if(dep.ecosystem==='system' || dep.ecosystem==='binary')return 'direct';
|
|
24
32
|
const source=dep.installEvidence?.source;
|
|
@@ -34,6 +42,7 @@ function imageComponentRole(dep={}) {
|
|
|
34
42
|
function imageComponentSource(dep={}) {
|
|
35
43
|
const p=String(dep.artifactPath || dep.installEvidence?.path || dep.manifestPaths?.[0] || '').replace(/\\/g,'/').replace(/^\/+/, '');
|
|
36
44
|
const source=dep.installEvidence?.source;
|
|
45
|
+
if(dep.provenance==='lockfile')return {category:'project',manager:dep.ecosystem,root:p.includes('/')?p.slice(0,p.lastIndexOf('/')):'.'};
|
|
37
46
|
const os=dep.ecosystem==='system' ? dep : dep.osPackageOwners?.[0];
|
|
38
47
|
if(os)return {category:'system',manager:os.manager || os.packageType || 'system'};
|
|
39
48
|
if(source==='retire' || dep.ecosystemType==='retire')return {category:'vendored',manager:'retirejs'};
|
|
@@ -41,7 +50,7 @@ function imageComponentSource(dep={}) {
|
|
|
41
50
|
if(dep.ecosystem==='npm' && npm)return {category:'global',manager:'npm',root:npm[1]};
|
|
42
51
|
const python=/^((?:usr(?:\/local)?\/lib(?:64)?\/python[^/]+|(?:root|home\/[^/]+)\/\.local\/lib\/python[^/]+)\/(?:site|dist)-packages)\//.exec(p);
|
|
43
52
|
if(dep.ecosystem==='pypi' && python)return {category:'global',manager:'python',root:python[1]};
|
|
44
|
-
const ruby=/^((?:usr(?:\/local)?\/(?:lib\/ruby\/gems|share\/gems)|var\/lib\/gems|(?:root|home\/[^/]+)\/\.gem\/ruby)(?:\/[^/]+)?)\/specifications\//.exec(p);
|
|
53
|
+
const ruby=/^((?:usr(?:\/local)?\/(?:lib\/ruby\/gems|share\/gems)|var\/lib\/gems|(?:root|home\/[^/]+)\/\.gem\/ruby|usr\/local\/bundle)(?:\/[^/]+)?)\/specifications\//.exec(p);
|
|
45
54
|
if(dep.ecosystem==='ruby' && ruby)return {category:'global',manager:'ruby',root:ruby[1]};
|
|
46
55
|
const composer=/^((?:root|home\/[^/]+)\/(?:\.composer|\.config\/composer))\/vendor\/composer\/installed\.(?:json|php)$/.exec(p);
|
|
47
56
|
if(dep.ecosystem==='composer' && composer)return {category:'global',manager:'composer',root:composer[1]};
|
|
@@ -51,4 +60,4 @@ function imageComponentSource(dep={}) {
|
|
|
51
60
|
return {category:'other',manager:dep.ecosystem || 'unknown'};
|
|
52
61
|
}
|
|
53
62
|
|
|
54
|
-
module.exports={IMAGE_COMPONENT_SCOPE,isNpmPackageDescriptor,isProjectDescriptor,imageComponentRole,imageComponentSource};
|
|
63
|
+
module.exports={IMAGE_COMPONENT_SCOPE,isSystemProjectPath,isNpmPackageDescriptor,isProjectDescriptor,imageComponentRole,imageComponentSource};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// A presentation projection: distribution verdicts remain unchanged in the
|
|
3
3
|
// canonical findings and image inventory. Only explicit CVE relationships can
|
|
4
4
|
// produce CVE rows, with per-CVE enrichment kept separate.
|
|
5
|
-
const {computePriority}=require('../priority');
|
|
5
|
+
const {computePriority}=require('../findings/priority');
|
|
6
6
|
const CVE=/^CVE-\d{4}-\d{4,}$/i;
|
|
7
7
|
function isCve(id){return typeof id==='string' && CVE.test(id);}
|
|
8
8
|
function ids(cve){return [...new Set([cve?.id,...(cve?.aliases||[]),...(cve?.upstream||[])].filter(isCve).map(id=>id.toUpperCase()))];}
|
|
@@ -27,7 +27,7 @@ function project(match,id){
|
|
|
27
27
|
// Aggregated advisory risk can reflect another CVE. Replace it with this CVE's
|
|
28
28
|
// own evidence before computing priority.
|
|
29
29
|
for(const key of ['score','severity','severitySource','scoreSource','cvssVector','cvssVersion','cwes','nvdRefs','nvdEvidence','riskEvidence','kev','kevEvidence','kevDateAdded','kevDueDate','kevRansomware','epssScore','epssPercentile','epssEvidence','priority','description','summary','published','modified','advisorySource','osvRefs','fixVersion','cveEvidence','euvd','certfr','gcve','gcveEvidence','euvdEvidence','certfrEvidence','euvdDetails','euvdDetailsEvidence'])delete c[key];
|
|
30
|
-
const euvd=require('../euvd').normalizeEuvdDetailDates(perCve?.euvdDetails);
|
|
30
|
+
const euvd=require('../providers/euvd/enrich').normalizeEuvdDetailDates(perCve?.euvdDetails || (ids(original).length===1 ? original.euvdDetails : null));
|
|
31
31
|
const hasOwn=identity && String(original.id||'').toUpperCase()===id;
|
|
32
32
|
const ownScore=hasOwn && original.score!=null, nvdScore=!ownScore && record?.score!=null, euvdScore=!ownScore && !nvdScore && euvd?.score!=null;
|
|
33
33
|
const scoreSource=ownScore?'original':nvdScore?'nvd':euvdScore?'euvd':null;
|
|
@@ -38,11 +38,14 @@ function project(match,id){
|
|
|
38
38
|
c.severity=knownOriginal?original.severity:knownNvd && scoreSource!=='euvd'?record.severity:scoreSource==='euvd' && euvd?.severity?euvd.severity:'UNKNOWN';
|
|
39
39
|
if(knownOriginal && original.severitySource)c.severitySource=original.severitySource;
|
|
40
40
|
if(hasOwn && String(original.riskEvidence?.id||'').toUpperCase()===id && ((ownScore && original.scoreSource===original.riskEvidence.source) || (knownOriginal && original.severitySource===original.riskEvidence.source)))c.riskEvidence={...original.riskEvidence};
|
|
41
|
-
c.description=record?.description
|
|
41
|
+
c.description=require('../findings/cve-record-coverage').usableText(record?.description,euvd?.description,perCve?.descriptionEvidence?.description,require('../findings/cve-record-coverage').advisoryDescription(original,id));
|
|
42
42
|
if(euvd){c.euvdDetails={...euvd};if(euvdScore){c.scoreSource='euvd';if(!knownOriginal && c.severity!=='UNKNOWN')c.severitySource='euvd';c.riskEvidence={source:'euvd',id,relationship:'identity'};}}
|
|
43
43
|
const vectorSource=scoreSource==='original'?original:scoreSource==='nvd'?record:scoreSource==='euvd'?euvd:null;
|
|
44
44
|
for(const k of ['cvssVector','cvssVersion'])if(vectorSource?.[k]!=null)c[k]=vectorSource[k];
|
|
45
45
|
for(const k of ['cwes','published','modified']){const v=record?.[k] ?? euvd?.[k] ?? (hasOwn ? original[k] : null);if(v!=null)c[k]=v;}
|
|
46
|
+
if(c.score==null && c.severity==='UNKNOWN' && perCve?.cveProjectMetric?.riskEvidence?.id===id){
|
|
47
|
+
Object.assign(c,perCve.cveProjectMetric,{scoreSource:'cveproject',severitySource:'cveproject'});
|
|
48
|
+
}
|
|
46
49
|
if(record){c.nvdEvidence={...record,records:[{...record}]};if(record.references)c.nvdRefs=record.references;
|
|
47
50
|
if(!c.riskEvidence && (nvdScore || (!knownOriginal && knownNvd && scoreSource!=='euvd')))c.riskEvidence={source:'nvd',id,relationship:'identity'};}
|
|
48
51
|
if(perCve){c.cveEvidence=[{...perCve,...(euvd?{euvdDetails:euvd}:{})}];for(const key of ['kev','kevDateAdded','kevDueDate','kevRansomware','epssScore','epssPercentile','euvd','certfr','gcve','gcveEvidence','euvdEvidence','certfrEvidence','euvdDetailsEvidence'])if(perCve[key]!==undefined)c[key]=perCve[key];}
|
|
@@ -64,11 +67,11 @@ function project(match,id){
|
|
|
64
67
|
const notice=advisory(match,id);if(notice)c.distributionAdvisories.push(notice);
|
|
65
68
|
c.fixVersion=notice?.fixVersion || (hasOwn ? original.fixVersion || null : null);
|
|
66
69
|
c.priority=computePriority(c);
|
|
67
|
-
return {...match,cve:c};
|
|
70
|
+
return {...match,cve:c,...(record?.vulnStatus==='Rejected'?{suppressed:true,suppressedReason:'CVE identifier rejected by its assigning authority (NVD record).'}:{})};
|
|
68
71
|
}
|
|
69
72
|
function merge(target,incoming){
|
|
70
73
|
const a=target.cve,b=incoming.cve;
|
|
71
|
-
a.applicabilityEvidence=require('../applicability-evidence').applicabilityEvidence(a,b);
|
|
74
|
+
a.applicabilityEvidence=require('../findings/applicability-evidence').applicabilityEvidence(a,b);
|
|
72
75
|
a.sourceGhsaIds=[...new Set([...(a.sourceGhsaIds||[]),...(b.sourceGhsaIds||[])])];
|
|
73
76
|
a.sourceGcveIds=[...new Set([...(a.sourceGcveIds||[]),...(b.sourceGcveIds||[])])];
|
|
74
77
|
// Source applicability evidence survives consolidation with a distribution
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const os = require('node:os');
|
|
6
|
+
const {execFile} = require('node:child_process');
|
|
7
|
+
const {promisify} = require('node:util');
|
|
8
|
+
const {DEFAULT_LIMITS} = require('./index');
|
|
9
|
+
|
|
10
|
+
const isDisk = file => /\.(?:raw|img|qcow2|vhdx?|vmdk|vdi)$/i.test(file);
|
|
11
|
+
const maxEntries = DEFAULT_LIMITS.maxEntries;
|
|
12
|
+
const maxFile = 512 * 1024 ** 2;
|
|
13
|
+
|
|
14
|
+
// Give the decoder one seekable, read-only descriptor. Backing-file names
|
|
15
|
+
// supplied in disk metadata cannot open another file on the host.
|
|
16
|
+
async function engine({fd,size,start}, filename, print) {
|
|
17
|
+
const wasm = process.versions.bun ? (await import('./disk-wasm.mjs')).default : require.resolve('7z-wasm/7zz.wasm');
|
|
18
|
+
const z = await require('7z-wasm')({wasmBinary:fs.readFileSync(wasm), print, printErr:print});
|
|
19
|
+
const FS = z.FS;
|
|
20
|
+
const node = FS.create('/' + filename, 0o444);
|
|
21
|
+
node.usedBytes = size;
|
|
22
|
+
node.stream_ops = {...node.stream_ops, read(stream, buffer, offset, length, position) {
|
|
23
|
+
if (!Number.isSafeInteger(position) || position < 0) throw Error('Invalid disk read offset');
|
|
24
|
+
if (position >= size) return 0;
|
|
25
|
+
return fs.readSync(fd, buffer, offset, Math.min(length,size-position), start+position);
|
|
26
|
+
}};
|
|
27
|
+
return z;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function safePath(file) {
|
|
31
|
+
if (!file || file.length > 4096 || /[\\\x00-\x1f\x7f]/.test(file)) return false;
|
|
32
|
+
return file.split('/').every(p => p && p !== '.' && p !== '..' && (process.platform !== 'win32' ||
|
|
33
|
+
(!/[<>:"|?*]|[. ]$/.test(p) && !/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\.|$)/i.test(p))));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function list(source, filename) {
|
|
37
|
+
let outerType, type, entries = 0, entry, bytes = 0;
|
|
38
|
+
const files = [];
|
|
39
|
+
let skipped = 0;
|
|
40
|
+
function finish() {
|
|
41
|
+
if (!entry) return;
|
|
42
|
+
if (!entry.path || !safePath(entry.path)) throw Error('Invalid disk member path');
|
|
43
|
+
if (!entry.folder && !entry.special) {
|
|
44
|
+
if (!Number.isSafeInteger(entry.size) || entry.size < 0) throw Error('Invalid disk member size');
|
|
45
|
+
if (entry.size > maxFile && !['GPT','MBR'].includes(type)) skipped++;
|
|
46
|
+
else files.push({path:entry.path,size:entry.size,offset:entry.offset});
|
|
47
|
+
}
|
|
48
|
+
entry = null;
|
|
49
|
+
}
|
|
50
|
+
let listing = false;
|
|
51
|
+
const z = await engine(source, filename, line => {
|
|
52
|
+
bytes += Buffer.byteLength(line);
|
|
53
|
+
if (bytes > 256 * 1024 ** 2) throw Error('Disk listing exceeds metadata budget');
|
|
54
|
+
if (!listing) {
|
|
55
|
+
if (line.startsWith('Type = ')) { type = line.slice(7); outerType ??= type; }
|
|
56
|
+
if (line === '----------') listing = true;
|
|
57
|
+
} else if (line.startsWith('Path = ')) {
|
|
58
|
+
finish();
|
|
59
|
+
if (++entries > maxEntries) throw Error('Disk entry limit exceeded');
|
|
60
|
+
entry = {path:line.slice(7)};
|
|
61
|
+
} else if (entry) {
|
|
62
|
+
if (line.startsWith('Size = ')) entry.size = Number(line.slice(7));
|
|
63
|
+
if (line.startsWith('Offset = ')) entry.offset = Number(line.slice(9));
|
|
64
|
+
if (line === 'Folder = +') entry.folder = true;
|
|
65
|
+
// 7-Zip lists trailing unallocated MBR space as a file with no type.
|
|
66
|
+
if (type === 'MBR' && line === 'File System = ') entry.special = true;
|
|
67
|
+
if (/^Mode = [^d-]|^(?:Symbolic Link|Hard Link|Reparse) = .+/.test(line)) entry.special = true;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
if (z.callMain(['l','-slt','/' + filename]) !== 0 || !listing) throw Object.assign(Error('Cannot inspect this disk or filesystem'), {code:'UNRECOGNIZED_DISK'});
|
|
71
|
+
finish();
|
|
72
|
+
return {files,outerType,type,skipped};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function extract(source, filename, destination, files, budget) {
|
|
76
|
+
if (!files.length) return;
|
|
77
|
+
let total = 0;
|
|
78
|
+
for (const member of files) total += member.size;
|
|
79
|
+
if (!Number.isSafeInteger(total) || total > budget.bytes) throw Error('Disk expansion exceeds available space or collection budget');
|
|
80
|
+
budget.bytes -= total;
|
|
81
|
+
const z = await engine(source,filename,()=>{});
|
|
82
|
+
const {FS, NODEFS} = z;
|
|
83
|
+
FS.mkdir('/out');
|
|
84
|
+
// Only known, listed files may be written. Directory creation uses this
|
|
85
|
+
// private initially empty tree. Never recreate symlinks, devices or hardlinks.
|
|
86
|
+
const allowed = new Map(files.map(f=>[path.join(destination,f.path),f.size]));
|
|
87
|
+
const dirs = new Set([destination]);
|
|
88
|
+
for (const file of allowed.keys()) {
|
|
89
|
+
let dir = path.dirname(file);
|
|
90
|
+
while (!dirs.has(dir)) {dirs.add(dir); dir=path.dirname(dir);}
|
|
91
|
+
}
|
|
92
|
+
const mknod = NODEFS.node_ops.mknod;
|
|
93
|
+
NODEFS.node_ops.mknod = (parent,name,mode,dev) => {
|
|
94
|
+
const dest = path.join(NODEFS.realPath(parent),name);
|
|
95
|
+
const dir = FS.isDir(mode);
|
|
96
|
+
if (!safePath(name) || !(dir ? dirs.has(dest) : FS.isFile(mode) && allowed.has(dest))) throw Error('Unexpected disk extraction path');
|
|
97
|
+
return mknod(parent,name,dir ? 0o40700 : 0o100600,dev);
|
|
98
|
+
};
|
|
99
|
+
NODEFS.node_ops.symlink = NODEFS.node_ops.rename = () => {throw Error('Disk links and renames are disabled');};
|
|
100
|
+
const checkSize = (node,end) => {
|
|
101
|
+
const limit = allowed.get(NODEFS.realPath(node));
|
|
102
|
+
if (limit === undefined || !Number.isSafeInteger(end) || end < 0 || end > limit) throw Error('Disk member exceeded its declared size');
|
|
103
|
+
};
|
|
104
|
+
NODEFS.node_ops.setattr = (node, attr) => {
|
|
105
|
+
if (attr.size !== undefined) {checkSize(node,attr.size); fs.truncateSync(NODEFS.realPath(node),attr.size);}
|
|
106
|
+
};
|
|
107
|
+
const write = NODEFS.stream_ops.write;
|
|
108
|
+
NODEFS.stream_ops.write = (stream,buf,off,len,pos) => {
|
|
109
|
+
checkSize(stream.node,pos+len);
|
|
110
|
+
return write(stream,buf,off,len,pos);
|
|
111
|
+
};
|
|
112
|
+
FS.mount(NODEFS,{root:destination},'/out');
|
|
113
|
+
FS.writeFile('/selected',files.map(f=>f.path).join('\n')+'\n');
|
|
114
|
+
if (z.callMain(['x','-y','-spd','-ssc','-scsUTF-8','-i@/selected','-o/out','/'+filename]) !== 0) throw Error('Disk extraction failed');
|
|
115
|
+
for (const [file,expected] of allowed) {
|
|
116
|
+
const st=fs.lstatSync(file);
|
|
117
|
+
if (!st.isFile() || st.size!==expected) throw Error('Disk member failed verification');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function readDisk(input, temp) {
|
|
122
|
+
const stat = fs.statfsSync(temp);
|
|
123
|
+
const budget = {bytes:Math.min(DEFAULT_LIMITS.maxBytes, Math.floor(stat.bavail * stat.bsize * 0.8))};
|
|
124
|
+
const targets=[];
|
|
125
|
+
let skippedPartitions = 0;
|
|
126
|
+
async function visitFile(file, label) {
|
|
127
|
+
const handle = await fs.promises.open(file,'r');
|
|
128
|
+
try {
|
|
129
|
+
const {size} = await handle.stat();
|
|
130
|
+
if (!Number.isSafeInteger(size)) throw Error('Invalid disk size');
|
|
131
|
+
await visit({fd:handle.fd,start:0,size},label);
|
|
132
|
+
} finally {await handle.close();}
|
|
133
|
+
}
|
|
134
|
+
async function visit(source, label) {
|
|
135
|
+
const filename = 'input' + (label ? '.img' : path.extname(input).toLowerCase());
|
|
136
|
+
let listing;
|
|
137
|
+
try { listing = await list(source,filename); }
|
|
138
|
+
catch (error) {
|
|
139
|
+
if (label && error.code === 'UNRECOGNIZED_DISK') { skippedPartitions++; return; }
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
if (!label && ['GPT','MBR'].includes(listing.type)) {
|
|
143
|
+
if (listing.files.length > 128) throw Error('Disk partition limit exceeded');
|
|
144
|
+
for (const part of listing.files) {
|
|
145
|
+
if (listing.outerType === listing.type && Number.isSafeInteger(part.offset)) {
|
|
146
|
+
// A raw partition can be scanned through a bounded window on the same fd.
|
|
147
|
+
if (part.offset < 0 || part.offset > source.size-part.size) throw Error('Invalid partition bounds');
|
|
148
|
+
await visit({fd:source.fd,start:part.offset,size:part.size},part.path);
|
|
149
|
+
} else {
|
|
150
|
+
const stage=fs.mkdtempSync(path.join(temp,'part-'));
|
|
151
|
+
try {
|
|
152
|
+
await extract(source,filename,stage,[part],budget);
|
|
153
|
+
await visitFile(path.join(stage,part.path),part.path);
|
|
154
|
+
} finally {fs.rmSync(stage,{recursive:true,force:true});}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
} else if (listing.type === 'Ext') {
|
|
158
|
+
const root=fs.mkdtempSync(path.join(temp,'root-'));
|
|
159
|
+
await extract(source,filename,root,listing.files,budget);
|
|
160
|
+
targets.push({root,partition:label,skipped:listing.skipped});
|
|
161
|
+
} else if (label) skippedPartitions++;
|
|
162
|
+
else throw Error('Unsupported disk filesystem: '+ (listing.type || 'unrecognized'));
|
|
163
|
+
}
|
|
164
|
+
await visitFile(input,null);
|
|
165
|
+
if (!targets.length) throw Error('No readable ext filesystem found in disk');
|
|
166
|
+
// Emscripten sets the worker exit code on unsuccessful format probes.
|
|
167
|
+
// The parent receives skipped-partition coverage alongside the usable roots.
|
|
168
|
+
process.exitCode = 0;
|
|
169
|
+
console.log(JSON.stringify({targets,skippedPartitions}));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async function openDisk(file) {
|
|
173
|
+
const temp=await fs.promises.mkdtemp(path.join(os.tmpdir(),'vigievuln-disk-'));
|
|
174
|
+
const cleanup=()=>fs.promises.rm(temp,{recursive:true,force:true});
|
|
175
|
+
try {
|
|
176
|
+
const compiled=process.versions.bun && /(?:^|[\\/])\$bunfs[\\/]/.test(process.argv[1]);
|
|
177
|
+
const args=compiled ? [] : [path.resolve(__dirname,'../../vigievuln.js')];
|
|
178
|
+
const {stdout}=await promisify(execFile)(process.execPath,[...args,'__read-system-disk',file,temp],
|
|
179
|
+
{timeout:15*60*1000,killSignal:'SIGKILL',maxBuffer:1024*1024});
|
|
180
|
+
const {targets,skippedPartitions}=JSON.parse(stdout);
|
|
181
|
+
return {cleanup,targets:targets.map(({root,partition,skipped})=>({
|
|
182
|
+
root,kind:'rootfs',metadata:{format:'directory',diskFormat:path.extname(file).slice(1),source:file,partition,
|
|
183
|
+
warnings:[...(skipped?[`${skipped} files exceed the per-file disk limit`]:[]),
|
|
184
|
+
...(skippedPartitions?[`${skippedPartitions} partitions use unsupported filesystems`]:[])]},
|
|
185
|
+
}))};
|
|
186
|
+
} catch(error) {await cleanup();throw Error(error.stderr?.trim() || error.message);}
|
|
187
|
+
}
|
|
188
|
+
module.exports={isDisk,openDisk,readDisk};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { catalog, binaryProduct } = require('./product-catalog');
|
|
4
|
+
const codecs = new Map(
|
|
5
|
+
[...catalog.values()].filter((product) => product.elfCodec).map((product) => [product.elfCodec, product])
|
|
6
|
+
);
|
|
7
|
+
const libraries = [...catalog.values()].filter((product) => product.library);
|
|
8
|
+
function libraryProduct(name) {
|
|
9
|
+
return libraries.find((product) => product.library.test(name));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function sectionsOf({ read, header, bits, word, u16, u32, max }) {
|
|
13
|
+
const wide = bits === 64,
|
|
14
|
+
stride = u16(header, wide ? 58 : 46),
|
|
15
|
+
count = u16(header, wide ? 60 : 48);
|
|
16
|
+
if (!count || count > 4096 || stride < (wide ? 64 : 40) || stride * count > max) return [];
|
|
17
|
+
const table = read(word(header, wide ? 40 : 32), stride * count);
|
|
18
|
+
return Array.from({ length: count }, (_, i) => {
|
|
19
|
+
const p = i * stride;
|
|
20
|
+
return {
|
|
21
|
+
name: u32(table, p),
|
|
22
|
+
type: u32(table, p + 4),
|
|
23
|
+
offset: word(table, p + (wide ? 24 : 16)),
|
|
24
|
+
size: word(table, p + (wide ? 32 : 20)),
|
|
25
|
+
link: u32(table, p + (wide ? 40 : 24)),
|
|
26
|
+
entry: word(table, p + (wide ? 56 : 36))
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function bunGraph(elf, sections) {
|
|
32
|
+
const trailer = Buffer.from('\n---- Bun! ----\n');
|
|
33
|
+
if (elf.size >= 24) {
|
|
34
|
+
const end = elf.read(elf.size - 24, 24);
|
|
35
|
+
if (end.subarray(0, 16).equals(trailer) && end.readBigUInt64LE(16) === BigInt(elf.size)) return true;
|
|
36
|
+
}
|
|
37
|
+
const names = sections[elf.u16(elf.header, elf.bits === 64 ? 62 : 50)];
|
|
38
|
+
if (!names || names.size > 65536) return false;
|
|
39
|
+
const strings = elf.read(names.offset, names.size);
|
|
40
|
+
for (const section of sections) {
|
|
41
|
+
if (
|
|
42
|
+
section.type !== 1 ||
|
|
43
|
+
strings.toString('latin1', section.name, section.name + 5) !== '.bun\0' ||
|
|
44
|
+
section.size < 32
|
|
45
|
+
)
|
|
46
|
+
continue;
|
|
47
|
+
const len = elf.read(section.offset, 8).readBigUInt64LE();
|
|
48
|
+
if (
|
|
49
|
+
len >= 24n &&
|
|
50
|
+
len <= BigInt(section.size - 8) &&
|
|
51
|
+
elf.read(section.offset + 8 + Number(len) - 16, 16).equals(trailer)
|
|
52
|
+
)
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function symbolBytes(elf, sections, wanted) {
|
|
59
|
+
const wide = elf.bits === 64,
|
|
60
|
+
result = new Map();
|
|
61
|
+
for (const section of sections) {
|
|
62
|
+
if (section.type !== 11) continue;
|
|
63
|
+
const strings = sections[section.link];
|
|
64
|
+
if (
|
|
65
|
+
strings?.type !== 3 ||
|
|
66
|
+
section.entry !== (wide ? 24 : 16) ||
|
|
67
|
+
section.size % section.entry ||
|
|
68
|
+
Math.max(section.size, strings.size) > elf.max
|
|
69
|
+
)
|
|
70
|
+
continue;
|
|
71
|
+
const names = elf.read(strings.offset, strings.size);
|
|
72
|
+
if (!wanted.every((name) => names.includes(name + '\0'))) continue;
|
|
73
|
+
const symbols = elf.read(section.offset, section.size);
|
|
74
|
+
for (let j = 0; j < symbols.length; j += section.entry) {
|
|
75
|
+
const start = elf.u32(symbols, j);
|
|
76
|
+
const end = names.subarray(start, start + 49).indexOf(0) + start;
|
|
77
|
+
if (end < start || end - start > 48) continue;
|
|
78
|
+
const name = names.toString('latin1', start, end);
|
|
79
|
+
if (!wanted.includes(name) || !elf.u16(symbols, j + (wide ? 6 : 14))) continue;
|
|
80
|
+
const type = symbols[j + (wide ? 4 : 12)];
|
|
81
|
+
if (!(type >> 4) || (type & 15) !== (name === 'Py_Version' ? 1 : 2)) continue;
|
|
82
|
+
const length = elf.word(symbols, j + (wide ? 16 : 8));
|
|
83
|
+
if (length < 1 || length > 32) continue;
|
|
84
|
+
result.set(name, elf.read(elf.mapped(elf.word(symbols, j + (wide ? 8 : 4)), length), length));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function constantReturn(bytes, machine) {
|
|
91
|
+
if (!bytes) return;
|
|
92
|
+
// Entire leaf function must be a literal return. No machine code is run.
|
|
93
|
+
if (machine === 62 || machine === 3) {
|
|
94
|
+
if (bytes.subarray(0, 4).equals(Buffer.from([0xf3, 0x0f, 0x1e, machine === 62 ? 0xfa : 0xfb])))
|
|
95
|
+
bytes = bytes.subarray(4);
|
|
96
|
+
if (bytes.equals(Buffer.from([0x31, 0xc0, 0xc3]))) return 0;
|
|
97
|
+
if (bytes.length === 6 && bytes[0] === 0xb8 && bytes[5] === 0xc3) return bytes.readUInt32LE(1);
|
|
98
|
+
}
|
|
99
|
+
if (machine === 183 && bytes.length === 8 && bytes.readUInt32LE(4) === 0xd65f03c0) {
|
|
100
|
+
const mov = bytes.readUInt32LE(0);
|
|
101
|
+
if ((mov & 0xffe0001f) >>> 0 === 0x52800000) return (mov >>> 5) & 0xffff;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function exportedVersion(product, elf, sections) {
|
|
106
|
+
if (product.elfCodec === 'py-version') {
|
|
107
|
+
const bytes = symbolBytes(elf, sections, ['Py_Version']).get('Py_Version');
|
|
108
|
+
if (!bytes || ![4, 8].includes(bytes.length)) return;
|
|
109
|
+
const hex = bytes.length === 4 ? elf.u32(bytes, 0) : elf.word(bytes, 0);
|
|
110
|
+
if (hex <= 0xffffffff && hex >>> 24 === 3 && (hex & 255) === 0xf0)
|
|
111
|
+
return {
|
|
112
|
+
id: product.id,
|
|
113
|
+
version: [hex >>> 24, (hex >>> 16) & 255, (hex >>> 8) & 255].join('.'),
|
|
114
|
+
source: 'Py_Version'
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
if (['webkit-version', 'jsc-version'].includes(product.elfCodec)) {
|
|
118
|
+
const prefix = product.elfCodec === 'jsc-version' ? 'jsc' : 'webkit';
|
|
119
|
+
const names = ['major', 'minor', 'micro'].map((part) => prefix + '_get_' + part + '_version');
|
|
120
|
+
const symbols = symbolBytes(elf, sections, names);
|
|
121
|
+
const parts = names.map((name) => constantReturn(symbols.get(name), elf.machine));
|
|
122
|
+
if (parts.every((n) => Number.isInteger(n) && n <= 65535) && parts[0] > 0)
|
|
123
|
+
return { id: product.id, version: parts.join('.'), source: prefix + ' version API' };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// For renamed/embedded Node, bind the inspector version to the release archive
|
|
128
|
+
// compiled into Node. Compatibility strings in another JS engine do not suffice.
|
|
129
|
+
function embeddedEngines(elf, product) {
|
|
130
|
+
const tags = new Set(),
|
|
131
|
+
releases = new Set();
|
|
132
|
+
const jsc = codecs.get('jsc-build');
|
|
133
|
+
const markers = new Set(jsc.elfBuildMarkers);
|
|
134
|
+
const checkNode = !['node-release', 'bun-standalone'].includes(product?.elfCodec);
|
|
135
|
+
const checkJsc = !['jsc-version', 'webkit-version'].includes(product?.elfCodec);
|
|
136
|
+
let registered = false;
|
|
137
|
+
if (!checkNode && !checkJsc) return [];
|
|
138
|
+
for (const chunk of readonlyChunks(elf)) {
|
|
139
|
+
if (checkJsc) for (const marker of markers) if (chunk.includes(marker)) markers.delete(marker);
|
|
140
|
+
if (!checkNode) {
|
|
141
|
+
if (!markers.size) break;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (chunk.includes('node_module_register\0')) registered = true;
|
|
145
|
+
if (tags.size <= 1 && chunk.includes('node.js/v'))
|
|
146
|
+
for (const m of chunk.matchAll(/\0node\.js\/v(\d+\.\d+\.\d+)(?=\0)/g)) {
|
|
147
|
+
tags.add(m[1]);
|
|
148
|
+
if (tags.size > 1) break;
|
|
149
|
+
}
|
|
150
|
+
if (releases.size <= 1 && chunk.includes('nodejs.org/download/release/'))
|
|
151
|
+
for (const m of chunk.matchAll(
|
|
152
|
+
/https:\/\/nodejs\.org\/download\/release\/v(\d+\.\d+\.\d+)\/node-v\1\.tar\.gz\0/g
|
|
153
|
+
)) {
|
|
154
|
+
releases.add(m[1]);
|
|
155
|
+
if (releases.size > 1) break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const products = [],
|
|
159
|
+
[version] = tags;
|
|
160
|
+
if (registered && tags.size === 1 && releases.size === 1 && releases.has(version))
|
|
161
|
+
products.push({ id: codecs.get('node-release').id, version, source: 'node-release-and-inspector' });
|
|
162
|
+
if (checkJsc && !markers.size) products.push({ id: jsc.id, version: null, source: 'jsc-build-markers' });
|
|
163
|
+
return products;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function* readonlyChunks(elf) {
|
|
167
|
+
let remaining = elf.size;
|
|
168
|
+
for (const segment of elf.segments.filter((s) => s.type === 1 && !(s.flags & 2))) {
|
|
169
|
+
if (segment.filesz > remaining) throw Error('overlapping ELF load segments');
|
|
170
|
+
remaining -= segment.filesz;
|
|
171
|
+
let tail = '';
|
|
172
|
+
const step = Math.min(256 * 1024, elf.max);
|
|
173
|
+
for (let pos = 0; pos < segment.filesz; pos += step) {
|
|
174
|
+
const data =
|
|
175
|
+
tail + elf.read(segment.offset + pos, Math.min(step, segment.filesz - pos)).toString('latin1');
|
|
176
|
+
yield data;
|
|
177
|
+
tail = data.slice(-160);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function embeddedProducts(name, elf) {
|
|
183
|
+
const sections = sectionsOf(elf);
|
|
184
|
+
const bundled = bunGraph(elf, sections);
|
|
185
|
+
const product = bundled
|
|
186
|
+
? codecs.get('bun-standalone')
|
|
187
|
+
: binaryProduct(name) ||
|
|
188
|
+
libraryProduct(name) ||
|
|
189
|
+
binaryProduct(elf.soname) ||
|
|
190
|
+
libraryProduct(elf.soname || '');
|
|
191
|
+
const products = elf.size >= 1024 * 1024 ? embeddedEngines(elf, product) : [];
|
|
192
|
+
if (!product) return products;
|
|
193
|
+
const exported = exportedVersion(product, elf, sections);
|
|
194
|
+
if (exported) products.push(exported);
|
|
195
|
+
if (!product.banner) return products;
|
|
196
|
+
// Read only mapped, read-only data. Small overlapping chunks also handle
|
|
197
|
+
// signatures spanning a read boundary without loading an entire executable.
|
|
198
|
+
const versions = new Set();
|
|
199
|
+
for (const data of readonlyChunks(elf)) {
|
|
200
|
+
for (const match of data.matchAll(product.banner)) {
|
|
201
|
+
const version = match.slice(1).join('.');
|
|
202
|
+
if (version.length <= 40) versions.add(version);
|
|
203
|
+
if (versions.size > 1) return products;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (versions.size)
|
|
207
|
+
products.push({
|
|
208
|
+
id: product.id,
|
|
209
|
+
version: [...versions][0],
|
|
210
|
+
source: bundled ? 'bun-module-graph' : 'embedded-version-banner'
|
|
211
|
+
});
|
|
212
|
+
else if (bundled) products.push({ id: 'bun', version: null, source: 'bun-module-graph' });
|
|
213
|
+
return products;
|
|
214
|
+
}
|
|
215
|
+
module.exports = { embeddedProducts, libraryProduct };
|