Skip to content

Commit

Permalink
WIP: report html
Browse files Browse the repository at this point in the history
  • Loading branch information
kazet committed Jul 17, 2024
1 parent 4887713 commit 7ba6cc3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions artemis/reporting/base/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class Report:
# The severity (added during report post-processing)
severity: Optional[Severity] = None

# HTML render of the report (added during post-processing)
html: Optional[str] = None

def __post_init__(self) -> None:
# Sanity check - at this moment, only URLs and domains are supported
assert self.target_is_url() or self.target_is_domain()
Expand Down
16 changes: 13 additions & 3 deletions artemis/reporting/export/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ def _build_messages_and_print_path(
with open(output_messages_directory_name / (top_level_target_shortened + ".html"), "w") as f:
f.write(message_template.render({"data": export_data_dict["messages"][top_level_target]}))

for message in export_data.messages.values():
for report in message.reports:
message_data = {
"contains_type": {report.report_type},
"reports": [report],
"custom_template_arguments": message.custom_template_arguments,
}
message_data["custom_template_arguments"]["skip_html_and_body_tags"] = True # type: ignore
message_data["custom_template_arguments"]["skip_header_and_footer_text"] = True # type: ignore
report.html = message_template.render({"data": message_data})

if not silent:
print()
print(termcolor.colored(f"Messages written to: {output_messages_directory_name}", attrs=["bold"]))
Expand Down Expand Up @@ -131,8 +142,9 @@ def export(
if not skip_hooks:
run_export_hooks(output_dir, export_data, silent)

_dump_export_data_and_print_path(export_data, output_dir, silent)
message_template = _build_message_template_and_print_path(output_dir, silent)
_build_messages_and_print_path(message_template, export_data, output_dir, silent)
_dump_export_data_and_print_path(export_data, output_dir, silent)

print_and_save_stats(export_data, output_dir, silent)

Expand All @@ -149,8 +161,6 @@ def export(
for tag in sorted([key for key in export_db_connector.tag_stats.keys() if key]):
print(f"\t{tag}: {export_db_connector.tag_stats[tag]}")

_build_messages_and_print_path(message_template, export_data, output_dir, silent)

if not silent:
for alert in export_data.alerts:
print(termcolor.colored("ALERT:" + alert, color="red"))
Expand Down
1 change: 1 addition & 0 deletions artemis/reporting/severity.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Severity(str, Enum):

SEVERITY_MAP = {
ReportType("forti_vuln"): Severity.HIGH,
ReportType("globalprotect_vuln"): Severity.HIGH,
ReportType("insecure_wordpress"): Severity.HIGH,
ReportType("nuclei_vulnerability"): Severity.HIGH,
ReportType("script_unregistered_domain"): Severity.HIGH,
Expand Down

0 comments on commit 7ba6cc3

Please sign in to comment.