diff --git a/audit/system/plugins/apache.py b/audit/system/plugins/apache.py index 520d5ae..c1f0c60 100644 --- a/audit/system/plugins/apache.py +++ b/audit/system/plugins/apache.py @@ -15,3 +15,20 @@ def apache_protocols() -> dict: return ssl +def apache_signature() -> dict: + signature = dict() + + signature["description"] = "Disable Apache signature" + signature["level"] = "high" + signature['value'] = 'ServerSignature On' + + return signature + +def apache_indexes() -> dict: + indexes = dict() + + indexes['description'] = 'Disable files and directory indexes' + indexes['level'] = 'medium' + indexes['value'] = 'Options -Indexes' + + return indexes diff --git a/core/plugins/apache.py b/core/plugins/apache.py index 338ad7e..a12967c 100644 --- a/core/plugins/apache.py +++ b/core/plugins/apache.py @@ -3,12 +3,14 @@ import re from os import listdir from os.path import isdir -from audit.system.plugins.apache import apache_protocols +from audit.system.plugins.apache import apache_protocols, apache_signature, apache_indexes class Apache: def __init__(self, arguments): self._ssl_versions = apache_protocols() + self._signature = apache_signature() + self._indexes = apache_indexes() self._reports = dict() self._apache_directory = arguments["apache_directory"] @@ -20,7 +22,16 @@ class Apache: def runAudit(self): print("Running test for Apache") - self._analyzingSslVersion() + + # Check if the directory exist + path = f"{self._apache_directory}" + if isdir(path): + self._analyzingSslVersion() + else: + self._reports['audit'] = False + self._reports["msg"] = "No directory found" + + print(self._reports) def getReports(self) -> dict: return self._reports @@ -30,14 +41,19 @@ class Apache: path = f"{self._apache_directory}/sites-available" if isdir(path): self._reports['audit'] = True + count = 0 for site in listdir(path): with open(f"{path}/{site}", 'rb') as f: self._parseFile(f) + count += 1 + + if count == 0: + self._reports['audit'] = False + self._reports['msg'] = \ + f'No virtual host found in the directory {path}' else: self._reports['audit'] = False - self._reports["msg"] = "No directory found" - - print(self._reports) + self._reports["msg"] = f"No directory {path} found" def _parseFile(self, fdata): data = fdata.read() @@ -102,3 +118,5 @@ class Apache: - level: high, medium or low """ self._reports['ssl'] = dict() + self._reports['signature'] = dict() + self._reports['indexes'] = dict()