diff --git a/operatingsystems/tests/test_models.py b/operatingsystems/tests/test_models.py index 64192c19..6f873cb7 100644 --- a/operatingsystems/tests/test_models.py +++ b/operatingsystems/tests/test_models.py @@ -115,18 +115,13 @@ def test_almalinux_dash_format(self): def test_almalinux_no_space(self): """Test AlmaLinux X.Y -> AlmaLinux X""" - self.assertEqual(normalize_el_osrelease('AlmaLinux 10.1'), 'AlmaLinux 10') + self.assertEqual(normalize_el_osrelease('AlmaLinux 10.1'), 'Alma Linux 10') def test_centos_with_minor_version(self): """Test CentOS X.Y -> CentOS X""" self.assertEqual(normalize_el_osrelease('CentOS 7.9'), 'CentOS 7') self.assertEqual(normalize_el_osrelease('CentOS 8.5'), 'CentOS 8') - def test_rhel_with_minor_version(self): - """Test RHEL X.Y -> RHEL X""" - self.assertEqual(normalize_el_osrelease('RHEL 8.2'), 'RHEL 8') - self.assertEqual(normalize_el_osrelease('RHEL 9.1'), 'RHEL 9') - def test_red_hat_enterprise_linux_with_minor_version(self): """Test Red Hat Enterprise Linux X.Y -> Red Hat Enterprise Linux X""" self.assertEqual( diff --git a/operatingsystems/utils.py b/operatingsystems/utils.py index 2544117f..b6e9c435 100644 --- a/operatingsystems/utils.py +++ b/operatingsystems/utils.py @@ -29,15 +29,20 @@ def normalize_el_osrelease(osrelease_name): elif osrelease_name.startswith('almalinux-'): major_version = osrelease_name.split('-')[1].split('.')[0] return f'Alma Linux {major_version}' + elif osrelease_name.startswith('AlmaLinux'): + version_part = osrelease_name[len('AlmaLinux'):].strip() + major_version = version_part.split('.')[0] + return f'Alma Linux {major_version}' + elif osrelease_name.startswith('rhel-'): + major_version = osrelease_name.split('-')[1] + return f'Red Hat Enterprise Linux {major_version}' elif osrelease_name in ['Amazon Linux', 'Amazon Linux AMI']: return 'Amazon Linux 1' el_distro_prefixes = [ 'Rocky Linux', 'Alma Linux', - 'AlmaLinux', 'CentOS', - 'RHEL', 'Red Hat Enterprise Linux', 'Oracle Linux', ] diff --git a/reports/models.py b/reports/models.py index bda18fed..a0f2bbef 100644 --- a/reports/models.py +++ b/reports/models.py @@ -16,6 +16,7 @@ # along with Patchman. If not, see import json +from urllib.parse import unquote from django.db import models from django.urls import reverse @@ -169,7 +170,11 @@ def parse(self, data, meta): for attr in attrs: if data.get(attr): - setattr(self, attr, data.get(attr)) + value = data.get(attr) + # Decode URL-encoded kernel (e.g., %2b -> +) + if attr == 'kernel': + value = unquote(value) + setattr(self, attr, value) else: setattr(self, attr, '') diff --git a/reports/views.py b/reports/views.py index 1a7651ae..18f60aa6 100644 --- a/reports/views.py +++ b/reports/views.py @@ -16,6 +16,7 @@ # along with Patchman. If not, see import json +from urllib.parse import unquote from django.contrib import messages from django.contrib.auth.decorators import login_required @@ -341,7 +342,7 @@ def create(self, request): host=hostname, domain=domain, tags=tags, - kernel=data['kernel'], + kernel=unquote(data['kernel']), arch=data['arch'], os=data['os'], report_ip=report_ip,