diff --git a/src/iac_scan_runner/results_summary.py b/src/iac_scan_runner/results_summary.py index 511e70b9ab73de2e528aeda528ac0c6900dd51c0..b5afef106f4600b7636b077c6d01e7927878d99a 100644 --- a/src/iac_scan_runner/results_summary.py +++ b/src/iac_scan_runner/results_summary.py @@ -227,7 +227,7 @@ class ResultsSummary: for scan in self.outcomes: - if not(scan == "uuid") and not(scan == "time") and not(scan == "archive") and self.outcomes[scan]["status"] == "Problems": + if not(scan == "uuid") and not(scan == "time") and not(scan == "archive") and not(scan == "execution-duration") and self.outcomes[scan]["status"] == "Problems": html_page = html_page + "<tr>" html_page = html_page + "<td>" + scan + "</td>" @@ -239,7 +239,7 @@ class ResultsSummary: for scan in self.outcomes: - if not(scan == "uuid") and not(scan == "time") and not(scan == "archive") and self.outcomes[scan]["status"] == "Passed": + if not(scan == "uuid") and not(scan == "time") and not(scan == "archive") and not(scan == "execution-duration") and self.outcomes[scan]["status"] == "Passed": html_page = html_page + "<tr>" html_page = html_page + "<td>" + scan + "</td>" html_page = html_page + "<td bgcolor='green'>" + str(self.outcomes[scan]["status"]) + "</td>" @@ -250,7 +250,7 @@ class ResultsSummary: for scan in self.outcomes: - if not(scan=="uuid") and not(scan=="time") and not(scan == "archive") and self.outcomes[scan]["status"] == "Info" : + if not(scan=="uuid") and not(scan=="time") and not(scan == "archive") and not(scan == "execution-duration") and self.outcomes[scan]["status"] == "Info" : html_page = html_page + "<tr>" html_page = html_page + "<td>" + scan + "</td>" html_page = html_page + "<td bgcolor='yellow'>" + str(self.outcomes[scan]["status"]) + "</td>" @@ -261,7 +261,7 @@ class ResultsSummary: for scan in self.outcomes: - if not(scan=="uuid") and not(scan=="time") and not(scan == "archive") and self.outcomes[scan]["status"] == "No files" : + if not(scan=="uuid") and not(scan=="time") and not(scan == "archive") and not(scan == "execution-duration") and self.outcomes[scan]["status"] == "No files" : html_page = html_page + "<tr>" html_page = html_page + "<td>" + scan + "</td>" html_page = html_page + "<td bgcolor='gray'>" + str(self.outcomes[scan]["status"]) + "</td>" diff --git a/src/iac_scan_runner/scan_runner.py b/src/iac_scan_runner/scan_runner.py index 3f61f65a2c6bdaccfdc09f54e12df259e6020985..99494eeb16d152c7ddc25d445b7dad0151812163 100644 --- a/src/iac_scan_runner/scan_runner.py +++ b/src/iac_scan_runner/scan_runner.py @@ -45,6 +45,7 @@ import uuid import os import json from datetime import datetime +import time class ScanRunner: def __init__(self): @@ -141,6 +142,7 @@ class ScanRunner: :param scan_response_type: Scan response type (JSON or HTML) :return: Dict or string with output for running checks """ + start_time = time.time() random_uuid = str(uuid.uuid4()) # TODO: Replace this hardcoded path with a parameter dir_name = "../outputs/logs/scan_run_" + random_uuid @@ -167,14 +169,16 @@ class ScanRunner: non_compatible_checks.append(check.name) write_string_to_file(check.name, dir_name, "No files to scan") self.results_summary.summarize_no_files(check.name) - + end_time = time.time() + duration = end_time-start_time self.results_summary.generate_html_prioritized(random_uuid) self.results_summary.outcomes["uuid"] = random_uuid self.results_summary.outcomes["archive"] = self.archive_name self.results_summary.outcomes["time"] = datetime.now().strftime("%m/%d/%Y, %H:%M:%S") + self.results_summary.outcomes["execution-duration"] = str(round(duration, 3)) self.results_summary.dump_outcomes(random_uuid) - + if(self.results_persistence.connection_problem == False and self.persistence_enabled == True): self.results_persistence.insert_result(self.results_summary.outcomes) @@ -190,12 +194,15 @@ class ScanRunner: non_compatible_checks.append(iac_check.name) write_string_to_file(iac_check.name, dir_name, "No files to scan") self.results_summary.summarize_no_files(iac_check.name) - + + end_time = time.time() + duration = end_time-start_time self.results_summary.generate_html_prioritized(random_uuid) self.results_summary.outcomes["uuid"] = random_uuid self.results_summary.outcomes["archive"] = self.archive_name self.results_summary.outcomes["time"] = datetime.now().strftime("%m/%d/%Y, %H:%M:%S") + self.results_summary.outcomes["execution-duration"] = str(round(duration, 3)) self.results_summary.dump_outcomes(random_uuid) if(self.results_persistence.connection_problem == False and self.persistence_enabled == True):