diff --git a/anchore_engine/services/policy_engine/__init__.py b/anchore_engine/services/policy_engine/__init__.py index 7b9022a48..8f990d1ad 100644 --- a/anchore_engine/services/policy_engine/__init__.py +++ b/anchore_engine/services/policy_engine/__init__.py @@ -138,6 +138,7 @@ def _init_distro_mappings(): from_distro="sles", to_distro="sles", flavor="RHEL" ), # RHEL since it uses RPMs for version checks DistroMapping(from_distro="rocky", to_distro="rhel", flavor="RHEL"), + DistroMapping(from_distro="almalinux", to_distro="rhel", flavor="RHEL"), ] # set up any data necessary at system init diff --git a/anchore_engine/services/policy_engine/engine/vulns/mappers.py b/anchore_engine/services/policy_engine/engine/vulns/mappers.py index 0fe8ba08b..8863a2c2d 100644 --- a/anchore_engine/services/policy_engine/engine/vulns/mappers.py +++ b/anchore_engine/services/policy_engine/engine/vulns/mappers.py @@ -698,6 +698,9 @@ def grype_to_engine_image_vulnerability( "rocky": DistroMapper( engine_distro="rocky", grype_os="rockylinux", grype_like_os="fedora" ), + "almalinux": DistroMapper( + engine_distro="almalinux", grype_os="almalinux", grype_like_os="fedora" + ), } diff --git a/tests/integration/services/policy_engine/db/test_distro_mapping.py b/tests/integration/services/policy_engine/db/test_distro_mapping.py index ebc59fe3d..17cd24525 100644 --- a/tests/integration/services/policy_engine/db/test_distro_mapping.py +++ b/tests/integration/services/policy_engine/db/test_distro_mapping.py @@ -80,5 +80,10 @@ def test_distro_from(anchore_db): logger.info("Distros for rocky 8 (rhel) = {}".format(distros)) assert distros is not None assert len(distros) == 1 + + distros = DistroMapping.distros_for("almalinux", "8", "rhel") + logger.info("Distros for almalinux 8 (rhel) = {}".format(distros)) + assert distros is not None + assert len(distros) == 1 finally: session.commit() diff --git a/tests/integration/services/policy_engine/test_namespaces.py b/tests/integration/services/policy_engine/test_namespaces.py index 5dfbedb2c..983f51250 100644 --- a/tests/integration/services/policy_engine/test_namespaces.py +++ b/tests/integration/services/policy_engine/test_namespaces.py @@ -231,13 +231,17 @@ def test_distromappings(initialized_mappings): assert c7.like_namespace_names == ["rhel:7"] r7 = DistroNamespace(name="rhel", version="7", like_distro="rhel") - assert set(r7.mapped_names()) == {"centos", "fedora", "rhel", "redhat", "rocky"} + assert set(r7.mapped_names()) == {"centos", "fedora", "rhel", "redhat", "rocky", "almalinux"} assert r7.like_namespace_names == ["rhel:7"] rocky7 = DistroNamespace(name="rocky", version="7", like_distro="rhel") assert rocky7.mapped_names() == [] assert rocky7.like_namespace_names == ["rhel:7"] + almalinux7 = DistroNamespace(name="almalinux", version="7", like_distro="rhel") + assert almalinux7.mapped_names() == [] + assert almalinux7.like_namespace_names == ["rhel:7"] + assert sorted(DistroMapping.distros_mapped_to("rhel", "7")) == sorted( [ DistroTuple("redhat", "7", "RHEL"), @@ -245,6 +249,7 @@ def test_distromappings(initialized_mappings): DistroTuple("centos", "7", "RHEL"), DistroTuple("fedora", "7", "RHEL"), DistroTuple("rocky", "7", "RHEL"), + DistroTuple("almalinux", "7", "RHEL"), ] ) @@ -259,3 +264,6 @@ def test_mapped_distros(initialized_mappings): assert DistroMapping.distros_for("rocky", "8", "rhel") == [ DistroTuple("rhel", "8", "RHEL") ] + assert DistroMapping.distros_for("almalinux", "8", "rhel") == [ + DistroTuple("rhel", "8", "RHEL") + ] diff --git a/tests/integration/services/policy_engine/utils.py b/tests/integration/services/policy_engine/utils.py index 2ff7f2b00..1c71cc9f6 100644 --- a/tests/integration/services/policy_engine/utils.py +++ b/tests/integration/services/policy_engine/utils.py @@ -42,6 +42,7 @@ def init_distro_mappings(): DistroMapping(from_distro="rhel", to_distro="centos", flavor="RHEL"), DistroMapping(from_distro="ubuntu", to_distro="ubuntu", flavor="DEB"), DistroMapping(from_distro="rocky", to_distro="rhel", flavor="RHEL"), + DistroMapping(from_distro="almalinux", to_distro="rhel", flavor="RHEL"), ] # set up any data necessary at system init diff --git a/tests/unit/anchore_engine/services/policy_engine/engine/vulns/test_mappers.py b/tests/unit/anchore_engine/services/policy_engine/engine/vulns/test_mappers.py index 54f1aaeed..44fe91491 100644 --- a/tests/unit/anchore_engine/services/policy_engine/engine/vulns/test_mappers.py +++ b/tests/unit/anchore_engine/services/policy_engine/engine/vulns/test_mappers.py @@ -24,6 +24,7 @@ pytest.param("sles", "sles", "sles", id="sles"), pytest.param("windows", "windows", "", id="windows"), pytest.param("rocky", "rockylinux", "fedora", id="rocky"), + pytest.param("almalinux", "almalinux", "fedora", id="almalinux"), ], ) def test_engine_distro_mappers(test_distro, expected_os, expected_like_os):