diff --git a/scripts/generateAndCheckSBOM.js b/scripts/generateAndCheckSBOM.js index 051a3d880..48f5b167f 100755 --- a/scripts/generateAndCheckSBOM.js +++ b/scripts/generateAndCheckSBOM.js @@ -206,6 +206,20 @@ function lookupVerdicts(entries, purl, ids, platformVersion) { const listed = ids.length > 0 && missing.length === 0; return { listed, missing, entries: matching.filter(e => names(e).some(id => ids.includes(id))) }; } + +// Whether a finding is known, asked of the whole document: the verdicts that silence it, `entries`, +// and the `risk` verdicts on packages that come with Spring Boot, `upstream`, which count only on +// the lines their `owned_lines` names. `owner` is 'spring-boot' when one of those took part, so the +// build can say the version comes from the reader's Spring Boot and not fail over it. The line is +// read from the version the build is judged as, `24.10.16` -> `24.10`. +function lookupKnown(doc, purl, ids, platformVersion) { + const line = String(platformVersion).split('-')[0].split('.').slice(0, 2).join('.'); + const upstream = (doc.upstream || []).filter(e => (e.owned_lines || []).includes(line)); + const found = lookupVerdicts((doc.entries || []).concat(upstream), purl, ids, platformVersion); + const owned = found.entries.filter(e => e.owner); + return { listed: found.listed, missing: found.missing, entries: found.entries, + owner: found.listed && owned.length ? owned[0].owner : null }; +} // ---- end of the copy async function loadCveStatus(version) { @@ -225,8 +239,8 @@ async function loadCveStatus(version) { log(`${CVE_STATUS_URL} has schema ${doc.schema}, expected ${CVE_STATUS_SCHEMA}, only the local list is used`); return; } - cveStatus = { entries: doc.entries, version }; - log(`Known vulnerabilities: ${doc.entries.length} verdicts from cve-status (generated ${doc.generated_at}) for ${version}, ${Object.keys(cveWhiteList).length} in the local list`); + cveStatus = { doc, version }; + log(`Known vulnerabilities: ${doc.entries.length} verdicts and ${(doc.upstream || []).length} Spring Boot risks from cve-status (generated ${doc.generated_at}) for ${version}, ${Object.keys(cveWhiteList).length} in the local list`); } function knownVulnerability(v, ids) { @@ -234,7 +248,12 @@ function knownVulnerability(v, ids) { if (asset && [...ids].sort().join(', ') === [...asset.cves].sort().join(', ')) { return { listed: true, description: asset.description }; } - const found = cveStatus && lookupVerdicts(cveStatus.entries, v, ids, cveStatus.version); + const found = cveStatus && lookupKnown(cveStatus.doc, v, ids, cveStatus.version); + if (found && found.listed && found.owner === 'spring-boot') { + // a real risk, but its version comes from the Spring Boot the application uses, not from Vaadin + const advice = [...new Set(found.entries.filter(e => e.owner).map(e => e.workaround || e.fix_expected).filter(Boolean))]; + return { listed: true, description: `[cve-status] Not a Vaadin issue: this version comes with Spring Boot, and the Spring Boot your application uses decides it. ${advice.join(' ')}` }; + } if (found && found.listed) { return { listed: true, description: `[cve-status] ${found.entries.map(e => e.description).join(' ')}` }; }