Skip to content

Conversation

yuvalmich
Copy link
Contributor

TLDR

Normalize evidence.identity field for consistent processing across CycloneDX versions

Summary

In different versions of CycloneDX, the evidence.identity field can be either:

  • a single object, or
  • an array of objects.

This inconsistency can lead to runtime issues when iterating over the field. To resolve this, this PR introduces a utility function normalizeIdentities(comp) that ensures evidence.identity is always treated as an array, allowing for safe iteration.

Changes

Added: normalizeIdentities(comp) function to normalize the evidence.identity field.

Updated: Replaced direct iteration over comp?.evidence?.identity || [] with normalizeIdentities(comp) to handle both single-object and array formats consistently.

Benefits

  • Prevents potential runtime errors or missed identity data.
  • Ensures forward/backward compatibility with varying CycloneDX schema versions.

Linked Issue

#1850

@yuvalmich yuvalmich requested a review from prabhu as a code owner June 9, 2025 11:25
Signed-off-by: Yuval Michaeli <yuvalmich2@gmail.com>
@prabhu prabhu merged commit 57fd668 into CycloneDX:master Jun 10, 2025
68 checks passed
@prabhu prabhu linked an issue Jun 10, 2025 that may be closed by this pull request
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.

[Question / Feature Request]: --technique option support in server mode
2 participants