Repository navigation
feat(bundle): add cross-document mapping-reference validation - #92
Conversation
|
@sonupreetam Thanks for the PR. I see that this has some duplicate parsing logic that also exists in the Assembler. What do you think of moving the logic there and doing incremental validation as it builds the bundle? |
3a3e0ba to
73dfae8
Compare
|
Thanks @jpower432, You're right about the duplication. I've reworked on it. For surfacing the results, I went with a A couple of open questions:
|
It seems reasonable to me to surface these in the
I suspect it would be more straight forward to add that type of validation to the SDK since there are different mapping types. Perhaps, the assembler should error on this mismatch by default and we provide an argument to allow "continue-on-error". WDYT? |
jpower432
left a comment
There was a problem hiding this comment.
Approving with two nits.
Extend parseFile to capture mapping-references and validate URL-less reference IDs against the collected metadata.id set after the full dependency graph is resolved. Warnings are surfaced via Bundle.Warnings. Closes gemaraproj#91 Signed-off-by: sonupreetam <spreetam@redhat.com>
73dfae8 to
dfc9325
Compare
|
Thank you very much @jpower432, both nits addressed. On the design questions:
Agreed, opened a draft PR (gemaraproj/gemara-publish-action#14) to have
Agreed. I can file a follow-up issue for that.
That makes sense to me. An |
Print mapping-reference validation warnings to stderr so users see diagnostics when URL-less reference IDs don't match any artifact metadata.id in the bundle. Depends on gemaraproj/go-gemara#92. Closes gemaraproj#13 Signed-off-by: sonupreetam <spreetam@redhat.com>
* feat(grc): surface Bundle.Warnings after assembly Print mapping-reference validation warnings to stderr so users see diagnostics when URL-less reference IDs don't match any artifact metadata.id in the bundle. Depends on gemaraproj/go-gemara#92. Closes #13 Signed-off-by: sonupreetam <spreetam@redhat.com> * chore(grc): bump go-gemara to v0.8.0 Pulls in Bundle.Warnings from go-gemara#92. Signed-off-by: sonupreetam <spreetam@redhat.com> * fix(grc): bump go-gemara to include oras-go v2.6.2 CVE fix Pulls in go-gemara main (2c7da20) which includes: - fix(deps): bump oras-go/v2 to v2.6.2 for CVE-2026-50163 (#102) - feat(bundle): error by default on unmatched mapping-reference IDs (#98) This resolves the Kusari Inspector failure on PR #14. Signed-off-by: sonupreetam <spreetam@redhat.com> --------- Signed-off-by: sonupreetam <spreetam@redhat.com>
Summary
parseFile's existing parsing rather than duplicating itparseFilenow capturesmappingRefsalongsiderefIDs/refURLsvalidateMappingRefschecks that every URL-lessmapping-reference.idmatches at least onemetadata.idin the assembled setBundle.Warningsfor consumers to inspect after assemblyContext
When a
mapping-referencehas nourl, itsidis expected to match a target artifact'smetadata.idfor bundle-local resolution. Currently there is no validation that catches a mismatch — it only surfaces as a resolution failure in downstream consumers like complypack.This catches authoring errors early — for example, a policy whose
mapping-reference.idis"csc"when the catalog it references hasmetadata.id"container-security-controls".References with a URL are skipped since they are resolved externally by the assembler (fetch errors are already hard errors).
Related
mapping-reference.id(merged)Bundle.Warningsingrc(follow-up)Test plan
metadata.idproduces no warningmetadata.idproduces a warningmetadata.idsmetadata.idproduces no warningMappingWarning.String()includes file, artifact ID, and reference IDgo test ./...)