Encode evidence identity as a single object when downgrading below 1.6 - #279
Open
sueun-dev wants to merge 1 commit into
Open
Encode evidence identity as a single object when downgrading below 1.6#279sueun-dev wants to merge 1 commit into
sueun-dev wants to merge 1 commit into
Conversation
component.evidence.identity is an array from 1.6 on, but the 1.5 schema declares it as a single object. convertEvidence truncated the array to its first entry but stored it back as Identities, so downgrading a 1.6+ BOM to 1.5 emitted an array and the document failed the bundled 1.5 schema: components.0.evidence.identity: Invalid type. Expected: object, given: array Keep the first identity as a single Identity object on a downgrade below 1.6 (clearing concludedValue, which is 1.6+), and drop the identity when the array is empty instead of panicking on ids[:1]. Same class as CycloneDX#248. Signed-off-by: Sueun Cho <sueun.dev@gmail.com>
Up to standards ✅🟢 Issues
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Downgrading a BOM whose
component.evidence.identityis an array (the form added in 1.6) to spec 1.5 or lower still emitted an array, but the 1.5 schema declarescomponentEvidence.identityas a single object. The downgraded document then fails the bundled 1.5 schema:convertEvidencealready truncated the array to its first entry, but stored it back inIdentities(the array field) rather thanIdentity(the single object), so the marshaler serialized an array.What changed:
convertEvidence: on a downgrade below 1.6, keep the first identity as a singleIdentityobject instead of a one-elementIdentitiesarray, and clearconcludedValue(1.6+) on it. An emptyIdentitiesnow clears the identity rather than panicking onids[:1].Test_componentConverter_convertEvidence: assert the 1.5 result is a singleIdentity(notIdentities) withconcludedValuedropped.Same class as #248 (a field left in place made the downgraded document fail the 1.5 schema). Related to #192.
Checked:
go test .go vet .,gofmt -l