Skip to content

Commit

Permalink
dnf sbom: handle arch absence
Browse files Browse the repository at this point in the history
  • Loading branch information
Habbie committed Sep 23, 2024
1 parent 0de9aac commit 2081f71
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions builder-support/helpers/generate-sbom-dnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ def addDependencyToSBOM(sbom, appInfos, pkg):
bomRef = 'lib:' + pkg.name
component = { 'name': pkg.name, 'bom-ref': bomRef, 'type': 'library'}
if pkg.release:
component['version'] = (pkg.version if pkg.epoch == 0 else str(pkg.epoch) + ':' + pkg.version) + '-' + pkg.release + '.' + pkg.arch
component['version'] = (pkg.version if pkg.epoch == 0 else str(pkg.epoch) + ':' + pkg.version) + '-' + pkg.release
else:
component['version'] = (pkg.version if pkg.epoch == 0 else str(pkg.epoch) + ':' + pkg.version) + '.' + pkg.arch
component['version'] = (pkg.version if pkg.epoch == 0 else str(pkg.epoch) + ':' + pkg.version)
if hasattr(pkg, 'arch'):
component['version'] += '.' + pkg.arch
if hasattr(pkg, 'vendor') and pkg.vendor is not None:
component['supplier'] = {'name': pkg.vendor}
if hasattr(pkg, 'publisher') and pkg.publisher is not None:
Expand Down Expand Up @@ -134,9 +136,12 @@ def generateSBOM(packageName, additionalDeps):
component = { 'name': appName, 'bom-ref': 'pkg:' + appName, 'type': 'application'}

if appInfos.release:
component['version'] = (appInfos.version if appInfos.epoch == 0 else str(appInfos.epoch) + ':' + appInfos.version) + '-' + appInfos.release + '.' + appInfos.arch
component['version'] = (appInfos.version if appInfos.epoch == 0 else str(appInfos.epoch) + ':' + appInfos.version) + '-' + appInfos.release
else:
component['version'] = (appInfos.version if appInfos.epoch == 0 else str(appInfos.epoch) + ':' + appInfos.version) + '.' + appInfos.arch
component['version'] = (appInfos.version if appInfos.epoch == 0 else str(appInfos.epoch) + ':' + appInfos.version)

if hasattr(appInfos, 'arch'):
component['version'] += '.' + appInfos.arch

component['supplier'] = {'name': appInfos.vendor if appInfos.vendor != '<NULL>' else 'PowerDNS.COM BV', 'url': ['https://www.powerdns.com']}
component['licenses'] = [{'license': {'id': licenseToSPDXIdentifier(appInfos.license)}}]
Expand Down

0 comments on commit 2081f71

Please sign in to comment.