diff --git a/alma_sbom/data/collectors/immudb/processor/apiver02.py b/alma_sbom/data/collectors/immudb/processor/apiver02.py index 7b4fff5..b437d88 100644 --- a/alma_sbom/data/collectors/immudb/processor/apiver02.py +++ b/alma_sbom/data/collectors/immudb/processor/apiver02.py @@ -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() @@ -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'), diff --git a/alma_sbom/data/collectors/immudb/processor/processor.py b/alma_sbom/data/collectors/immudb/processor/processor.py index 720c706..0ec3900 100644 --- a/alma_sbom/data/collectors/immudb/processor/processor.py +++ b/alma_sbom/data/collectors/immudb/processor/processor.py @@ -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