vigievuln 1.3.3 → 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 +57 -0
- package/README.md +34 -19
- package/completions/vigievuln.bash +14 -3
- package/completions/vigievuln.zsh +11 -8
- 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 +11 -2
- 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/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 +5 -4
- package/lib/artifacts/index.js +36 -13
- package/lib/artifacts/inventory-scope.js +53 -3
- package/lib/artifacts/product-advisories.js +51 -46
- package/lib/artifacts/product-catalog.js +6 -1
- 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 +15 -2
- package/lib/artifacts/report-path.js +29 -0
- package/lib/artifacts/report.js +66 -36
- 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 +295 -67
- 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 +20 -14
- 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 -6
- 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 +157 -46
- 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/scan.js +11 -3
- 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} +3 -3
- 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
|
@@ -5,8 +5,8 @@ const {parseCpe23,matchVersionRange,loadCpeCoordMap}=require('./cpe');
|
|
|
5
5
|
// Reuse the native normalizer and version evaluator, including exclusions,
|
|
6
6
|
// version changes, platform restrictions and disagreement between providers.
|
|
7
7
|
function projectNvdAffected(record) {
|
|
8
|
-
const {extractAffectedRanges}=require('
|
|
9
|
-
const {normalizeLegacySplitRanges}=require('
|
|
8
|
+
const {extractAffectedRanges}=require('../cveproject/download');
|
|
9
|
+
const {normalizeLegacySplitRanges}=require('../cveproject/legacy-ranges');
|
|
10
10
|
if(!record || !/^CVE-\d{4}-\d+$/.test(record.id || '') || /^rejected$/i.test(record.vulnStatus || ''))return null;
|
|
11
11
|
const affected=[];
|
|
12
12
|
for(const group of Array.isArray(record.affected) ? record.affected : []) {
|
|
@@ -18,8 +18,8 @@ function projectNvdAffected(record) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function matchNvdAffected(deps,matches,opts={}) {
|
|
21
|
-
const {newIndex,addToIndex}=require('
|
|
22
|
-
const {matchDepsAgainstCves}=require('
|
|
21
|
+
const {newIndex,addToIndex}=require('../cveproject/download');
|
|
22
|
+
const {matchDepsAgainstCves}=require('../../advisories/cve-match');
|
|
23
23
|
const index=newIndex(),seen=new Set(),records=new Map();
|
|
24
24
|
for(const m of matches) {
|
|
25
25
|
const c=m.cve;
|
|
@@ -38,8 +38,25 @@ function matchNvdAffected(deps,matches,opts={}) {
|
|
|
38
38
|
// OSV documents independently of whether their ranges match this scan's version.
|
|
39
39
|
// This allows an older release scanned alone to reuse the same NVD evidence as
|
|
40
40
|
// it would in a reactor containing a newer release of that package.
|
|
41
|
-
function collectPackageNvdBindings(deps,store) {
|
|
41
|
+
function collectPackageNvdBindings(deps,store,findings=[]) {
|
|
42
42
|
const out=[],seen=new Set();
|
|
43
|
+
// A second record for an already established CVE on every installed version
|
|
44
|
+
// is enrichment. A missing record may affect discovery on another version.
|
|
45
|
+
const found=new Map(),installed=new Map();
|
|
46
|
+
for(const dep of deps.values()){
|
|
47
|
+
if(dep.ecosystem!=='maven'||dep.provenance==='binary')continue;
|
|
48
|
+
const coord=`${dep.groupId}:${dep.artifactId}`;
|
|
49
|
+
if(!installed.has(coord))installed.set(coord,new Set());
|
|
50
|
+
for(const version of dep.versions?.length?dep.versions:[dep.version])installed.get(coord).add(version);
|
|
51
|
+
}
|
|
52
|
+
for(const {dep,cve,cpeFiltered} of findings){
|
|
53
|
+
if(cpeFiltered || dep?.ecosystem!=='maven' || !dep.version)continue;
|
|
54
|
+
const ids=new Set([cve?.id,...cve?.aliases||[]].filter(id=>/^CVE-\d{4}-\d+$/.test(id)));
|
|
55
|
+
if(ids.size!==1)continue;
|
|
56
|
+
const key=JSON.stringify([dep.groupId+':'+dep.artifactId,[...ids][0]]);
|
|
57
|
+
if(!found.has(key))found.set(key,new Set());
|
|
58
|
+
found.get(key).add(dep.version);
|
|
59
|
+
}
|
|
43
60
|
for(const dep of deps.values()) {
|
|
44
61
|
if(dep.ecosystem!=='maven' || dep.provenance==='binary')continue;
|
|
45
62
|
const coord=`${dep.groupId}:${dep.artifactId}`;
|
|
@@ -57,6 +74,8 @@ function collectPackageNvdBindings(deps,store) {
|
|
|
57
74
|
// affected entry. Do not manufacture a package binding for every alias.
|
|
58
75
|
if(cves.length!==1 || ids.has(cves[0]))continue;
|
|
59
76
|
ids.add(cves[0]);
|
|
77
|
+
const confirmed=found.get(JSON.stringify([coord,cves[0]]));
|
|
78
|
+
if(confirmed && [...installed.get(coord)].every(version=>confirmed.has(version)))continue;
|
|
60
79
|
out.push({dep,source:'osv',bindingOnly:true,cve:{id:cves[0]}});
|
|
61
80
|
}
|
|
62
81
|
}
|
|
@@ -68,37 +87,34 @@ function collectPackageNvdBindings(deps,store) {
|
|
|
68
87
|
// framework products, runtime constraints and negated configurations do not qualify.
|
|
69
88
|
function matchBoundNvdRanges(deps,matches,map=loadCpeCoordMap()) {
|
|
70
89
|
const out=[],seen=new Set(matches.filter(m=>!m.bindingOnly).flatMap(m=>[m.cve?.id,...m.cve?.aliases||[]].filter(Boolean).map(id=>`${m.dep?.coordKey}|${m.dep?.version}|${id}`)));
|
|
71
|
-
function leaves(node) {
|
|
72
|
-
if(!node || node.negate || (node.operator && node.operator!=='OR'))return [];
|
|
73
|
-
return [...(node.cpeMatch||[]),...(node.nodes||node.children||[]).flatMap(leaves)];
|
|
74
|
-
}
|
|
75
90
|
for(const match of matches) {
|
|
76
91
|
if(match.suppressed || match.cpeFiltered || !(match.source||'').split('+').includes('osv'))continue;
|
|
77
92
|
const {dep,cve}=match;
|
|
78
93
|
if(dep?.ecosystem!=='maven' || !/^CVE-\d{4}-\d+$/.test(cve?.id||''))continue;
|
|
79
94
|
const coord=`${dep.groupId}:${dep.artifactId}`;
|
|
80
|
-
const
|
|
81
|
-
const c=parseCpe23(
|
|
82
|
-
if(
|
|
95
|
+
const isProduct = leaf => {
|
|
96
|
+
const c=parseCpe23(leaf.criteria||leaf.cpe23Uri);
|
|
97
|
+
if(!c || c.part!=='a' || c.product!==dep.artifactId)return false;
|
|
83
98
|
const mapping=map.byVendorProduct?.[`${c.vendor}:${c.product}`];
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const fields=(r.criteria||r.cpe23Uri).split(':');
|
|
87
|
-
if(fields.length!==13 || fields.slice(6).some(x=>x!=='*'))return false;
|
|
88
|
-
if(['versionStartIncluding','versionStartExcluding','versionEndIncluding','versionEndExcluding'].some(k=>r[k]!=null && !/^[0-9][A-Za-z0-9._+-]*$/.test(r[k])))return false;
|
|
89
|
-
return true;
|
|
90
|
-
});
|
|
91
|
-
if(!ranges.length)continue;
|
|
99
|
+
return mapping?.length===1 && mapping[0]===coord;
|
|
100
|
+
};
|
|
92
101
|
for(const d of deps.values()) {
|
|
93
102
|
if(d.ecosystem!=='maven' || `${d.groupId}:${d.artifactId}`!==coord || d.provenance==='binary')continue;
|
|
94
103
|
for(const version of d.versions?.length?d.versions:[d.version]) {
|
|
95
104
|
if(typeof version!=='string' || !/^[0-9][A-Za-z0-9._+-]*$/.test(version))continue;
|
|
96
105
|
const key=`${d.coordKey}|${version}|${cve.id}`;
|
|
97
|
-
if(seen.has(key)
|
|
106
|
+
if(seen.has(key))continue;
|
|
107
|
+
const affected=require('./cpe').evaluateProductConfiguration({nodes:cve.configurations||[]},isProduct,leaf=>{
|
|
108
|
+
const fields=(leaf.criteria||leaf.cpe23Uri).split(':');
|
|
109
|
+
if(fields.length!==13 || !['*','-'].includes(fields[6]) ||
|
|
110
|
+
['versionStartIncluding','versionStartExcluding','versionEndIncluding','versionEndExcluding'].some(k=>leaf[k]!=null && !/^[0-9][A-Za-z0-9._+-]*$/.test(leaf[k])))return null;
|
|
111
|
+
return matchVersionRange(version,leaf);
|
|
112
|
+
});
|
|
113
|
+
if(affected!==true)continue;
|
|
98
114
|
seen.add(key);
|
|
99
115
|
out.push({dep:{...d,version},confidence:'exact',source:'nvd',cve:{
|
|
100
116
|
id:cve.id,description:cve.description,severity:cve.severity,score:cve.score,
|
|
101
|
-
configurations:cve.configurations,fixVersion:null,fixEvaluation:'unknown',
|
|
117
|
+
sourceAdvisoryId:cve.id,nvdRecordEvidence:cve.nvdRecordEvidence,configurations:cve.configurations,fixVersion:null,fixEvaluation:'unknown',
|
|
102
118
|
identityEvidence:'OSV package binding and unique artifact CPE'
|
|
103
119
|
}});
|
|
104
120
|
}
|
|
@@ -9,10 +9,10 @@ const fs = require("fs");
|
|
|
9
9
|
const path = require("path");
|
|
10
10
|
const os = require("os");
|
|
11
11
|
const { unzipSync } = require("fflate");
|
|
12
|
-
const { compareMavenVersions } = require("
|
|
13
|
-
const { vulnToMatch } = require("./
|
|
12
|
+
const { compareMavenVersions } = require("../../codecs/maven/version");
|
|
13
|
+
const { vulnToMatch } = require("./query");
|
|
14
14
|
|
|
15
|
-
const OSV_DB_DIR = path.join(require("
|
|
15
|
+
const OSV_DB_DIR = path.join(require("../../cache/directory").getCacheDir(), "osv-db");
|
|
16
16
|
const BUCKET = "https://osv-vulnerabilities.storage.googleapis.com";
|
|
17
17
|
const TTL_MS = 4 * 3600 * 1000;
|
|
18
18
|
// OSV ecosystem export name per fad codec id. Maven only for now (version ordering).
|
|
@@ -97,14 +97,14 @@ async function ensureOsvDb(opts = {}) {
|
|
|
97
97
|
return index && index.ecosystem === ecoName && index.byPackage && typeof index.byPackage === 'object' && !Array.isArray(index.byPackage) && Number.isFinite(index._builtAt) && index._builtAt > 0 && index._builtAt <= Date.now() + 300000 ? index : null;
|
|
98
98
|
} catch { return null; } };
|
|
99
99
|
const loadBest = () => { const a = loadRecords(), b = loadAny(); return a && (!b || a._builtAt >= b._builtAt) ? a : b; };
|
|
100
|
-
const loadFresh = () => { const j = loadBest(); return j && require('
|
|
100
|
+
const loadFresh = () => { const j = loadBest(); return j && require('../../cache/policy').fresh(j._builtAt || 0, TTL_MS) ? j : null; };
|
|
101
101
|
|
|
102
102
|
if (offline) return loadBest();
|
|
103
103
|
if (!refresh) { const f = loadFresh(); if (f) return f; }
|
|
104
104
|
try {
|
|
105
105
|
// Large ZIP64 upstream exports need the server's streaming validator.
|
|
106
106
|
if (ecosystem !== 'maven') throw new Error(`direct OSV ${ecoName} import is not supported; import a verified seed`);
|
|
107
|
-
const res = await require("
|
|
107
|
+
const res = await require("..").getResource("osvdb", "ecosystem-archive", { ecosystem: ecoName },
|
|
108
108
|
{ fetcher, headers: { "User-Agent": "vigievuln-osv-db" } });
|
|
109
109
|
if (!res || !res.ok) { if (verbose) console.warn(`osv-db: HTTP ${res?.status}`); return loadBest(); }
|
|
110
110
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
@@ -192,12 +192,13 @@ function compareSemver(a, b) {
|
|
|
192
192
|
|
|
193
193
|
// Three-valued evaluator: unsupported semantics and malformed versions are
|
|
194
194
|
// unknown, not clean. GIT ranges need a commit graph and are never guessed.
|
|
195
|
-
function rangeVerdict(version, range, ecosystem) {
|
|
195
|
+
function rangeVerdict(version, range, ecosystem, compareVersion) {
|
|
196
196
|
if (!range || !['SEMVER', 'ECOSYSTEM'].includes(range.type) || !Array.isArray(range.events) || !range.events.length) return null;
|
|
197
197
|
let cmp;
|
|
198
198
|
if (range.type === 'SEMVER' || ['npm', 'Go'].includes(ecosystem)) cmp = compareSemver;
|
|
199
|
+
else if (compareVersion) cmp = compareVersion;
|
|
199
200
|
else if (ecosystem === 'Maven') cmp = safeMavenCompare;
|
|
200
|
-
else if (ecosystem === 'RubyGems') cmp = require('
|
|
201
|
+
else if (ecosystem === 'RubyGems') cmp = require('../../codecs/ruby/version').compareRubyVersions;
|
|
201
202
|
else return null;
|
|
202
203
|
const v = String(version);
|
|
203
204
|
// Validate version itself even for an open range introduced at 0.
|
|
@@ -237,9 +238,9 @@ function vulnVerdict(version, vuln, ecosystem, opts = {}) {
|
|
|
237
238
|
// external OSV documents cannot change OSV's version-list semantics.
|
|
238
239
|
const partial = opts.source === 'vigievuln' && a.database_specific?.vigievuln_partial_versions === true;
|
|
239
240
|
if (partial) {
|
|
240
|
-
const tested = vulnVerdict(version, {affected:[{versions, ranges:a.ranges || []}]}, ecosystem);
|
|
241
|
+
const tested = vulnVerdict(version, {affected:[{versions, ranges:a.ranges || []}]}, ecosystem, {compareVersion:opts.compareVersion});
|
|
241
242
|
const knownSafe = Array.isArray(a.database_specific.unaffected_versions)
|
|
242
|
-
? vulnVerdict(version, {affected:[{versions:a.database_specific.unaffected_versions}]}, ecosystem)
|
|
243
|
+
? vulnVerdict(version, {affected:[{versions:a.database_specific.unaffected_versions}]}, ecosystem, {compareVersion:opts.compareVersion})
|
|
243
244
|
: false;
|
|
244
245
|
if (tested === true && knownSafe === true) { unknown = true; continue; }
|
|
245
246
|
if (tested === true) return true;
|
|
@@ -257,21 +258,22 @@ function vulnVerdict(version, vuln, ecosystem, opts = {}) {
|
|
|
257
258
|
for (const candidate of versions) {
|
|
258
259
|
let comparison = null;
|
|
259
260
|
try {
|
|
260
|
-
if (
|
|
261
|
+
if (opts.compareVersion) comparison = opts.compareVersion(version,candidate);
|
|
262
|
+
else if (ecosystem === 'Maven') comparison = safeMavenCompare(String(version), String(candidate));
|
|
261
263
|
else if (['npm', 'Go'].includes(ecosystem)) comparison = compareSemver(version, candidate);
|
|
262
|
-
else if (ecosystem === 'RubyGems') comparison = require('
|
|
264
|
+
else if (ecosystem === 'RubyGems') comparison = require('../../codecs/ruby/version').compareRubyVersions(version, candidate);
|
|
263
265
|
} catch { /* unknown */ }
|
|
264
266
|
if (comparison === 0) return true;
|
|
265
267
|
if (comparison == null) unknown = true;
|
|
266
268
|
}
|
|
267
269
|
for (const r of (Array.isArray(a.ranges) ? a.ranges : [])) {
|
|
268
|
-
const verdict = rangeVerdict(version, r, ecosystem);
|
|
270
|
+
const verdict = rangeVerdict(version, r, ecosystem, opts.compareVersion);
|
|
269
271
|
if (verdict === true) return true;
|
|
270
272
|
if (verdict === null) unknown = true;
|
|
271
273
|
}
|
|
272
274
|
// Version spellings outside understood ecosystems can be equivalent even
|
|
273
275
|
// when the literal strings differ (e.g. PEP 440 1.0 and 1.0.0).
|
|
274
|
-
if (!(a.ranges || []).length && versions.length && !['Maven', 'npm', 'Go', 'RubyGems'].includes(ecosystem)) unknown = true;
|
|
276
|
+
if (!(a.ranges || []).length && versions.length && !opts.compareVersion && !['Maven', 'npm', 'Go', 'RubyGems'].includes(ecosystem)) unknown = true;
|
|
275
277
|
if (!(a.ranges || []).length && !versions.length) unknown = true;
|
|
276
278
|
}
|
|
277
279
|
return unknown ? null : false;
|
|
@@ -286,7 +288,7 @@ function matchOsvDbDeps(resolvedDeps, index, { onUnknown } = {}) {
|
|
|
286
288
|
const out = [];
|
|
287
289
|
const seen = new Set();
|
|
288
290
|
const ecoName = index.ecosystem || 'Maven'; // legacy Maven index has no schema
|
|
289
|
-
const { osvEcosystemFor, osvPkgName } = require('./
|
|
291
|
+
const { osvEcosystemFor, osvPkgName } = require('./query');
|
|
290
292
|
for (const dep of resolvedDeps.values()) {
|
|
291
293
|
if (!Object.hasOwn(ECO, dep.ecosystem === 'yarn' ? 'npm' : dep.ecosystem) || osvEcosystemFor(dep) !== ecoName) continue;
|
|
292
294
|
if (dep.provenance === "binary") continue;
|
|
@@ -321,7 +323,7 @@ function matchOsvDbDeps(resolvedDeps, index, { onUnknown } = {}) {
|
|
|
321
323
|
/** Stream seed records; do not publish partial matches if integrity fails. */
|
|
322
324
|
async function matchOsvDbRecords(resolvedDeps, index, { onUnknown } = {}) {
|
|
323
325
|
if (!index?.recordsFile || !ECO || !Object.values(ECO).includes(index.ecosystem)) throw new Error('invalid OSV seed');
|
|
324
|
-
const { osvEcosystemFor, osvPkgName } = require('./
|
|
326
|
+
const { osvEcosystemFor, osvPkgName } = require('./query');
|
|
325
327
|
const targets = new Map();
|
|
326
328
|
for (const dep of resolvedDeps.values()) {
|
|
327
329
|
if (!dep || !Object.hasOwn(ECO, dep.ecosystem === 'yarn' ? 'npm' : dep.ecosystem) || osvEcosystemFor(dep) !== index.ecosystem || dep.provenance === 'binary') continue;
|
|
@@ -332,7 +334,7 @@ async function matchOsvDbRecords(resolvedDeps, index, { onUnknown } = {}) {
|
|
|
332
334
|
}
|
|
333
335
|
const stream = fs.createReadStream(index.recordsFile), hash = require('crypto').createHash('sha256');
|
|
334
336
|
stream.on('data', chunk => hash.update(chunk));
|
|
335
|
-
const lines = require('
|
|
337
|
+
const lines = require('../../inventory/line-stream').readTextLines(stream);
|
|
336
338
|
const out = [], seen = new Set(), unknown = [], unknownKeys = new Set(); let count = 0;
|
|
337
339
|
try {
|
|
338
340
|
for await (const line of lines) {
|