Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

Fix #1331, Add Almalinux OS support #1337

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions anchore_engine/services/policy_engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions anchore_engine/services/policy_engine/engine/vulns/mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
),
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
10 changes: 9 additions & 1 deletion tests/integration/services/policy_engine/test_namespaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,25 @@ 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"),
DistroTuple("rhel", "7", "RHEL"),
DistroTuple("centos", "7", "RHEL"),
DistroTuple("fedora", "7", "RHEL"),
DistroTuple("rocky", "7", "RHEL"),
DistroTuple("almalinux", "7", "RHEL"),
]
)

Expand All @@ -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")
]
1 change: 1 addition & 0 deletions tests/integration/services/policy_engine/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down