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
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coverage is a record of checks performed, independent of their findings.
|
|
3
|
+
* A missing source or unknown version can never become a reassuring no-match.
|
|
4
|
+
*/
|
|
5
|
+
const EXECUTIONS = new Set(["completed", "partial", "not-run", "failed", "not-applicable"]);
|
|
6
|
+
const RESULTS = new Set(["affected", "no-match", "indeterminate", "not-applicable"]);
|
|
7
|
+
|
|
8
|
+
// A private component, or one the public catalogue does not know, is treated like a
|
|
9
|
+
// private package of any other ecosystem: it is listed as private, not as a failed check.
|
|
10
|
+
const PRIVATE_DIAGNOSTICS = new Set(["CMS_PRIVATE_COMPONENT", "CMS_PROVIDER_COMPONENT_UNKNOWN"]);
|
|
11
|
+
const isPrivateCheck = check => PRIVATE_DIAGNOSTICS.has(check?.diagnostic);
|
|
12
|
+
|
|
13
|
+
function createCoverage() {
|
|
14
|
+
const records = [];
|
|
15
|
+
const keys = new Set();
|
|
16
|
+
return {
|
|
17
|
+
records,
|
|
18
|
+
record(input) {
|
|
19
|
+
if (!input || !input.applicationId || !input.capability) throw new Error("coverage requires applicationId and capability");
|
|
20
|
+
const { execution, result } = input;
|
|
21
|
+
if (!EXECUTIONS.has(execution)) throw new Error(`invalid coverage execution: ${execution}`);
|
|
22
|
+
if (!RESULTS.has(result)) throw new Error(`invalid coverage result: ${result}`);
|
|
23
|
+
if (result === "no-match" && execution !== "completed") throw new Error("no-match requires a completed check");
|
|
24
|
+
if (execution === "not-applicable" && result !== "not-applicable") throw new Error("not-applicable execution requires not-applicable result");
|
|
25
|
+
if ((execution === "failed" || execution === "not-run") && result === "affected") throw new Error("an unexecuted check cannot establish affected");
|
|
26
|
+
const expected = input.expected ?? 0;
|
|
27
|
+
const executed = input.executed ?? 0;
|
|
28
|
+
if (![expected, executed].every(n => Number.isSafeInteger(n) && n >= 0)) throw new Error("coverage counts must be nonnegative integers");
|
|
29
|
+
if (execution === "completed" && executed < expected) throw new Error("completed check has fewer executions than expected");
|
|
30
|
+
const key = [input.applicationId, input.occurrenceId || "", input.capability, input.sourceId || ""].join("\0");
|
|
31
|
+
if (keys.has(key)) throw new Error("duplicate coverage check");
|
|
32
|
+
keys.add(key);
|
|
33
|
+
const entry = { ...input, expected, executed, ...(isPrivateCheck(input) ? { affectsCompleteness: false } : {}) };
|
|
34
|
+
records.push(entry);
|
|
35
|
+
return entry;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Private application components, in the shape of the private-package list of the other ecosystems. */
|
|
41
|
+
function privateComponents(appState, relativise = p => p) {
|
|
42
|
+
const types = new Map((appState.applications || []).map(app => [app.id, app.type]));
|
|
43
|
+
const items = new Map();
|
|
44
|
+
for (const c of appState.inventory || []) {
|
|
45
|
+
const declared = c.visibility === "private";
|
|
46
|
+
const unknown = (appState.coverage || []).some(r => r.occurrenceId === c.id && r.diagnostic === "CMS_PROVIDER_COMPONENT_UNKNOWN");
|
|
47
|
+
if (!declared && !unknown) continue;
|
|
48
|
+
const label = /^[a-z0-9][a-z0-9._-]*$/i.test(c.slug || "") ? c.slug : c.name || c.coord || c.id;
|
|
49
|
+
items.set(c.id, { id: `${c.kind || "component"} · ${label}${c.version ? "@" + c.version : ""}`,
|
|
50
|
+
ecosystem: types.get(c.applicationId) || "application", manifestPaths: c.path ? [relativise(c.path)] : [] });
|
|
51
|
+
}
|
|
52
|
+
return [...items.values()];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function summarizeCoverage(records = []) {
|
|
56
|
+
const out = { checks: records.length, completed: 0, partial: 0, failed: 0, notRun: 0, expected: 0, executed: 0 };
|
|
57
|
+
for (const r of records) {
|
|
58
|
+
if (r.execution === "completed") out.completed++;
|
|
59
|
+
else if (r.execution === "partial") out.partial++;
|
|
60
|
+
else if (r.execution === "failed") out.failed++;
|
|
61
|
+
else if (r.execution === "not-run") out.notRun++;
|
|
62
|
+
out.expected += r.expected || 0;
|
|
63
|
+
out.executed += r.executed || 0;
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function requiredCoverageComplete(records = [], capabilities = []) {
|
|
69
|
+
if (!capabilities.length) return true;
|
|
70
|
+
const applications = new Set(records.map(r => r.applicationId));
|
|
71
|
+
if (!applications.size) return false;
|
|
72
|
+
for (const applicationId of applications) {
|
|
73
|
+
for (const capability of capabilities) {
|
|
74
|
+
const checks = records.filter(r => r.applicationId === applicationId && r.capability === capability);
|
|
75
|
+
if (!checks.length || checks.some(r => !isPrivateCheck(r) && r.execution !== "completed" && r.execution !== "not-applicable")) return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Group incomplete module checks by cause, retaining every affected component.
|
|
82
|
+
function applicationWarnings(appState, srcRoot = '') {
|
|
83
|
+
const diagnostics = appState.diagnostics.filter(d => !PRIVATE_DIAGNOSTICS.has(d.code)).map(d => ({ type: d.sourceIds?.length ? "source-unavailable" : "cms-coverage", code: d.code,
|
|
84
|
+
applicationId: d.applicationId || null, ...(d.path ? { path: d.path } : {}),
|
|
85
|
+
message: `${d.applicationId || d.pluginId || "application"}: ${d.message}` }));
|
|
86
|
+
const componentById = new Map(appState.inventory.map(c => [c.id, c]));
|
|
87
|
+
const groups = new Map();
|
|
88
|
+
for (const c of appState.coverage) {
|
|
89
|
+
if (c.execution !== "partial" && c.execution !== "not-run" && c.execution !== "failed") continue;
|
|
90
|
+
if (isPrivateCheck(c)) continue; // listed once with the private packages of every ecosystem
|
|
91
|
+
if (appState.diagnostics.some(d => d.applicationId === c.applicationId && d.code === c.diagnostic)) continue;
|
|
92
|
+
const diagnostic = c.diagnostic || "CMS_INCOMPLETE";
|
|
93
|
+
const key = `${c.applicationId}\0${c.capability}\0${c.sourceId || ""}\0${diagnostic}`;
|
|
94
|
+
if (!groups.has(key)) groups.set(key, { applicationId: c.applicationId, capability: c.capability,
|
|
95
|
+
sourceId: c.sourceId || null, execution: c.execution, diagnostic, checks: [] });
|
|
96
|
+
groups.get(key).checks.push(c);
|
|
97
|
+
}
|
|
98
|
+
const gaps = [...groups.values()].map(g => {
|
|
99
|
+
const items = g.checks.map(c => {
|
|
100
|
+
const component = componentById.get(c.occurrenceId);
|
|
101
|
+
return { id: component ? `${component.kind || "component"} · ${component.name || component.coord || component.id}`
|
|
102
|
+
: c.occurrenceId || g.applicationId,
|
|
103
|
+
manifestPaths: component?.path ? [require('node:path').join(srcRoot, component.path)] : [] };
|
|
104
|
+
});
|
|
105
|
+
return { type: "cms-coverage", code: g.diagnostic, count: g.checks.length,
|
|
106
|
+
applicationId: g.applicationId, capability: g.capability, sourceId: g.sourceId,
|
|
107
|
+
execution: g.execution, diagnostic: g.diagnostic, items,
|
|
108
|
+
message: `${g.applicationId}: ${g.capability}${g.sourceId ? ` (${g.sourceId})` : ""} — ` +
|
|
109
|
+
`${g.checks.length} component(s) not evaluated (${g.diagnostic})` };
|
|
110
|
+
});
|
|
111
|
+
return diagnostics.concat(gaps);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
module.exports = { applicationWarnings, createCoverage, summarizeCoverage, requiredCoverageComplete, privateComponents, isPrivateCheck, EXECUTIONS, RESULTS };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* lib/provenance.js — scan-provenance / reproducibility manifest.
|
|
2
|
+
* lib/scan/provenance.js — scan-provenance / reproducibility manifest.
|
|
3
3
|
*
|
|
4
4
|
* A professional audit must be defensible and reproducible: a finding has to be
|
|
5
5
|
* explainable from the exact inputs that produced it, and a second auditor should be
|
|
@@ -19,7 +19,7 @@ const fs = require("fs");
|
|
|
19
19
|
const path = require("path");
|
|
20
20
|
const os = require("os");
|
|
21
21
|
|
|
22
|
-
const DEFAULT_CACHE_DIR = path.join(require("
|
|
22
|
+
const DEFAULT_CACHE_DIR = path.join(require("../cache/directory").getCacheDir());
|
|
23
23
|
|
|
24
24
|
function readJson(file) {
|
|
25
25
|
try { return JSON.parse(fs.readFileSync(file, "utf8")); } catch { return null; }
|
|
@@ -41,6 +41,7 @@ const SOURCE_DEFS = [
|
|
|
41
41
|
{ id: "cve", label: "CVEProject (Maven index)", rel: "cve-data/meta.json", kind: "cve-meta" },
|
|
42
42
|
{ id: "osv", label: "OSV.dev", rel: "osv-cache", kind: "dir", flag: "osv" },
|
|
43
43
|
{ id: "packagistAudit", label: "Packagist security advisories", rel: "packagist-advisories", kind: "dir", flag: "packagistAudit" },
|
|
44
|
+
{ id: "rubyAdvisories", label: "Ruby advisory database (rubysec)", rel: "rubysec", kind: "dir", flag: "rubyAdvisories" },
|
|
44
45
|
...[["maven", "Maven"], ["npm", "npm"], ["pypi", "PyPI"], ["composer", "Packagist"], ["nuget", "NuGet"], ["go", "Go"], ["ruby", "RubyGems"]].map(([eco, label]) => ({ id: `osvDb-${eco}`, label: `OSV local DB (${label})`, rel: `osv-db/${eco}-index.json`, kind: "osv-db", eco })),
|
|
45
46
|
{ id: "nvd", label: "NIST NVD", rel: "nvd-cache", kind: "dir", flag: "nvd" },
|
|
46
47
|
{ id: "epss", label: "EPSS (FIRST.org)", rel: "epss-cache.json", kind: "meta", flag: "epss" },
|
|
@@ -62,7 +63,7 @@ const SOURCE_DEFS = [
|
|
|
62
63
|
function readSource(def, cacheDir) {
|
|
63
64
|
if (def.kind === "derived") return { status: "derived", asOf: null, detail: "Derived locally from CVE identifiers" };
|
|
64
65
|
if(!fs.existsSync(path.join(cacheDir,'cache.sqlite')))return {status:'missing',asOf:null,detail:null};
|
|
65
|
-
const db=require('
|
|
66
|
+
const db=require('../cache/db').getCacheDb(cacheDir),repo=require('../cache/repository').createCacheRepository(cacheDir);
|
|
66
67
|
if(def.id==='nvd'){
|
|
67
68
|
const row=db.prepare('SELECT COUNT(*) count,MIN(fetched_at) oldest FROM nvd_records').get();
|
|
68
69
|
return row.count?{status:'cached',asOf:iso(row.oldest),detail:`${row.count} cached records`}:{status:'missing',asOf:null,detail:null};
|
|
@@ -75,6 +76,10 @@ function readSource(def, cacheDir) {
|
|
|
75
76
|
const row=db.prepare("SELECT COUNT(*) count,MAX(fetched_at) newest FROM cache_entries WHERE namespace='packagist-audit'").get();
|
|
76
77
|
return row.count?{status:'cached',asOf:iso(row.newest),detail:`${row.count} cached packages`}:{status:'missing',asOf:null,detail:null};
|
|
77
78
|
}
|
|
79
|
+
if(def.id==='rubyAdvisories'){
|
|
80
|
+
const saved=repo.get('rubysec','advisory-db')?.value;
|
|
81
|
+
return saved?{status:'cached',asOf:iso(saved.fetchedAt),detail:`${saved.count} advisories`}:{status:'missing',asOf:null,detail:null};
|
|
82
|
+
}
|
|
78
83
|
if(def.id==='osv'||def.kind==='osv-db')return {status:'missing',asOf:null,detail:null};
|
|
79
84
|
const catalogue={kev:'kev',epss:'epss',euvd:'euvd',certfr:'certfr',gcve:'gcve'}[def.id];
|
|
80
85
|
const auxiliary={npm:'npm-registry',nuget:'nuget',packagist:'packagist',go:'go-proxy',rubygems:'rubygems'}[def.id]||path.basename(def.rel);
|
|
@@ -105,7 +110,7 @@ function readSource(def, cacheDir) {
|
|
|
105
110
|
*/
|
|
106
111
|
function collectDataSources({ cacheDir = DEFAULT_CACHE_DIR, options = {}, ecosystems = null } = {}) {
|
|
107
112
|
let store = null;
|
|
108
|
-
if (fs.existsSync(path.join(cacheDir,'cache.sqlite'))) store = require('
|
|
113
|
+
if (fs.existsSync(path.join(cacheDir,'cache.sqlite'))) store = require('../advisories/store').openAdvisoryStore({cacheDir});
|
|
109
114
|
try {
|
|
110
115
|
const ttlMs = options.advisoryQueryTtlMs != null ? Number(options.advisoryQueryTtlMs) : (options.advisoryQueryTtl != null ? Number(options.advisoryQueryTtl) * 3600000 : 4 * 3600000);
|
|
111
116
|
const osvEcosystems = {maven:'Maven',npm:'npm',pypi:'PyPI',composer:'Packagist',nuget:'NuGet',go:'Go',ruby:'RubyGems'};
|
|
@@ -121,6 +126,7 @@ function collectDataSources({ cacheDir = DEFAULT_CACHE_DIR, options = {}, ecosys
|
|
|
121
126
|
if (def.id === 'cve') return !active || [...active].some(id=>id !== 'binary');
|
|
122
127
|
if (def.id === 'mavenCentral') return uses('maven') || uses('gradle');
|
|
123
128
|
if (['packagistAudit','packagist'].includes(def.id)) return uses('composer');
|
|
129
|
+
if (def.id === 'rubyAdvisories') return uses('ruby');
|
|
124
130
|
if (def.id === 'npm') return uses('npm') || uses('yarn');
|
|
125
131
|
if (['nuget','go','rubygems'].includes(def.id)) return uses(def.id === 'rubygems' ? 'ruby' : def.id);
|
|
126
132
|
return true;
|
|
@@ -152,7 +158,7 @@ function collectDataSources({ cacheDir = DEFAULT_CACHE_DIR, options = {}, ecosys
|
|
|
152
158
|
function runConfiguration(options = {}) {
|
|
153
159
|
let proxyOrigin = null;
|
|
154
160
|
if (options.proxyCache) {
|
|
155
|
-
try { proxyOrigin = require("
|
|
161
|
+
try { proxyOrigin = require("../cache/proxy-scope").proxyOrigin(options.proxyCache); } catch { /* do not record credentials or malformed URLs */ }
|
|
156
162
|
}
|
|
157
163
|
return {
|
|
158
164
|
ecosystems: options.ecosystem || "auto",
|
|
@@ -170,6 +176,7 @@ function runConfiguration(options = {}) {
|
|
|
170
176
|
stableAdvisoryAgeDays: options.stableAdvisoryAgeDays ?? 365,
|
|
171
177
|
forceUpdate: !!options.forceUpdate,
|
|
172
178
|
packagistAudit: options.packagistAudit !== false,
|
|
179
|
+
rubyAdvisories: options.rubyAdvisories !== false,
|
|
173
180
|
nvd: options.nvd !== false,
|
|
174
181
|
epss: options.epss !== false,
|
|
175
182
|
kev: options.kev !== false,
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {osvPkgName, osvEcosystemFor} = require('../providers/osv/query');
|
|
4
|
+
const {depIdentity} = require('../advisories/native-package-match');
|
|
5
|
+
const structure = new Set(['dependency-coverage','go-coverage','unresolved-versions','no-lockfile','parse-error','missing-include','local-replace','image-scan-failed']);
|
|
6
|
+
const discovery = new Set(['osv-coverage','packagist-advisory-data-unknown','packagist-non-packagist-package','retire-failed']);
|
|
7
|
+
const ecosystems = new Set(['npm','yarn','maven','gradle','composer','pypi','go','ruby','nuget','system']);
|
|
8
|
+
|
|
9
|
+
function isBlocking(w) {
|
|
10
|
+
return w?.reliabilityFailure === true || (w?.severity !== 'info' && w?.affectsCompleteness !== false &&
|
|
11
|
+
(structure.has(w?.type) || discovery.has(w?.type)));
|
|
12
|
+
}
|
|
13
|
+
function incompleteCheck(check) {
|
|
14
|
+
return ['failed','partial','not-run'].includes(check.execution) && check.expected !== false &&
|
|
15
|
+
check.affectsCompleteness !== false && ['inventory','advisories'].includes(check.capability);
|
|
16
|
+
}
|
|
17
|
+
function coverageWarning(message, extra={}) {
|
|
18
|
+
return {type:'scan-reliability', reliabilityFailure:true, message,...extra};
|
|
19
|
+
}
|
|
20
|
+
function createDiscoveryCoverage() {
|
|
21
|
+
const verified = new Map();
|
|
22
|
+
function identity(dep,version) {
|
|
23
|
+
return JSON.stringify([dep.ecosystem==='system' ? depIdentity(dep)?.ecosystem || 'system' : osvEcosystemFor(dep),
|
|
24
|
+
dep.ecosystem==='system' ? dep.name : osvPkgName(dep), String(version || ''), dep.artifactTargetId || '', dep.architecture || '']);
|
|
25
|
+
}
|
|
26
|
+
function consulted(dep,source,version=dep.version) {
|
|
27
|
+
const key=identity(dep,version);
|
|
28
|
+
if(!verified.has(key))verified.set(key,new Set());
|
|
29
|
+
verified.get(key).add(source);
|
|
30
|
+
}
|
|
31
|
+
function privateMatcher({privateDeps=[],privateMavenIds=[]}={}) {
|
|
32
|
+
// Consume the existing registry classification, never infer absence from an
|
|
33
|
+
// advisory miss, an authentication error, or a source outage.
|
|
34
|
+
const privateVersions=new Set(privateDeps.flatMap(dep=>(dep.versions?.length ? dep.versions : [dep.version]).map(version=>identity(dep,version))));
|
|
35
|
+
const privateMaven=new Set(privateMavenIds);
|
|
36
|
+
return (dep,version)=>privateVersions.has(identity(dep,version)) ||
|
|
37
|
+
(['maven','gradle'].includes(dep.ecosystem) &&
|
|
38
|
+
(privateMaven.has(`${dep.groupId || dep.namespace}:${dep.artifactId || dep.name}`) ||
|
|
39
|
+
privateMaven.has(`${dep.groupId || dep.namespace}:${dep.artifactId || dep.name}:${version}`)));
|
|
40
|
+
}
|
|
41
|
+
function publicDependencies(deps,privateOptions,privateOnly=false) {
|
|
42
|
+
const isPrivate=privateMatcher(privateOptions),result=new Map();
|
|
43
|
+
for(const [key,dep] of deps){
|
|
44
|
+
const all=dep.versions?.length ? dep.versions : [dep.version];
|
|
45
|
+
const versions=all.filter(v=>isPrivate(dep,v)===privateOnly);
|
|
46
|
+
if(!versions.length)continue;
|
|
47
|
+
result.set(key,versions.length===all.length ? dep : {...dep,versions,version:versions.includes(dep.version)?dep.version:versions[0]});
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
function assess(deps,{store,options={},nativeSources=[],completeSources=[],reviewed=false,privateDeps=[],privateMavenIds=[]}={}) {
|
|
52
|
+
const missing = new Map(), global = new Set(completeSources), ttlMs=require('../advisories/freshness').runTtl(options.advisoryQueryTtlMs??4*3600000);
|
|
53
|
+
let assessed = 0, unassessed = 0;
|
|
54
|
+
const native = new Set(nativeSources),isPrivate=privateMatcher({privateDeps,privateMavenIds});
|
|
55
|
+
const usable = q=>q?.complete && !q.provenance?.stale && !q.provenance?.refreshFailure && !q.stale && (options.offline || q.fresh);
|
|
56
|
+
for(const source of native) {
|
|
57
|
+
if(usable(store.getSourceCoverage(source,'*',{ttlMs}))) global.add(source);
|
|
58
|
+
}
|
|
59
|
+
if(native.has('cveproject')) {
|
|
60
|
+
const snapshot=store.db?.prepare("SELECT fetched_at,metadata_json FROM cache_snapshots WHERE namespace='cve_lookup' AND complete=1 AND stale=0").get();
|
|
61
|
+
const local=snapshot && JSON.parse(snapshot.metadata_json);
|
|
62
|
+
const nativeCoverage=store.getSourceCoverage('cveproject','*',{ttlMs});
|
|
63
|
+
if(local?.fullArchive && local.releaseTag && nativeCoverage?.provenance?.releaseTag===local.releaseTag &&
|
|
64
|
+
(options.offline || Date.now()-snapshot.fetched_at<=ttlMs))global.add('cveproject');
|
|
65
|
+
}
|
|
66
|
+
for(const dep of deps.values()) {
|
|
67
|
+
if(dep.scope==='parent')continue;
|
|
68
|
+
// Raw binary identification is an inventory check, not a package advisory
|
|
69
|
+
// query. A product/version (or a hash lookup miss) cannot establish the
|
|
70
|
+
// package ecosystem required by OSV. Keep these in the unmanaged inventory.
|
|
71
|
+
// Dependencies extracted from build metadata use binary-module provenance
|
|
72
|
+
// and retain the normal package/version coverage requirement below.
|
|
73
|
+
if(dep.provenance==='binary' || dep.ecosystem==='binary')continue;
|
|
74
|
+
const versions=dep.versions?.length ? dep.versions : [dep.version];
|
|
75
|
+
if(versions.every(version=>isPrivate(dep,version)))continue;
|
|
76
|
+
if(!ecosystems.has(dep.ecosystem)){
|
|
77
|
+
// An unsupported package codec does not establish inapplicability.
|
|
78
|
+
const name=dep.identity?.name || dep.name || dep.artifactId || dep.coordKey;
|
|
79
|
+
const version=dep.identity?.version || dep.version;
|
|
80
|
+
const id=version ? `${name}@${version}` : name;
|
|
81
|
+
const key=JSON.stringify([dep.ecosystem,dep.coordKey,id]);
|
|
82
|
+
if(!missing.has(key)){assessed++;unassessed++;}
|
|
83
|
+
missing.set(key,{id,ecosystem:dep.ecosystem,detail:'No verified package/version assessment for this component.'});
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const pkg=depIdentity(dep);
|
|
87
|
+
const sources=new Set(pkg ? global : []);
|
|
88
|
+
if(store && pkg) {
|
|
89
|
+
for(const source of [...native,...(reviewed && ['maven','npm','yarn'].includes(dep.ecosystem)?['vigievuln']:[])]) {
|
|
90
|
+
if(sources.has(source))continue;
|
|
91
|
+
if(pkg.names.every(name=>usable(store.getQuery({source,ecosystem:pkg.ecosystem,name,version:'*'},{ttlMs}))))sources.add(source);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
for(const version of versions) {
|
|
95
|
+
if(isPrivate(dep,version))continue;
|
|
96
|
+
const key=identity(dep,version), hits=verified.get(key)||new Set();
|
|
97
|
+
const absent=[];
|
|
98
|
+
if(!hits.has('osv'))absent.push('OSV');
|
|
99
|
+
if(!sources.size && ![...hits].some(s=>s!=='osv'))absent.push('a second advisory source');
|
|
100
|
+
assessed++;
|
|
101
|
+
if(absent.length===2)unassessed++;
|
|
102
|
+
if(absent.length)missing.set(key,{id:`${pkg?.names?.[0] || dep.name}@${version || '?'}`,ecosystem:dep.ecosystem,missing:absent,detail:absent.join(' + ')});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if(!missing.size)return null;
|
|
106
|
+
return coverageWarning(`Advisory discovery is incomplete for ${missing.size} package/version(s). Each requires OSV and another package advisory source.`,
|
|
107
|
+
{code:'package-advisory-coverage',count:missing.size,assessed,unassessed,
|
|
108
|
+
// No advisory source assessed any package: nothing reliable can be published.
|
|
109
|
+
fatal:assessed>0 && unassessed===assessed,items:[...missing].sort(([a],[b])=>a<b?-1:a>b?1:0).map(([,item])=>item)});
|
|
110
|
+
}
|
|
111
|
+
return {consulted,assess,publicDependencies};
|
|
112
|
+
}
|
|
113
|
+
// Publication policy. An incomplete scan still publishes its report, marked
|
|
114
|
+
// incomplete, with every gap listed. It is cancelled only when nothing reliable
|
|
115
|
+
// can be shown: no dependency inventory, or no advisory source assessed any
|
|
116
|
+
// package. --fail-on-incomplete restores the strict behaviour for the listed
|
|
117
|
+
// capabilities.
|
|
118
|
+
function warningCapability(w) {
|
|
119
|
+
if (w?.capability) return w.capability === 'sources' ? 'advisories' : w.capability;
|
|
120
|
+
return structure.has(w?.type) ? 'inventory' : 'advisories';
|
|
121
|
+
}
|
|
122
|
+
function publication(warnings,{inventoryCount=null,strict=[]}={}) {
|
|
123
|
+
const blockers=(warnings||[]).filter(isBlocking);
|
|
124
|
+
const required=new Set((strict||[]).map(c=>c==='sources'?'advisories':c));
|
|
125
|
+
const fatal=blockers.filter(w=>w.fatal===true);
|
|
126
|
+
const noInventory=inventoryCount===0 && blockers.some(w=>warningCapability(w)==='inventory');
|
|
127
|
+
const strictBlockers=required.size ? blockers.filter(w=>required.has(warningCapability(w))) : [];
|
|
128
|
+
const cancel=fatal.length>0 || noInventory || strictBlockers.length>0;
|
|
129
|
+
// The decisive gaps come first; the cancellation still names every other gap.
|
|
130
|
+
const decisive=fatal.length ? fatal : noInventory ? blockers.filter(w=>warningCapability(w)==='inventory') : strictBlockers;
|
|
131
|
+
return {blockers,cancel,incomplete:!cancel && blockers.length>0,
|
|
132
|
+
reasons:cancel ? [...decisive,...blockers.filter(w=>!decisive.includes(w))] : []};
|
|
133
|
+
}
|
|
134
|
+
const LISTED_ITEMS=20;
|
|
135
|
+
function describe(warnings,lang) {
|
|
136
|
+
const lines=[];
|
|
137
|
+
for(const warning of warnings){
|
|
138
|
+
lines.push(warning.message);
|
|
139
|
+
const items=warning.items || [];
|
|
140
|
+
for(const item of items.slice(0,LISTED_ITEMS))lines.push(' '+(item.id || item)+(item.detail ? ' — '+item.detail : ''));
|
|
141
|
+
if(items.length>LISTED_ITEMS)lines.push(' '+(lang==='fr' ? `… et ${items.length-LISTED_ITEMS} autre(s), détaillé(s) dans le rapport` : `… and ${items.length-LISTED_ITEMS} more, listed in the report`));
|
|
142
|
+
}
|
|
143
|
+
return lines;
|
|
144
|
+
}
|
|
145
|
+
function incompleteNotice(blockers,lang) {
|
|
146
|
+
const n=blockers.length;
|
|
147
|
+
const head=lang==='fr'
|
|
148
|
+
? `Couverture incomplète : ${n} contrôle(s) non abouti(s). Le rapport est publié et marqué incomplet ; des vulnérabilités peuvent manquer. --fail-on-incomplete traite ce cas comme un échec.`
|
|
149
|
+
: `Coverage incomplete: ${n} check(s) could not be completed. The report is published and marked incomplete; vulnerabilities may be missing. Use --fail-on-incomplete to treat this as a failure.`;
|
|
150
|
+
return [...new Set([head,...describe(blockers,lang)])].join('\n');
|
|
151
|
+
}
|
|
152
|
+
function cancellation(warnings,lang) {
|
|
153
|
+
const fr=lang==='fr';
|
|
154
|
+
const lines=[fr ? 'Scan annulé. Aucun rapport publié.' : 'Scan cancelled. No report published.',...describe(warnings,lang)];
|
|
155
|
+
return [...new Set(lines)].join('\n');
|
|
156
|
+
}
|
|
157
|
+
module.exports={createDiscoveryCoverage,isBlocking,incompleteCheck,coverageWarning,cancellation,publication,incompleteNotice,warningCapability};
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* lib/source-health.js — is this report complete, and if not, which source went dark?
|
|
2
|
+
* lib/scan/source-health.js — is this report complete, and if not, which source went dark?
|
|
3
3
|
*
|
|
4
4
|
* An audit tool's worst output is a scan that ran to completion with a quiet hole in it.
|
|
5
|
-
* `lib/maven
|
|
5
|
+
* `lib/providers/maven/repo.js` already reasons this way for mirrors ("dropping Central would
|
|
6
6
|
* silently turn a transient blip into a coverage hole"), but only Maven mirrors were
|
|
7
7
|
* covered and nothing was ever reported. This generalises it to every remote source.
|
|
8
8
|
*
|
|
9
9
|
* The rule, ONLINE only:
|
|
10
10
|
* - a lookup served from the warm cache issues no request, so a source whose cache
|
|
11
11
|
* covers everything is silent even if the site is down. That is full coverage.
|
|
12
|
-
* - a request that gets no usable answer after the retry schedule is a hole. The
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* `--offline` never aborts: that mode's contract is already "warm cache only".
|
|
12
|
+
* - a request that gets no usable answer after the retry schedule is a hole. The scan reports incomplete coverage. A required discovery or structure failure returns exit 2
|
|
13
|
+
* before publishing reports.
|
|
14
|
+
* Offline scans use cached evidence and apply the same required coverage checks.
|
|
16
15
|
*
|
|
17
16
|
* The retry schedule applies ONLY to single-endpoint sources. A request carrying an
|
|
18
17
|
* AbortSignal comes from a caller with its own deadline and its own failover across
|
|
19
18
|
* mirrors/registries, so it is passed straight through.
|
|
20
19
|
*
|
|
21
20
|
* A definitive 404/410 is an ANSWER, not an outage — it is precisely how private and
|
|
22
|
-
* internal packages are detected (lib/private-deps.js). Only 403/429/5xx and transport
|
|
21
|
+
* internal packages are detected (lib/inventory/private-deps.js). Only 403/429/5xx and transport
|
|
23
22
|
* failures count against a host.
|
|
24
23
|
*
|
|
25
24
|
* @author: N.BRAUN
|
|
@@ -28,9 +27,11 @@
|
|
|
28
27
|
|
|
29
28
|
/** Remote sources, by id. `hosts` are matched as exact host or dot-suffix. */
|
|
30
29
|
const SOURCES = {
|
|
30
|
+
mavenGoogle: {label:'Google Maven (Android)',flag:'check Google Maven availability',hosts:['dl.google.com','maven.google.com']},
|
|
31
31
|
githubApi: { label: "GitHub publisher advisories", flag: "--prestashop-advisories <file> / --typo3-advisories <file>", hosts: ["api.github.com"] },
|
|
32
32
|
cve: { label: "CVE index (CVEProject)", flag: "--cve-offline", hosts: ["github.com", "raw.githubusercontent.com", "objects.githubusercontent.com", "codeload.github.com"] },
|
|
33
33
|
wordfence: { label: "Wordfence", flag: "--wordfence-feed <file>", hosts: ["wordfence.com"] },
|
|
34
|
+
wpvulnerability: { label: "WPVulnerability", flag: "check public advisory source availability", hosts: ["wpvulnerability.net"] },
|
|
34
35
|
wordpress: { label: "WordPress checksums", flag: "--wp-checksums <file>", hosts: ["api.wordpress.org"] },
|
|
35
36
|
drupalAdvisories: { label: "Drupal advisories", flag: "--drupal-advisories <file>", hosts: ["packages.drupal.org"] },
|
|
36
37
|
osv: { label: "OSV.dev", flag: "--no-osv", hosts: ["api.osv.dev", "osv-vulnerabilities.storage.googleapis.com"] },
|
|
@@ -54,6 +55,8 @@ const SOURCES = {
|
|
|
54
55
|
const RETRY_ATTEMPTS = 5;
|
|
55
56
|
// Internal request metadata, consumed by guardedFetch and never sent as a header.
|
|
56
57
|
const REQUEST_KEY = Symbol('source-health-request-key');
|
|
58
|
+
const ATTEMPT_TIMEOUT = Symbol('per-attempt-timeout');
|
|
59
|
+
const REQUEST_SOURCE = Symbol('source-for-request');
|
|
57
60
|
let retryAttempts = RETRY_ATTEMPTS;
|
|
58
61
|
|
|
59
62
|
/**
|
|
@@ -113,7 +116,7 @@ function errCode(res, err) {
|
|
|
113
116
|
const m = /\b(E[A-Z]{3,}|ENOTFOUND|ECONNREFUSED|ETIMEDOUT|UND_ERR_[A-Z_]+)\b/.exec(err.message || "");
|
|
114
117
|
return m ? m[1] : (err.message || "network error").slice(0, 60);
|
|
115
118
|
}
|
|
116
|
-
return res?.headers?.get?.('x-fad-proxy') ? require('
|
|
119
|
+
return res?.headers?.get?.('x-fad-proxy') ? require('../providers/request-failure').responseFailure(res).reason : `HTTP ${res?.status ?? "?"}`;
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
/** Per-run ledger of sources that went dark. */
|
|
@@ -209,6 +212,11 @@ function guardedFetch({ health, fetch: baseFetch = globalThis.fetch, sleep = ms
|
|
|
209
212
|
// to hit an outage owns the loop; the rest await its verdict instead of each sleeping
|
|
210
213
|
// 40s of their own — on a 400-dependency reactor that difference is the whole run.
|
|
211
214
|
const probes = new Map();
|
|
215
|
+
function send(url, init) {
|
|
216
|
+
if (!init?.[ATTEMPT_TIMEOUT]) return baseFetch(url, init);
|
|
217
|
+
const { [ATTEMPT_TIMEOUT]: ms, ...rest } = init;
|
|
218
|
+
return baseFetch(url, { ...rest, signal: AbortSignal.timeout(ms) });
|
|
219
|
+
}
|
|
212
220
|
|
|
213
221
|
/**
|
|
214
222
|
* Run the retry schedule for `src`, starting from the failure the caller already saw
|
|
@@ -217,37 +225,49 @@ function guardedFetch({ health, fetch: baseFetch = globalThis.fetch, sleep = ms
|
|
|
217
225
|
*/
|
|
218
226
|
async function recover(src, url, init, first, key) {
|
|
219
227
|
let res = first.res, err = first.err;
|
|
228
|
+
let remainingMs = Math.max(120000, delays.reduce((sum, delay) => sum + delay, 0));
|
|
220
229
|
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
221
|
-
|
|
222
|
-
|
|
230
|
+
const retryAfter = res && [429, 503].includes(res.status) ? require('../providers/request-failure').responseFailure(res).retryAfterSeconds : 0;
|
|
231
|
+
const delayMs = Math.max(delays[attempt], (retryAfter || 0) * 1000);
|
|
232
|
+
const event = { source: src.id, label: src.label, attempt: attempt + 1, of: attempts, code: errCode(res, err), delayMs, url: String(url) };
|
|
233
|
+
if (delayMs > remainingMs) {
|
|
234
|
+
onRetry?.({ ...event, exhausted: true });
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
onRetry?.(event);
|
|
238
|
+
remainingMs -= delayMs;
|
|
239
|
+
if (res?.body && !res.body.locked) void res.body.cancel().catch(() => {});
|
|
240
|
+
await sleep(delayMs);
|
|
223
241
|
res = null; err = null;
|
|
224
|
-
try { res = await
|
|
242
|
+
try { res = await send(url, init); }
|
|
225
243
|
catch (e) { err = e; }
|
|
226
244
|
if (classifyResponse(res, err) === "answered") return { alive: true, res };
|
|
245
|
+
if (handledRateLimit && (res?.status === 429 || res?.status === 503 && res.headers?.get?.("x-fad-proxy") === "denied")) break;
|
|
227
246
|
}
|
|
228
247
|
health.markOutage(src.id, { url: String(url), code: errCode(res, err), requestKey:key });
|
|
229
|
-
return { alive: false };
|
|
248
|
+
return { alive: false, res, err };
|
|
230
249
|
}
|
|
231
250
|
|
|
232
251
|
return async function guarded(url, init) {
|
|
233
252
|
const key = init?.[REQUEST_KEY] || requestKey;
|
|
234
253
|
if (init && Object.hasOwn(init, REQUEST_KEY)) { init = { ...init }; delete init[REQUEST_KEY]; }
|
|
235
|
-
const src = sourceForUrl(
|
|
254
|
+
const src = init?.[REQUEST_SOURCE] || sourceForUrl(url?.url || url);
|
|
255
|
+
if (init?.[REQUEST_SOURCE]) { init = { ...init }; delete init[REQUEST_SOURCE]; }
|
|
236
256
|
if (!src) return baseFetch(url, init);
|
|
237
257
|
// A caller that supplied an AbortSignal owns the deadline — and in fad every such
|
|
238
|
-
// caller (lib/maven
|
|
258
|
+
// caller (lib/providers/maven/repo.js across mirrors, lib/providers/registries.js and the npm registry
|
|
239
259
|
// across bases) also owns a FAILOVER to the next host. Retrying inside that budget
|
|
240
260
|
// is futile once the signal has fired, and costs 40s of backoff per dead mirror
|
|
241
261
|
// where the caller would have moved on immediately. Hand the outcome straight back
|
|
242
262
|
// and let the rotation do its job; exhaustion is reported by the caller, not here.
|
|
243
|
-
if (init && init
|
|
263
|
+
if (init?.signal && !init[ATTEMPT_TIMEOUT]) return baseFetch(url, init);
|
|
244
264
|
if (health.isDown(src.id)) {
|
|
245
265
|
const original = health.degraded().find(e => e.id === src.id)?.codes?.[0];
|
|
246
266
|
health.markOutage(src.id, { url: String(url), code: 'source already unreachable', requestKey:key });
|
|
247
267
|
throw new Error(`${src.label} already unreachable this run${original ? ` (${original})` : ''} (${src.flag} to scan without it)`);
|
|
248
268
|
}
|
|
249
269
|
let res = null, err = null;
|
|
250
|
-
try { res = await
|
|
270
|
+
try { res = await send(url, init); }
|
|
251
271
|
catch (e) { err = e; }
|
|
252
272
|
if (classifyResponse(res, err) === "answered") return res;
|
|
253
273
|
if (handledRateLimit && res && (res.status === 429 || res.status === 503 && res.headers?.get?.('x-fad-proxy') === 'denied')) {
|
|
@@ -263,7 +283,11 @@ function guardedFetch({ health, fetch: baseFetch = globalThis.fetch, sleep = ms
|
|
|
263
283
|
}
|
|
264
284
|
const verdict = await probe;
|
|
265
285
|
if (!verdict.alive) {
|
|
266
|
-
if (
|
|
286
|
+
if (owner) {
|
|
287
|
+
if (verdict.err) throw verdict.err;
|
|
288
|
+
return verdict.res;
|
|
289
|
+
}
|
|
290
|
+
health.markOutage(src.id, {url:String(url),code:errCode(res,err),requestKey:key});
|
|
267
291
|
if (err) throw err;
|
|
268
292
|
return res;
|
|
269
293
|
}
|
|
@@ -273,7 +297,7 @@ function guardedFetch({ health, fetch: baseFetch = globalThis.fetch, sleep = ms
|
|
|
273
297
|
// the host is up but this lookup is genuinely holed — record it rather than return a
|
|
274
298
|
// silent gap.
|
|
275
299
|
let r2 = null, e2 = null;
|
|
276
|
-
try { r2 = await
|
|
300
|
+
try { r2 = await send(url, init); }
|
|
277
301
|
catch (e) { e2 = e; }
|
|
278
302
|
if (classifyResponse(r2, e2) !== "answered") {
|
|
279
303
|
health.markOutage(src.id, { url: String(url), code: errCode(r2, e2), requestKey:key });
|
|
@@ -284,7 +308,7 @@ function guardedFetch({ health, fetch: baseFetch = globalThis.fetch, sleep = ms
|
|
|
284
308
|
}
|
|
285
309
|
|
|
286
310
|
/**
|
|
287
|
-
* Classify one fan-out miss, as lib/maven
|
|
311
|
+
* Classify one fan-out miss, as lib/providers/maven/repo.js and lib/providers/registries.js phrase it to their
|
|
288
312
|
* `onMiss` hook: "HTTP <status>" or "network: <message>". A 404 (and an auth wall) is a
|
|
289
313
|
* host that ANSWERED; only throttling, server errors and transport failures are not.
|
|
290
314
|
*/
|
|
@@ -310,8 +334,16 @@ function noteFanoutExhausted(url, reasons, { requestKey } = {}) {
|
|
|
310
334
|
activeLedger.markOutage(src.id, { url: String(url), code: String(list[0] || "no answer"), requestKey });
|
|
311
335
|
}
|
|
312
336
|
|
|
337
|
+
function displaySourceRetry(r) {
|
|
338
|
+
const wait = `${Math.ceil(r.delayMs / 1000)}s`;
|
|
339
|
+
const action = r.exhausted ? `retry wait of ${wait} exceeds the remaining budget`
|
|
340
|
+
: `attempt ${r.attempt}/${r.of}, retrying in ${wait}`;
|
|
341
|
+
require("../ui").networkNotice(`${r.label} — ${r.code}, ${action}`);
|
|
342
|
+
}
|
|
343
|
+
|
|
313
344
|
module.exports = {
|
|
314
|
-
|
|
345
|
+
displaySourceRetry,
|
|
346
|
+
SOURCES, sourceForUrl, classifyResponse, errCode, REQUEST_KEY, ATTEMPT_TIMEOUT, REQUEST_SOURCE,
|
|
315
347
|
RETRY_ATTEMPTS, retryDelaysMs, setRetryAttempts, getRetryAttempts, describeSchedule,
|
|
316
348
|
createSourceHealth, formatAbort, guardedFetch,
|
|
317
349
|
classifyMissReason, noteFanoutExhausted, setActiveLedger,
|
|
@@ -25,7 +25,7 @@ function applySourceProfile(options, {explicit = () => false} = {}) {
|
|
|
25
25
|
out.distributionSourceRegion = profile; // Each adapter declares its operator independently.
|
|
26
26
|
out.publisherSourceRegion = profile;
|
|
27
27
|
if (profile === 'eu') {
|
|
28
|
-
Object.assign(out, {osv:false, osvDb:false, nvd:false, epss:false, kev:false, retire:false, nvdCpeMatch:false});
|
|
28
|
+
Object.assign(out, {osv:false, osvDb:false, nvd:false, epss:false, kev:false, retire:false, nvdCpeMatch:false, rubyAdvisories:false});
|
|
29
29
|
out.disableCveProject = true;
|
|
30
30
|
} else {
|
|
31
31
|
Object.assign(out, {euvd:false, certfr:false, packagistAudit:false});
|
|
@@ -43,7 +43,7 @@ function applySourceProfile(options, {explicit = () => false} = {}) {
|
|
|
43
43
|
|
|
44
44
|
/** Network transport guard: provider bypasses and unrecognised redirects fail closed. */
|
|
45
45
|
function proxyOnlyFetch(fetcher, proxyUrl) {
|
|
46
|
-
const { proxyOrigin } = require('
|
|
46
|
+
const { proxyOrigin } = require('../cache/proxy-scope');
|
|
47
47
|
const origin = proxyOrigin(proxyUrl);
|
|
48
48
|
return (input, init = {}) => {
|
|
49
49
|
let url;
|
|
@@ -56,7 +56,7 @@ function proxyOnlyFetch(fetcher, proxyUrl) {
|
|
|
56
56
|
|
|
57
57
|
/** Dedicated transport used only by the official account client while issuing a key. */
|
|
58
58
|
function officialAccountFetch(fetcher) {
|
|
59
|
-
const {ACCOUNT_ORIGIN} = require('
|
|
59
|
+
const {ACCOUNT_ORIGIN} = require('../service/account-client');
|
|
60
60
|
const methods = new Map([['/v1/accounts/me','GET'],['/v1/accounts/login','POST'],['/v1/accounts/logout','POST'],['/v1/accounts/terms','POST'],['/v1/accounts/proxy-keys','POST']]);
|
|
61
61
|
return (input, init = {}) => {
|
|
62
62
|
let url; try { url = new URL(typeof input === 'string' || input instanceof URL ? String(input) : input.url); }
|
|
@@ -35,11 +35,11 @@ async function createProxyKey(account) {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
async function checkHostedProxy(url, token, fetcher = globalThis.fetch) {
|
|
38
|
+
async function checkHostedProxy(url, token, fetcher = globalThis.fetch, {waitBudgetMs, throttle = require('../providers/proxy-throttle').createProxyThrottle()} = {}) {
|
|
39
39
|
let response;
|
|
40
40
|
try {
|
|
41
|
-
response = await fetcher(url + "/v1/proxy/status", { headers: { authorization: "Bearer " + token, "x-vigievuln-client-version": require('
|
|
42
|
-
redirect: "error", signal: AbortSignal.timeout(15000) });
|
|
41
|
+
response = await throttle.request(() => fetcher(url + "/v1/proxy/status", { headers: { authorization: "Bearer " + token, "x-vigievuln-client-version": require('../../package.json').version },
|
|
42
|
+
redirect: "error", signal: AbortSignal.timeout(15000) }), null, {label:"proxy.status", waitBudgetMs});
|
|
43
43
|
} catch { throw new Error("VigieVuln proxy is unreachable; check your connection and proxy endpoint"); }
|
|
44
44
|
try {
|
|
45
45
|
if (response.status === 401 || response.status === 403) throw new Error("VigieVuln proxy key is invalid, expired or revoked; create a key from your verified account");
|
|
@@ -39,7 +39,7 @@ function sanitizeDescriptor(input) {
|
|
|
39
39
|
if (!d || !SIMPLE.test(d.ecosystem || "") || !SIMPLE.test(d.ecosystemType || "") ||
|
|
40
40
|
name === null || namespace === null ||
|
|
41
41
|
!["direct","transitive","unknown"].includes(d.relation) || !SIMPLE.test(d.scope || "")) throw new Error(`invalid dependency ${i}`);
|
|
42
|
-
const version = d.version == null ? null : require("
|
|
42
|
+
const version = d.version == null ? null : require("../inventory/deps-descriptor").cleanVersion(d.version);
|
|
43
43
|
if (d.version != null && !version) throw new Error(`invalid version for dependency ${i}`);
|
|
44
44
|
if (d.versions !== undefined && (!Array.isArray(d.versions) || d.versions.length !== (version ? 1 : 0) || (version && d.versions[0] !== version)))
|
|
45
45
|
throw new Error(`ambiguous versions for dependency ${i}`);
|
|
@@ -49,6 +49,22 @@ function sanitizeDescriptor(input) {
|
|
|
49
49
|
const out={schema:"fad-deps/2",generator:"vigievuln",deps};
|
|
50
50
|
return out;
|
|
51
51
|
}
|
|
52
|
+
// The refusal text of a JSON error body, bounded and reduced to printable characters:
|
|
53
|
+
// it is shown in a terminal and comes from the network.
|
|
54
|
+
async function refusalReason(response) {
|
|
55
|
+
try {
|
|
56
|
+
if (!/^application\/json(?:\s*;|$)/i.test(response.headers.get('content-type') || '') || !response.body) return '';
|
|
57
|
+
const reader = response.body.getReader(), chunks = [];
|
|
58
|
+
let size = 0;
|
|
59
|
+
try {
|
|
60
|
+
while (size <= 4096) { const {value, done} = await reader.read(); if (done) break; size += value.byteLength; chunks.push(Buffer.from(value)); }
|
|
61
|
+
} finally { void reader.cancel().catch(() => {}); }
|
|
62
|
+
if (size > 4096) return '';
|
|
63
|
+
const data = JSON.parse(new TextDecoder('utf-8', {fatal:true}).decode(Buffer.concat(chunks)));
|
|
64
|
+
const text = typeof data?.error === 'string' ? data.error.replace(/[^\x20-\x7e]/g, ' ').replace(/\s+/g, ' ').trim() : '';
|
|
65
|
+
return text.length > 200 ? text.slice(0, 199) + '…' : text;
|
|
66
|
+
} catch { return ''; }
|
|
67
|
+
}
|
|
52
68
|
async function projectRequest(path, {session, method="GET", body, fetcher=globalThis.fetch, timeoutMs=15000} = {}) {
|
|
53
69
|
if (typeof session !== "string" || !/^[A-Za-z0-9_-]{1,200}$/.test(session)) throw new Error("an account session is required");
|
|
54
70
|
if (!/^\/v1\/projects(?:\/[0-9a-f-]+)?$/i.test(path)) throw new Error("invalid project endpoint");
|
|
@@ -77,7 +93,9 @@ async function projectRequest(path, {session, method="GET", body, fetcher=global
|
|
|
77
93
|
}
|
|
78
94
|
if (!response.ok) {
|
|
79
95
|
const code = ({401:'UNAUTHORIZED',403:'FORBIDDEN',409:'REVISION_CONFLICT',429:'RATE_LIMITED'})[response.status] || 'HTTP_ERROR';
|
|
80
|
-
|
|
96
|
+
// The service says why it refused (quota, schema, revision): a bare status left the user guessing.
|
|
97
|
+
const reason = await refusalReason(response);
|
|
98
|
+
throw new ProjectClientError(code, `project request failed (HTTP ${response.status})${reason ? ': ' + reason : ''}`, response.status);
|
|
81
99
|
}
|
|
82
100
|
if (!/^application\/json(?:\s*;|$)/i.test(response.headers.get('content-type') || '') || !response.body) throw invalid();
|
|
83
101
|
if (Number(response.headers.get('content-length')) > MAX_RESPONSE_BYTES) throw tooLarge();
|