template refactor

This commit is contained in:
2025-10-21 23:05:43 -05:00
parent 4846af66c4
commit ed3b1de1cd
12 changed files with 990 additions and 587 deletions

View File

@@ -45,8 +45,8 @@ def results_to_open_sets(
out[hr.address] = {"tcp": tcp, "udp": udp}
return out
# Build the "reports" dict (what the HTML renderer expects)
def build_reports(
# Build the grouped_reports (what the HTML renderer expects)
def build_grouped_reports(
scan_config: "ScanConfigFile",
discovered: Dict[str, Dict[str, Set[int]]],
) -> GroupedReports:
@@ -149,34 +149,34 @@ def run_repo_scan(scan_config:ScanConfigFile):
# tack the filename on the end of our data path
file_out_path = Path() / "data" / "output" / scan_config.reporting.report_filename
LIGHT_TEMPLATE = "report_light.html.j2"
DARK_TEMPLATE = "report_dark.html.j2"
template = LIGHT_TEMPLATE
if scan_config.reporting.dark_mode:
template = DARK_TEMPLATE
if scan_config.reporting.full_details:
show_only_issues = False
else:
show_only_issues = True
logger.info(f"Reporting Template Set to: {template}")
logger.info(f"Reporting Dark Mode set to: {scan_config.reporting.dark_mode}")
logger.info(f"Reporting Only Issues: {show_only_issues}")
scanner = nmap_scanner(scan_config)
scan_results = scanner.scan_targets()
discovered_sets = results_to_open_sets(scan_results, count_as_open={"open", "open|filtered"})
reports = build_reports(scan_config, discovered_sets)
grouped_reports = build_grouped_reports(scan_config, discovered_sets)
# build the HTML report
write_html_report_jinja(reports=reports,
# write_html_report_jinja(grouped=grouped_reports,
# host_results=scan_results,
# out_path=file_out_path,
# title=scan_config.reporting.report_name,
# template_name=template,
# only_issues=show_only_issues)
write_html_report_jinja(grouped=grouped_reports,
host_results=scan_results,
out_path=file_out_path,
title=scan_config.reporting.report_name,
template_name=template,
dark_mode=scan_config.reporting.dark_mode,
only_issues=show_only_issues)
scanner.cleanup()
def main():