Skip to content
Merged
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
7 changes: 1 addition & 6 deletions operatingsystems/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 7 additions & 2 deletions operatingsystems/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]
Expand Down
7 changes: 6 additions & 1 deletion reports/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with Patchman. If not, see <http://www.gnu.org/licenses/>

import json
from urllib.parse import unquote

from django.db import models
from django.urls import reverse
Expand Down Expand Up @@ -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, '')

Expand Down
3 changes: 2 additions & 1 deletion reports/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with Patchman. If not, see <http://www.gnu.org/licenses/>

import json
from urllib.parse import unquote

from django.contrib import messages
from django.contrib.auth.decorators import login_required
Expand Down Expand Up @@ -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,
Expand Down