Skip to content

Commit

Permalink
feat(cyclonedx): Set basic supplier information
Browse files Browse the repository at this point in the history
While at it, also set author information for package components.

See [1] for context.

[1]: #7449

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Dec 10, 2024
1 parent cd6e57e commit 097eb5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions plugins/reporters/cyclonedx/src/main/kotlin/BomExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import org.cyclonedx.model.Dependency
import org.cyclonedx.model.ExtensibleType
import org.cyclonedx.model.ExternalReference
import org.cyclonedx.model.LicenseChoice
import org.cyclonedx.model.OrganizationalContact
import org.cyclonedx.model.OrganizationalEntity
import org.cyclonedx.model.vulnerability.Vulnerability.Rating.Method

import org.ossreviewtoolkit.model.Identifier
Expand Down Expand Up @@ -118,6 +120,11 @@ internal fun Bom.addComponent(input: ReporterInput, pkg: Package, dependencyType
name = pkg.id.name
version = pkg.id.version

authors = pkg.authors.map { OrganizationalContact().apply { name = it } }
supplier = authors.takeUnless { it.isEmpty() }?.let {
OrganizationalEntity().apply { contacts = authors }
}

description = pkg.description

// TODO: Map package-manager-specific OPTIONAL scopes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import org.cyclonedx.model.ExternalReference
import org.cyclonedx.model.LicenseChoice
import org.cyclonedx.model.Metadata
import org.cyclonedx.model.OrganizationalContact
import org.cyclonedx.model.OrganizationalEntity
import org.cyclonedx.model.license.Expression
import org.cyclonedx.model.metadata.ToolInformation

Expand Down Expand Up @@ -215,6 +216,10 @@ class CycloneDxReporter(
version = project.id.version

authors = project.authors.map { OrganizationalContact().apply { name = it } }
supplier = authors.takeUnless { it.isEmpty() }?.let {
OrganizationalEntity().apply { contacts = authors }
}

description = project.description
}
}
Expand Down

0 comments on commit 097eb5d

Please sign in to comment.