Skip to content

Commit

Permalink
Create reporter.py
Browse files Browse the repository at this point in the history
Signed-off-by: Aureum01 <[email protected]>
  • Loading branch information
Aureum01 authored May 16, 2023
1 parent a617dcf commit e2900b8
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/reporter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import logging
import json
import csv

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

class Reporter:
def __init__(self, vulnerable_domains):
self.vulnerable_domains = vulnerable_domains

def report(self, output_file="vulnerable_domains.txt"):
output_format = output_file.split(".")[-1]

if output_format == "json":
self.report_json(output_file)
elif output_format == "csv":
self.report_csv(output_file)
else:
self.report_txt(output_file)

logger.info("Vulnerabilities reported.")

def report_json(self, output_file):
with open(output_file, "w") as f:
json.dump(list(self.vulnerable_domains), f, indent=4)

def report_csv(self, output_file):
with open(output_file, "w") as f:
writer = csv.writer(f)
writer.writerow(["Domain"])
for domain in self.vulnerable_domains:
writer.writerow([domain])

def report_txt(self, output_file):
with open(output_file, "w") as f:
for domain in self.vulnerable_domains:
f.write(f"{domain}\n")

0 comments on commit e2900b8

Please sign in to comment.