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
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
// Prepare the native source stores independently of OSV/NVD. Failed refreshes
|
|
3
3
|
// keep earlier observations and are returned as coverage, never clean verdicts.
|
|
4
4
|
const path=require('node:path');
|
|
5
|
-
const {openAdvisoryStore}=require('./
|
|
5
|
+
const {openAdvisoryStore}=require('./store');
|
|
6
6
|
function selectedNativeSources(options={}){
|
|
7
7
|
const requested=options.nativeSources||['cveproject','gcve'];if(!Array.isArray(requested)||requested.some(s=>!['cveproject','gcve'].includes(s)))throw Error('invalid native source selection');
|
|
8
8
|
return [...new Set(requested)].filter(s=>s==='cveproject'?!options.disableCveProject:!options.disableGcve&&options.gcve!==false);
|
|
9
9
|
}
|
|
10
10
|
async function prepareNativeSources(deps,options={}){
|
|
11
|
-
const cacheDir=options.cacheDir||require('
|
|
11
|
+
const cacheDir=options.cacheDir||require('../cache/directory').getCacheDir(),store=options.store||openAdvisoryStore({cacheDir}),close=!options.store;
|
|
12
12
|
const sources=selectedNativeSources(options),coverage=[],warnings=[],ttlMs=options.advisoryQueryTtlMs??4*3600000;
|
|
13
13
|
try{
|
|
14
|
+
const packages=require('../providers/cveproject/packages-proxy').packageIdentities(deps);
|
|
15
|
+
if(!packages.length)return {sources:[],coverage:[],warnings:[]};
|
|
14
16
|
for(const source of sources){
|
|
15
17
|
let refreshError=null;
|
|
16
18
|
const existing=store.getSourceCoverage(source,'*');
|
|
@@ -20,27 +22,28 @@ async function prepareNativeSources(deps,options={}){
|
|
|
20
22
|
try{
|
|
21
23
|
if(options.nativeSourceAdapters?.[source]) await options.nativeSourceAdapters[source]({deps,store,cacheDir,options});
|
|
22
24
|
else if(source==='gcve'){
|
|
23
|
-
const feed=require('
|
|
24
|
-
} else if(require('
|
|
25
|
+
const feed=require('../providers/gcve/feed');await feed.updateGcveIndex({...(options.gcveOptions||{}),cacheFile:path.join(cacheDir,'gcve-data','index.json'),fetcher:require('../providers').hasProxyRoute()?feed.proxyGcveFetcher:(options.fetcher||globalThis.fetch)});
|
|
26
|
+
} else if(require('../providers').hasProxyRoute()){
|
|
27
|
+
options.onCveProgress?.('Querying package advisories via proxy');
|
|
25
28
|
// Ask the fleet's typed native package index for all ecosystems. Older
|
|
26
29
|
// servers can still supply their legacy npm/Maven projections, while a
|
|
27
30
|
// failed generic lookup remains an explicit incomplete source.
|
|
28
|
-
try{await require('
|
|
31
|
+
try{await require('../providers/cveproject/packages-proxy').refreshPackageCves(deps,store,{ttlMs});}
|
|
29
32
|
catch(error){
|
|
30
|
-
if(require('
|
|
31
|
-
if([...deps.values()].some(d=>d.ecosystem==='maven' && d.provenance!=='binary')){const scanner=(require('
|
|
33
|
+
if(require('../providers/cveproject/npm-proxy').packageNames(deps).length)await require('../providers/cveproject/npm-proxy').refreshNpmCves(deps,store,{ttlMs});
|
|
34
|
+
if([...deps.values()].some(d=>d.ecosystem==='maven' && d.provenance!=='binary')){const scanner=(require('../codecs/maven.codec').nativeScanners||[]).find(x=>x.kind==='cve');if(scanner?.scan)await scanner.scan(deps,{hostedProxy:true,offline:false,queryTtlMs:ttlMs});}
|
|
32
35
|
throw error;
|
|
33
36
|
}
|
|
34
37
|
} else {
|
|
35
|
-
await require('
|
|
38
|
+
await require('../providers/cveproject/download').ensureCveIndex({force:!!options.forceUpdate,offline:false,ttlMs,cacheDir,onProgress:options.onCveProgress});
|
|
36
39
|
}
|
|
37
40
|
}catch(e){refreshError=e.message;warnings.push({type:'source-unavailable',code:'source-request-failed',source,status:e.status||null,reason:e.message,resources:[source],message:`${source} refresh failed: ${e.message}`});}
|
|
38
41
|
}
|
|
39
42
|
const current=store.getSourceCoverage(source,'*');
|
|
40
43
|
const exists=!!store.db.prepare('SELECT 1 AS n FROM advisory_records WHERE source=? LIMIT 1').get(source);
|
|
41
|
-
const identities=new Map(
|
|
44
|
+
const identities=new Map(packages.map(p=>[JSON.stringify([p.ecosystem,p.name]),{source,ecosystem:p.ecosystem,name:p.name,version:'*'}]));
|
|
42
45
|
const queries=[...identities.values()].map(tuple=>store.getQuery(tuple,{ttlMs})).filter(Boolean);
|
|
43
|
-
const scoped=identities.size>0 && queries.length===identities.size;
|
|
46
|
+
const scoped=identities.size>0 && queries.length===identities.size && queries.every(q=>q.complete!==false);
|
|
44
47
|
const scopedAt=scoped?Math.min(...queries.map(q=>q.fetchedAt)):null;
|
|
45
48
|
const fetchedAt=current?.fetchedAt || scopedAt;
|
|
46
49
|
const age=fetchedAt && Date.now()-fetchedAt;
|
|
@@ -49,10 +52,10 @@ async function prepareNativeSources(deps,options={}){
|
|
|
49
52
|
const available=exists || !!current || scoped;
|
|
50
53
|
const issue=refreshError?'refresh-failed':!available?'missing-source':invalidDate?'invalid-timestamp':declaredStale||(!offline&&expired)?'stale-source':null;
|
|
51
54
|
const complete=!!current?.complete&&!expired&&!declaredStale&&!invalidDate&&!refreshError;
|
|
52
|
-
const reason=refreshError || (!available?
|
|
55
|
+
const reason=refreshError || (!available?(offline ? `The offline auditor cache contains no ${source} snapshot or verified lookup for the selected packages.` : `${source} returned no verifiable package consultation.`):invalidDate?'Source collection timestamp is in the future':declaredStale?'The provider marked its source data stale':!offline&&expired?'Source evidence could not be refreshed':scoped?'Selected package identities checked':!current?.complete?'Prepared advisory records checked':expired?'Prepared source snapshot used offline':'Source snapshot consulted');
|
|
53
56
|
coverage.push({source,status:complete?'complete':available?'incomplete':'missing',complete,
|
|
54
57
|
execution:issue?(available?'partial':'not-run'):'completed',result:issue?'indeterminate':'available',
|
|
55
|
-
scope:scoped?'consulted-packages':'available-native-records',issue,fetchedAt:fetchedAt||null,freshness:expired?'expired':'current',reason});
|
|
58
|
+
scope:scoped?'consulted-packages':'available-native-records',issue,fetchedAt:fetchedAt||null,freshness:!fetchedAt?'unknown':expired?'expired':'current',reason});
|
|
56
59
|
}
|
|
57
60
|
return {sources,coverage,warnings};
|
|
58
61
|
} finally {if(close)store.close();}
|
|
@@ -6,7 +6,7 @@ const path = require('node:path');
|
|
|
6
6
|
const MAX_RECORD = 16 * 1024 * 1024;
|
|
7
7
|
|
|
8
8
|
function explicitNpmPackage(affected) {
|
|
9
|
-
const p=require('
|
|
9
|
+
const p=require('../providers/gcve/local-index').explicitPackage(affected);
|
|
10
10
|
if(p?.ecosystem==='npm')return p;
|
|
11
11
|
if(affected?.packageURL!=null || affected?.purl!=null)return null;
|
|
12
12
|
// Some CNA records use a package name with an explicit npm registry
|
|
@@ -23,7 +23,7 @@ function cveEnvelope(raw, { fetchedAt, provenance = {transport:'direct'} } = {})
|
|
|
23
23
|
if (!/^CVE-\d{4}-\d{4,}$/i.test(String(id || '')) || !['PUBLISHED','REJECTED','RESERVED'].includes(raw?.cveMetadata?.state)) throw new Error('invalid native CVEProject record');
|
|
24
24
|
const packages = [];
|
|
25
25
|
if (raw.cveMetadata.state === 'PUBLISHED') {
|
|
26
|
-
const projected = require('
|
|
26
|
+
const projected = require('../providers/cveproject/download').extractMavenRelevantCve(raw);
|
|
27
27
|
for (const a of projected?.affected || []) {
|
|
28
28
|
for (const name of (a.packageNames || [])) packages.push({ecosystem:'Maven',name});
|
|
29
29
|
if (a.product) packages.push({ecosystem:'CVEProduct',name:String(a.product).toLowerCase()});
|
|
@@ -39,7 +39,7 @@ function cveEnvelope(raw, { fetchedAt, provenance = {transport:'direct'} } = {})
|
|
|
39
39
|
return {source:'cveproject',id:id.toUpperCase(),document:raw,fetchedAt,provenance,packages};
|
|
40
40
|
}
|
|
41
41
|
function gcveEnvelope(stored, { provenance = {transport:'direct'} } = {}) {
|
|
42
|
-
const {identity}=require('
|
|
42
|
+
const {identity}=require('../providers/gcve/local-index');
|
|
43
43
|
const raw=stored?.raw, ident=identity(raw,stored?.gna), at=Date.parse(stored.collectedAt);
|
|
44
44
|
if (!Number.isSafeInteger(at) || at <= 0 || at > Date.now()+300000) throw new Error('invalid GCVE collection date');
|
|
45
45
|
const packages=[];
|
|
@@ -80,9 +80,10 @@ async function importGcveIndex(store,index,{provenance={transport:'direct'}}={})
|
|
|
80
80
|
await store.importEnvelopes(entries(),{coverages:[{source:'gcve',ecosystem:'*',fetchedAt,complete,provenance}]});
|
|
81
81
|
return {count:index.records.length,complete};
|
|
82
82
|
}
|
|
83
|
-
async function importCveDirectory(store, root, {fetchedAt=Date.now(),provenance={transport:'direct'}}={}) {
|
|
83
|
+
async function importCveDirectory(store, root, {fetchedAt=Date.now(),provenance={transport:'direct'},onProgress}={}) {
|
|
84
84
|
async function* entries() {
|
|
85
85
|
const dirs=[root];
|
|
86
|
+
let processed=0;
|
|
86
87
|
while (dirs.length) {
|
|
87
88
|
const dir=dirs.pop();
|
|
88
89
|
for (const entry of await fs.promises.readdir(dir,{withFileTypes:true})) {
|
|
@@ -93,6 +94,7 @@ async function importCveDirectory(store, root, {fetchedAt=Date.now(),provenance=
|
|
|
93
94
|
const raw=JSON.parse(await fs.promises.readFile(file,'utf8'));
|
|
94
95
|
if (raw?.cveMetadata?.cveId?.toLowerCase() !== entry.name.slice(0,-5).toLowerCase()) throw new Error('CVEProject record filename mismatch');
|
|
95
96
|
yield cveEnvelope(raw,{fetchedAt,provenance});
|
|
97
|
+
if (++processed % 5000 === 0) onProgress?.(processed);
|
|
96
98
|
}
|
|
97
99
|
}
|
|
98
100
|
}
|
|
@@ -117,7 +119,7 @@ module.exports.projectedCveEnvelope=projectedCveEnvelope;
|
|
|
117
119
|
* for which any native revision or rejection is known. Legacy lacks per-record
|
|
118
120
|
* revision stamps, so its coverage remains explicitly partial. */
|
|
119
121
|
function matchCveStore(deps, store, legacyIndex = null) {
|
|
120
|
-
const {newIndex,addToIndex,extractMavenRelevantCve}=require('
|
|
122
|
+
const {newIndex,addToIndex,extractMavenRelevantCve}=require('../providers/cveproject/download');
|
|
121
123
|
const {matchDepsAgainstCves}=require('./cve-match');
|
|
122
124
|
const index=newIndex(), legacyStoreIndex=newIndex(), seen=new Set(), legacySeen=new Set();
|
|
123
125
|
for (const dep of deps.values()) {
|
|
@@ -160,13 +162,13 @@ module.exports.matchCveStore=matchCveStore;
|
|
|
160
162
|
// version strictly above every affected upper bound, a matching independent
|
|
161
163
|
// OSV advisory can corroborate the negative without changing CVE semantics.
|
|
162
164
|
function corroboratedNpmNegative(store, record, name, version, entries) {
|
|
163
|
-
const compare=require('
|
|
165
|
+
const compare=require('../providers/osv/db').compareSemver;
|
|
164
166
|
if (!entries.length || entries.some(a => a.platforms?.length || a.defaultStatus !== 'unaffected' ||
|
|
165
167
|
!Array.isArray(a.versions) || !a.versions.length || a.versions.some(v =>
|
|
166
168
|
!v || v.status !== 'affected' || String(v.versionType || '').toLowerCase() !== 'custom' ||
|
|
167
169
|
v.changes?.length || (!!v.lessThan === !!v.lessThanOrEqual) ||
|
|
168
170
|
compare(String(version), String(v.lessThan || v.lessThanOrEqual)) !== 1))) return false;
|
|
169
|
-
const {packageName}=require('./
|
|
171
|
+
const {packageName}=require('./store'), {vulnVerdict}=require('../providers/osv/db');
|
|
170
172
|
const docs=store.getPackageRecords('npm',name,{source:'osv'}).filter(item => {
|
|
171
173
|
const doc=item.document;
|
|
172
174
|
return !item.withdrawnAt && !doc?.withdrawn && [doc?.id,...(doc?.aliases || [])].includes(record.id);
|
|
@@ -182,10 +184,10 @@ function corroboratedNpmNegative(store, record, name, version, entries) {
|
|
|
182
184
|
/** Match explicit npm PURLs in native CVEProject records. A missing package
|
|
183
185
|
* or undecidable range is never interpreted as proof that it is unaffected. */
|
|
184
186
|
function matchNativeNpmCves(deps, store) {
|
|
185
|
-
const {extractAffectedRanges}=require('
|
|
186
|
-
const {affectedVerdict}=require('
|
|
187
|
-
const {osvPkgName}=require('
|
|
188
|
-
const {packageName}=require('./
|
|
187
|
+
const {extractAffectedRanges}=require('../providers/cveproject/download');
|
|
188
|
+
const {affectedVerdict}=require('../providers/cveproject/version-verdict');
|
|
189
|
+
const {osvPkgName}=require('../providers/osv/query');
|
|
190
|
+
const {packageName}=require('./store');
|
|
189
191
|
const matches=[], unknown=[], seen=new Set();
|
|
190
192
|
for(const dep of deps.values()) {
|
|
191
193
|
if(!['npm','yarn'].includes(dep.ecosystem) || dep.provenance==='binary')continue;
|
|
@@ -232,8 +234,8 @@ module.exports.matchNativeNpmCves=matchNativeNpmCves;
|
|
|
232
234
|
/** Use the existing GCVE matcher on native candidates and filter legacy IDs
|
|
233
235
|
* superseded by any native revision, including rejected records. */
|
|
234
236
|
function matchGcveStore(deps, store, legacyIndex = null) {
|
|
235
|
-
const {buildGcveIndex,matchGcveDeps}=require('
|
|
236
|
-
const {osvEcosystemFor,osvPkgName}=require('
|
|
237
|
+
const {buildGcveIndex,matchGcveDeps}=require('../providers/gcve/local-index');
|
|
238
|
+
const {osvEcosystemFor,osvPkgName}=require('../providers/osv/query');
|
|
237
239
|
const native=new Map();
|
|
238
240
|
for (const dep of deps.values()) {
|
|
239
241
|
if (dep.provenance === 'binary') continue;
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
const fs=require('node:fs');
|
|
4
4
|
const path=require('node:path');
|
|
5
|
-
const {openCacheDb}=require('
|
|
6
|
-
const {compress,decompress}=require('
|
|
7
|
-
const rules=require('./
|
|
5
|
+
const {openCacheDb}=require('../cache/db');
|
|
6
|
+
const {compress,decompress}=require('../cache/advisory-compression');
|
|
7
|
+
const rules=require('./store');
|
|
8
8
|
const {validateRecord,validateQuery,validateCoverage,packageName,packageKeys,queryKey,coverageKey,advisoryId,queryCoversRecord,isWithdrawn,revision,wins,hash,key}=rules;
|
|
9
9
|
const DEFAULT_QUERY_TTL_MS=4 * 3600e3;
|
|
10
10
|
const parse=value=>JSON.parse(value);
|
|
11
11
|
const text=value=>JSON.stringify(value);
|
|
12
12
|
|
|
13
13
|
class SqliteAdvisoryStore {
|
|
14
|
-
constructor({cacheDir=require('
|
|
14
|
+
constructor({cacheDir=require('../cache/directory').getCacheDir()}={}){
|
|
15
15
|
this.cacheDir=cacheDir;
|
|
16
16
|
this.db=openCacheDb({cacheDir});
|
|
17
17
|
}
|
|
@@ -103,7 +103,7 @@ class SqliteAdvisoryStore {
|
|
|
103
103
|
let coverageEcosystem=tuple.ecosystem;
|
|
104
104
|
let current=this.db.prepare("SELECT * FROM advisory_coverage WHERE source=? AND ecosystem=? AND slot='current'").get(source,coverageEcosystem);
|
|
105
105
|
if(!current && source==='osv' && tuple.name){
|
|
106
|
-
coverageEcosystem=require('
|
|
106
|
+
coverageEcosystem=require('../cache/airgap-project').packageScope(tuple.ecosystem,tuple.name);
|
|
107
107
|
current=this.db.prepare("SELECT * FROM advisory_coverage WHERE source=? AND ecosystem=? AND slot='current'").get(source,coverageEcosystem);
|
|
108
108
|
}
|
|
109
109
|
if(!current)return null;
|
|
@@ -147,7 +147,7 @@ function* journalTransactions(file, { allowTail = false } = {}) {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
class AdvisoryStore {
|
|
150
|
-
constructor({ cacheDir = require('
|
|
150
|
+
constructor({ cacheDir = require('../cache/directory').getCacheDir() } = {}) {
|
|
151
151
|
this.directory = path.join(cacheDir, 'advisory-store');
|
|
152
152
|
this.journal = path.join(this.directory, 'events.jsonl');
|
|
153
153
|
this.checkpoint = path.join(this.directory, 'checkpoint.json');
|
|
@@ -480,5 +480,5 @@ class AdvisoryStore {
|
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
482
|
|
|
483
|
-
function openAdvisoryStore(options) { return require('./
|
|
483
|
+
function openAdvisoryStore(options) { return require('./store-sqlite').openAdvisoryStore(options); }
|
|
484
484
|
module.exports = { openAdvisoryStore, AdvisoryStore, DEFAULT_QUERY_TTL_MS, validateRecord, validateQuery, validateCoverage, packageName, packageKeys, queryKey, coverageKey, recordKey, advisoryId, queryCoversRecord, isWithdrawn, selectAdvisoryRecord, revision, wins, hash, key, journalTransactions };
|
|
@@ -53,7 +53,9 @@ function buildApplicationRelations(srcRoot, applications = [], components = [],
|
|
|
53
53
|
depCoordKey: item.dep.coordKey, version: item.occurrence.version,
|
|
54
54
|
manifestPath: item.occurrence.manifestPath,
|
|
55
55
|
applicationRelation: !component ? "unknown" :
|
|
56
|
-
component.coord?.toLowerCase() === item.coord && TARGET_KINDS.has(component.kind)
|
|
56
|
+
(component.coord?.toLowerCase() === item.coord && TARGET_KINDS.has(component.kind)) ||
|
|
57
|
+
(["core","framework"].includes(component.kind) && path.posix.dirname(item.relManifest) === app.root &&
|
|
58
|
+
item.occurrence.managerRelation === "direct") ? "direct" : "indirect",
|
|
57
59
|
attributionStatus: component ? "confirmed" : "unknown", proof,
|
|
58
60
|
dependencyPath,
|
|
59
61
|
});
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const nativePath = require('node:path');
|
|
4
|
+
const path = nativePath.posix;
|
|
5
|
+
const extensionKinds = new Set(['module','plugin','theme','bundle','component','profile','extension','mu-plugin','drop-in','template','package']);
|
|
6
|
+
const isExtension = component => extensionKinds.has(component.kind);
|
|
7
|
+
const within = (file,dir) => dir === '.' || file === dir || file.startsWith(dir+'/');
|
|
8
|
+
|
|
9
|
+
// Recognise the CMS's extension directories even when a particular extension
|
|
10
|
+
// has no readable version marker. A directory name alone is no catalogue identity.
|
|
11
|
+
const directories = {
|
|
12
|
+
ghost: /^content\/themes(?:\/[^/]+)?(?:\/|$)/,
|
|
13
|
+
prestashop: /^(?:(?:admin[^/]*\/)?themes|modules)(?:\/[^/]+)?(?:\/|$)/,
|
|
14
|
+
wordpress: /^(?:plugins|mu-plugins|themes)(?:\/[^/]+)?(?:\/|$)/,
|
|
15
|
+
drupal: /^(?:(?:core|sites\/[^/]+)\/)?(?:modules|themes|profiles)(?:\/(?:contrib|custom))?(?:\/[^/]+)?(?:\/|$)/,
|
|
16
|
+
joomla: /^(?:administrator\/)?(?:plugins(?:\/[^/]+)?|templates|modules|components)(?:\/[^/]+)?(?:\/|$)/,
|
|
17
|
+
typo3: /^(?:typo3conf\/ext|typo3\/sysext)(?:\/[^/]+)?(?:\/|$)/,
|
|
18
|
+
magento: /^app\/(?:code(?:\/[^/]+){0,2}|design(?:\/[^/]+){0,3})(?:\/|$)/,
|
|
19
|
+
spip: /^(?:plugins|plugins-dist)(?:\/[^/]+)?(?:\/|$)/,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function extensionLayout(applications, inventory) {
|
|
23
|
+
const apps = applications.filter(a=>a.type !== 'project').slice().sort((a,b)=>b.root.length-a.root.length);
|
|
24
|
+
const byApp = new Map();
|
|
25
|
+
const lockedExtensions = new Set();
|
|
26
|
+
for (const c of inventory) if (isExtension(c) && c.coord) {
|
|
27
|
+
for (const proof of c.evidence || []) if (proof.path && path.basename(proof.path)==='composer.lock') {
|
|
28
|
+
lockedExtensions.add(JSON.stringify([proof.path,c.coord.toLowerCase(),c.versionConflict?.locked || c.version]));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (const c of inventory) if (isExtension(c) && c.path) {
|
|
32
|
+
if (!byApp.has(c.applicationId)) byApp.set(c.applicationId,new Map());
|
|
33
|
+
byApp.get(c.applicationId).set(c.path,c);
|
|
34
|
+
}
|
|
35
|
+
function lookup(app,file,directory=false) {
|
|
36
|
+
if (!file || path.isAbsolute(file) || file==='..' || file.startsWith('../') || file===app.root || !within(file,app.root)) return null;
|
|
37
|
+
const owners = byApp.get(app.id);
|
|
38
|
+
for (let dir=file; owners && dir!==app.root && dir!=='.' && dir!=='/'; dir=path.dirname(dir)) {
|
|
39
|
+
if (owners.has(dir)) return {app,component:owners.get(dir)};
|
|
40
|
+
}
|
|
41
|
+
const base = app.type==='wordpress' ? app.contentRoot || path.join(app.root,'wp-content') : app.documentRoot || app.root;
|
|
42
|
+
const rel = path.relative(base,directory ? file : path.dirname(file));
|
|
43
|
+
const expression = Object.hasOwn(directories,app.type) ? directories[app.type] : null;
|
|
44
|
+
const match = expression?.exec(rel);
|
|
45
|
+
if (!match) {
|
|
46
|
+
const site = path.relative(app.documentRoot || app.root,file);
|
|
47
|
+
if ((app.type==='wordpress' && /^(?:wp-includes|wp-admin)(?:\/|$)/.test(site)) ||
|
|
48
|
+
(app.type==='drupal' && /^core(?:\/|$)/.test(site))) return {app,core:true};
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
// Keep the path in the proof even if the plugin could not identify the module.
|
|
52
|
+
return {app,path:path.join(base,match[0].replace(/\/$/,''))};
|
|
53
|
+
}
|
|
54
|
+
function owner(file,directory=false) {
|
|
55
|
+
for (const app of apps) {
|
|
56
|
+
const match = lookup(app,file,directory);
|
|
57
|
+
if (match) return match;
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
function lockedExtension(dep) {
|
|
62
|
+
return dep.ecosystem==='composer' && dep.provenance==='lockfile' &&
|
|
63
|
+
lockedExtensions.has(JSON.stringify([dep.artifactPath,[dep.namespace,dep.name].filter(Boolean).join('/').toLowerCase(),dep.version]));
|
|
64
|
+
}
|
|
65
|
+
return {lookup,owner,lockedExtension};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Application-level ownership is separate from the package manager's directness
|
|
69
|
+
// within the module's own manifest. Preserve both for private-module remediation.
|
|
70
|
+
function attributeLayoutFindings(matches, applications, inventory, srcRoot) {
|
|
71
|
+
if (!applications.length) return;
|
|
72
|
+
const layout = extensionLayout(applications,inventory);
|
|
73
|
+
const modules = new Set(inventory.filter(isExtension).map(c=>c.id));
|
|
74
|
+
const roots = new Map(applications.map(app=>[app.root,app]));
|
|
75
|
+
for (const m of matches) {
|
|
76
|
+
const dep = m.dep;
|
|
77
|
+
if (!dep || dep.ecosystem==='system' || dep.systemSection==='runtime' ||
|
|
78
|
+
['system','global'].includes(dep.imageSource?.category) || (!srcRoot && !dep.artifactTargetId)) continue;
|
|
79
|
+
if (srcRoot && dep.artifactTargetId) continue;
|
|
80
|
+
const files = dep.artifactPath ? [dep.artifactPath] : dep.manifestPaths || [];
|
|
81
|
+
const paths = files.map(file=>srcRoot && nativePath.isAbsolute(file)
|
|
82
|
+
? nativePath.relative(srcRoot,file).split(nativePath.sep).join('/') : file);
|
|
83
|
+
if (!paths.length || paths.some(f=>!f || f==='..' || f.startsWith('../'))) continue;
|
|
84
|
+
const owner = layout.owner(paths[0]);
|
|
85
|
+
if (owner && paths.every(f=>{
|
|
86
|
+
const o=layout.lookup(owner.app,f);
|
|
87
|
+
return o && (o.component?.id || o.path)===(owner.component?.id || owner.path);
|
|
88
|
+
})) {
|
|
89
|
+
if ((owner.core && dep.provenance==='application') || m.ownerComponentIds?.some(id=>modules.has(id))) continue;
|
|
90
|
+
const self = moduleSelf(dep,owner.component);
|
|
91
|
+
m.applicationIds=[owner.app.id];
|
|
92
|
+
m.ownerComponentIds=owner.component ? [owner.component.id] : [];
|
|
93
|
+
m.applicationRelation=self ? 'direct' : 'indirect';
|
|
94
|
+
m.applicationExposures=[{applicationId:owner.app.id,ownerComponentIds:m.ownerComponentIds,applicationRelation:m.applicationRelation}];
|
|
95
|
+
m.attributionStatus=owner.component || owner.core ? 'confirmed' : 'unknown';
|
|
96
|
+
} else if (!m.applicationIds?.length && paths.every(f=>path.dirname(f)===path.dirname(paths[0]))) {
|
|
97
|
+
const app=roots.get(path.dirname(paths[0]));
|
|
98
|
+
if (app) {
|
|
99
|
+
m.applicationIds=[app.id];
|
|
100
|
+
m.applicationRelation=managerRelation(dep);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function managerRelation(dep) {
|
|
107
|
+
const declared = dep.occurrences?.find(o=>o.version===dep.version && dep.manifestPaths?.includes(o.manifestPath))?.managerRelation || dep.managerRelation;
|
|
108
|
+
if (declared==='direct') return 'direct';
|
|
109
|
+
if (declared==='transitive' || declared==='indirect' || dep.scope==='transitive') return 'indirect';
|
|
110
|
+
if (declared==='unknown' || (dep.ecosystem==='composer' && dep.provenance==='lockfile')) return 'unknown';
|
|
111
|
+
if (dep.systemSection==='project' || ['prod','dev','compile','optional','peer','test'].includes(dep.scope)) return 'direct';
|
|
112
|
+
return 'unknown';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function moduleSelf(dep,component) {
|
|
116
|
+
return !!component?.coord && component.coord.toLowerCase()===[dep.namespace,dep.name].filter(Boolean).join('/').toLowerCase() &&
|
|
117
|
+
(!component.version || component.version===dep.version);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function applyExtensionScope(dep,layout) {
|
|
121
|
+
if (!dep.systemApplicationIds?.length || dep.systemSection==='runtime') return;
|
|
122
|
+
const owner = layout.owner(dep.artifactPath);
|
|
123
|
+
if (!owner && !layout.lockedExtension(dep)) return;
|
|
124
|
+
if (!dep.managerRelation && dep.provenance==='lockfile') dep.managerRelation=managerRelation(dep);
|
|
125
|
+
const self = !owner || moduleSelf(dep,owner.component);
|
|
126
|
+
if (self && owner?.app.type==='ghost' && owner.component?.kind==='theme' && dep.provenance==='installed' &&
|
|
127
|
+
dep.artifactPath===path.join(owner.component.path,'package.json')) dep.registryIdentity='cms-theme';
|
|
128
|
+
dep.systemSection=self ? 'project' : 'dependency';
|
|
129
|
+
dep.imageRole=self ? 'direct' : 'transitive';
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Advisory plugins assess one installed application at a time. Keep the
|
|
133
|
+
// original physical finding ID and evidence when displaying an embedded app.
|
|
134
|
+
function reparentAssessments(state, embedded) {
|
|
135
|
+
const parents = new Map(embedded.map(entry=>[entry.app.id,entry]));
|
|
136
|
+
for (const key of ['coverage','diagnostics']) for (const record of state[key] || []) {
|
|
137
|
+
const owner = parents.get(record.applicationId);
|
|
138
|
+
if (!owner) continue;
|
|
139
|
+
record.embeddedApplicationId = record.applicationId;
|
|
140
|
+
record.applicationId = owner.applicationId;
|
|
141
|
+
if (record.componentId) {
|
|
142
|
+
record.embeddedComponentId = record.componentId;
|
|
143
|
+
record.componentId = owner.ownerComponentId;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (const m of state.findings || []) {
|
|
147
|
+
if (!m.applicationIds?.some(id=>parents.has(id))) continue;
|
|
148
|
+
const exposures = m.applicationIds.map(id=>{
|
|
149
|
+
const owner = parents.get(id);
|
|
150
|
+
if (owner) return {applicationId:owner.applicationId,ownerComponentIds:owner.ownerComponentId ? [owner.ownerComponentId] : [],
|
|
151
|
+
applicationRelation:'indirect'};
|
|
152
|
+
return m.applicationExposures?.find(e=>e.applicationId===id) ||
|
|
153
|
+
{applicationId:id,ownerComponentIds:m.ownerComponentIds || [],applicationRelation:m.applicationRelation};
|
|
154
|
+
});
|
|
155
|
+
m.applicationExposures = exposures;
|
|
156
|
+
m.applicationIds = [...new Set(exposures.map(e=>e.applicationId))];
|
|
157
|
+
m.ownerComponentIds = [...new Set(exposures.flatMap(e=>e.ownerComponentIds))];
|
|
158
|
+
m.applicationRelation = exposures.some(e=>e.applicationRelation==='direct') ? 'direct' : 'indirect';
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Drop a descriptor- or framework-derived instance inside an extension. All
|
|
163
|
+
// other proven applications (including independent nested sites) keep their IDs.
|
|
164
|
+
function reconcileApplications(state, deps = []) {
|
|
165
|
+
const layout = extensionLayout(state.applications,state.inventory);
|
|
166
|
+
const replaced = new Map();
|
|
167
|
+
for (const a of state.applications) {
|
|
168
|
+
const match = layout.owner(a.root,true);
|
|
169
|
+
if (match) replaced.set(a.id,match.app.id);
|
|
170
|
+
}
|
|
171
|
+
if (!replaced.size) return;
|
|
172
|
+
function parent(id) {
|
|
173
|
+
while (replaced.has(id)) id=replaced.get(id);
|
|
174
|
+
return id;
|
|
175
|
+
}
|
|
176
|
+
const byId = new Map(state.applications.map(a=>[a.id,a]));
|
|
177
|
+
const embedded = [];
|
|
178
|
+
for (const app of state.applications) {
|
|
179
|
+
if (!replaced.has(app.id) || !app.pluginId) continue;
|
|
180
|
+
const applicationId = parent(app.id);
|
|
181
|
+
const component = layout.lookup(byId.get(applicationId),app.root,true)?.component;
|
|
182
|
+
embedded.push({app,applicationId,ownerComponentId:component?.id || null,
|
|
183
|
+
inventory:state.inventory.filter(c=>c.applicationId===app.id)});
|
|
184
|
+
}
|
|
185
|
+
if (embedded.length) {
|
|
186
|
+
state.embeddedApplications = [...(state.embeddedApplications || []),...embedded];
|
|
187
|
+
reparentAssessments(state,embedded);
|
|
188
|
+
}
|
|
189
|
+
state.applications = state.applications.filter(a=>!replaced.has(a.id));
|
|
190
|
+
state.inventory = state.inventory.filter(c=>!replaced.has(c.applicationId));
|
|
191
|
+
for (const key of ['relations','diagnostics','coverage']) if (state[key])
|
|
192
|
+
state[key]=state[key].filter(c=>!replaced.has(c.applicationId));
|
|
193
|
+
if (state.findings) state.findings=state.findings.filter(m=>!m.applicationIds?.length || m.applicationIds.some(id=>!replaced.has(id)));
|
|
194
|
+
for (const dep of deps) if (dep.systemApplicationIds?.some(id=>replaced.has(id)))
|
|
195
|
+
dep.systemApplicationIds=[...new Set(dep.systemApplicationIds.map(parent))];
|
|
196
|
+
return replaced;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
module.exports={reparentAssessments,isExtension,extensionLayout,reconcileApplications,attributeLayoutFindings,managerRelation,moduleSelf,applyExtensionScope};
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
const { responseFetchedAt } = require("../providers/common");
|
|
8
8
|
const crypto = require("node:crypto");
|
|
9
|
-
const { indexFeed } = require("
|
|
10
|
-
const { validateSnapshot: validateGithubAdvisories } = require("
|
|
11
|
-
const { validateChecksums } = require("
|
|
9
|
+
const { indexFeed } = require("../providers/wordfence/v3");
|
|
10
|
+
const { validateSnapshot: validateGithubAdvisories } = require("../providers/github/advisories");
|
|
11
|
+
const { validateChecksums } = require("../providers/wordpress/checksums");
|
|
12
12
|
|
|
13
13
|
const DRUPAL_ADVISORIES_URL = "https://packages.drupal.org/8/security-advisories";
|
|
14
14
|
const WORDFENCE_PRODUCTION_URL = "https://www.wordfence.com/api/intelligence/v3/vulnerabilities/production";
|
|
@@ -37,7 +37,7 @@ async function fetchDrupalAdvisories(packages = [], { fetchImpl = globalThis.fet
|
|
|
37
37
|
const url = new URL(apiUrl);
|
|
38
38
|
for (const pkg of queried) url.searchParams.append("packages[]", pkg);
|
|
39
39
|
const { body, sha256, fetchedAt } = await responseJson(await require("../providers").getResource("drupal", "advisories", { packages: queried },
|
|
40
|
-
{ fetcher: fetchImpl,
|
|
40
|
+
{ fetcher: fetchImpl, requestTimeoutMs: 60000,
|
|
41
41
|
...(apiUrl === DRUPAL_ADVISORIES_URL ? {} : { urlOverride: url.toString(), direct: true }) }),
|
|
42
42
|
"Drupal security-advisories");
|
|
43
43
|
meta.collectedAt = new Date(Math.min(fetchedAt, now)).toISOString();
|
|
@@ -74,13 +74,13 @@ async function fetchWordfenceFeed(url, { fetchImpl = globalThis.fetch, now = Dat
|
|
|
74
74
|
if (require("../providers").hasProxyRoute()) {
|
|
75
75
|
if (sourceUrl !== WORDFENCE_PRODUCTION_URL)
|
|
76
76
|
throw new Error("Wordfence proxy projections require the official source; direct bulk fallback is unavailable");
|
|
77
|
-
return require("
|
|
77
|
+
return require("../providers/wordfence/client").fetchWordfenceProjection(components, { fetchImpl, now, apiKey: key, software });
|
|
78
78
|
}
|
|
79
79
|
const proxyCredentials = sourceUrl === WORDFENCE_PRODUCTION_URL && require("../providers").hasProxyRoute();
|
|
80
80
|
if (!key && !proxyCredentials)
|
|
81
81
|
throw new Error("Wordfence live scan requires an API key (--wordfence-api-key or WORDFENCE_API_KEY), or the official feed via --proxy-cache with a server key");
|
|
82
82
|
const response = await require("../providers").getResource("wordfence", "production-feed", {}, {
|
|
83
|
-
fetcher: fetchImpl,
|
|
83
|
+
fetcher: fetchImpl, requestTimeoutMs: 120000, headers: key ? { Authorization: `Bearer ${key}` } : {},
|
|
84
84
|
...(sourceUrl === WORDFENCE_PRODUCTION_URL ? {} : { urlOverride: sourceUrl, direct: true }),
|
|
85
85
|
});
|
|
86
86
|
if (!response?.ok && !key && proxyCredentials)
|
|
@@ -117,7 +117,7 @@ async function fetchGithubAdvisories(repo, { fetchImpl = globalThis.fetch, apiUr
|
|
|
117
117
|
const requestParams = { repo, page, perPage: 100 };
|
|
118
118
|
const canonicalUrl = require("../providers").getProvider("github").build("publisher-advisories", requestParams).url;
|
|
119
119
|
const response = await require("../providers").getResource("github", "publisher-advisories", requestParams,
|
|
120
|
-
{ fetcher: fetchImpl,
|
|
120
|
+
{ fetcher: fetchImpl, requestTimeoutMs: 60000,
|
|
121
121
|
headers: { Accept: "application/vnd.github+json", "User-Agent": "vigievuln-github-advisories" },
|
|
122
122
|
...(url === canonicalUrl ? {} : { urlOverride: url, direct: true }) });
|
|
123
123
|
const { body, fetchedAt } = await responseJson(response, "Github security-advisories");
|
|
@@ -141,14 +141,14 @@ async function fetchGithubAdvisories(repo, { fetchImpl = globalThis.fetch, apiUr
|
|
|
141
141
|
* instead of producing a bogus comparison against an unusable reference.
|
|
142
142
|
*/
|
|
143
143
|
async function fetchWordpressChecksums(version, locale = "en_US", { fetchImpl = globalThis.fetch,
|
|
144
|
-
apiUrl = require("
|
|
144
|
+
apiUrl = require("../providers/wordpress/checksums").WP_CHECKSUMS_API, now = Date.now() } = {}) {
|
|
145
145
|
const cleanVersion = String(version || "").trim();
|
|
146
146
|
if (!cleanVersion) throw new Error("WordPress checksums require a core version");
|
|
147
147
|
const url = `${apiUrl}?version=${encodeURIComponent(cleanVersion)}&locale=${encodeURIComponent(String(locale || "en_US"))}`;
|
|
148
148
|
const { body, sha256, fetchedAt } = await responseJson(await require("../providers").getResource("wordpress", "checksums",
|
|
149
149
|
{ version: cleanVersion, locale: String(locale || "en_US") },
|
|
150
|
-
{ fetcher: fetchImpl,
|
|
151
|
-
...(apiUrl === require("
|
|
150
|
+
{ fetcher: fetchImpl, requestTimeoutMs: 60000,
|
|
151
|
+
...(apiUrl === require("../providers/wordpress/checksums").WP_CHECKSUMS_API ? {} : { urlOverride: url, direct: true }) }),
|
|
152
152
|
"WordPress checksums");
|
|
153
153
|
const collectedAt = new Date(Math.min(fetchedAt, now)).toISOString();
|
|
154
154
|
const meta = { collectedAt, completeness: "tool-fetched", sourceUrl: url };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const path = require("node:path");
|
|
2
2
|
const fs = require("node:fs");
|
|
3
3
|
const yaml = require("js-yaml");
|
|
4
|
-
const { assessDrupalAdvisories } = require("
|
|
5
|
-
const { fetchDrupalAdvisories, mergeDrupalSnapshots, writeSnapshotAtomically } = require("../
|
|
4
|
+
const { assessDrupalAdvisories } = require("../../providers/drupal/advisories");
|
|
5
|
+
const { fetchDrupalAdvisories, mergeDrupalSnapshots, writeSnapshotAtomically } = require("../live-snapshot");
|
|
6
6
|
const { localSourceSnapshot } = require("./wave2-common");
|
|
7
7
|
|
|
8
8
|
const join = (dir, file) => dir === "." ? file : `${dir}/${file}`;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const path=require('node:path').posix;
|
|
3
|
+
function manifest(ctx,dir){
|
|
4
|
+
const file=path.join(dir,'package.json');
|
|
5
|
+
try{return JSON.parse(ctx.readText(file,1024*1024));}catch{return null;}
|
|
6
|
+
}
|
|
7
|
+
module.exports={
|
|
8
|
+
id:'ghost',apiVersion:1,version:'1.0.0',label:'Ghost',supportedLayouts:['installation','source'],
|
|
9
|
+
requiredCodecs:['npm'],providerIds:[],capabilities:{inventory:'qualified'},
|
|
10
|
+
discover(ctx){
|
|
11
|
+
return ctx.index.directories.filter(dir=>ctx.index.hasFile(path.join(dir,'core/boot.js')) &&
|
|
12
|
+
ctx.index.hasFile(path.join(dir,'index.js')) && manifest(ctx,dir)?.name==='ghost')
|
|
13
|
+
.map(root=>({root,evidence:[{path:path.join(root,'package.json'),field:'name'},{path:path.join(root,'core/boot.js')}]}));
|
|
14
|
+
},
|
|
15
|
+
collect(app,ctx){
|
|
16
|
+
const data=manifest(ctx,app.root);
|
|
17
|
+
const components=[{id:app.id+':core',applicationId:app.id,kind:'core',name:'Ghost',coord:'ghost',
|
|
18
|
+
version:data?.version || null,visibility:'public',path:app.root,
|
|
19
|
+
evidence:[{path:path.join(app.root,'package.json'),field:'version'}]}];
|
|
20
|
+
const themes=path.join(app.root,'content/themes');
|
|
21
|
+
for(const dir of ctx.index.directories){
|
|
22
|
+
if(path.dirname(dir)!==themes || !ctx.index.hasFile(path.join(dir,'package.json')))continue;
|
|
23
|
+
const theme=manifest(ctx,dir);
|
|
24
|
+
if(!theme?.name || !theme.engines?.ghost)continue;
|
|
25
|
+
const repository = typeof theme.repository === 'string' ? theme.repository : theme.repository?.url;
|
|
26
|
+
const repo = /^https:\/\/github\.com\/TryGhost\/(Casper|Source)(?:\.git)?\/?$/i.exec(repository || '')?.[1]?.toLowerCase();
|
|
27
|
+
const official = repo && repo === String(theme.name).toLowerCase() && !ctx.isPrivatePath(dir);
|
|
28
|
+
components.push({...(official ? {releaseRepository:'TryGhost/'+(repo==='casper'?'Casper':'Source')} : {}),id:app.id+':theme:'+path.basename(dir),applicationId:app.id,kind:'theme',name:theme.name,coord:theme.name,
|
|
29
|
+
version:theme.version || null,path:dir,visibility:ctx.isPrivatePath(dir)?'private':official?'public':'unknown',activation:'unknown',
|
|
30
|
+
evidence:[{path:path.join(dir,'package.json'),field:'version'}]});
|
|
31
|
+
}
|
|
32
|
+
return {components,coverage:[{applicationId:app.id,capability:'inventory',execution:'completed',result:'not-applicable',
|
|
33
|
+
expected:components.length,executed:components.length}],diagnostics:[]};
|
|
34
|
+
},
|
|
35
|
+
assess(){return [];},remediation(){return null;},
|
|
36
|
+
};
|
|
@@ -9,7 +9,7 @@ const magento = require("./magento");
|
|
|
9
9
|
const spip = require("./spip");
|
|
10
10
|
const { assertPluginShape } = require("./plugin.interface");
|
|
11
11
|
|
|
12
|
-
const PLUGINS = [symfony, wordpress, drupal, laravel, joomla, prestashop, typo3, magento, spip];
|
|
12
|
+
const PLUGINS = [symfony, wordpress, drupal, laravel, joomla, prestashop, typo3, magento, spip, require('./ghost'), require('./redmine')];
|
|
13
13
|
for (const plugin of PLUGINS) assertPluginShape(plugin);
|
|
14
14
|
|
|
15
15
|
function allApplicationPlugins() { return PLUGINS.slice(); }
|