mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 18:05:38 +08:00
refactor(sbom): reuse Go module records for graph coverage (#17451)
This commit is contained in:
@@ -546,12 +546,12 @@ const projectGoCycloneDx = (
|
||||
"Go parent subject must identify the report's exact artifact.",
|
||||
);
|
||||
if (!subject.ok) return subject;
|
||||
const info = report.build_info;
|
||||
const modules = [
|
||||
...(info?.module.main === null || info === null ? [] : [info.module.main]),
|
||||
...(info?.module.dependencies ?? []),
|
||||
];
|
||||
const published = modules.map(publishedGoModule);
|
||||
const recorded = report.build_info?.module;
|
||||
const main = recorded?.main;
|
||||
const dependencyModules = recorded?.dependencies ?? [];
|
||||
const published = (
|
||||
main == null ? dependencyModules : [main, ...dependencyModules]
|
||||
).map(publishedGoModule);
|
||||
const minimumBytes = documentBytesAtLeast(0, published, goComponentBytes);
|
||||
if (minimumBytes > CYCLONEDX_DOCUMENT_BYTE_LIMIT)
|
||||
return documentAllowanceExceeded(minimumBytes, "lower_bound");
|
||||
@@ -572,27 +572,22 @@ const projectGoCycloneDx = (
|
||||
goComponentProperties(item),
|
||||
);
|
||||
});
|
||||
const mainRef =
|
||||
info?.module.main === null || info === null ? undefined : refs[0];
|
||||
const dependencyRefs = mainRef === undefined ? [] : refs.slice(1);
|
||||
const mainRef = main == null ? undefined : refs[0];
|
||||
// Empty dependsOn claims absence. That claim is valid only when every module line parsed.
|
||||
const dependencies =
|
||||
mainRef === undefined ||
|
||||
(info?.module.complete === false && dependencyRefs.length === 0)
|
||||
(recorded?.complete === false && dependencyModules.length === 0)
|
||||
? undefined
|
||||
: [
|
||||
{
|
||||
ref: mainRef,
|
||||
dependsOn: uniqueRefs(dependencyRefs),
|
||||
dependsOn: uniqueRefs(refs.slice(1)),
|
||||
},
|
||||
];
|
||||
const moduleRecordDecoded =
|
||||
info !== null &&
|
||||
(info.module.main !== null || info.module.dependencies.length > 0);
|
||||
const sourceCoverage: SourceCoverage =
|
||||
info === null || (info.module.complete && !moduleRecordDecoded)
|
||||
recorded === undefined || (recorded.complete && published.length === 0)
|
||||
? { aggregate: "unknown", records: "absent" }
|
||||
: info.module.complete
|
||||
: recorded.complete
|
||||
? { aggregate: "unknown", records: "present" }
|
||||
: { aggregate: "incomplete", records: "partial" };
|
||||
const reportedUnknowns = goBinaryUnknowns(report);
|
||||
|
||||
Reference in New Issue
Block a user