Update parsing for reporting
This commit is contained in:
parent
7e2c6b3ee8
commit
8b2e9cbd29
@ -22,7 +22,7 @@ class Parsing(ParsingBase):
|
||||
lines = data.splitlines()
|
||||
numLines = 1
|
||||
|
||||
self._constructResults(filename='/etc/sysctl.conf')
|
||||
self._constructReports(filename='/etc/sysctl.conf')
|
||||
|
||||
vulnerabilityFound = dict()
|
||||
|
||||
@ -53,24 +53,26 @@ class Parsing(ParsingBase):
|
||||
# And check if the flag is specified and need to put on the sysctl config
|
||||
for entry in vulnerabilityFound:
|
||||
obj = vulnerabilityFound[entry]
|
||||
self._reports[entry]['result'] = dict()
|
||||
if obj['occurence'] > 0:
|
||||
print(entry)
|
||||
print(obj)
|
||||
#print(entry)
|
||||
#print(obj)
|
||||
if obj['current_value'] != obj['recommand_value']:
|
||||
self._reports[entry]['result'] = "failed"
|
||||
self._reports[entry]['message'] = \
|
||||
f"You specify this value {obj['current_value']}" \
|
||||
", you should use this value {obj['recommand_value']}"
|
||||
self._reports[entry]['result']['result'] = "failed"
|
||||
#self._reports[entry]['message'] = \
|
||||
# f"You specify this value {obj['current_value']}" \
|
||||
# ", you should use this value {obj['recommand_value']}"
|
||||
else:
|
||||
self._reports[entry]['result'] = "success"
|
||||
self._reports[entry]['result']['result'] = "failed"
|
||||
else:
|
||||
# No find the flag, we recommand to enable it
|
||||
self._reports[entry]['message'] = ""
|
||||
self._reports[entry]['result']['result'] = "failed"
|
||||
|
||||
# We can generate the report
|
||||
print(self._reports)
|
||||
print("")
|
||||
print(vulnerabilityFound)
|
||||
from json import dumps
|
||||
print(dumps(vulnerabilityFound, indent=4))
|
||||
|
||||
def _parsingFile(self, line, obj, vulnerabilityFound) -> bool:
|
||||
"""
|
||||
@ -92,7 +94,7 @@ class Parsing(ParsingBase):
|
||||
|
||||
return result
|
||||
|
||||
def _constructResults(self, filename):
|
||||
def _constructReports(self, filename):
|
||||
"""
|
||||
Construct dictionary for result of the tests
|
||||
Each entry contains:
|
||||
|
Loading…
Reference in New Issue
Block a user