Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:GA
salt.22692
remove-wrong-_parse_cpe_name-from-grains.core-4...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File remove-wrong-_parse_cpe_name-from-grains.core-453.patch of Package salt.22692
From 21d60c4c03eae28cd68345f5ca3f959c9e9b6eaf Mon Sep 17 00:00:00 2001 From: Victor Zhestkov <35733135+vzhestkov@users.noreply.github.com> Date: Mon, 8 Nov 2021 18:13:59 +0300 Subject: [PATCH] Remove wrong _parse_cpe_name from grains.core (#453) --- salt/grains/core.py | 28 ------------------ tests/unit/grains/test_core.py | 53 +++++++++++++++++++++++++++------- 2 files changed, 43 insertions(+), 38 deletions(-) diff --git a/salt/grains/core.py b/salt/grains/core.py index 846d2e6e2d..8642ee80ff 100644 --- a/salt/grains/core.py +++ b/salt/grains/core.py @@ -1660,34 +1660,6 @@ def _parse_cpe_name(cpe): return ret -def _parse_cpe_name(cpe): - ''' - Parse CPE_NAME data from the os-release - - Info: https://csrc.nist.gov/projects/security-content-automation-protocol/scap-specifications/cpe - - :param cpe: - :return: - ''' - part = { - 'o': 'operating system', - 'h': 'hardware', - 'a': 'application', - } - ret = {} - cpe = (cpe or '').split(':') - if len(cpe) > 4 and cpe[0] == 'cpe': - if cpe[1].startswith('/'): # WFN to URI - ret['vendor'], ret['product'], ret['version'] = cpe[2:5] - ret['phase'] = cpe[5] if len(cpe) > 5 else None - ret['part'] = part.get(cpe[1][1:]) - elif len(cpe) == 13 and cpe[1] == '2.3': # WFN to a string - ret['vendor'], ret['product'], ret['version'], ret['phase'] = [x if x != '*' else None for x in cpe[3:7]] - ret['part'] = part.get(cpe[2]) - - return ret - - def os_data(): ''' Return grains pertaining to the operating system diff --git a/tests/unit/grains/test_core.py b/tests/unit/grains/test_core.py index 9ea1727058..0d57a142c5 100644 --- a/tests/unit/grains/test_core.py +++ b/tests/unit/grains/test_core.py @@ -109,16 +109,49 @@ class CoreGrainsTestCase(TestCase, LoaderModuleMockMixin): ''' Parse correct CPE_NAME data v2.3 formatted :return: - ''' - for cpe, cpe_ret in [('cpe:2.3:o:microsoft:windows_xp:5.1.601:beta:*:*:*:*:*:*', - {'phase': 'beta', 'version': '5.1.601', 'product': 'windows_xp', - 'vendor': 'microsoft', 'part': 'operating system'}), - ('cpe:2.3:h:corellian:millenium_falcon:1.0:*:*:*:*:*:*:*', - {'phase': None, 'version': '1.0', 'product': 'millenium_falcon', - 'vendor': 'corellian', 'part': 'hardware'}), - ('cpe:2.3:*:dark_empire:light_saber:3.0:beta:*:*:*:*:*:*', - {'phase': 'beta', 'version': '3.0', 'product': 'light_saber', - 'vendor': 'dark_empire', 'part': None})]: + """ + for cpe, cpe_ret in [ + ( + "cpe:2.3:o:microsoft:windows_xp:5.1.601:beta:*:*:*:*:*:*", + { + "phase": "beta", + "version": "5.1.601", + "product": "windows_xp", + "vendor": "microsoft", + "part": "operating system", + }, + ), + ( + "cpe:2.3:h:corellian:millenium_falcon:1.0:*:*:*:*:*:*:*", + { + "phase": None, + "version": "1.0", + "product": "millenium_falcon", + "vendor": "corellian", + "part": "hardware", + }, + ), + ( + "cpe:2.3:*:dark_empire:light_saber:3.0:beta:*:*:*:*:*:*", + { + "phase": "beta", + "version": "3.0", + "product": "light_saber", + "vendor": "dark_empire", + "part": None, + }, + ), + ( + "cpe:2.3:o:amazon:amazon_linux:2", + { + "phase": None, + "version": "2", + "product": "amazon_linux", + "vendor": "amazon", + "part": "operating system", + }, + ), + ]: ret = core._parse_cpe_name(cpe) for key in cpe_ret: assert key in ret -- 2.33.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor