MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / parse_lynis_dat

Function parse_lynis_dat

lynis_parser.py:50–83  ·  view source on GitHub ↗

Parse the contents of lynis-report.dat into structured data.

(content: str)

Source from the content-addressed store, hash-verified

48
49
50def parse_lynis_dat(content: str) -> Dict[str, object]:
51 """Parse the contents of lynis-report.dat into structured data."""
52 data = {
53 "metadata": {},
54 "warnings": [],
55 "suggestions": [],
56 "vulnerable_packages": [],
57 }
58
59 if not content:
60 return data
61
62 for line in content.splitlines():
63 stripped = line.strip()
64 if not stripped or stripped.startswith("#"):
65 continue
66 if "=" not in stripped:
67 continue
68
69 key, value = stripped.split("=", 1)
70 key = key.strip()
71 value = value.strip()
72
73 base_key = key.split("[", 1)[0]
74 if base_key == "warning":
75 data["warnings"].append(_split_pipe_payload(value))
76 elif base_key == "suggestion":
77 data["suggestions"].append(_split_pipe_payload(value))
78 elif base_key == "vulnerable_package":
79 data["vulnerable_packages"].append(_parse_vulnerable_package(value))
80 else:
81 data["metadata"][base_key] = value
82
83 return data

Callers 3

_collect_lynisMethod · 0.90
get_vulnerability_intelFunction · 0.90
_download_full_reportMethod · 0.90

Calls 3

_split_pipe_payloadFunction · 0.85
appendMethod · 0.80

Tested by 1

_download_full_reportMethod · 0.72