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
package/lib/artifacts/scan.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
const fs = require('node:fs');
|
|
4
4
|
const path = require('node:path');
|
|
5
5
|
const crypto = require('node:crypto');
|
|
6
|
-
const { makeDepRecord } = require('../dep-record');
|
|
6
|
+
const { makeDepRecord } = require('../inventory/dep-record');
|
|
7
7
|
const {IMAGE_COMPONENT_SCOPE,imageComponentRole,imageComponentSource} = require('./component-scope');
|
|
8
8
|
const { openArtifact } = require('./index');
|
|
9
9
|
const { collectInstalledApplications } = require('./applications');
|
|
10
|
-
const { collectSystemInventory
|
|
10
|
+
const { collectSystemInventory } = require('../system-inventory/collect');
|
|
11
11
|
|
|
12
12
|
const SNAPSHOT_SCHEMA = 'vigievuln-artifact-inventory/1';
|
|
13
13
|
const sha = value => crypto.createHash('sha256').update(value).digest('hex');
|
|
@@ -22,11 +22,23 @@ function coverageRecords(values = [], targetId, capability) {
|
|
|
22
22
|
incomplete: 'partial', unknown: 'partial', missing: 'not-run', failed: 'failed', absent: 'not-applicable' })[value.status] || 'partial';
|
|
23
23
|
return { ...value, artifactTargetId: targetId, capability: value.capability || capability,
|
|
24
24
|
collector: value.collector || value.source || `${capability}-${index}`, execution,
|
|
25
|
-
result: value.result || (execution === 'not-applicable' ? 'not-applicable' :
|
|
25
|
+
result: value.result || (execution === 'not-applicable' ? 'not-applicable' :
|
|
26
|
+
execution === 'completed' && capability === 'inventory' ? 'inventoried' : 'indeterminate') };
|
|
26
27
|
});
|
|
27
28
|
}
|
|
29
|
+
// Strip the collected root from a path. On Windows what remains is written with forward
|
|
30
|
+
// slashes: an inventory names paths the same way wherever it was collected.
|
|
31
|
+
function relativeToRoot(value, root, sep, replacement = '') {
|
|
32
|
+
const native = root + sep, posix = root.replace(/\\/g, '/') + '/';
|
|
33
|
+
if (!value.includes(native) && !value.includes(posix)) return value;
|
|
34
|
+
const stripped = value.split(native).join(replacement).split(posix).join(replacement);
|
|
35
|
+
return sep === '\\' ? stripped.replace(/\\/g, '/') : stripped;
|
|
36
|
+
}
|
|
28
37
|
function portable(value, root, replacement = '') {
|
|
29
|
-
|
|
38
|
+
// For a live filesystem root, absolute evidence paths already refer to the
|
|
39
|
+
// target. Replacing "//" would corrupt URLs in package metadata.
|
|
40
|
+
if (root === path.parse(root).root) return value;
|
|
41
|
+
if (typeof value === 'string') return relativeToRoot(value, root, path.sep, replacement);
|
|
30
42
|
if (Array.isArray(value)) return value.map(v => portable(v, root, replacement));
|
|
31
43
|
if (value && typeof value === 'object') return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, portable(v, root, replacement)]));
|
|
32
44
|
return value;
|
|
@@ -65,7 +77,7 @@ async function inventoryTarget(target, options = {}) {
|
|
|
65
77
|
const packages = portable(system.packages, target.root).map(p => ({ ...p, ...(p.ownedPaths ? { ownedPaths: [...p.ownedPaths].sort() } : {}) })).sort(order);
|
|
66
78
|
const appDeps = portable([...applications.deps.values(), ...binaries.deps.values(), ...(imageJs?.deps || [])], target.root).sort(order);
|
|
67
79
|
const id = target.kind === 'rootfs' && target.metadata.format === 'directory'
|
|
68
|
-
? `rootfs-inventory:sha256:${sha(JSON.stringify({ distribution: system.distribution, packages, deps: appDeps }))}` : target.id;
|
|
80
|
+
? `rootfs-inventory:sha256:${sha(JSON.stringify({ systemSource:options.systemSource, distribution: system.distribution, packages, deps: appDeps }))}` : target.id;
|
|
69
81
|
const owners = new Map();
|
|
70
82
|
const pathKey = value => path.posix.normalize('/' + String(value || '').replace(/\\/g, '/').replace(/^\/+/, ''));
|
|
71
83
|
for (const pkg of packages) for (const ownedPath of pkg.ownedPaths || []) {
|
|
@@ -74,23 +86,23 @@ async function inventoryTarget(target, options = {}) {
|
|
|
74
86
|
// symlink: ownership of a link does not confer ownership of its destination.
|
|
75
87
|
try {
|
|
76
88
|
const root = fs.realpathSync(target.root), parent = fs.realpathSync(path.dirname(path.join(root, ownedPath.replace(/^\/+/, ''))));
|
|
77
|
-
if (parent === root || parent.startsWith(root + path.sep)) keys.add(pathKey(path.relative(root, path.join(parent, path.basename(ownedPath)))));
|
|
89
|
+
if (parent === root || parent.startsWith(root.endsWith(path.sep) ? root : root + path.sep)) keys.add(pathKey(path.relative(root, path.join(parent, path.basename(ownedPath)))));
|
|
78
90
|
} catch { /* Removed/unavailable owned paths do not create invented evidence. */ }
|
|
79
91
|
for (const key of keys) {
|
|
80
92
|
const list = owners.get(key) || [];
|
|
81
|
-
list.push({ name: pkg.name, version: pkg.version, manager: pkg.manager, evidencePath: pkg.manifestPath });
|
|
93
|
+
list.push({ name: pkg.name, version: pkg.version, manager: pkg.manager, ...(pkg.architecture && {architecture:pkg.architecture}), evidencePath: pkg.manifestPath });
|
|
82
94
|
owners.set(key, list);
|
|
83
95
|
}
|
|
84
96
|
}
|
|
85
97
|
const deps = [...packages.map(p => systemDep(p, id, system.distribution)), ...appDeps.map(d => {
|
|
86
98
|
const evidence = d.binaryEvidence?.binaryPath || d.installEvidence?.path || d.manifestPaths?.[0];
|
|
87
99
|
// A shared aggregate manifest does not prove that every package it names is OS-owned.
|
|
88
|
-
const aggregate = ['composer', 'composer-php', 'nuget'].includes(d.installEvidence?.source);
|
|
100
|
+
const aggregate = d.provenance === 'lockfile' || ['composer', 'composer-php', 'nuget'].includes(d.installEvidence?.source);
|
|
89
101
|
const owned = evidence && !aggregate ? owners.get(pathKey(evidence)) : null;
|
|
90
102
|
return qualify(owned?.length ? { ...d, osPackageOwners: owned } : d, id);
|
|
91
103
|
})];
|
|
92
104
|
require('./image-products').applyProductVersions(deps);
|
|
93
|
-
for(const dep of deps){dep.imageRole=imageComponentRole(dep);dep.imageSource=imageComponentSource(dep);dep.scope=dep.imageRole==='transitive'?'transitive':'runtime';}
|
|
105
|
+
for(const dep of deps){dep.imageRole=imageComponentRole(dep);dep.imageSource=imageComponentSource(dep);if(dep.provenance!=='lockfile')dep.scope=dep.imageRole==='transitive'?'transitive':'runtime';}
|
|
94
106
|
const warnings = portable(normalizeWarnings([...(system.warnings || []), ...applications.warnings, ...binaries.warnings, ...(imageJs?.warnings || []),
|
|
95
107
|
...(target.metadata.warnings || [])]), target.root);
|
|
96
108
|
const coverage = coverageRecords(system.coverage, id, 'inventory');
|
|
@@ -101,17 +113,18 @@ async function inventoryTarget(target, options = {}) {
|
|
|
101
113
|
}
|
|
102
114
|
if(imageJs)coverage.push({...imageJs.coverage,artifactTargetId:id});
|
|
103
115
|
coverage.push({ artifactTargetId: id, capability: 'inventory', collector: 'installed-applications',
|
|
104
|
-
execution: applications.
|
|
116
|
+
execution: applications.coverage.complete ? 'completed' : 'partial', result: applications.coverage.complete ? 'inventoried' : 'indeterminate', count: applications.deps.size });
|
|
105
117
|
coverage.push({ artifactTargetId: id, capability: 'inventory', collector: 'native-binaries',
|
|
106
|
-
execution: binaries.warnings.length ? 'partial' : 'completed', result: 'indeterminate', count: [...binaries.deps.values()].filter(d => d.ecosystem === 'binary').length });
|
|
118
|
+
execution: binaries.warnings.length ? 'partial' : 'completed', result: binaries.warnings.length ? 'indeterminate' : 'inventoried', count: [...binaries.deps.values()].filter(d => d.ecosystem === 'binary').length });
|
|
107
119
|
if (target.metadata.warnings?.length) coverage.push({ artifactTargetId: id, capability: 'inventory', collector: 'artifact-reader', execution: 'partial', result: 'indeterminate' });
|
|
108
|
-
const
|
|
120
|
+
const originalSource = target.metadata.source || target.root;
|
|
121
|
+
const source = options.source || path.basename(originalSource) || originalSource;
|
|
109
122
|
const acquisition = options.registry ? { kind: 'registry', reference: source } : {
|
|
110
|
-
kind: target.metadata.format === 'directory' ? 'rootfs-directory' : target.metadata.format === 'oci-layout' && target.metadata.source && fs.statSync(target.metadata.source).isDirectory() ? 'oci-layout' : 'archive', source,
|
|
123
|
+
kind: target.metadata.diskFormat ? 'vm-disk' : target.metadata.format === 'directory' ? 'rootfs-directory' : target.metadata.format === 'oci-layout' && target.metadata.source && fs.statSync(target.metadata.source).isDirectory() ? 'oci-layout' : 'archive', source,
|
|
111
124
|
};
|
|
112
125
|
return { id, kind: target.kind, metadata: { ...target.metadata, componentScope:IMAGE_COMPONENT_SCOPE, source, acquisition, definitions: [], definitionDiscovery: {status:'not-supplied'} },
|
|
113
126
|
evidence: 'content-inventory', inventoryAt: new Date().toISOString(), distribution: system.distribution,
|
|
114
|
-
packages, deps, coverage, warnings, componentCount: deps.length };
|
|
127
|
+
packages, deps, coverage, warnings: require('./access-warnings').foldAccessWarnings(warnings), componentCount: deps.length };
|
|
115
128
|
}
|
|
116
129
|
|
|
117
130
|
function sbomTarget(input, options = {}) {
|
|
@@ -143,6 +156,28 @@ function validateSnapshot(doc) {
|
|
|
143
156
|
for (const target of content.targets) {
|
|
144
157
|
if (!target || typeof target.id !== 'string' || !target.id || targetIds.has(target.id) || !target.metadata || !Array.isArray(target.deps) || !Array.isArray(target.packages) || !Array.isArray(target.coverage) || !Array.isArray(target.warnings)) throw Error('invalid or duplicate artifact inventory target');
|
|
145
158
|
targetIds.add(target.id);
|
|
159
|
+
const apps = target.metadata.systemApplications;
|
|
160
|
+
if (apps !== undefined) {
|
|
161
|
+
if (!Array.isArray(apps?.applications) || !Array.isArray(apps.inventory)) throw Error('invalid system application inventory');
|
|
162
|
+
const ids = new Set();
|
|
163
|
+
function checkApp(app) {
|
|
164
|
+
if (typeof app?.id !== 'string' || !app.id.startsWith(target.id + ':') || ids.has(app.id) ||
|
|
165
|
+
typeof app.root !== 'string' || !app.root || /[\\\x00]/.test(app.root) || app.root.startsWith('/') || app.root.split('/').includes('..'))
|
|
166
|
+
throw Error('invalid system application or root');
|
|
167
|
+
ids.add(app.id);
|
|
168
|
+
}
|
|
169
|
+
for (const app of apps.applications) checkApp(app);
|
|
170
|
+
const parents = new Set(ids);
|
|
171
|
+
if (apps.embeddedApplications !== undefined) {
|
|
172
|
+
if (!Array.isArray(apps.embeddedApplications)) throw Error('invalid embedded applications');
|
|
173
|
+
for (const entry of apps.embeddedApplications) {
|
|
174
|
+
checkApp(entry?.app);
|
|
175
|
+
if (!parents.has(entry.applicationId) || !Array.isArray(entry.inventory) ||
|
|
176
|
+
entry.inventory.some(c=>c?.applicationId!==entry.app.id)) throw Error('invalid embedded application owner');
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (apps.inventory.some(item => !parents.has(item?.applicationId))) throw Error('invalid system application component owner');
|
|
180
|
+
}
|
|
146
181
|
for (const dep of target.deps) {
|
|
147
182
|
if (typeof dep?.coordKey !== 'string' || !dep.coordKey || componentIds.has(dep.coordKey) || dep.artifactTargetId !== target.id || typeof dep.ecosystem !== 'string' || typeof dep.name !== 'string') throw Error('invalid or duplicate artifact inventory component');
|
|
148
183
|
componentIds.add(dep.coordKey);
|
|
@@ -155,21 +190,40 @@ function readSnapshot(file, options = {}) {
|
|
|
155
190
|
if (fs.statSync(file).size > (options.maxSnapshotBytes ?? 128 * 1024 * 1024)) throw Error('artifact inventory exceeds configured size limit');
|
|
156
191
|
return validateSnapshot(JSON.parse(fs.readFileSync(file, 'utf8'))).map(t => ({ ...require('./inventory-scope').applyComponentScope(t), evidence: 'cached-inventory', originalEvidence: t.originalEvidence || t.evidence }));
|
|
157
192
|
}
|
|
158
|
-
async function writeSnapshot(file, targets) {
|
|
193
|
+
async function writeSnapshot(file, targets, {compact = false, validate = false} = {}) {
|
|
159
194
|
const absolute = path.resolve(file);
|
|
195
|
+
const snapshot = createSnapshot(targets);
|
|
196
|
+
if (validate) validateSnapshot(snapshot);
|
|
160
197
|
await fs.promises.mkdir(path.dirname(absolute), { recursive: true });
|
|
161
198
|
const temp = absolute + '.' + crypto.randomUUID() + '.tmp';
|
|
162
|
-
try { await fs.promises.writeFile(temp, JSON.stringify(
|
|
199
|
+
try { await fs.promises.writeFile(temp, JSON.stringify(snapshot, null, compact ? undefined : 2) + '\n', { mode: 0o600 }); await fs.promises.rename(temp, absolute); }
|
|
163
200
|
finally { await fs.promises.rm(temp, { force: true }); }
|
|
164
201
|
}
|
|
165
202
|
|
|
166
203
|
async function acquireInventories(input, options = {}) {
|
|
204
|
+
if(options.localDockerReference){
|
|
205
|
+
const local=await require('../images/local-docker').openImage(input,options.dockerSocket);
|
|
206
|
+
if(local){
|
|
207
|
+
try{
|
|
208
|
+
const targets=await acquireInventories(local.path,{...options,localDockerReference:null,source:input});
|
|
209
|
+
for(const target of targets){target.metadata.localDocker=local.metadata;target.metadata.acquisition={...target.metadata.acquisition,reference:input,kind:'docker'};}
|
|
210
|
+
return targets;
|
|
211
|
+
}finally{await local.cleanup();}
|
|
212
|
+
}
|
|
213
|
+
// Never silently: a mistyped path, or a locally built image while the Docker Engine is
|
|
214
|
+
// unreachable, would otherwise become a lookup of that name on a public registry.
|
|
215
|
+
if(!options.offline){
|
|
216
|
+
let where=input;try{const ref=require('../images/registry').parseReference(input);where=`${ref.registry}/${ref.repository}`;}catch{}
|
|
217
|
+
options.onSourceWarning?.(`${input} is not a local path and was not found in the local Docker Engine; acquiring it from ${where}.`);
|
|
218
|
+
}
|
|
219
|
+
return acquireInventories(input,{...options,localDockerReference:null,registry:true});
|
|
220
|
+
}
|
|
167
221
|
if (options.inventory) return readSnapshot(input, options);
|
|
168
222
|
if (options.sbom) return [sbomTarget(input, options)];
|
|
169
|
-
const cache = options.registry ? require('../cache
|
|
170
|
-
const legacyCacheKey = sha(JSON.stringify([input, options.platform || null, !!options.preferSbom]));
|
|
171
|
-
const ref = options.registry ? require('../
|
|
172
|
-
const cacheKey = ref ? sha(JSON.stringify([`${ref.registry}/${ref.repository}@${ref.reference}`, options.platform || null, !!options.preferSbom])) : legacyCacheKey;
|
|
223
|
+
const cache = options.registry ? require('../cache/repository').createCacheRepository(options.cacheDir) : null;
|
|
224
|
+
const legacyCacheKey = sha(JSON.stringify([input, options.platform || null, !!options.preferSbom,...(options.system ? [true] : [])]));
|
|
225
|
+
const ref = options.registry ? require('../images/registry').parseReference(input) : null;
|
|
226
|
+
const cacheKey = ref ? sha(JSON.stringify([`${ref.registry}/${ref.repository}@${ref.reference}`, options.platform || null, !!options.preferSbom,...(options.system ? [true] : [])])) : legacyCacheKey;
|
|
173
227
|
if (options.registry && options.offline) {
|
|
174
228
|
const saved = cache.get('image-inventory', cacheKey) || cache.get('image-inventory', legacyCacheKey);
|
|
175
229
|
if (!saved?.value || saved.value.schema !== SNAPSHOT_SCHEMA) throw Error('image inventory is not cached; import an inventory/archive or prepare this reference online');
|
|
@@ -183,7 +237,7 @@ async function acquireInventories(input, options = {}) {
|
|
|
183
237
|
if (cache) cache.put('image-inventory', cacheKey, createSnapshot(targets));
|
|
184
238
|
return targets;
|
|
185
239
|
};
|
|
186
|
-
if (cache && !options.imageRetire && !options.forceUpdate && !require('../cache
|
|
240
|
+
if (cache && !options.imageRetire && !options.forceUpdate && !require('../cache/policy').shouldForceUpdate()) {
|
|
187
241
|
let targets;
|
|
188
242
|
try {
|
|
189
243
|
const saved = cache.get('image-inventory', cacheKey) || cache.get('image-inventory', legacyCacheKey);
|
|
@@ -195,7 +249,7 @@ async function acquireInventories(input, options = {}) {
|
|
|
195
249
|
// Older APK inventories discarded the maintainer needed to identify vendor NGINX.
|
|
196
250
|
const vendorMetadataComplete=scoped?.every(t=>(t.packages||[]).every(p=>p.manager!=='apk'||p.sourceName!=='nginx'||p.packageMetadata));
|
|
197
251
|
if (digest && vendorMetadataComplete && scoped.every(t => t.evidence === 'content-inventory' && t.metadata?.componentScope === require('./component-scope').IMAGE_COMPONENT_SCOPE && !t.warnings.some(w => w.reason === require('./inventory-scope').SCOPE_REASON) && t.metadata?.acquisition?.indexDigest === digest)) {
|
|
198
|
-
const current = ref.reference.includes(':') ? ref.reference : await require('../
|
|
252
|
+
const current = ref.reference.includes(':') ? ref.reference : await require('../images/registry').fetchRegistryDigest(input,
|
|
199
253
|
{...options, fetcher:options.registryFetcher || options.fetcher, limits:options.registryLimits});
|
|
200
254
|
if (current === digest) return scoped.map(target => ({...target, evidence:'cached-inventory', originalEvidence:target.originalEvidence || target.evidence}));
|
|
201
255
|
}
|
|
@@ -205,7 +259,7 @@ async function acquireInventories(input, options = {}) {
|
|
|
205
259
|
if (options.registry) {
|
|
206
260
|
if (options.preferSbom && !options.imageRetire) {
|
|
207
261
|
try {
|
|
208
|
-
const discovered = await require('../
|
|
262
|
+
const discovered = await require('../images/registry').fetchRegistrySboms(input, { ...options, fetcher: options.registryFetcher || options.fetcher, limits: options.registryLimits });
|
|
209
263
|
// Never drop image platforms when only a subset has publisher metadata.
|
|
210
264
|
const subjects = new Set(discovered.documents.map(d => d.expectedDigest));
|
|
211
265
|
if (discovered.documents.length && subjects.size >= (discovered.metadata.platforms?.length || 1)) {
|
|
@@ -226,16 +280,20 @@ async function acquireInventories(input, options = {}) {
|
|
|
226
280
|
sbomAttempt = { status: 'fallback', reason: 'Publisher inventory could not be validated; full image content was requested.' };
|
|
227
281
|
}
|
|
228
282
|
}
|
|
229
|
-
registry = await require('../
|
|
283
|
+
registry = await require('../images/registry').fetchRegistryImage(input, { ...options, fetcher: options.registryFetcher || options.fetcher, limits: options.registryLimits });
|
|
230
284
|
}
|
|
231
|
-
|
|
285
|
+
const source=registry?.path || input;
|
|
286
|
+
const disk=require('./disk');
|
|
287
|
+
opened=options.system && !registry && fs.statSync(source).isFile() && disk.isDisk(source) ? await disk.openDisk(source,options)
|
|
288
|
+
: await openArtifact(source, { ...options, limits: options.artifactLimits });
|
|
232
289
|
const targets = [];
|
|
233
290
|
for (const target of opened.targets) {
|
|
234
291
|
if (options.platform) {
|
|
235
292
|
const platform = target.metadata.platform;
|
|
236
293
|
if (!platform || [platform.os, platform.architecture, platform.variant].filter(Boolean).join('/') !== options.platform && [platform.os, platform.architecture].join('/') !== options.platform) continue;
|
|
237
294
|
}
|
|
238
|
-
const
|
|
295
|
+
const collect=options.system?require('../cli-collect').collectSystemTarget:inventoryTarget;
|
|
296
|
+
const inventory = await collect(target, { ...options, source: registry ? input : options.source });
|
|
239
297
|
if (registry) { inventory.metadata.registryEvidence = registry.metadata; inventory.metadata.acquisition.resolvedDigest = inventory.metadata.digest || null; inventory.metadata.acquisition.indexDigest = registry.metadata.digest; }
|
|
240
298
|
if (sbomAttempt) inventory.metadata.publisherInventory = sbomAttempt;
|
|
241
299
|
targets.push(inventory);
|
|
@@ -246,8 +304,17 @@ async function acquireInventories(input, options = {}) {
|
|
|
246
304
|
}
|
|
247
305
|
|
|
248
306
|
async function assessInventories(targets, options = {}) {
|
|
307
|
+
const { assessSystemInventory, syncSystemAdvisories } = require('../system-inventory');
|
|
249
308
|
options.onArtifactProgress?.({stage:'Component identities'});
|
|
250
309
|
targets=targets.map(target=>require('./inventory-scope').applyComponentScope(target,{checkPolicy:false}));
|
|
310
|
+
// The RPM database lists each imported signing key as a "gpg-pubkey" entry (version = key
|
|
311
|
+
// id). It is not software: no advisory can exist for it, and none is expected.
|
|
312
|
+
for(const target of targets){
|
|
313
|
+
const keys=target.packages.filter(p=>p.manager==='rpm' && p.name==='gpg-pubkey');
|
|
314
|
+
if(!keys.length)continue;
|
|
315
|
+
target.packages=target.packages.filter(p=>!keys.includes(p));
|
|
316
|
+
target.metadata={...target.metadata,rpmSigningKeys:keys.map(p=>({id:p.version,release:p.release??null}))};
|
|
317
|
+
}
|
|
251
318
|
for(const target of targets){
|
|
252
319
|
for(const pkg of target.packages){const origin=require('../system-inventory/distribution-sources').identifyPackageOrigin(pkg,options);if(origin)pkg.packageOrigin=origin;}
|
|
253
320
|
for(const dep of target.deps){const origin=require('../system-inventory/distribution-sources').identifyPackageOrigin(dep,options);if(origin)dep.packageOrigin=origin;}
|
|
@@ -255,6 +322,15 @@ async function assessInventories(targets, options = {}) {
|
|
|
255
322
|
for(const dep of identity.deps){const qualified=qualify({...dep,imageRole:'direct',scope:'runtime'},target.id);if(!target.deps.some(d=>d.coordKey===qualified.coordKey))target.deps.push(qualified);}
|
|
256
323
|
target.coverage.push({...identity.coverage,artifactTargetId:target.id,capability:'inventory'});
|
|
257
324
|
target.warnings.push(...identity.warnings);
|
|
325
|
+
// A Go binary built from a checkout names its main module "(devel)". Without verified
|
|
326
|
+
// version evidence the application's own advisories cannot be assessed: say so.
|
|
327
|
+
const identifiedBinaries=new Set(identity.deps.map(d=>d.binaryEvidence?.binaryPath));
|
|
328
|
+
const unversioned=target.deps.filter(d=>d.ecosystem==='binary' && !identifiedBinaries.has(d.artifactPath||d.manifestPaths?.[0])).map(d=>{
|
|
329
|
+
const main=(d.binaryMetadata?.go?.modules||[]).filter(m=>m.kind==='mod');
|
|
330
|
+
return main.length===1 && main[0].version==='(devel)' && main[0].path ? `${main[0].path} (${d.artifactPath||d.manifestPaths?.[0]})` : null;
|
|
331
|
+
}).filter(Boolean);
|
|
332
|
+
if(unversioned.length)target.warnings.push({type:'dependency-coverage',severity:'info',capability:'advisories',reason:'go-main-module-unversioned',count:unversioned.length,
|
|
333
|
+
items:unversioned.map(id=>({id})),message:`${unversioned.length} Go application module(s) carry no verifiable version: advisories for the application itself were not assessed; its embedded dependencies were.`});
|
|
258
334
|
}
|
|
259
335
|
const resolvedDeps = new Map(), cveMatches = [], warnings = [], artifacts = [], warmed = new Set();
|
|
260
336
|
const nativeDeps=new Map();
|
|
@@ -264,28 +340,60 @@ async function assessInventories(targets, options = {}) {
|
|
|
264
340
|
const nativeOptions={...options};
|
|
265
341
|
try{
|
|
266
342
|
options.onArtifactProgress?.({stage:'Native advisory preparation'});
|
|
267
|
-
nativePreparation=await require('../native-source-prepare').prepareNativeSources(nativeDeps,nativeOptions);
|
|
343
|
+
nativePreparation=await require('../advisories/native-source-prepare').prepareNativeSources(nativeDeps,nativeOptions);
|
|
268
344
|
if(nativePreparation.sources.length){
|
|
269
|
-
const store=require('../
|
|
345
|
+
const store=require('../advisories/store').openAdvisoryStore({cacheDir:options.cacheDir});
|
|
270
346
|
options.onArtifactProgress?.({stage:'Native advisory matching'});
|
|
271
|
-
try{native=require('../native
|
|
347
|
+
try{native=require('../advisories/native').matchNativePackages(nativeDeps,store,{sources:nativePreparation.sources});}finally{store.close();}
|
|
272
348
|
}
|
|
273
|
-
}catch(error){nativePreparation.warnings.push(`Native advisory scan failed: ${error.message}`);native.coverage={status:'
|
|
349
|
+
}catch(error){nativePreparation.warnings.push(`Native advisory scan failed: ${error.message}`);native.coverage={status:'failed',reason:error.message};}
|
|
274
350
|
}
|
|
275
351
|
for (const original of targets) {
|
|
276
352
|
const target = JSON.parse(JSON.stringify(original));
|
|
277
353
|
let targetWarnings = normalizeWarnings(target.warnings);
|
|
354
|
+
if (target.metadata.systemApplications && target.metadata.inspectLocalImages === false)
|
|
355
|
+
targetWarnings = targetWarnings.filter(w=>w.reason!=='image-reference-parse-error');
|
|
356
|
+
const reliability=require('../scan/reliability');
|
|
357
|
+
const discoveryCoverage=reliability.createDiscoveryCoverage();
|
|
278
358
|
const assessedPackages = new Set();
|
|
279
|
-
|
|
359
|
+
let distributionState = options.osv===false ? 'disabled' : undefined;
|
|
360
|
+
// The auditor evaluates lifecycle through system maintenance. An unsupported
|
|
361
|
+
// lifecycle hook in an inventory plugin is not a second requested lookup.
|
|
362
|
+
const coverage = target.metadata.systemApplications
|
|
363
|
+
? target.coverage.filter(c=>c.diagnostic!=='CMS_LIFECYCLE_NOT_QUALIFIED')
|
|
364
|
+
: [...target.coverage];
|
|
365
|
+
if (options.publisherAdvisories !== false && target.metadata.systemApplications?.applications.some(app => app.pluginId)) {
|
|
366
|
+
const assessed = await require('../applications/plugins/runner').runApplicationPlugins(null, {
|
|
367
|
+
savedInventory:target.metadata.systemApplications, scanContext:'installation', offline:!!options.offline, fetchImpl:options.fetcher,
|
|
368
|
+
plugins:require('../applications/plugins').allApplicationPlugins(),
|
|
369
|
+
advisoryCacheDir:path.join(options.cacheDir || require('../cache/directory').getCacheDir(),'advisory-snapshots'),
|
|
370
|
+
wordfenceFeedPath:options.wordfenceFeed, drupalAdvisoriesPath:options.drupalAdvisories,
|
|
371
|
+
prestashopAdvisoriesPath:options.prestashopAdvisories, typo3AdvisoriesPath:options.typo3Advisories,
|
|
372
|
+
spipAdvisoriesPath:options.spipAdvisories,
|
|
373
|
+
});
|
|
374
|
+
for (const match of assessed.findings) {
|
|
375
|
+
const dep = qualify({...match.dep,systemSection:'project',systemApplicationIds:match.applicationIds,coordKey:JSON.stringify([match.dep.coordKey,match.ownerComponentIds])},target.id);
|
|
376
|
+
cveMatches.push({...match,dep});
|
|
377
|
+
}
|
|
378
|
+
coverage.push(...assessed.coverage.map(c=>({...c,collector:c.sourceId || 'system-applications',artifactTargetId:target.id})));
|
|
379
|
+
targetWarnings.push(...require('../scan/coverage').applicationWarnings({
|
|
380
|
+
diagnostics:assessed.diagnostics, inventory:target.metadata.systemApplications.inventory,
|
|
381
|
+
coverage:coverage.filter(c=>c.applicationId),
|
|
382
|
+
}));
|
|
383
|
+
}
|
|
280
384
|
options.onArtifactProgress?.({stage:'Distribution advisories'});
|
|
281
385
|
const distroKey = JSON.stringify(target.distribution);
|
|
282
|
-
|
|
386
|
+
const advisoryScope = target.packages.length && options.osv !== false ? require('../system-inventory').scope(target.distribution,options) : null;
|
|
387
|
+
// A scope made of several ecosystems, or fed by a security database, has no per-package
|
|
388
|
+
// query: its advisories are always taken in bulk, hosted service or not.
|
|
389
|
+
const bulkOnly = !!(advisoryScope?.accepts || advisoryScope?.secdb);
|
|
390
|
+
if (options.osv !== false && !options.offline && target.packages.length && !warmed.has(distroKey) && (bulkOnly || !require('../providers').hasHostedProxy())) {
|
|
283
391
|
warmed.add(distroKey);
|
|
284
392
|
try {
|
|
285
393
|
const scope=require('../system-inventory').scope(target.distribution,options);
|
|
286
|
-
const cached=scope && require('../cache
|
|
394
|
+
const cached=scope && require('../cache/repository').createCacheRepository(options.cacheDir).getSnapshot('system-osv:'+scope.ecosystem);
|
|
287
395
|
const age=Date.now()-(cached?.fetchedAt||0);
|
|
288
|
-
if(options.refresh || !cached?.complete || cached.stale || age<0 || age>=require('../cache
|
|
396
|
+
if(options.refresh || !cached?.complete || cached.stale || age<0 || age>=require('../cache/policy').DEFAULT_TTL_MS)
|
|
289
397
|
await syncSystemAdvisories(target.distribution, options);
|
|
290
398
|
}
|
|
291
399
|
catch (error) { targetWarnings.push({ type: 'source-unavailable', capability: 'sources', message: `System advisory refresh failed: ${error.message}` }); }
|
|
@@ -297,26 +405,38 @@ async function assessInventories(targets, options = {}) {
|
|
|
297
405
|
}
|
|
298
406
|
for(const warning of nativePreparation.warnings)targetWarnings.push(typeof warning==='string'?{type:'source-unavailable',capability:'sources',message:warning}:{capability:'sources',...warning});
|
|
299
407
|
const nativeUnknown=native.unknown.filter(item=>!item.artifactTargetId||item.artifactTargetId===target.id);
|
|
300
|
-
if(nativeUnknown.length){coverage.push({artifactTargetId:target.id,capability:'sources',collector:'native-comparisons',execution:'completed',result:'indeterminate',affectsCompleteness:false,affectsAssessment:true,count:nativeUnknown.length});targetWarnings.push({...require('../diagnostics').advisoryEvidenceDiagnostic(nativeUnknown),capability:'sources'});}
|
|
408
|
+
if(nativeUnknown.length){coverage.push({artifactTargetId:target.id,capability:'sources',collector:'native-comparisons',execution:'completed',result:'indeterminate',affectsCompleteness:false,affectsAssessment:true,count:nativeUnknown.length});targetWarnings.push({...require('../scan/diagnostics').advisoryEvidenceDiagnostic(nativeUnknown),capability:'sources'});}
|
|
301
409
|
if (target.packages.length && options.osv === false) {
|
|
302
410
|
coverage.push({ artifactTargetId: target.id, capability: 'advisories', collector: 'system-osv', execution: 'not-applicable', result: 'not-consulted', expected:false, reason: 'OSV is excluded by source configuration.' });
|
|
303
411
|
} else if (target.packages.length) {
|
|
304
412
|
const systemInventory = { distribution: target.distribution, packages: target.packages.filter(p=>!['third-party','ambiguous'].includes(p.packageOrigin?.status)) };
|
|
305
413
|
const excluded=target.packages.length-systemInventory.packages.length;
|
|
306
414
|
if(excluded){const reason='Distribution OSV ranges do not establish applicability for packages declaring another vendor.';coverage.push({artifactTargetId:target.id,capability:'advisories',collector:'system-osv-vendor-scope',execution:'partial',result:'indeterminate',count:excluded,reason});targetWarnings.push({type:'dependency-coverage',severity:'info',capability:'advisories',message:reason});}
|
|
307
|
-
const hostedOnline = !options.offline && require('../providers').hasHostedProxy();
|
|
415
|
+
const hostedOnline = !options.offline && require('../providers').hasHostedProxy() && !bulkOnly;
|
|
308
416
|
let assessment;
|
|
309
417
|
try {
|
|
310
418
|
assessment = hostedOnline ? await require('../system-inventory').assessTargetedSystemInventory(systemInventory, options)
|
|
311
419
|
: await assessSystemInventory(systemInventory, options);
|
|
312
|
-
if (
|
|
313
|
-
|
|
314
|
-
|
|
420
|
+
if (!hostedOnline && assessment.coverage.some(c => c.status !== 'complete')) {
|
|
421
|
+
// Ask OSV for the exact installed versions when the bulk ranges cannot
|
|
422
|
+
// establish them. Offline runs can replay those verified consultations.
|
|
423
|
+
const targeted = bulkOnly ? {assessedPackages:[],coverage:[]} : await require('../system-inventory').assessTargetedSystemInventory(systemInventory, options);
|
|
424
|
+
if (targeted.assessedPackages?.length === systemInventory.packages.length ||
|
|
425
|
+
(options.offline && assessment.coverage.some(c=>c.status==='missing') && targeted.coverage.some(c=>c.consulted>c.unknown)))
|
|
426
|
+
assessment = targeted;
|
|
315
427
|
}
|
|
316
428
|
} catch(error) {
|
|
317
429
|
assessment={matches:[],coverage:[{source:'system-osv',status:'incomplete',reason:error.message}],warnings:[`System OSV assessment failed: ${error.message}`]};
|
|
318
430
|
}
|
|
319
|
-
if
|
|
431
|
+
if(options.offline && assessment.coverage.some(c=>c.status==='missing'))distributionState='distribution-cache-missing';
|
|
432
|
+
// A comparison that failed for one package says nothing about other packages.
|
|
433
|
+
const verified = new Set(assessment.assessedPackages || []);
|
|
434
|
+
const keyOf = p=>`${p.manager}:${p.name}@${p.version}`;
|
|
435
|
+
const unchecked = new Set(systemInventory.packages.filter(p=>!verified.has(p)).map(keyOf));
|
|
436
|
+
for(const pkg of verified)if(!unchecked.has(keyOf(pkg))){
|
|
437
|
+
assessedPackages.add(keyOf(pkg));
|
|
438
|
+
discoveryCoverage.consulted(systemDep(pkg,target.id,target.distribution),'osv');
|
|
439
|
+
}
|
|
320
440
|
coverage.push(...coverageRecords(assessment.coverage, target.id, 'advisories'));
|
|
321
441
|
targetWarnings.push(...normalizeWarnings(assessment.warnings, 'advisories'));
|
|
322
442
|
for (const match of assessment.matches) {
|
|
@@ -329,46 +449,85 @@ async function assessInventories(targets, options = {}) {
|
|
|
329
449
|
}
|
|
330
450
|
}
|
|
331
451
|
options.onArtifactProgress?.({stage:'Distribution security trackers'});
|
|
332
|
-
const distribution=await require('../system-inventory/distribution-sources').assessDistributionSources({distribution:target.distribution,packages:target.packages},{...options,
|
|
452
|
+
const distribution=await require('../system-inventory/distribution-sources').assessDistributionSources({distribution:target.distribution,packages:target.packages},{...options,
|
|
453
|
+
onPackageConsulted:(pkg,source)=>discoveryCoverage.consulted(systemDep(pkg,target.id,target.distribution),source),confirmedMatches:[...cveMatches,...native.matches].filter(m=>m.dep?.artifactTargetId===target.id)});
|
|
333
454
|
coverage.push(...coverageRecords(distribution.coverage,target.id,'advisories'));
|
|
334
455
|
targetWarnings.push(...normalizeWarnings(distribution.warnings,'advisories'));
|
|
456
|
+
// A known limit of the source, stated in the report rather than left to be guessed: errata
|
|
457
|
+
// describe fixes. It does not apply when a source of unfixed vulnerabilities answered.
|
|
458
|
+
const unfixedCovered = distribution.coverage.some(c => c.source === 'redhat-oval' && c.execution === 'completed');
|
|
459
|
+
if (advisoryScope?.fixedOnly && !unfixedCovered) targetWarnings.push({type:'dependency-coverage',severity:'info',capability:'advisories',reason:'distribution-fixed-advisories-only',
|
|
460
|
+
message:`${target.distribution.name || advisoryScope.base}: its packages are assessed against the distribution's published errata. A vulnerability the distribution has not fixed yet has no erratum and is not listed.`});
|
|
335
461
|
for(const match of distribution.matches){const dep=systemDep(match.dep,target.id,target.distribution);cveMatches.push({...match,dep:resolvedDeps.get(dep.coordKey)||dep});}
|
|
336
462
|
const imageJsAssessment=await require('./retire').assessImageJs(target,options);
|
|
337
|
-
|
|
463
|
+
for(const item of imageJsAssessment.matches)cveMatches.push(item);
|
|
338
464
|
coverage.push(imageJsAssessment.coverage);
|
|
339
465
|
targetWarnings.push(...imageJsAssessment.warnings);
|
|
340
466
|
options.onArtifactProgress?.({stage:'Application advisories'});
|
|
341
|
-
const appDeps = new Map(target.deps.filter(d => d.ecosystem !== 'system' && d.ecosystem !== 'binary' && d.ecosystem !== 'image-product' && d.installEvidence?.source !== 'retire' && (!d.osPackageOwners?.length || !!d.binaryEvidence)).map(d => [d.coordKey, d]));
|
|
342
|
-
|
|
467
|
+
const appDeps = new Map(target.deps.filter(d => d.registryIdentity !== 'cms-theme' && d.ecosystem !== 'system' && d.ecosystem !== 'binary' && d.ecosystem !== 'image-product' && d.installEvidence?.source !== 'retire' && (!d.osPackageOwners?.length || !!d.binaryEvidence)).map(d => [d.coordKey, d]));
|
|
468
|
+
// Distribution headers/metadata identify the upstream release, but downstream
|
|
469
|
+
// fixes can be backported. Keep these comparisons as evidence to investigate.
|
|
470
|
+
const owned = new Map(target.metadata.systemApplications ? target.deps.filter(d =>
|
|
471
|
+
d.osPackageOwners?.length && !d.binaryEvidence && d.provenance === 'installed' &&
|
|
472
|
+
['ruby','pypi','npm','composer'].includes(d.ecosystem) && d.installEvidence && d.version
|
|
473
|
+
).map(d => [d.coordKey,d]) : []);
|
|
474
|
+
const osvDeps = new Map([...appDeps, ...owned]);
|
|
475
|
+
if (osvDeps.size && options.osv === false) {
|
|
343
476
|
coverage.push({ artifactTargetId: target.id, capability:'advisories',collector:'osv-application',execution:'not-applicable',result:'not-consulted',expected:false,reason:'OSV is excluded by source configuration.' });
|
|
344
|
-
} else if (
|
|
477
|
+
} else if (osvDeps.size) {
|
|
345
478
|
const appWarnings = [];
|
|
346
479
|
try {
|
|
347
|
-
const matches = await require('../osv').queryOsvForDeps(
|
|
480
|
+
const matches = await require('../providers/osv/query').queryOsvForDeps(osvDeps, { ...options, allowStaleFallback: true, onConsulted:discoveryCoverage.consulted,
|
|
348
481
|
onWarning: warning => appWarnings.push(typeof warning === 'string' ? { type: 'osv-coverage', message: warning } : warning) });
|
|
349
|
-
|
|
350
|
-
const
|
|
482
|
+
const upstream = matches.filter(m=>owned.has(m.dep.coordKey));
|
|
483
|
+
const findings = matches.filter(m=>!owned.has(m.dep.coordKey));
|
|
484
|
+
for(const item of require('./applications').upstreamPackageObservations(
|
|
485
|
+
upstream, [...cveMatches,...native.matches].filter(m=>m.dep?.artifactTargetId===target.id), distribution.observations
|
|
486
|
+
))distribution.observations.push(item);
|
|
487
|
+
for(const item of findings)cveMatches.push(item);
|
|
488
|
+
const incomplete=appWarnings.some(w=>!require('../scan/diagnostics').isInformational(w));
|
|
351
489
|
coverage.push({ artifactTargetId: target.id, capability: 'advisories', collector: 'osv-application',
|
|
352
|
-
execution: incomplete ? 'partial' : 'completed', result:
|
|
490
|
+
execution: incomplete ? 'partial' : 'completed', result: findings.length ? 'affected' : incomplete || upstream.length ? 'indeterminate' : 'no-match', count: osvDeps.size });
|
|
353
491
|
} catch (error) {
|
|
354
492
|
appWarnings.push({ type: 'source-unavailable', message: `Application advisory scan failed: ${error.message}` });
|
|
355
493
|
coverage.push({ artifactTargetId: target.id, capability: 'advisories', collector: 'osv-application', execution: 'failed', result: 'indeterminate' });
|
|
356
494
|
}
|
|
357
495
|
targetWarnings.push(...normalizeWarnings(appWarnings, 'advisories'));
|
|
358
496
|
}
|
|
497
|
+
// Gems installed by an application, not by the distribution: the Ruby advisory database
|
|
498
|
+
// records advisories OSV does not carry for RubyGems (lib/providers/rubysec).
|
|
499
|
+
const gems = new Map([...appDeps].filter(([, dep]) => dep.ecosystem === 'ruby'));
|
|
500
|
+
if (gems.size && options.rubyAdvisories !== false) {
|
|
501
|
+
try {
|
|
502
|
+
const found = await require('../providers/rubysec/advisories').queryRubyAdvisories(gems, { cacheDir: options.cacheDir, offline: options.offline,
|
|
503
|
+
fetcher: options.fetcher, forceUpdate: options.forceUpdate, onConsulted: discoveryCoverage.consulted, onWarning: warning => targetWarnings.push({ ...warning, capability: 'advisories' }) });
|
|
504
|
+
for (const item of found) cveMatches.push(item);
|
|
505
|
+
coverage.push({ artifactTargetId: target.id, capability: 'advisories', collector: 'rubysec', execution: 'completed', result: found.length ? 'affected' : 'no-match', count: gems.size });
|
|
506
|
+
} catch (error) {
|
|
507
|
+
coverage.push({ artifactTargetId: target.id, capability: 'advisories', collector: 'rubysec', execution: 'failed', result: 'indeterminate', reason: error.message });
|
|
508
|
+
targetWarnings.push({ type: 'source-unavailable', capability: 'advisories', source: 'rubysec', message: `Ruby advisory database: ${error.message}` });
|
|
509
|
+
}
|
|
510
|
+
}
|
|
359
511
|
options.onArtifactProgress?.({stage:'Publisher advisories'});
|
|
360
|
-
const publisher=await require('./publisher-advisories').assessPublisherAdvisories(appDeps,options);
|
|
361
|
-
|
|
512
|
+
const publisher=await require('./publisher-advisories').assessPublisherAdvisories(appDeps,{...options,onPackageConsulted:discoveryCoverage.consulted});
|
|
513
|
+
for(const item of publisher.matches)cveMatches.push(item);
|
|
362
514
|
coverage.push(...coverageRecords(publisher.coverage,target.id,'advisories'));
|
|
363
515
|
targetWarnings.push(...normalizeWarnings(publisher.warnings,'advisories'));
|
|
364
516
|
const products=await require('./product-advisories').assessProductAdvisories(target,options);
|
|
365
|
-
|
|
517
|
+
for(const match of products.matches)if(!resolvedDeps.has(match.dep.coordKey))resolvedDeps.set(match.dep.coordKey,match.dep);
|
|
518
|
+
for(const item of products.matches)cveMatches.push(item);
|
|
519
|
+
const conditions = products.coverage.flatMap(check => (check.undecidableIds || []).map(id => ({
|
|
520
|
+
id, package: check.product, version: check.version, reason: check.reason
|
|
521
|
+
})));
|
|
522
|
+
if (conditions.length) targetWarnings.push({
|
|
523
|
+
...require('../scan/diagnostics').advisoryEvidenceDiagnostic(conditions), capability: 'advisories'
|
|
524
|
+
});
|
|
366
525
|
coverage.push(...coverageRecords(products.coverage,target.id,'advisories'));
|
|
367
|
-
const productInventory=require('./image-products').productCoverage(target,products.coverage,assessedPackages,[...cveMatches,...native.matches]);
|
|
526
|
+
const productInventory=require('./image-products').productCoverage(target,products.coverage,assessedPackages,[...cveMatches,...native.matches],distributionState);
|
|
368
527
|
const identifiedBinaryPaths=new Set(target.deps.filter(d=>(d.ecosystem==='binary' && d.binaryEvidence?.product && d.version) || d.binaryEvidence?.source==='go-vcs-and-module-proxy').map(d=>d.binaryEvidence.binaryPath));
|
|
369
528
|
const unknownBinaries = target.deps.filter(d => d.ecosystem === 'binary' && !d.osPackageOwners?.length && !identifiedBinaryPaths.has(d.artifactPath));
|
|
370
529
|
if (unknownBinaries.length) {
|
|
371
|
-
coverage.push({ artifactTargetId: target.id, capability: 'advisories', collector: 'native-binaries', execution: '
|
|
530
|
+
coverage.push({ artifactTargetId: target.id, capability: 'advisories', collector: 'native-binaries', execution: 'not-applicable', result: 'indeterminate', affectsCompleteness:false, count: unknownBinaries.length, reason: 'These files expose no supported package/version identity for advisory queries.' });
|
|
372
531
|
targetWarnings.push({ type: 'dependency-coverage', severity:'info', capability: 'advisories', message: `${unknownBinaries.length} native binaries have no authenticated package/version identity.` });
|
|
373
532
|
}
|
|
374
533
|
const archiveContext=require('./applications').classifyOwnedArchiveWarnings(targetWarnings,target.packages,assessedPackages);
|
|
@@ -376,7 +535,7 @@ async function assessInventories(targets, options = {}) {
|
|
|
376
535
|
targetWarnings=archiveContext.warnings;
|
|
377
536
|
// Reclassify the collector only when none of its original inventory
|
|
378
537
|
// diagnostics remain; never hide malformed archives or unresolved files.
|
|
379
|
-
if(!targetWarnings.some(w=>w.capability==='inventory' && !require('../diagnostics').isInformational(w)))
|
|
538
|
+
if(!targetWarnings.some(w=>w.capability==='inventory' && !require('../scan/diagnostics').isInformational(w)))
|
|
380
539
|
for(const check of coverage)if(check.collector==='installed-applications' && check.execution==='partial')check.execution='completed';
|
|
381
540
|
targetWarnings.push(...archiveContext.informational.map(({warning,owner,path})=>({...warning,severity:'info',type:'os-owned-component',owner,
|
|
382
541
|
message:`${path} is covered by its installed OS package ${owner.name}@${owner.version}; no independent Maven identity is declared.`})));
|
|
@@ -384,26 +543,63 @@ async function assessInventories(targets, options = {}) {
|
|
|
384
543
|
for (const check of coverage) {
|
|
385
544
|
if (check.affectsCompleteness === false || ['completed', 'not-applicable'].includes(check.execution)) continue;
|
|
386
545
|
if (check.collector==='native-binaries' || check.collector==='native-comparisons' || check.collector==='go-main-identity' || check.collector==='system-osv-vendor-scope' || check.issue==='missing-source') continue;
|
|
387
|
-
if (targetWarnings.some(w => w.capability === check.capability && !require('../diagnostics').isInformational(w))) continue;
|
|
546
|
+
if (targetWarnings.some(w => w.capability === check.capability && !require('../scan/diagnostics').isInformational(w))) continue;
|
|
388
547
|
targetWarnings.push({ type: check.capability === 'inventory' ? 'dependency-coverage' : 'source-unavailable',
|
|
389
548
|
capability: check.capability, message: `${check.collector || check.source || check.capability}: ${check.reason || check.execution}; coverage is incomplete.` });
|
|
390
549
|
}
|
|
550
|
+
// A component owned by an OS package is assessed through that package, required below. Its
|
|
551
|
+
// upstream comparison on OSV is evidence to investigate, not a coverage requirement: it has
|
|
552
|
+
// no native CVE consultation of its own, which a proxied scan reported as a missing source.
|
|
553
|
+
const requiredDeps = new Map(appDeps);
|
|
554
|
+
for (const pkg of target.packages) {
|
|
555
|
+
const dep=systemDep(pkg,target.id,target.distribution);
|
|
556
|
+
requiredDeps.set(dep.coordKey,dep);
|
|
557
|
+
}
|
|
558
|
+
// Products identified by CPE are checked by the product/version adapter.
|
|
559
|
+
// An excluded adapter is a real gap for a product it could check.
|
|
560
|
+
for (const check of products.coverage) {
|
|
561
|
+
if (check.collector === 'nvd-image-product' && check.execution === 'not-applicable') {
|
|
562
|
+
targetWarnings.push(reliability.coverageWarning(`No applicability check for ${check.product}@${check.version}: ${check.reason}`));
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
if(requiredDeps.size) {
|
|
566
|
+
const store=require('../advisories/store').openAdvisoryStore({cacheDir:options.cacheDir});
|
|
567
|
+
try {
|
|
568
|
+
const checkedSources=nativePreparation.coverage.filter(c=>!c.issue && native.coverage?.status!=='failed').map(c=>c.source);
|
|
569
|
+
const gap=discoveryCoverage.assess(requiredDeps,{store,options,nativeSources:checkedSources,reviewed:options.osv!==false});
|
|
570
|
+
if(gap)targetWarnings.push(gap);
|
|
571
|
+
} finally {store.close();}
|
|
572
|
+
}
|
|
573
|
+
for(const check of coverage.filter(reliability.incompleteCheck)){
|
|
574
|
+
targetWarnings.push(reliability.coverageWarning(`${check.collector || check.sourceId}: ${check.reason || check.execution} (${check.capability}).`));
|
|
575
|
+
}
|
|
576
|
+
for(const warning of targetWarnings) {
|
|
577
|
+
if(warning.severity!=='info' && warning.affectsCompleteness!==false && (warning.capability==='advisories' ||
|
|
578
|
+
warning.code==='source-request-failed' || (warning.source && nativePreparation.sources.includes(warning.source))))warning.reliabilityFailure=true;
|
|
579
|
+
}
|
|
391
580
|
warnings.push(...targetWarnings.map(w => ({ artifactTargetId: target.id, ...w })));
|
|
392
581
|
artifacts.push({ id: target.id, kind: target.kind, metadata: target.metadata, evidence: target.evidence,
|
|
393
582
|
originalEvidence: target.originalEvidence, distribution: target.distribution, inventoryAt: target.inventoryAt,
|
|
394
|
-
componentCount: target.deps.length, coverage, productInventory, advisoryObservations:distribution.observations, components: target.deps.map(d => ({ ecosystem: d.ecosystem, packageType: d.packageType,
|
|
583
|
+
componentCount: target.deps.length, coverage, productInventory, advisoryObservations:distribution.observations, components: target.deps.map(d => ({ ...(d.systemSection ? {systemSection:d.systemSection,systemApplicationIds:d.systemApplicationIds || []} : {}), ecosystem: d.ecosystem, packageType: d.packageType,
|
|
395
584
|
namespace: d.namespace, name: d.name, version: d.version, sourceName:d.sourceName || null, sourceVersion:d.sourceVersion || null, packageOrigin:d.packageOrigin || null, architecture: d.architecture, artifactPath: d.artifactPath,
|
|
396
585
|
imageProduct:require('./image-products').describe(d), provenance: d.provenance, imageRole:d.imageRole || null, imageSource:d.imageSource || imageComponentSource(d), installEvidence:d.installEvidence, manager:d.manager, coordKey: d.coordKey, binaryEvidence:d.binaryEvidence, osPackageOwners: d.osPackageOwners || [],
|
|
397
|
-
purl: require('../purl').purlFor(d) })) });
|
|
586
|
+
purl: require('../inventory/purl').purlFor(d) })) });
|
|
398
587
|
}
|
|
399
|
-
const combined=require('../merge
|
|
400
|
-
|
|
588
|
+
const combined=require('../findings/merge').foldAnnouncements(require('../findings/merge').mergeBySource(cveMatches,native.matches));
|
|
589
|
+
const applicabilityStore=require('../advisories/store').openAdvisoryStore({cacheDir:options.cacheDir});
|
|
590
|
+
try{
|
|
591
|
+
const checked=require('../system-inventory/package-applicability').reconcileSystemFindings(combined,applicabilityStore);
|
|
592
|
+
cveMatches.splice(0,cveMatches.length,...checked.matches);
|
|
593
|
+
for(const artifact of artifacts)for(const item of checked.observations.filter(o=>o.dep.artifactTargetId===artifact.id))artifact.advisoryObservations.push(item);
|
|
594
|
+
}finally{applicabilityStore.close();}
|
|
401
595
|
for (const artifact of artifacts) {
|
|
402
596
|
options.onArtifactProgress?.({stage:'Image updates'});
|
|
403
|
-
try { artifact.imageUpdate=await require('../
|
|
597
|
+
try { artifact.imageUpdate=await require('../images/update').resolveImageUpdate(artifact.metadata,options); }
|
|
404
598
|
catch (error) { artifact.imageUpdate={status:'unknown',reference:artifact.metadata?.acquisition?.reference||null,reason:`Image update lookup unavailable: ${error.message}`,verifiedFix:false}; }
|
|
405
599
|
const matches = cveMatches.filter(m => m.dep?.artifactTargetId === artifact.id);
|
|
406
600
|
options.onArtifactProgress?.({stage:'CVE enrichment'});
|
|
601
|
+
const visibleComponents = require('./report-inventory').reportedComponents(artifact,matches);
|
|
602
|
+
await require('./release-versions').attachReleaseVersions(artifact,visibleComponents,options);
|
|
407
603
|
const enrichment = await require('./enrichment').enrichArtifactFindings(matches, options);
|
|
408
604
|
const recordSources = new Set(['nvd', 'euvd', 'euvd-details']);
|
|
409
605
|
artifact.coverage.push(...enrichment.coverage.map(c => ({ ...c, artifactTargetId: artifact.id,
|
|
@@ -411,12 +607,44 @@ async function assessInventories(targets, options = {}) {
|
|
|
411
607
|
diagnostics:enrichment.warnings.filter(w => w.source === c.collector) } : {}) })));
|
|
412
608
|
warnings.push(...enrichment.warnings.filter(w => !recordSources.has(w.source)).map(w => ({ ...w, artifactTargetId: artifact.id })));
|
|
413
609
|
}
|
|
414
|
-
|
|
610
|
+
await require('../findings/cve-descriptions').completeCveDescriptions(cveMatches,options);
|
|
611
|
+
const recordSummary = require('../findings/cve-record-coverage').summarizeCveRecords(cveMatches,
|
|
415
612
|
{ ...options, coverage: artifacts.flatMap(a => a.coverage) });
|
|
416
613
|
if (recordSummary.warning) warnings.push(recordSummary.warning);
|
|
417
|
-
require('../priority').attachPriority(cveMatches);
|
|
418
|
-
const diagnostics=require('../diagnostics').partitionDiagnostics(warnings);
|
|
419
|
-
|
|
614
|
+
require('../findings/priority').attachPriority(cveMatches);
|
|
615
|
+
const diagnostics=require('../scan/diagnostics').partitionDiagnostics(warnings);
|
|
616
|
+
const systemTargets = artifacts.filter(a => a.metadata.systemApplications);
|
|
617
|
+
const applicationRelations = systemTargets.flatMap(a=>a.metadata.systemApplications.relations || []);
|
|
618
|
+
const relationsByDep = new Map();
|
|
619
|
+
for (const relation of applicationRelations) {
|
|
620
|
+
if (!relationsByDep.has(relation.depCoordKey)) relationsByDep.set(relation.depCoordKey,[]);
|
|
621
|
+
relationsByDep.get(relation.depCoordKey).push(relation);
|
|
622
|
+
}
|
|
623
|
+
for (const match of cveMatches) {
|
|
624
|
+
const dep = match.dep;
|
|
625
|
+
const relations = relationsByDep.get(dep?.coordKey);
|
|
626
|
+
if (relations?.length) {
|
|
627
|
+
const occurrence = {version:dep.version,manifestPath:dep.artifactPath,scope:dep.scope,isDev:dep.isDev};
|
|
628
|
+
const [attributed] = require('../applications/inventory').expandComposerFindings(
|
|
629
|
+
[{...match,dep:{...dep,occurrences:[occurrence]}}],'.',relations);
|
|
630
|
+
Object.assign(match,attributed);
|
|
631
|
+
}
|
|
632
|
+
if (dep?.systemApplicationIds?.length) {
|
|
633
|
+
if (!match.applicationIds?.length) match.applicationIds = dep.systemApplicationIds;
|
|
634
|
+
if (!match.applicationRelation) match.applicationRelation = require('../applications/layout').managerRelation(dep);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
for (const target of systemTargets) {
|
|
638
|
+
const {applications,inventory} = target.metadata.systemApplications;
|
|
639
|
+
require('../applications/layout').attributeLayoutFindings(cveMatches.filter(m=>m.dep?.artifactTargetId===target.id),applications,inventory);
|
|
640
|
+
}
|
|
641
|
+
const systemApplications = systemTargets.length ? {
|
|
642
|
+
applicationRelations,
|
|
643
|
+
applications:systemTargets.flatMap(a=>a.metadata.systemApplications.applications.map(app=>({...app,artifactTargetId:a.id}))),
|
|
644
|
+
coverage:systemTargets.flatMap(a=>a.coverage.filter(check=>check.applicationId)),
|
|
645
|
+
applicationInventory:systemTargets.flatMap(a=>a.metadata.systemApplications.inventory.map(c=>({...c,artifactTargetId:a.id}))),
|
|
646
|
+
} : {};
|
|
647
|
+
return { resolvedDeps, cveMatches: require('../findings/summary').uniqueFindings(cveMatches), ...systemApplications, ...diagnostics, artifacts };
|
|
420
648
|
}
|
|
421
649
|
|
|
422
650
|
function incompleteCapabilities(result, required = ['inventory', 'advisories', 'sources']) {
|
|
@@ -424,7 +652,7 @@ function incompleteCapabilities(result, required = ['inventory', 'advisories', '
|
|
|
424
652
|
for (const target of result.artifacts) {
|
|
425
653
|
for (const capability of required) {
|
|
426
654
|
if (capability === 'sources') {
|
|
427
|
-
if (result.warnings.some(w => w.affectsCompleteness !== false && w.artifactTargetId === target.id && /source|osv/.test(w.type))) gaps.push({ target: target.id, capability });
|
|
655
|
+
if (result.warnings.some(w => w.affectsCompleteness !== false && w.artifactTargetId === target.id && (/source|osv/.test(w.type) || w.reliabilityFailure))) gaps.push({ target: target.id, capability });
|
|
428
656
|
} else {
|
|
429
657
|
const records = target.coverage.filter(c => c.capability === capability);
|
|
430
658
|
if (!records.length || records.some(c => c.affectsCompleteness !== false && !['completed', 'not-applicable'].includes(c.execution))) gaps.push({ target: target.id, capability });
|
|
@@ -434,5 +662,5 @@ function incompleteCapabilities(result, required = ['inventory', 'advisories', '
|
|
|
434
662
|
return gaps;
|
|
435
663
|
}
|
|
436
664
|
|
|
437
|
-
module.exports = { acquireInventories, assessInventories, inventoryTarget, sbomTarget, readSnapshot, writeSnapshot,
|
|
665
|
+
module.exports = { acquireInventories, assessInventories, inventoryTarget, sbomTarget, readSnapshot, writeSnapshot, relativeToRoot,
|
|
438
666
|
createSnapshot, validateSnapshot, incompleteCapabilities, coverageRecords, systemDep, SNAPSHOT_SCHEMA };
|