Skip to content

Encode evidence identity as a single object when downgrading below 1.6 - #279

Open
sueun-dev wants to merge 1 commit into
CycloneDX:masterfrom
sueun-dev:fix-evidence-identity-downgrade-1.5
Open

Encode evidence identity as a single object when downgrading below 1.6#279
sueun-dev wants to merge 1 commit into
CycloneDX:masterfrom
sueun-dev:fix-evidence-identity-downgrade-1.5

Conversation

@sueun-dev

Copy link
Copy Markdown

Downgrading a BOM whose component.evidence.identity is an array (the form added in 1.6) to spec 1.5 or lower still emitted an array, but the 1.5 schema declares componentEvidence.identity as a single object. The downgraded document then fails the bundled 1.5 schema:

components.0.evidence.identity: Invalid type. Expected: object, given: array

convertEvidence already truncated the array to its first entry, but stored it back in Identities (the array field) rather than Identity (the single object), so the marshaler serialized an array.

What changed:

  • convertEvidence: on a downgrade below 1.6, keep the first identity as a single Identity object instead of a one-element Identities array, and clear concludedValue (1.6+) on it. An empty Identities now clears the identity rather than panicking on ids[:1].
  • Test_componentConverter_convertEvidence: assert the 1.5 result is a single Identity (not Identities) with concludedValue dropped.

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

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>
@sueun-dev
sueun-dev requested a review from a team as a code owner July 28, 2026 11:39
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant