Skip to content

Commit

Permalink
Fix: notus deb package parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Kraemii committed Aug 15, 2024
1 parent 6303c94 commit a22dcee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
14 changes: 10 additions & 4 deletions notus/scanner/models/packages/deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
11 changes: 11 additions & 0 deletions tests/models/packages/test_deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit a22dcee

Please sign in to comment.