From 3cd25dce85db70b9d301aae05ce49b8d06fc6a85 Mon Sep 17 00:00:00 2001 From: gbucchino Date: Fri, 8 Sep 2023 16:34:48 +0200 Subject: [PATCH] Update postfix audit --- audit/system/plugins/postfix/parsing.py | 13 ++++++++++--- audit/system/plugins/postfix/postfix.py | 10 ++++++---- core/report.py | 3 ++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/audit/system/plugins/postfix/parsing.py b/audit/system/plugins/postfix/parsing.py index 3ed57bb..e6843a2 100644 --- a/audit/system/plugins/postfix/parsing.py +++ b/audit/system/plugins/postfix/parsing.py @@ -11,8 +11,6 @@ class Parsing(ParsingBase): self._reports = dict() self._objects = objects self._postfix_file = arguments["postfix_file"] - print(self._objects) - print(arguments) def runParsing(self): # Generate report @@ -30,9 +28,18 @@ class Parsing(ParsingBase): data = fdata.read() lines = data.splitlines() + obj = self._objects['regexp'].split("=") + directive = obj[0].strip() + value = obj[1].strip() + print(self._objects) + for line in lines: line = line.decode('utf-8') - print(line) + grDirective = re.search(directive, line) + if grDirective: + grValue = re.search(value, line) + if grValue: + print(line) def _generateReport(self, objects): # We can generate the report diff --git a/audit/system/plugins/postfix/postfix.py b/audit/system/plugins/postfix/postfix.py index 91af529..56d1657 100644 --- a/audit/system/plugins/postfix/postfix.py +++ b/audit/system/plugins/postfix/postfix.py @@ -1,7 +1,9 @@ #!/usr/bin/env python3 -def postfix() -> dict: - postfix = dict() - postfix['regexp'] = "inet_interfaces = all" - postfix['replace'] = "inet_interfaces = loopback-only" +def postfix() -> list: + postfix = list() + postfix.append({ + 'directive': "inet_interfaces", + 'value': "loopback-only", + }) return postfix diff --git a/core/report.py b/core/report.py index 3e6dcca..b4db34e 100644 --- a/core/report.py +++ b/core/report.py @@ -23,7 +23,8 @@ def generateHtmlReport(data): #print(plugin) dataJinja2['plugins'].append(f"{plugin}.html.j2") - if 'postfix' in dataJinja2['plugins']: + if 'postfix' in data['system']: + #print(data['system']['postfix']) pass if 'sysctl' in data['system']: