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