fix(sbom): apply and check GOST properties on nested components too - #322
Conversation
GOST upsert and validation walked only metadata.component and the top-level components list, and the container value in the product SBOM was aggregated from the top level alone. A base or imported SBOM with nested components kept its old values, passed validation with missing properties, and could hold a higher value than the container above it, which the ISPRAS checker rejects. Recurse through nested components in Upsert, Validate and aggregateGOST so the whole tree gets the configured values, is checked, and the container reflects the maximum over all descendants. Signed-off-by: Radmir Khurum <radmir.khurum@flant.com>
Verification
Follow-up
|
…nt too Upsert and Validate descended into bom.Components but not into metadata.component.components, so a BOM whose root component nests its parts — the shape werf itself emits for a container-format product — left those parts untouched and unvalidated. Walk them with the same recursion. Signed-off-by: Radmir Khurum <radmir.khurum@flant.com>
Independent review (gpt, read-only) + mutation loopReview verdict: approve, one Minor finding — Mutation loop run by hand on the PR head, each mutation restored afterwards:
Reviewer's other notes, not acted on: nested error message does not carry the parent path (same as before for top-level duplicates); |
40cec65
into
fix/sbom/product-deps-refs
Summary
build.sbom.gost.*reached onlymetadata.componentand the top-levelcomponentslist. A base or imported SBOM carrying nested components kept whatever values it had below the first level, passed the GOST gate with properties missing there, and in the container-format product SBOM the container value ignored everything below the top level. Stacked on #321.What
gost.UpsertsetsGOST:attack_surface/GOST:security_functionon every component at any nesting depth — undercomponentsand undermetadata.component.componentsalike — not only the top level.gost.Validatefails withcomponent "<name>": missing mandatory GOST propertiesfor a nested component without them; previously nested components were never inspected.3p-ispras-sbom-checker --format container(файл корректный) with the container values unchanged, as expected for the flat component lists syft emits.setMissingGOSTOnComponentstill prefers the value already on the image root. The model question (whether the container is always derived or may be set) is open on the tracking card and not decided here.Why
UpsertandValidateiteratedbom.Componentsone level deep, andaggregateGOSTread only the slice it was handed. A nested component was therefore invisible to all three: it kept foreign values from its origin SBOM, was not validated, and did not participate in the container maximum. The ISPRAS checker enforcescontainer == max(all descendants)for both fields, so a nestedyesunder a container computed asindirectis a hardERRORat submission time, while our own validation stayed silent.Alternative considered: leaving
Upsertshallow and only makingaggregateGOSTtransitive. Rejected: the gate would then accept an SBOM whose nested components lack the properties entirely, and the checker treats a missing property as invalid.