diff --git a/notus/scanner/models/packages/deb.py b/notus/scanner/models/packages/deb.py index d484180..18e4d63 100644 --- a/notus/scanner/models/packages/deb.py +++ b/notus/scanner/models/packages/deb.py @@ -12,10 +12,16 @@ from .package import Package, PackageComparison -_deb_compile = re.compile(r"(.*)-(?:(\d*):)?(\d.*)-(.*)") -_deb_compile_wo_revision = re.compile(r"(.*)-(?:(\d*):)?(\d.*)") -_deb_compile_version = re.compile(r"(?:(\d*):)?(\d.*)-(.*)") -_deb_compile_version_wo_revision = re.compile(r"(?:(\d*):)?(\d.*)") +_deb_compile = re.compile( + r"^([a-z0-9](?:[a-z0-9+-.])+)-(?:(\d*):)?(\d[\d\w+-.~]*)(?:-([\d\w+-.~]*))$" +) +_deb_compile_wo_revision = re.compile( + r"^([a-z0-9](?:[a-z0-9+-.])+)-(?:(\d*):)?(\d[\d\w+.~]*)$" +) +_deb_compile_version = re.compile( + r"^(?:(\d*):)?(\d[\d\w+-.~]*)(?:-([\d\w+-.~]*))$" +) +_deb_compile_version_wo_revision = re.compile(r"^(?:(\d*):)?(\d[\d\w+.~]*)$") logger = logging.getLogger(__name__) diff --git a/tests/models/packages/test_deb.py b/tests/models/packages/test_deb.py index e1580a1..5a464e0 100644 --- a/tests/models/packages/test_deb.py +++ b/tests/models/packages/test_deb.py @@ -180,6 +180,17 @@ def test_from_full_name(self): self.assertEqual(package.debian_revision, "") self.assertEqual(package.full_name, "apport-symptoms-020") + package = DEBPackage.from_full_name( + "mariadb-server-10.6-1:10.6.18+maria~ubu2204" + ) + self.assertEqual(package.name, "mariadb-server-10.6") + self.assertEqual(package.epoch, "1") + self.assertEqual(package.upstream_version, "10.6.18+maria~ubu2204") + self.assertEqual(package.debian_revision, "") + self.assertEqual( + package.full_name, "mariadb-server-10.6-1:10.6.18+maria~ubu2204" + ) + def test_from_name_and_full_version(self): """it should be possible to create packages from name and full version"""