Parsing postfix
This commit is contained in:
parent
2325d9a5a0
commit
9e5ae61c69
@ -6,20 +6,33 @@ from parsing.base import ParsingBase
|
||||
|
||||
|
||||
class Parsing(ParsingBase):
|
||||
def __init__(self, objects):
|
||||
def __init__(self, objects, arguments):
|
||||
self._parsing = dict()
|
||||
self._reports = dict()
|
||||
self._objects = objects
|
||||
self._postfix_file = arguments["postfix_file"]
|
||||
print(self._objects)
|
||||
print(arguments)
|
||||
|
||||
def runParsing(self):
|
||||
# Generate report
|
||||
self._constructReports()
|
||||
|
||||
|
||||
print(self._reports)
|
||||
# Check if the file exist
|
||||
try:
|
||||
with open(self._postfix_file, 'rb') as fdata:
|
||||
self._parseFile(fdata)
|
||||
except FileNotFoundError:
|
||||
print("No postfix file found. Add into the report")
|
||||
pass
|
||||
|
||||
def _parseFile(self):
|
||||
pass
|
||||
def _parseFile(self, fdata):
|
||||
data = fdata.read()
|
||||
lines = data.splitlines()
|
||||
|
||||
for line in lines:
|
||||
line = line.decode('utf-8')
|
||||
print(line)
|
||||
|
||||
def _generateReport(self, objects):
|
||||
# We can generate the report
|
||||
|
@ -15,6 +15,9 @@ class Parsing(ParsingBase):
|
||||
# Generate report
|
||||
self._constructReports()
|
||||
|
||||
# TODO:
|
||||
# We are not parse file and process. We parse file and process and for each
|
||||
# line, we try to find in the file and in the process
|
||||
for audit in self._audit:
|
||||
if audit['audit'] == 'file':
|
||||
with open(audit['value'], 'rb') as fdata:
|
||||
|
@ -67,7 +67,10 @@ def main():
|
||||
print("Auditing the system...")
|
||||
for audit in AUDIT_SYSTEM:
|
||||
if audit not in configs["system"]["exclude_plugins"]:
|
||||
report["system"][audit] = dispatcher.runPlugin(audit, configs["system"][audit])
|
||||
report["system"][audit] = dispatcher.runPlugin(
|
||||
audit,
|
||||
configs["system"][audit]
|
||||
)
|
||||
|
||||
if args.audit == "application":
|
||||
print("Auditing the application...")
|
||||
@ -84,8 +87,7 @@ def sysctl(*args) -> dict:
|
||||
|
||||
@Dispatcher.register_plugins
|
||||
def postfix(*args) -> dict:
|
||||
arguments = args[1]
|
||||
postfix = Postfix()
|
||||
postfix = Postfix(args[1])
|
||||
postfix.runAudit()
|
||||
return postfix.getReports()
|
||||
|
||||
|
@ -4,19 +4,26 @@ from audit.system.plugins.postfix.parsing import Parsing
|
||||
from audit.system.plugins.postfix.postfix import postfix
|
||||
|
||||
class Postfix:
|
||||
def __init__(self):
|
||||
def __init__(self, arguments):
|
||||
self._objects = dict()
|
||||
self._reports = dict()
|
||||
self._arguments = arguments
|
||||
|
||||
self._postfix()
|
||||
|
||||
self._parsing = Parsing(self._objects)
|
||||
self._parsing = Parsing(self._objects, arguments)
|
||||
|
||||
def _postfix(self):
|
||||
"""
|
||||
Store all data to analyze in the object variable
|
||||
"""
|
||||
self._objects = postfix()
|
||||
|
||||
def runAudit(self):
|
||||
print("Running test for postfix")
|
||||
self._parsing.runParsing()
|
||||
|
||||
self._reports = self._parsing.getResults()
|
||||
|
||||
def getReports(self) -> dict:
|
||||
return self._reports
|
||||
|
@ -28,12 +28,9 @@ class Sysctl:
|
||||
|
||||
def runAudit(self):
|
||||
print("Running test for sysctl")
|
||||
# Read /etc/sysctl.conf
|
||||
self._parsing.runParsing()
|
||||
#self._reports.append(self._parsing.getResults())
|
||||
self._reports = self._parsing.getResults()
|
||||
|
||||
# Run process sysctl
|
||||
self._parsing.runParsing()
|
||||
self._reports = self._parsing.getResults()
|
||||
|
||||
def getReports(self) -> dict:
|
||||
return self._reports
|
||||
|
Loading…
Reference in New Issue
Block a user