diff --git a/atomic_reactor/utils/rpm.py b/atomic_reactor/utils/rpm.py index 6a3e9c5e2..21d3167b7 100644 --- a/atomic_reactor/utils/rpm.py +++ b/atomic_reactor/utils/rpm.py @@ -20,6 +20,7 @@ 'SIZE', 'SIGMD5', 'BUILDTIME', + 'RPMTAG_MODULARITYLABEL', 'SIGPGP:pgpsig', 'SIGGPG:pgpsig', 'DSAHEADER:pgpsig', @@ -107,6 +108,7 @@ def field(tag): 'arch': field('ARCH'), 'sigmd5': field('SIGMD5'), 'signature': signature, + 'module': field('RPMTAG_MODULARITYLABEL'), } # Special handling for epoch as it must be an integer or None diff --git a/tests/plugins/test_rpmqa.py b/tests/plugins/test_rpmqa.py index 4a9e96c22..a5227c0c5 100644 --- a/tests/plugins/test_rpmqa.py +++ b/tests/plugins/test_rpmqa.py @@ -21,27 +21,27 @@ TEST_IMAGE = "fedora:latest" -PACKAGE_LIST = ['python-docker-py;1.3.1;1.fc24;noarch;(none);' - '191456;7c1f60d8cde73e97a45e0c489f4a3b26;1438058212;(none);(none);(none);(none)', - 'fedora-repos-rawhide;24;0.1;noarch;(none);' - '2149;d41df1e059544d906363605d47477e60;1436940126;(none);(none);(none);(none)', - 'gpg-pubkey-doc;1.0;1;noarch;(none);' - '1000;00000000000000000000000000000000;1436940126;(none);(none);(none);(none)'] +PACKAGE_LIST = ['python-docker-py;1.3.1;1.fc24;noarch;(none);191456;' + '7c1f60d8cde73e97a45e0c489f4a3b26;1438058212;module;(none);(none);(none);(none)', + 'fedora-repos-rawhide;24;0.1;noarch;(none);2149;' + 'd41df1e059544d906363605d47477e60;1436940126;module;(none);(none);(none);(none)', + 'gpg-pubkey-doc;1.0;1;noarch;(none);1000;' + '00000000000000000000000000000000;1436940126;module;(none);(none);(none);(none)'] PACKAGE_LIST_WITH_AUTOGENERATED = PACKAGE_LIST + ['gpg-pubkey;qwe123;zxcasd123;(none);(none);0;' - '(none);1370645731;(none);(none)'] + '(none);1370645731;module;(none);(none)'] PACKAGE_LIST_WITH_AUTOGENERATED_B = [x.encode("utf-8") for x in PACKAGE_LIST_WITH_AUTOGENERATED] PACKAGE_LIST_SBOM = ['vim-minimal;9.0.803;1.fc36;x86_64;(none);' # arch, no epoch - '1695845;00000000000000000000000000000000;1436940126;' + '1695845;00000000000000000000000000000000;1436940126;module;' '(none);(none);(none);(none)', 'yum;4.14.0;1.fc36;noarch;(none);' # noarch, no epoch - '22187;00000000000000000000000000000000;1436940126;' + '22187;00000000000000000000000000000000;1436940126;module;' '(none);(none);(none);(none)', 'kernel-core;6.0.5;200.fc36;x86_64;3;' # arch, epoch - '101213053;00000000000000000000000000000000;1436940126;' + '101213053;00000000000000000000000000000000;1436940126;module;' '(none);(none);(none);(none)', 'kernel-core;6.0.5;200.fc36;x86_64;3;' # duplicate - '101213053;00000000000000000000000000000000;1436940126;' + '101213053;00000000000000000000000000000000;1436940126;module;' '(none);(none);(none);(none)'] SBOM_COMPONENTS = [{"type": "library", "name": "vim-minimal", "version": "9.0.803-1.fc36", "purl": "pkg:rpm/vim-minimal@9.0.803-1.fc36?arch=x86_64"}, diff --git a/tests/utils/test_rpm.py b/tests/utils/test_rpm.py index f698b2317..951e4929d 100644 --- a/tests/utils/test_rpm.py +++ b/tests/utils/test_rpm.py @@ -16,7 +16,7 @@ @pytest.mark.parametrize(('tags', 'separator', 'expected'), [ (None, None, - r"-qa --qf '%{NAME};%{VERSION};%{RELEASE};%{ARCH};%{EPOCH};%{SIZE};%{SIGMD5};%{BUILDTIME};%{SIGPGP:pgpsig};%{SIGGPG:pgpsig};%{DSAHEADER:pgpsig};%{RSAHEADER:pgpsig}\n'"), # noqa + r"-qa --qf '%{NAME};%{VERSION};%{RELEASE};%{ARCH};%{EPOCH};%{SIZE};%{SIGMD5};%{BUILDTIME};%{RPMTAG_MODULARITYLABEL};%{SIGPGP:pgpsig};%{SIGGPG:pgpsig};%{DSAHEADER:pgpsig};%{RSAHEADER:pgpsig}\n'"), # noqa (['NAME', 'VERSION'], "|", r"-qa --qf '%{NAME}|%{VERSION}\n'"), ]) @@ -40,8 +40,9 @@ def fake_rpm_line( size = "2000" sigmd5 = FAKE_SIGMD5.decode() buildtime = "23000" + module = "some_module" return ( - f"{name};{version};{release};{arch};{epoch};{size};{sigmd5};{buildtime}" + f"{name};{version};{release};{arch};{epoch};{size};{sigmd5};{buildtime};{module}" f";{pgp};{gpg};{dsa};{rsa}" ) @@ -66,6 +67,7 @@ def fake_rpm_line( 'epoch': 0, 'sigmd5': FAKE_SIGMD5.decode(), 'signature': "01234567890abc", + 'module': "some_module", } assert res == [ { @@ -115,5 +117,6 @@ def fake_rpm_line( 'epoch': None, 'sigmd5': None, 'signature': None, + 'module': None, } ]