Skip to content

Commit

Permalink
fix(cyclonedx): Avoid a NPE when clearing extensibleTypes
Browse files Browse the repository at this point in the history
This is a fixup for 023dfb6 which started to conditionally set the
`LicenseChoice`. If the condition is not met and `licenses` is `null`,
do not try to clear `extensibleTypes` from them.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Jul 16, 2024
1 parent 262d966 commit d686957
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions plugins/reporters/cyclonedx/src/main/kotlin/CycloneDxReporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,15 @@ private fun generateBom(bom: Bom, schemaVersion: Version, fileExtension: String)
// Clear the "dependencyType".
component.extensibleTypes = null

component.licenses.licenses.forEach { license ->
// Clear the "origin".
license.extensibleTypes = null
}
if (component.licenses?.licenses != null) {
component.licenses.licenses.forEach { license ->
// Clear the "origin".
license.extensibleTypes = null
}

// Remove duplicates that may occur due to clearing the distinguishing extensive type.
component.licenses.licenses = component.licenses.licenses.distinct()
// Remove duplicates that may occur due to clearing the distinguishing extensive type.
component.licenses.licenses = component.licenses.licenses.distinct()
}
}
}

Expand Down

0 comments on commit d686957

Please sign in to comment.