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,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* lib/osv.js — query OSV.dev for Maven-ecosystem vulnerabilities.
|
|
2
|
+
* lib/providers/osv/query.js — query OSV.dev for Maven-ecosystem vulnerabilities.
|
|
3
3
|
*
|
|
4
4
|
* OSV.dev (Google + GitHub Security Lab) aggregates CVE + GHSA data and
|
|
5
5
|
* maintains a curated Maven-coordinate mapping. For Maven recall this is
|
|
@@ -20,7 +20,7 @@ const fs = require("fs");
|
|
|
20
20
|
const path = require("path");
|
|
21
21
|
const os = require("os");
|
|
22
22
|
|
|
23
|
-
const OSV_CACHE_DIR = path.join(require("
|
|
23
|
+
const OSV_CACHE_DIR = path.join(require("../../cache/directory").getCacheDir(), "osv-cache");
|
|
24
24
|
const OSV_BASE = "https://api.osv.dev";
|
|
25
25
|
const BATCH_SIZE = 800; // OSV limit is 1000; stay under for safety
|
|
26
26
|
|
|
@@ -44,14 +44,7 @@ function normalizeSeverity(s) {
|
|
|
44
44
|
return SEVERITY_ALIASES[up] || up;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
if (!Number.isFinite(n)) return "UNKNOWN";
|
|
49
|
-
if (n >= 9) return "CRITICAL";
|
|
50
|
-
if (n >= 7) return "HIGH";
|
|
51
|
-
if (n >= 4) return "MEDIUM";
|
|
52
|
-
if (n > 0) return "LOW";
|
|
53
|
-
return "NONE";
|
|
54
|
-
}
|
|
47
|
+
const severityFromScore = score => require("../../findings/severity").severityFromScore(score, "UNKNOWN");
|
|
55
48
|
|
|
56
49
|
// Compute a CVSS v3.0/3.1 base score from its vector string. Returns null for
|
|
57
50
|
// non-v3 vectors (v2/v4) or anything unparseable. OSV stores the *vector* in
|
|
@@ -85,20 +78,40 @@ function cvss3BaseScore(vector) {
|
|
|
85
78
|
return Math.ceil(base * 10) / 10; // CVSS roundup to one decimal
|
|
86
79
|
}
|
|
87
80
|
|
|
88
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Best CVSS info from an OSV vuln: { score, vector, version } (version like "3.1").
|
|
83
|
+
* Every entry is read: the first SCORABLE one wins (v3.x vector or bare number). Ubuntu
|
|
84
|
+
* lists CVSS_V4 first, then CVSS_V3 — stopping at the unscorable v4 lost the v3 score
|
|
85
|
+
* (UBUNTU-CVE-2025-6965 came out UNKNOWN). With nothing scorable, the first CVSS vector
|
|
86
|
+
* is still returned as evidence, with a null score (no v4 score is invented).
|
|
87
|
+
*/
|
|
89
88
|
function cvssInfoFromVuln(vuln) {
|
|
89
|
+
let unscored = null;
|
|
90
90
|
for (const s of vuln.severity || []) {
|
|
91
91
|
const str = String(s.score || "");
|
|
92
92
|
const mver = str.match(/^CVSS:(\d\.\d)\//);
|
|
93
93
|
if (mver) {
|
|
94
94
|
const version = mver[1];
|
|
95
95
|
const score = (version === "3.0" || version === "3.1") ? cvss3BaseScore(str) : null;
|
|
96
|
-
return { score, vector: str, version };
|
|
96
|
+
if (score != null) return { score, vector: str, version };
|
|
97
|
+
if (!unscored) unscored = { score: null, vector: str, version };
|
|
98
|
+
continue;
|
|
97
99
|
}
|
|
98
100
|
const mnum = str.match(/^\s*(\d+(\.\d+)?)\s*$/); // a bare numeric score ("9.8")
|
|
99
101
|
if (mnum) return { score: parseFloat(mnum[1]), vector: null, version: null };
|
|
100
102
|
}
|
|
101
|
-
return { score: null, vector: null, version: null };
|
|
103
|
+
return unscored || { score: null, vector: null, version: null };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// A distribution's own qualitative rating in severity[] (e.g. { type: "Ubuntu", score: "medium" }).
|
|
107
|
+
// Only the four standard bands are taken; "negligible"/"untriaged" stay UNKNOWN.
|
|
108
|
+
function qualitativeSeverityFromVuln(vuln) {
|
|
109
|
+
for (const s of vuln.severity || []) {
|
|
110
|
+
if (/^CVSS/i.test(String(s.type || ""))) continue;
|
|
111
|
+
const label = normalizeSeverity(String(s.score || "").trim());
|
|
112
|
+
if (["CRITICAL", "HIGH", "MEDIUM", "LOW"].includes(label)) return label;
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
102
115
|
}
|
|
103
116
|
|
|
104
117
|
/** Map an OSV vuln to { severity, score }. */
|
|
@@ -107,6 +120,8 @@ function severityFromOsv(vuln) {
|
|
|
107
120
|
const { score } = cvssInfoFromVuln(vuln);
|
|
108
121
|
if (direct) return { severity: normalizeSeverity(direct), score };
|
|
109
122
|
if (score != null) return { severity: severityFromScore(score), score };
|
|
123
|
+
const qualitative = qualitativeSeverityFromVuln(vuln);
|
|
124
|
+
if (qualitative) return { severity: qualitative, score: null };
|
|
110
125
|
return { severity: "UNKNOWN", score: null };
|
|
111
126
|
}
|
|
112
127
|
|
|
@@ -121,7 +136,7 @@ function scoreFromVuln(vuln) { return cvssInfoFromVuln(vuln).score; }
|
|
|
121
136
|
* published fix, or the dep is already patched), return null rather than suggest a downgrade.
|
|
122
137
|
*/
|
|
123
138
|
function fixVersionFromOsv(vuln, depKey, depVersion) {
|
|
124
|
-
const { compareMavenVersions } = require("
|
|
139
|
+
const { compareMavenVersions } = require("../../codecs/maven/version");
|
|
125
140
|
const fixes = [];
|
|
126
141
|
for (const a of vuln.affected || []) {
|
|
127
142
|
const name = a.package?.name?.toLowerCase();
|
|
@@ -143,7 +158,7 @@ function fixVersionFromOsv(vuln, depKey, depVersion) {
|
|
|
143
158
|
/** The fix on the dep's OWN branch (see maven-version#branchFixFromOsvEvents). → { branchFix } | {} */
|
|
144
159
|
function branchFixFromOsv(vuln, depKey, depVersion) {
|
|
145
160
|
if (!depVersion) return {};
|
|
146
|
-
const { branchFixFromOsvEvents } = require("
|
|
161
|
+
const { branchFixFromOsvEvents } = require("../../codecs/maven/version");
|
|
147
162
|
for (const a of vuln.affected || []) {
|
|
148
163
|
const name = a.package?.name?.toLowerCase();
|
|
149
164
|
if (name && name !== String(depKey).toLowerCase()) continue;
|
|
@@ -159,21 +174,38 @@ function branchFixFromOsv(vuln, depKey, depVersion) {
|
|
|
159
174
|
function fixForDependency(dep, vuln, { source } = {}) {
|
|
160
175
|
const maven=dep.ecosystem === 'maven' || dep.ecosystem === 'gradle';
|
|
161
176
|
const ecosystem=osvEcosystemFor(dep);
|
|
162
|
-
if (!maven && !['npm','Go'].includes(ecosystem)) return {fixVersion:null};
|
|
163
|
-
const {compareSemver,vulnVerdict,rangeVerdict,packageKey}=require('./
|
|
177
|
+
if (!maven && !['npm','Go','RubyGems','PyPI','Packagist'].includes(ecosystem)) return {fixVersion:null};
|
|
178
|
+
const {compareSemver,vulnVerdict,rangeVerdict,packageKey}=require('./db');
|
|
164
179
|
const name=osvPkgName(dep);
|
|
165
180
|
const affected=(vuln.affected || []).filter(a=>a?.package?.ecosystem===ecosystem &&
|
|
166
181
|
(maven ? a.package.name===name : packageKey(a.package.name,ecosystem)===packageKey(name,ecosystem)));
|
|
182
|
+
// Use these additional orderings only to verify a proposed remediation.
|
|
183
|
+
const compareVersion = ecosystem === 'PyPI' ? (a,b)=>{
|
|
184
|
+
const pep = require('@renovatebot/pep440');
|
|
185
|
+
if ([a,b].some(v=>typeof v !== 'string' || v.length>255 || /\d{16}/.test(v) || !pep.valid(v))) return null;
|
|
186
|
+
return pep.compare(a,b);
|
|
187
|
+
} : ecosystem === 'Packagist' ? (a,b)=>{
|
|
188
|
+
// Stable Composer tags normalize to four numeric components.
|
|
189
|
+
const numeric = /^[vV]?\d+(?:\.\d+){0,3}$/;
|
|
190
|
+
if ([a,b].some(v=>typeof v !== 'string' || v.length>255 || !numeric.test(v))) return null;
|
|
191
|
+
const parts = v=>v.replace(/^[vV]/,'').split('.').map(BigInt);
|
|
192
|
+
const x=parts(a), y=parts(b);
|
|
193
|
+
for (let i=0;i<4;i++) {
|
|
194
|
+
const left=x[i] ?? 0n, right=y[i] ?? 0n;
|
|
195
|
+
if (left!==right) return left<right ? -1 : 1;
|
|
196
|
+
}
|
|
197
|
+
return 0;
|
|
198
|
+
} : null;
|
|
167
199
|
const compare=maven ? (a,b)=>{
|
|
168
200
|
// Maven's comparator uses Numbers for numeric components. Never replace
|
|
169
201
|
// an indeterminate comparison with lexical ordering or a rounded number.
|
|
170
202
|
if (!a || !b || /\$\{|\d{16}/.test(a) || /\$\{|\d{16}/.test(b)) return null;
|
|
171
|
-
try { return require('
|
|
172
|
-
} : compareSemver;
|
|
203
|
+
try { return require('../../codecs/maven/version').compareMavenVersions(a,b); } catch { return null; }
|
|
204
|
+
} : compareVersion || (ecosystem === 'RubyGems' ? require('../../codecs/ruby/version').compareRubyVersions : compareSemver);
|
|
173
205
|
if (!affected.length || !dep.version || compare(String(dep.version),String(dep.version)) !== 0) return {fixVersion:null};
|
|
174
206
|
const candidates=[];
|
|
175
207
|
for(const a of affected) for(const r of (Array.isArray(a.ranges) ? a.ranges : [])) for(const event of (Array.isArray(r?.events) ? r.events : []))
|
|
176
|
-
if(typeof event?.fixed==='string' && compare(event.fixed,String(dep.version)) > 0) candidates.push(event.fixed);
|
|
208
|
+
if(['ECOSYSTEM','SEMVER'].includes(r.type) && typeof event?.fixed==='string' && compare(event.fixed,String(dep.version)) > 0) candidates.push(event.fixed);
|
|
177
209
|
// Reviewed VV records may prove individual safe versions without proving a
|
|
178
210
|
// continuous range. Never apply this extension to third-party OSV records.
|
|
179
211
|
const exact = new Set();
|
|
@@ -186,7 +218,7 @@ function fixForDependency(dep, vuln, { source } = {}) {
|
|
|
186
218
|
candidates.sort((a,b)=>compare(a,b));
|
|
187
219
|
// A negative must cover every applicable entry, not only the entry that
|
|
188
220
|
// supplied the candidate. In particular unknown/conflicting evidence fails.
|
|
189
|
-
const fixed=candidates.find(v=>vulnVerdict(v,{affected},ecosystem,
|
|
221
|
+
const fixed=candidates.find(v=>vulnVerdict(v,{affected},ecosystem,{source,compareVersion})===false) || null;
|
|
190
222
|
const evidence = fixed && exact.has(fixed) ? {fixEvidence:'explicit-unaffected-version'} : {};
|
|
191
223
|
if (!maven || !fixed) return {fixVersion:fixed,...evidence};
|
|
192
224
|
for(const a of affected) for(const r of (Array.isArray(a.ranges) ? a.ranges : [])) {
|
|
@@ -215,7 +247,7 @@ function osvEcosystemFor(dep) { return OSV_ECO[dep.ecosystem] || "Maven"; }
|
|
|
215
247
|
|
|
216
248
|
/** Build the OSV package-name key for a dep — delegated to the dep's codec. */
|
|
217
249
|
function osvPkgName(dep) {
|
|
218
|
-
const { getCodec } = require("
|
|
250
|
+
const { getCodec } = require("../../codecs");
|
|
219
251
|
const c = getCodec(dep.ecosystem);
|
|
220
252
|
if (c) return c.osvPackageName(dep);
|
|
221
253
|
// Fallback historique si le codec est introuvable.
|
|
@@ -244,6 +276,9 @@ function vulnToMatch(dep, vuln, opts = {}) {
|
|
|
244
276
|
if (description.length > 2000) description = description.slice(0, 2000) + "…";
|
|
245
277
|
// Categorise OSV references: ADVISORY / FIX / REPORT / WEB / PACKAGE / ARTICLE / EVIDENCE
|
|
246
278
|
const refs = (vuln.references || []).map(r => ({ type: String(r.type || "WEB").toUpperCase(), url: r.url }));
|
|
279
|
+
const weaknessIds = vuln.database_specific?.cwe_ids;
|
|
280
|
+
const cwes = Array.isArray(weaknessIds) ? [...new Set(weaknessIds
|
|
281
|
+
.filter(id => typeof id === "string" && /^CWE-[1-9]\d*$/i.test(id)).map(id => id.toUpperCase()))] : [];
|
|
247
282
|
return {
|
|
248
283
|
dep,
|
|
249
284
|
cve: {
|
|
@@ -260,7 +295,9 @@ function vulnToMatch(dep, vuln, opts = {}) {
|
|
|
260
295
|
published: vuln.published || null,
|
|
261
296
|
modified: vuln.modified || null,
|
|
262
297
|
osvRefs: refs,
|
|
263
|
-
|
|
298
|
+
...(cwes.length ? {cwes} : {}),
|
|
299
|
+
aliases: id !== vuln.id ? [...new Set([...(vuln.aliases || []), vuln.id])] : vuln.aliases || [],
|
|
300
|
+
sourceAdvisoryId: vuln.id,
|
|
264
301
|
},
|
|
265
302
|
source: "osv",
|
|
266
303
|
confidence: "exact",
|
|
@@ -280,44 +317,54 @@ function observation(response) {
|
|
|
280
317
|
const headers = response?.headers;
|
|
281
318
|
const status = headers?.get?.('x-fad-proxy');
|
|
282
319
|
const stamp = Date.parse(headers?.get?.('x-fad-proxy-fetched-at') || '');
|
|
283
|
-
const isProxy = require('
|
|
320
|
+
const isProxy = require('..').hasProxyRoute();
|
|
284
321
|
const valid = Number.isFinite(stamp) && stamp > 0 && stamp <= Date.now() + 300000;
|
|
285
322
|
const reason=headers?.get?.('x-fad-proxy-reason'), rawStatus=headers?.get?.('x-fad-proxy-refresh-status'), refreshStatus=/^[45]\d\d$/.test(rawStatus||'') ? Number(rawStatus) : null;
|
|
286
323
|
const refreshFailure=reason==='refresh-failed' || refreshStatus ? {reason:reason==='refresh-failed'?'refresh-failed':'http-error',...(refreshStatus?{status:refreshStatus}:{})} : null;
|
|
287
|
-
return { fetchedAt: valid ? stamp : isProxy ? 1 : Date.now(), stale: status === 'stale' || (isProxy && (!valid || Date.now()-stamp >= require('
|
|
324
|
+
return { fetchedAt: valid ? stamp : isProxy ? 1 : Date.now(), stale: status === 'stale' || (isProxy && (!valid || Date.now()-stamp >= require('../../cache/policy').DEFAULT_TTL_MS)), ...(refreshFailure?{refreshFailure}:{}) };
|
|
288
325
|
}
|
|
289
326
|
|
|
290
327
|
// querybatch can paginate EACH query independently. An empty object is a valid
|
|
291
328
|
// no-findings result; a missing result, an error or an unfinished page is not.
|
|
292
|
-
async function fetchBatchPages(batch, fetcher) {
|
|
293
|
-
const results = batch.map(() => ({ vulns: [], fetchedAt: Date.now(), stale: false }));
|
|
329
|
+
async function fetchBatchPages(batch, fetcher, onFailure) {
|
|
330
|
+
const results = batch.map(() => ({ vulns: [], fetchedAt: Date.now(), stale: false, complete: false }));
|
|
294
331
|
let pending = batch.map((query, index) => ({ query, index, seen: new Set() }));
|
|
295
332
|
while (pending.length) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
333
|
+
let items, observed;
|
|
334
|
+
try {
|
|
335
|
+
const res = await require("..").getResource("osv", "packages", {
|
|
336
|
+
queries: pending.map(({ query }) => ({
|
|
337
|
+
ecosystem: query.package.ecosystem, name: query.package.name, version: query.version,
|
|
338
|
+
...(query.page_token ? { page_token: query.page_token } : {}),
|
|
339
|
+
})),
|
|
340
|
+
}, { fetcher, forceRefresh:true, headers: { "User-Agent": "vigievuln-osv" } });
|
|
341
|
+
if (!res.ok) throw incompleteOsv(`querybatch HTTP ${res.status}`);
|
|
342
|
+
observed = observation(res);
|
|
343
|
+
items = (await res.json())?.results;
|
|
344
|
+
if (!Array.isArray(items) || items.length !== pending.length)
|
|
345
|
+
throw incompleteOsv("querybatch returned a missing or truncated result list");
|
|
346
|
+
} catch (error) {
|
|
347
|
+
onFailure(error.message);
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
307
350
|
const next = [];
|
|
308
351
|
for (let i = 0; i < pending.length; i++) {
|
|
309
|
-
const item =
|
|
310
|
-
results[slot.index].fetchedAt = Math.min(results[slot.index].fetchedAt, observed.fetchedAt);
|
|
311
|
-
results[slot.index].stale ||= observed.stale;
|
|
312
|
-
if(observed.refreshFailure)results[slot.index].refreshFailure=observed.refreshFailure;
|
|
352
|
+
const item = items[i], slot = pending[i], result = results[slot.index];
|
|
313
353
|
if (!item || typeof item !== "object" || Array.isArray(item) || item.error
|
|
314
|
-
|| (item.vulns !== undefined && (!Array.isArray(item.vulns) || !item.vulns.every(v => validVulnId(v?.id)))))
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
354
|
+
|| (item.vulns !== undefined && (!Array.isArray(item.vulns) || !item.vulns.every(v => validVulnId(v?.id))))) {
|
|
355
|
+
onFailure("querybatch returned an invalid result");
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
result.fetchedAt = Math.min(result.fetchedAt, observed.fetchedAt);
|
|
359
|
+
result.stale ||= observed.stale;
|
|
360
|
+
if (observed.refreshFailure) result.refreshFailure = observed.refreshFailure;
|
|
361
|
+
result.vulns.push(...(item.vulns || []));
|
|
362
|
+
const token = item.next_page_token;
|
|
363
|
+
if (!token) {
|
|
364
|
+
result.complete = true;
|
|
365
|
+
} else if (typeof token !== "string" || slot.seen.has(token) || slot.seen.size >= 1000) {
|
|
366
|
+
onFailure("invalid or repeated pagination token");
|
|
367
|
+
} else {
|
|
321
368
|
slot.seen.add(token);
|
|
322
369
|
next.push({ ...slot, query: { ...slot.query, page_token: token } });
|
|
323
370
|
}
|
|
@@ -336,28 +383,31 @@ function staleSeverity(observation, offline, maxAgeMs) {
|
|
|
336
383
|
async function queryBatch(deps, opts = {}) {
|
|
337
384
|
if (!deps.length) return [];
|
|
338
385
|
const { offline, fetcher = globalThis.fetch, onProgress, onWarning, queryTtlMs = 4 * 3600 * 1000 } = opts;
|
|
339
|
-
const root = opts.cacheDir || require('
|
|
340
|
-
const store = opts.store || require('
|
|
386
|
+
const root = opts.cacheDir || require('../../cache/directory').getCacheDir();
|
|
387
|
+
const store = opts.store || require('../../advisories/store').openAdvisoryStore({cacheDir:root});
|
|
341
388
|
try {
|
|
342
389
|
const tuple = d => ({source:'osv', ecosystem:osvEcosystemFor(d), name:osvPkgName(d), version:String(d.version).trim()});
|
|
343
390
|
const views = [], pending = [], output = new Array(deps.length), warnings = [], reviewedFreshnessNotices = new Set();
|
|
391
|
+
const partial = new Map();
|
|
344
392
|
const warn = (type, message, severity) => warnings.push({type,message,...(severity ? {severity} : {})});
|
|
345
393
|
for (let i=0; i<deps.length; i++) {
|
|
346
394
|
const q=tuple(deps[i]);
|
|
347
395
|
const view=store.getPackageView(q,{ttlMs:queryTtlMs});
|
|
348
396
|
views[i]=view;
|
|
349
|
-
if (!offline && (opts.forceUpdate || require('
|
|
397
|
+
if (!offline && (opts.forceUpdate || require('../../cache/policy').shouldForceUpdate() || !view.query || !view.query.fresh || view.querySuperseded)) pending.push({index:i, tuple:q});
|
|
350
398
|
}
|
|
351
399
|
if (pending.length) {
|
|
352
400
|
try {
|
|
353
401
|
const fetched=[];
|
|
402
|
+
const reportFailure = message => {
|
|
403
|
+
if (!opts.allowStaleFallback) throw incompleteOsv(message);
|
|
404
|
+
warn('source-unavailable', `OSV: refresh failed; coverage is incomplete (${message}).`);
|
|
405
|
+
};
|
|
354
406
|
for (let i=0;i<pending.length;i+=BATCH_SIZE) {
|
|
355
407
|
if (onProgress) onProgress(Math.floor(i/BATCH_SIZE)+1,Math.ceil(pending.length/BATCH_SIZE));
|
|
356
408
|
const part=pending.slice(i,i+BATCH_SIZE);
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
fetched.push(...results);
|
|
360
|
-
} catch(error) { throw error.code === 'OSV_INCOMPLETE' ? error : incompleteOsv(error.message); }
|
|
409
|
+
const results=await fetchBatchPages(part.map(({tuple:q})=>({package:{ecosystem:q.ecosystem,name:q.name},version:q.version})),fetcher,reportFailure);
|
|
410
|
+
fetched.push(...results);
|
|
361
411
|
}
|
|
362
412
|
const ids=[...new Set(fetched.flatMap(x=>x.vulns.map(v=>v.id)))], details=new Map(), failures=[];
|
|
363
413
|
let cursor=0,done=0;
|
|
@@ -366,8 +416,8 @@ async function queryBatch(deps, opts = {}) {
|
|
|
366
416
|
const id=ids[cursor++];
|
|
367
417
|
try {
|
|
368
418
|
const existing=store.getRecord('osv',id);
|
|
369
|
-
if (existing?.provenance?.origin === require('
|
|
370
|
-
const r=await require('
|
|
419
|
+
if (existing?.provenance?.origin === require('..').resourceOrigin() && !existing.provenance.stale && !existing.document?.withdrawn && existing.fetchedAt > 0 && existing.fetchedAt <= Date.now() && require('../../cache/record-freshness').stableRecord('osv',existing.document,opts)) { details.set(id,{body:existing.document,fetchedAt:existing.fetchedAt,stale:false,reusedStable:true}); if(onProgress)onProgress(++done,ids.length); continue; }
|
|
420
|
+
const r=await require('..').getResource('osv','vuln',{id},{fetcher,forceRefresh:true,headers:{'User-Agent':'vigievuln-osv'}});
|
|
371
421
|
if (!r.ok) throw Error(`HTTP ${r.status}`);
|
|
372
422
|
const body=await r.json(); if (body?.id!==id) throw Error('invalid advisory detail');
|
|
373
423
|
details.set(id,{body,...observation(r)});
|
|
@@ -375,9 +425,9 @@ async function queryBatch(deps, opts = {}) {
|
|
|
375
425
|
if(onProgress)onProgress(++done,ids.length);
|
|
376
426
|
}
|
|
377
427
|
}));
|
|
378
|
-
if(failures.length)
|
|
379
|
-
const transport=require('
|
|
380
|
-
const records=[...details.values()].filter(d=>!d.reusedStable).map(d=>({source:'osv',document:d.body,fetchedAt:d.fetchedAt,provenance:{transport,origin:require('
|
|
428
|
+
if (failures.length) reportFailure(`${failures.length} advisory detail(s) unavailable (${failures.sort()[0]})`);
|
|
429
|
+
const transport=require('..').hasProxyRoute()?'proxy':'direct';
|
|
430
|
+
const records=[...details.values()].filter(d=>!d.reusedStable).map(d=>({source:'osv',document:d.body,fetchedAt:d.fetchedAt,provenance:{transport,origin:require('..').resourceOrigin(),stale:d.stale,...(d.refreshFailure?{refreshFailure:d.refreshFailure}:{})}}));
|
|
381
431
|
// Keep revision evidence independently of the write transaction: a full
|
|
382
432
|
// disk must not allow an older API payload to resurrect a known withdrawal.
|
|
383
433
|
const existingRecords=new Map(ids.map(id=>[id,store.getRecord('osv',id)]));
|
|
@@ -385,20 +435,22 @@ async function queryBatch(deps, opts = {}) {
|
|
|
385
435
|
const queries=[];
|
|
386
436
|
for(let i=0;i<pending.length;i++) {
|
|
387
437
|
const entry=pending[i], result=fetched[i], ids=[...new Set(result.vulns.map(v=>v.id))];
|
|
388
|
-
const
|
|
438
|
+
const verifiedIds = ids.filter(id => details.has(id));
|
|
439
|
+
const relevant=verifiedIds.map(id=>details.get(id));
|
|
389
440
|
const fetchedAt=Math.min(result.fetchedAt,...relevant.filter(d=>!d.reusedStable).map(d=>d.fetchedAt));
|
|
390
441
|
const stale=result.stale || relevant.some(d=>d.stale);
|
|
391
442
|
const refreshFailure=result.refreshFailure || relevant.find(d=>d.refreshFailure)?.refreshFailure;
|
|
392
|
-
const documentHashes=Object.fromEntries(
|
|
393
|
-
queries.push({...entry.tuple,ids,fetchedAt,complete:
|
|
443
|
+
const documentHashes=Object.fromEntries(verifiedIds.map(id=>[id,require('node:crypto').createHash('sha256').update(JSON.stringify(details.get(id).body)).digest('hex')]));
|
|
444
|
+
queries.push({...entry.tuple,ids:verifiedIds,fetchedAt,complete:result.complete && verifiedIds.length === ids.length,provenance:{transport,stale,...(refreshFailure?{refreshFailure}:{}),documentHashes}});
|
|
394
445
|
}
|
|
395
446
|
try {
|
|
396
447
|
// A query is committed only after all its details are durable. Partial
|
|
397
448
|
// failure leaves no new evidence of a clean package.
|
|
398
449
|
if(records.length)await store.importEnvelopes(records);
|
|
399
|
-
|
|
450
|
+
const completeQueries = queries.filter(q => q.complete);
|
|
451
|
+
for(let i=0;i<completeQueries.length;i+=200)store.commit({queries:completeQueries.slice(i,i+200)});
|
|
400
452
|
} catch(error) {warn('source-unavailable',`OSV: live results could not be saved for offline use (${error.message}).`);}
|
|
401
|
-
const {vulnVerdict,packageKey}=require('./
|
|
453
|
+
const {vulnVerdict,packageKey}=require('./db');
|
|
402
454
|
for(let i=0;i<pending.length;i++) {
|
|
403
455
|
const entry=pending[i],query=queries[i],found=[];
|
|
404
456
|
let savedView=views[entry.index];
|
|
@@ -415,7 +467,7 @@ async function queryBatch(deps, opts = {}) {
|
|
|
415
467
|
let existing=existingRecords.get(id);
|
|
416
468
|
try { existing=store.getRecord('osv',id) || existing; }
|
|
417
469
|
catch(error) { warn('source-unavailable',`OSV: saved revision of ${id} could not be reread (${error.message}); previously read revision evidence is retained.`); }
|
|
418
|
-
const winner=require('
|
|
470
|
+
const winner=require('../../advisories/store').selectAdvisoryRecord(incomingRecords.get(id) || existing,existing).document;
|
|
419
471
|
if(winner.withdrawn)continue;
|
|
420
472
|
if(JSON.stringify(winner)!==JSON.stringify(fetched)) {
|
|
421
473
|
const relevant=(winner.affected || []).filter(a=>a?.package?.ecosystem===entry.tuple.ecosystem && (entry.tuple.ecosystem === 'Maven' ? a.package.name === entry.tuple.name : packageKey(a.package.name,entry.tuple.ecosystem)===packageKey(entry.tuple.name,entry.tuple.ecosystem)));
|
|
@@ -425,15 +477,25 @@ async function queryBatch(deps, opts = {}) {
|
|
|
425
477
|
}
|
|
426
478
|
found.push(vulnToMatch(deps[entry.index],winner));
|
|
427
479
|
}
|
|
428
|
-
|
|
480
|
+
if (query.complete) {
|
|
481
|
+
output[entry.index] = found;
|
|
482
|
+
if (!query.provenance.stale) opts.onConsulted?.(deps[entry.index], 'osv');
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
// Retain verified live matches. Consult previous evidence only for
|
|
486
|
+
// details or pages the source could not supply during this refresh.
|
|
487
|
+
partial.set(entry.index, { found, verified: new Set(query.ids),
|
|
488
|
+
listed: fetched[i].complete ? new Set(fetched[i].vulns.map(v => v.id)) : null });
|
|
489
|
+
}
|
|
429
490
|
}
|
|
430
491
|
} catch(error) {
|
|
431
492
|
if (!opts.allowStaleFallback) throw error;
|
|
432
493
|
warn('source-unavailable',`OSV: refresh failed; cached advisories are used with incomplete coverage (${error.message}).`);
|
|
433
494
|
}
|
|
434
495
|
}
|
|
435
|
-
const {vulnVerdict,packageKey}=require('./
|
|
496
|
+
const {vulnVerdict,packageKey}=require('./db');
|
|
436
497
|
const unverified = new Map();
|
|
498
|
+
const undecidable = [];
|
|
437
499
|
for(let i=0;i<deps.length;i++) {
|
|
438
500
|
if(output[i])continue;
|
|
439
501
|
const d=deps[i],q=tuple(d),view=views[i], query=view.query;
|
|
@@ -447,38 +509,46 @@ async function queryBatch(deps, opts = {}) {
|
|
|
447
509
|
// newer advisory supersedes it, evaluate that advisory below; the age
|
|
448
510
|
// of an unrelated older catalogue does not make the query stale.
|
|
449
511
|
if (view.coverage && !view.coverage.fresh && !query) warn('source-stale',`OSV: ${q.ecosystem} seed is ${view.coverage.fetchedAt>1 ? `from ${new Date(view.coverage.fetchedAt).toISOString()}` : 'of unknown age'}.`,staleSeverity(view.coverage,offline,opts.maxAdvisoryAgeMs));
|
|
450
|
-
const
|
|
512
|
+
const unknownBefore = undecidable.length;
|
|
513
|
+
const live = partial.get(i);
|
|
514
|
+
const ids=new Set(query?.ids || []), found=live?.found || []; let unknown=false;
|
|
451
515
|
for(const item of view.records) {
|
|
452
516
|
const v=item.document;if(v.withdrawn)continue;
|
|
517
|
+
if (live && (live.verified.has(v.id) || (live.listed && !live.listed.has(v.id)))) continue;
|
|
453
518
|
if(item.source==='osv-legacy-maven')warn('osv-coverage',`OSV: legacy Maven advisory ${v.id} is partial; its withdrawal status is unknown.`);
|
|
454
519
|
let affected;
|
|
455
|
-
if(query && require('
|
|
520
|
+
if(query && require('../../advisories/store').queryCoversRecord(query,item)) affected=ids.has(v.id);
|
|
456
521
|
else if(opts.useStoredRanges === false) { unknown=true; continue; }
|
|
457
522
|
else {
|
|
458
523
|
const relevant=(v.affected || []).filter(a=>a?.package?.ecosystem===q.ecosystem && (q.ecosystem === 'Maven' ? a.package.name === q.name : packageKey(a.package.name,q.ecosystem)===packageKey(q.name,q.ecosystem)));
|
|
459
524
|
affected=relevant.length ? vulnVerdict(q.version,{...v,affected:relevant},q.ecosystem) : ids.has(v.id) ? true : false;
|
|
460
525
|
}
|
|
461
|
-
if(affected===null)
|
|
526
|
+
if (affected === null) undecidable.push({id:v.id, package:q.name, version:q.version, reason:'OSV version range cannot be evaluated.'});
|
|
527
|
+
else if (affected) found.push(vulnToMatch(d,v));
|
|
462
528
|
}
|
|
463
|
-
if(unknown)warn('osv-coverage',`OSV: at least one advisory for ${q.name}@${q.version}
|
|
529
|
+
if(unknown)warn('osv-coverage',`OSV: at least one advisory for ${q.name}@${q.version} requires a verified package/version consultation with stored range matching disabled.`);
|
|
530
|
+
const proof = query || (opts.useStoredRanges !== false && view.coverage);
|
|
531
|
+
if (!live && !unknown && undecidable.length === unknownBefore && proof?.complete && !proof.provenance?.stale &&
|
|
532
|
+
!proof.provenance?.refreshFailure && (offline || proof.fresh)) opts.onConsulted?.(d,'osv');
|
|
464
533
|
output[i]=found;
|
|
465
534
|
}
|
|
535
|
+
if (undecidable.length) onWarning?.(require('../../scan/diagnostics').advisoryEvidenceDiagnostic(undecidable));
|
|
466
536
|
for(const [ecosystem,packages] of unverified) {
|
|
467
537
|
const examples=[...packages].slice(0,3).join(', ');
|
|
468
|
-
warn('osv-coverage',`OSV: offline coverage is incomplete for ${packages.size} ${ecosystem} package/version(s) without a verified consultation (${examples}${packages.size>3?', …':''}). Available advisory ranges were still matched; no finding does not prove those versions clean.`);
|
|
538
|
+
warn('osv-coverage',`OSV: ${offline ? 'offline ' : ''}coverage is incomplete for ${packages.size} ${ecosystem} package/version(s) without a verified consultation (${examples}${packages.size>3?', …':''}). Available advisory ranges were still matched; no finding does not prove those versions clean.`);
|
|
469
539
|
}
|
|
470
540
|
// VigieVuln's reviewed advisories are an independent source in the local
|
|
471
541
|
// advisory journal. They remain available offline and never inherit OSV's
|
|
472
542
|
// coverage claims or source identity.
|
|
473
543
|
for(let i=0;i<deps.length;i++) {
|
|
474
544
|
const d=deps[i],q=tuple(d);
|
|
475
|
-
const ownQuery=store.getQuery({source:'vigievuln',ecosystem:q.ecosystem,name:q.name,version:'*'},{ttlMs:queryTtlMs});
|
|
545
|
+
const ownQuery=store.getQuery({source:'vigievuln',ecosystem:q.ecosystem,name:q.name,version:'*'},{ttlMs:offline?queryTtlMs:require('../../advisories/freshness').runTtl(queryTtlMs)});
|
|
476
546
|
const ownKey=`${q.ecosystem}\0${q.name}`;
|
|
477
547
|
if(ownQuery&&!ownQuery.fresh&&!reviewedFreshnessNotices.has(ownKey)){reviewedFreshnessNotices.add(ownKey);const severity=staleSeverity(ownQuery,offline,opts.maxAdvisoryAgeMs);onWarning?.({type:'source-stale',...(severity?{severity}:{}),message:`VigieVuln: reviewed advisory consultation for ${q.name} is from ${new Date(ownQuery.fetchedAt).toISOString()}.`});}
|
|
478
548
|
for(const item of store.getPackageRecords(q.ecosystem,q.name,{source:'vigievuln'})) {
|
|
479
549
|
const v=item.document;
|
|
480
550
|
if(v.withdrawn)continue;
|
|
481
|
-
if(!require('
|
|
551
|
+
if(!require('../vigievuln/advisories').isCurrentForPackage(store,q,item))continue;
|
|
482
552
|
const relevant=(v.affected||[]).filter(a=>a?.package?.ecosystem===q.ecosystem && typeof a.package.name==='string' && (q.ecosystem==='Maven' ? a.package.name===q.name : packageKey(a.package.name,q.ecosystem)===packageKey(q.name,q.ecosystem)));
|
|
483
553
|
const verdict=relevant.length ? vulnVerdict(q.version,{...v,affected:relevant},q.ecosystem,{source:'vigievuln'}) : null;
|
|
484
554
|
if(verdict===null && relevant.length) warn('source-unavailable',`VigieVuln: ${v.id} has only partial version evidence for ${q.name}@${q.version}.`);
|
|
@@ -510,18 +580,18 @@ async function queryBatch(deps, opts = {}) {
|
|
|
510
580
|
|
|
511
581
|
/** Reviewed-source matching also works when OSV is explicitly disabled. */
|
|
512
582
|
function queryReviewedForDeps(resolvedDeps,opts={}) {
|
|
513
|
-
const store=opts.store||require('
|
|
583
|
+
const store=opts.store||require('../../advisories/store').openAdvisoryStore({cacheDir:opts.cacheDir||require('../../cache/directory').getCacheDir()});
|
|
514
584
|
try {
|
|
515
|
-
const {vulnVerdict,packageKey}=require('./
|
|
585
|
+
const {vulnVerdict,packageKey}=require('./db');const matches=[],warned=new Set();
|
|
516
586
|
for(const d of resolvedDeps.values()) {
|
|
517
587
|
if(!d || d.scope==='parent' || d.provenance==='binary')continue;
|
|
518
588
|
const ecosystem=osvEcosystemFor(d),name=osvPkgName(d);if(!name)continue;
|
|
519
|
-
const ownQuery=store.getQuery({source:'vigievuln',ecosystem,name,version:'*'},{ttlMs:opts.queryTtlMs ?? 4 * 3600000});
|
|
589
|
+
const ownQuery=store.getQuery({source:'vigievuln',ecosystem,name,version:'*'},{ttlMs:opts.offline?(opts.queryTtlMs ?? 4 * 3600000):require('../../advisories/freshness').runTtl(opts.queryTtlMs ?? 4 * 3600000)});
|
|
520
590
|
if(ownQuery&&!ownQuery.fresh&&!warned.has(`${ecosystem}\0${name}`)){warned.add(`${ecosystem}\0${name}`);const severity=staleSeverity(ownQuery,opts.offline,opts.maxAdvisoryAgeMs);opts.onWarning?.({type:'source-stale',...(severity?{severity}:{}),message:`VigieVuln: reviewed advisory consultation for ${name} is from ${new Date(ownQuery.fetchedAt).toISOString()}.`});}
|
|
521
591
|
for(const version of d.versions?.length?d.versions:[d.version]) {
|
|
522
592
|
if(!version||/\$\{|SNAPSHOT/i.test(version))continue;
|
|
523
593
|
for(const item of store.getPackageRecords(ecosystem,name,{source:'vigievuln'})) {
|
|
524
|
-
if(item.document.withdrawn || !require('
|
|
594
|
+
if(item.document.withdrawn || !require('../vigievuln/advisories').isCurrentForPackage(store,{ecosystem,name},item))continue;
|
|
525
595
|
const relevant=(item.document.affected||[]).filter(a=>a?.package?.ecosystem===ecosystem && typeof a.package.name==='string' && (ecosystem==='Maven'?a.package.name===name:packageKey(a.package.name,ecosystem)===packageKey(name,ecosystem)));
|
|
526
596
|
if(!relevant.length)continue;
|
|
527
597
|
const verdict=vulnVerdict(String(version),{...item.document,affected:relevant},ecosystem,{source:'vigievuln'});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Requests contain only public archive coordinates or a curated upstream project ID.
|
|
4
|
+
const archives = {
|
|
5
|
+
debian:'https://deb.debian.org/debian', 'debian-security':'https://deb.debian.org/debian-security',
|
|
6
|
+
'debian-archive':'https://archive.debian.org/debian', 'debian-archive-security':'https://archive.debian.org/debian-security',
|
|
7
|
+
ubuntu:'https://archive.ubuntu.com/ubuntu', 'ubuntu-security':'https://security.ubuntu.com/ubuntu',
|
|
8
|
+
'ubuntu-ports':'https://ports.ubuntu.com/ubuntu-ports', 'ubuntu-archive':'https://old-releases.ubuntu.com/ubuntu',
|
|
9
|
+
};
|
|
10
|
+
const suite = /^[a-z]{2,24}(?:-updates|-security|\/updates)?$/;
|
|
11
|
+
const index = /^(?:main|contrib|non-free(?:-firmware)?|restricted|universe|multiverse)\/binary-(?:amd64|i386|arm64|armhf|armel|ppc64el|s390x|riscv64|mips64el|mipsel)\/Packages\.(?:gz|xz)$/;
|
|
12
|
+
const alpine = /^v\d{1,2}\.\d{1,2}$/;
|
|
13
|
+
const apkArch = /^(?:x86|x86_64|armhf|armv7|aarch64|ppc64le|s390x|riscv64|loongarch64)$/;
|
|
14
|
+
function build(type,p={}) {
|
|
15
|
+
if(type==='upstream' && Number.isSafeInteger(p.project) && p.project>0 && p.project<=1000000)
|
|
16
|
+
return {url:'https://release-monitoring.org/api/v2/versions/?project_id='+p.project};
|
|
17
|
+
if(type==='apk' && alpine.test(p.series) && apkArch.test(p.arch) && ['main','community'].includes(p.section))
|
|
18
|
+
return {url:`https://dl-cdn.alpinelinux.org/alpine/${p.series}/${p.section}/${p.arch}/APKINDEX.tar.gz`};
|
|
19
|
+
if(Object.hasOwn(archives,p.archive) && suite.test(p.suite)) {
|
|
20
|
+
const root=archives[p.archive]+'/dists/'+p.suite+'/';
|
|
21
|
+
if(type==='release')return {url:root+'Release'};
|
|
22
|
+
if(type==='index' && index.test(p.file))return {url:root+p.file};
|
|
23
|
+
}
|
|
24
|
+
throw Error('Invalid release catalogue coordinates');
|
|
25
|
+
}
|
|
26
|
+
module.exports={id:'package-releases',ttlMs:4*3600000,build,archives,suite,index,alpine,apkArch};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* lib/packagist
|
|
2
|
+
* lib/providers/packagist/audit.js — the Packagist security-advisories lane for Composer deps.
|
|
3
3
|
*
|
|
4
4
|
* `composer audit` (Composer ≥ 2.4) queries `https://packagist.org/api/security-advisories/`
|
|
5
5
|
* — the advisory database Packagist builds from GitHub advisories and FriendsOfPHP, keyed
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* Only package NAMES travel to packagist.org (never versions), exactly like the existing
|
|
14
14
|
* Packagist registry pass in lib/codecs/composer/registry.js. Under `--offline` this lane
|
|
15
15
|
* reads the warm cache and makes zero network calls. An unavailable packagist.org is
|
|
16
|
-
* reported as incomplete coverage
|
|
16
|
+
* reported as incomplete discovery coverage and fails the vulnerability scan.
|
|
17
17
|
*
|
|
18
18
|
* Advisories are cached per package in ~/.fad-checker/packagist-advisories/ (24 h TTL;
|
|
19
19
|
* offline ignores the TTL, same rule as OSV/NVD: the warmed cache is the only source on
|
|
@@ -27,7 +27,7 @@ const path = require("path");
|
|
|
27
27
|
const os = require("os");
|
|
28
28
|
|
|
29
29
|
const PACKAGIST_AUDIT_API = "https://packagist.org/api/security-advisories/";
|
|
30
|
-
const DEFAULT_CACHE_DIR = path.join(require("
|
|
30
|
+
const DEFAULT_CACHE_DIR = path.join(require("../../cache/directory").getCacheDir(), "packagist-advisories");
|
|
31
31
|
const CACHE_TTL_MS = 4 * 3600 * 1000;
|
|
32
32
|
const BATCH_SIZE = 100; // composer audit sends 100 packages per request; stay aligned
|
|
33
33
|
|
|
@@ -153,7 +153,7 @@ function parseConstraintToken(raw) {
|
|
|
153
153
|
// branch (>=7.4 <7.5) — a deliberate fad reading kept from the first version
|
|
154
154
|
// of this lane (Composer itself would read "==7.4.0.0").
|
|
155
155
|
// A bare SUFFIXED token ("1.0.0-beta1") stays undecidable: publisher feeds
|
|
156
|
-
// reuse this evaluator (lib/
|
|
156
|
+
// reuse this evaluator (lib/providers/github/advisories.js) and
|
|
157
157
|
// write malformed intervals in that shape, so equality would be a guess there.
|
|
158
158
|
if (v.hasStab) return null;
|
|
159
159
|
const parts = /^v?(\d+(?:\.\d+)*)/.exec(m[2].trim())[1].split(".").length;
|
|
@@ -256,11 +256,11 @@ function cacheFileName(name) {
|
|
|
256
256
|
function readCache(cacheDir, name, { ignoreTtl = false } = {}) {
|
|
257
257
|
try {
|
|
258
258
|
const root=path.basename(cacheDir)==='packagist-advisories'?path.dirname(cacheDir):cacheDir;
|
|
259
|
-
const data = require('
|
|
259
|
+
const data = require('../../cache/repository').createCacheRepository(root).get('packagist-audit',name)?.value;
|
|
260
260
|
// Legacy empty entries may have come from omitted packages or malformed
|
|
261
261
|
// responses, so they cannot establish a clean answer after the schema fix.
|
|
262
262
|
if (Array.isArray(data.body) && (data._schema === 2 || data.body.length) &&
|
|
263
|
-
(ignoreTtl || require('
|
|
263
|
+
(ignoreTtl || require('../../cache/policy').fresh(data._fetchedAt, CACHE_TTL_MS))) return data.body;
|
|
264
264
|
} catch { /* miss */ }
|
|
265
265
|
return null;
|
|
266
266
|
}
|
|
@@ -268,7 +268,7 @@ function readCache(cacheDir, name, { ignoreTtl = false } = {}) {
|
|
|
268
268
|
function writeCache(cacheDir, name, body) {
|
|
269
269
|
try {
|
|
270
270
|
const root=path.basename(cacheDir)==='packagist-advisories'?path.dirname(cacheDir):cacheDir;
|
|
271
|
-
require('
|
|
271
|
+
require('../../cache/repository').createCacheRepository(root).put('packagist-audit',name,{ _schema: 2, _fetchedAt: Date.now(), body });
|
|
272
272
|
} catch { /* a cache write failure must never kill the scan */ }
|
|
273
273
|
}
|
|
274
274
|
|
|
@@ -317,6 +317,7 @@ function advisoryToMatch(depRecord, adv) {
|
|
|
317
317
|
dep: depRecord,
|
|
318
318
|
cve: {
|
|
319
319
|
id,
|
|
320
|
+
sourceAdvisoryId: adv.advisoryId,
|
|
320
321
|
severity: normalizeSeverity(adv.severity),
|
|
321
322
|
score: null,
|
|
322
323
|
description: String(adv.title || "").trim(),
|
|
@@ -374,6 +375,7 @@ async function queryPackagistAudit(resolvedDeps, opts = {}) {
|
|
|
374
375
|
const names = new Set();
|
|
375
376
|
const skipped = new Set();
|
|
376
377
|
const unknown = new Set();
|
|
378
|
+
const failed = new Set();
|
|
377
379
|
for (const depRecord of (resolvedDeps ? resolvedDeps.values() : [])) {
|
|
378
380
|
if (depRecord.ecosystem !== "composer") continue;
|
|
379
381
|
if (belongsToOtherComposerRegistry(depRecord)) {
|
|
@@ -389,11 +391,12 @@ async function queryPackagistAudit(resolvedDeps, opts = {}) {
|
|
|
389
391
|
|
|
390
392
|
const missing = [];
|
|
391
393
|
for (const name of names) {
|
|
392
|
-
const hit = !offline && require("
|
|
394
|
+
const hit = !offline && require("..").hasHostedProxy() ? null : readCache(cacheDir, name, { ignoreTtl: !!offline });
|
|
393
395
|
if (hit !== null) advisoriesByPkg[name] = hit;
|
|
394
396
|
else missing.push(name);
|
|
395
397
|
}
|
|
396
398
|
|
|
399
|
+
if (offline) for (const name of missing) unknown.add(name);
|
|
397
400
|
if (missing.length && !offline) {
|
|
398
401
|
const batches = [];
|
|
399
402
|
for (let i = 0; i < missing.length; i += BATCH_SIZE) batches.push(missing.slice(i, i + BATCH_SIZE));
|
|
@@ -402,7 +405,7 @@ async function queryPackagistAudit(resolvedDeps, opts = {}) {
|
|
|
402
405
|
else if (verbose && batches.length > 1) console.log(` Packagist audit batch ${i + 1}/${batches.length} (${batches[i].length} packages)…`);
|
|
403
406
|
const url = `${PACKAGIST_AUDIT_API}?${batches[i].map(n => `packages[]=${encodeURIComponent(n)}`).join("&")}`;
|
|
404
407
|
try {
|
|
405
|
-
const res = await require("
|
|
408
|
+
const res = await require("..").getResource("packagist", "advisories", { packages: batches[i] },
|
|
406
409
|
{ fetcher, headers: { "User-Agent": "vigievuln-packagist-audit", Accept: "application/json" } });
|
|
407
410
|
if (!res.ok) throw new Error(`Packagist audit HTTP ${res.status}`);
|
|
408
411
|
const data = await res.json();
|
|
@@ -422,18 +425,35 @@ async function queryPackagistAudit(resolvedDeps, opts = {}) {
|
|
|
422
425
|
typeof adv.affectedVersions !== "string"))
|
|
423
426
|
throw new Error(`Packagist audit has invalid advisory records for ${name}`);
|
|
424
427
|
}
|
|
428
|
+
const stale = res.headers?.get?.('x-fad-proxy') === 'stale';
|
|
429
|
+
if (stale) opts.onWarning?.({type:'source-stale',message:'Packagist: the advisory lookup returned stale data.'});
|
|
425
430
|
for (const name of batches[i]) {
|
|
426
431
|
if (!byName.has(name)) continue;
|
|
427
432
|
advisoriesByPkg[name] = byName.get(name);
|
|
428
|
-
|
|
433
|
+
if (stale) failed.add(name);
|
|
434
|
+
else writeCache(cacheDir, name, advisoriesByPkg[name]);
|
|
429
435
|
}
|
|
430
436
|
} catch (err) {
|
|
431
|
-
|
|
437
|
+
const failure = new Error(`Packagist audit batch ${i + 1}/${batches.length} failed: ${err.message}`, { cause: err });
|
|
438
|
+
if (!opts.onWarning) throw failure;
|
|
439
|
+
opts.onWarning({type: 'source-unavailable', message: `Packagist: ${failure.message}. Advisory coverage is incomplete.`});
|
|
440
|
+
for (const name of batches[i]) {
|
|
441
|
+
failed.add(name);
|
|
442
|
+
const saved = readCache(cacheDir, name, {ignoreTtl:true});
|
|
443
|
+
if (saved !== null) advisoriesByPkg[name] = saved;
|
|
444
|
+
}
|
|
432
445
|
}
|
|
433
446
|
}
|
|
434
447
|
}
|
|
435
448
|
if (unknown.size && onUnknown) onUnknown([...unknown].sort());
|
|
436
449
|
|
|
450
|
+
if (opts.onConsulted) for (const dep of resolvedDeps.values()) {
|
|
451
|
+
if (dep.ecosystem !== 'composer' || belongsToOtherComposerRegistry(dep)) continue;
|
|
452
|
+
const name = (dep.namespace+'/'+dep.name).toLowerCase(), list=advisoriesByPkg[name];
|
|
453
|
+
if (!list || failed.has(name)) continue;
|
|
454
|
+
for (const version of dep.versions?.length ? dep.versions : [dep.version])
|
|
455
|
+
if (isConcreteVersion(version) && list.every(a=>satisfiesComposerConstraint(version,a.affectedVersions)!==null)) opts.onConsulted(dep,'packagist',version);
|
|
456
|
+
}
|
|
437
457
|
return collectPackagistMatches(resolvedDeps, advisoriesByPkg);
|
|
438
458
|
}
|
|
439
459
|
|