diff --git a/core/plugins/apache.py b/core/plugins/apache.py index b265893..0cc0d77 100644 --- a/core/plugins/apache.py +++ b/core/plugins/apache.py @@ -180,7 +180,7 @@ class Apache: self._reports["indexes"]["audit"] = True with open(path, 'rb') as fdata: - self._reports["indexes"]["indexes"] = \ + self._reports["indexes"] = \ self._parsingApacheConfig(fdata) else: self._reports["indexes"]["audit"] = False @@ -195,10 +195,11 @@ class Apache: # Each entry in the variable directories contains a list # of with all data in it # We create another entry when a found - directories = list() + directories = dict() directoryFound = False index = 0 optsFound = list() + currentPath = None for line in lines: line = line.decode('utf-8') @@ -208,53 +209,53 @@ class Apache: grDirectory = re.search("", line, re.IGNORECASE) if grDirectory: directoryFound = False index += 1 + currentPath = None # We will find if we find an indexes option - for d in directories: - for entry in d: - # We get the directory path - path = self._getDirectoryPath(entry) - report["directories"][path] = dict() + for directory in directories: + report["directories"][directory] = dict() + report["directories"][directory]["options"] = list() - # Try to find the Option flag + for line in directories[directory]: grFlag = re.search( f"{self._indexes['flag']}", - entry, + line, re.IGNORECASE ) if grFlag: for opt in self._indexes['options']: grOption = re.search( f"-{opt}", - entry, + line, re.IGNORECASE ) if grOption: optsFound.append(opt) - report["audit"] = True - report["options"] = dict() - if len(optsFound) == len(self._indexes['options']): - report["result"] = "success" - else: - report["result"] = "failed" - for opt in self._indexes["options"]: - if opt not in optsFound: - report["options"][opt] = f"{opt} is not removed. You should disable it" + # We can check if you found the options + if len(optsFound) == len(self._indexes['options']): + report["directories"][directory]["result"] = "success" + else: + report["directories"][directory]["result"] = "failed" + for opt in self._indexes["options"]: + if opt not in optsFound: + report["directories"][directory]["options"].append( + f"{opt} is not removed. You should disable it" + ) + report["audit"] = True report["description"] = self._indexes["description"] report["level"] = self._indexes["level"] report["recommand_value"] = self._indexes["recommand_value"] - print(report) return report def _getDirectoryPath(self, line) -> str: diff --git a/core/report.py b/core/report.py index 9a7557b..471459c 100644 --- a/core/report.py +++ b/core/report.py @@ -47,16 +47,13 @@ def generateHtmlReport(path, data): "apache-virtualhost" ) if data['system']['apache']['signature']['audit']: - print(dataJinja2['apache']['signature']) _generateAccordion( dataJinja2["apache"]["signature"]["signature"], "apache-signature" ) - print("") if data['system']['apache']['indexes']['audit']: - print(dataJinja2['apache']['indexes']) _generateAccordion( - dataJinja2["apache"]["indexes"]["indexes"], + dataJinja2["apache"]["indexes"]["directories"], "apache-indexes" ) diff --git a/reports/templates/apache-indexes.html.j2 b/reports/templates/apache-indexes.html.j2 index 723d736..1416b8c 100644 --- a/reports/templates/apache-indexes.html.j2 +++ b/reports/templates/apache-indexes.html.j2 @@ -1,38 +1,38 @@ {% if data["apache"]["indexes"]["audit"] %} - {% for item in data['apache']['indexes']['indexes'] %} + {% for item in data['apache']['indexes']['directories'] %}

-

-
+
- {{ data['apache']['indexes']['indexes'][item]['description'] }}.
- {% if data['apache']['indexes']['indexes'][item]['result'] == 'failed' %} + {{ data['apache']['indexes']['description'] }}.
+ {% if data['apache']['indexes']["directories"][item]['result'] == 'failed' %} Result of the audit:

-                {% for protocol in data['apache']['indexes']['indexes'][item]['msg'] %}
-                    {{ protocol }}
+                {% for indexes in data['apache']['indexes']["directories"][item]['options'] %}
+                    {{ indexes }}
                 {% endfor %}
                 
- For resolving the issue, add this line in the VirtualHost file: + For resolving the issue, add this line in the apache config file:

-                  {{ data['apache']['indexes']['indexes'][item]['recommand_value'] }}
+                  {{ data['apache']['indexes']['recommand_value'] }}
                 
diff --git a/reports/templates/apache-signature.html.j2 b/reports/templates/apache-signature.html.j2 index 5eba14f..970b174 100644 --- a/reports/templates/apache-signature.html.j2 +++ b/reports/templates/apache-signature.html.j2 @@ -13,7 +13,7 @@ {{ data['apache']['signature']['signature'][item]['level'] }} -
+
{{ data['apache']['signature']['signature'][item]['description'] }}.
{% if data['apache']['signature']['signature'][item]['result'] == 'failed' %} diff --git a/reports/templates/apache-ssl.html.j2 b/reports/templates/apache-ssl.html.j2 index b0cf941..7e4378d 100644 --- a/reports/templates/apache-ssl.html.j2 +++ b/reports/templates/apache-ssl.html.j2 @@ -13,7 +13,7 @@ {{ data['apache']['ssl']['virtualhost'][item]['level'] }} -
+
{{ data['apache']['ssl']['virtualhost'][item]['description'] }}.
{% if data['apache']['ssl']['virtualhost'][item]['result'] == 'failed' %}