Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: strip the '\x00' from the ibm_fw_vernum_encoded before parsing #3378

Merged
merged 4 commits into from
Apr 19, 2022
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
9 changes: 5 additions & 4 deletions insights/parsers/ibm_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ class IBMFirmwareLevel(Parser):

Typical content looks like::

FW950.30 (VL950_092)
FW950.30 (VL950_092)\x00

Attributes:
raw (str): The RAW content of the `ibm,fw-vernum_encoded` file.
firmware_level (str): The firmware level required by FLRT.

Examples:
Expand All @@ -72,9 +73,9 @@ def parse_content(self, content):
if not content:
raise SkipException("Empty output.")

_, fwl = content[0].split(None, 1)
self.raw = content[0]

if not fwl:
if "(" not in self.raw or ")" not in self.raw:
raise SkipException("Nothing to parse.")

self.firmware_level = fwl.strip('()')
self.firmware_level = self.raw[self.raw.index('(') + 1:self.raw.index(')')]
9 changes: 8 additions & 1 deletion insights/parsers/tests/test_ibm_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
""".strip()

PROC_IBM_FWL = """
FW950.30 (VL950_092)
FW950.30 (VL950_092)\x00
""".strip()

PROC_IBM_FWL_NG = """
FW950.30 VL950_092\x00
""".strip()


Expand All @@ -31,6 +35,9 @@ def test_ibm_proc_empty():
with pytest.raises(SkipException):
IBMFirmwareLevel(context_wrap(''))

with pytest.raises(SkipException):
IBMFirmwareLevel(context_wrap(PROC_IBM_FWL_NG))


def test_ibm_proc_doc_examples():
env = {
Expand Down