Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/598'
Browse files Browse the repository at this point in the history
* origin/pr/598:
  Add os-release ID_LIKE to features
  • Loading branch information
marmarek committed Jun 12, 2024
2 parents f528fc7 + 0f3bef9 commit a044cf5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions qubes/ext/core_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ async def qubes_features_request(self, vm, event, untrusted_features):
# entry point already validates values for safe characters
vm.features["os-distribution"] = \
untrusted_features["os-distribution"]
if "os-distribution-like" in untrusted_features \
and untrusted_features["os-distribution-like"]:
# entry point already validates values for safe characters
vm.features["os-distribution-like"] = \
untrusted_features["os-distribution-like"]
if "os-version" in untrusted_features \
and untrusted_features["os-version"]:
# no letters in versions please
Expand Down
7 changes: 7 additions & 0 deletions qubes/tests/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,13 @@ def test_031_distro_meta_ubuntu(self):
untrusted_features={
'os': 'Linux',
'os-distribution': 'ubuntu',
'os-distribution-like': 'debian',
'os-version': '22.04',
'os-eol': '2027-06-01',
}))
self.assertListEqual(self.vm.mock_calls, [
('features.__setitem__', ('os-distribution', 'ubuntu'), {}),
('features.__setitem__', ('os-distribution-like', 'debian'), {}),
('features.__setitem__', ('os-version', '22.04'), {}),
('features.__setitem__', ('os-eol', '2027-06-01'), {}),
('features.get', ('qrexec', False), {}),
Expand All @@ -285,11 +287,13 @@ def test_032_distro_meta_invalid(self):
untrusted_features={
'os': 'Linux',
'os-distribution': 'ubuntu',
'os-distribution-like': 'debian',
'os-version': '123aaa',
'os-eol': '20270601',
}))
self.assertListEqual(self.vm.mock_calls, [
('features.__setitem__', ('os-distribution', 'ubuntu'), {}),
('features.__setitem__', ('os-distribution-like', 'debian'), {}),
('log.warning', unittest.mock.ANY, {}),
('log.warning', unittest.mock.ANY, {}),
('features.get', ('qrexec', False), {}),
Expand All @@ -303,11 +307,13 @@ def test_033_distro_meta_invalid2(self):
untrusted_features={
'os': 'Linux',
'os-distribution': 'ubuntu',
'os-distribution-like': 'debian',
'os-version': 'a123',
'os-eol': '2027-06-40',
}))
self.assertListEqual(self.vm.mock_calls, [
('features.__setitem__', ('os-distribution', 'ubuntu'), {}),
('features.__setitem__', ('os-distribution-like', 'debian'), {}),
('log.warning', unittest.mock.ANY, {}),
('log.warning', unittest.mock.ANY, {}),
('features.get', ('qrexec', False), {}),
Expand All @@ -321,6 +327,7 @@ def test_034_distro_meta_empty(self):
untrusted_features={
'os': '',
'os-distribution': '',
'os-distribution-like': '',
'os-version': '',
'os-eol': '',
}))
Expand Down
4 changes: 4 additions & 0 deletions qubes/tests/integ/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,12 @@ def test_010_os_metadata(self):
self.assertIsNotNone(tpl.features.get('os-eol'))
elif self.template.startswith('whonix-'):
self.assertEqual(tpl.features.get('os-distribution'), 'whonix')
self.assertEqual(tpl.features.get('os-distribution-like'), 'debian')
version = self.template.split('-')[2]
self.assertEqual(tpl.features.get('os-version'), version)
elif self.template.startswith('kali-core'):
self.assertEqual(tpl.features.get('os-distribution'), 'kali')
self.assertEqual(tpl.features.get('os-distribution-like'), 'debian')

@unittest.skipUnless(
spawn.find_executable('xdotool'), "xdotool not installed")
Expand Down

0 comments on commit a044cf5

Please sign in to comment.