Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions alma_sbom/data/collectors/immudb/processor/apiver02.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_package(self) -> Package:
name = self.immudb_metadata.get('name'),
version = self.immudb_metadata.get('version'),
release = self.immudb_metadata.get('release'),
arch = self.immudb_metadata.get('arch'),
arch = self._resolve_arch(),
)
pkg_props, build_props, sbom_props = self._properties_from_immudb_info_about_package()

Expand All @@ -57,7 +57,7 @@ def _properties_from_immudb_info_about_package(self) -> tuple[
epoch = normalize_epoch(self.immudb_metadata['epoch']) if 'epoch' in self.immudb_metadata else None,
version=self.immudb_metadata.get('version'),
release=self.immudb_metadata.get('release'),
arch=self.immudb_metadata.get('arch'),
arch=self._resolve_arch(),
buildhost=self.immudb_metadata.get('build_host'),
sourcerpm=self.immudb_metadata.get('sourcerpm'),
timestamp=self.immudb_info.get('timestamp'),
Expand Down
11 changes: 11 additions & 0 deletions alma_sbom/data/collectors/immudb/processor/processor.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your fix!

It seems this issue only occurs in api_ver=0.2 in the alma-sbom implementation.
So, could you move _resolve_arch() to DataProcessor02 class?

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ def __init__(self, immudb_info: dict, immudb_metadata: dict, hash: Hash):
self.immudb_metadata = immudb_metadata
self.hash = hash

def _resolve_arch(self) -> str:
"""Return corrected arch for source RPMs.

immudb metadata may store the builder machine arch (e.g. x86_64)
instead of 'src' for SRPMs. Use build_arch and the Name field
as authoritative signals to fix this.
"""
if self.immudb_metadata.get('build_arch') == 'src' or self.immudb_info.get('Name', '').endswith('.src.rpm'):
return 'src'
return self.immudb_metadata.get('arch')

@abstractmethod
def get_api_ver(self) -> str:
pass
Expand Down
Loading