Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions scripts/generateAndCheckSBOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -225,16 +239,21 @@ 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) {
const asset = cveWhiteList[v];
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(' ')}` };
}
Expand Down
Loading