diff --git a/src/iac_scan_runner/compatibility.py b/src/iac_scan_runner/compatibility.py index 1b818f03f3a8a067fc985e6f1a9af0626d289ec4..829d959a93da00d6a5576e4b2263461877136c49 100644 --- a/src/iac_scan_runner/compatibility.py +++ b/src/iac_scan_runner/compatibility.py @@ -4,16 +4,16 @@ from typing import List class Compatibility: # TODO: This matrix should be revised and extended, it is just a proof of concept here as for now compatibility_matrix = { - "terraform": ["tfsec", "tflint", "terrascan", "git-leaks", "git-secrets"], - "yaml": ["git-leaks", "yamllint", "git-secrets", "ansible-lint", "steampunk-scanner"], - "shell": ["shellcheck", "git-leaks", "git-secrets"], - "python": ["pylint", "bandit", "pyup-safety"], - #"ansible": ["ansible-lint", "steampunk-scanner"], - "java": ["checkstyle"], - "js": ["es-lint", "ts-lint"], - "html": ["htmlhint"], - "docker": ["hadolint"], - "other": ["git-leaks", "git-secrets"], + "terraform": ["tfsec", "tflint", "terrascan", "git-leaks", "git-secrets", "cloc"], + "yaml": ["git-leaks", "yamllint", "git-secrets", "ansible-lint", "steampunk-scanner", "cloc"], + "shell": ["shellcheck", "git-leaks", "git-secrets", "cloc"], + "python": ["pylint", "bandit", "pyup-safety", "cloc"], + "java": ["checkstyle", "cloc"], + "js": ["es-lint", "ts-lint", "cloc"], + "html": ["htmlhint", "cloc"], + "docker": ["hadolint", "cloc"], + "common": ["git-leaks", "git-secrets", "cloc"], + "other": [] } def __init__(self): @@ -48,12 +48,13 @@ class Compatibility: scanned_js = [] scanned_docker = [] scanned_other = [] - + scanned_all = [] # TODO: List of supported file types should be extended # TODO: Remove hardcoded check names try: for root, folders, names in os.walk(iac_directory): for f in names: + scanned_all.append(f) if (f.find(".tf") > -1) or (f.find(".tftpl") > -1): types.append("terraform") scanned_terraform.append(f) @@ -89,6 +90,8 @@ class Compatibility: else: types.append("other") scanned_other.append(f) + + types.append("common") self.scanned_files["terraform"] = str(scanned_terraform) self.scanned_files["python"] = str(scanned_py) @@ -99,6 +102,7 @@ class Compatibility: self.scanned_files["js"] = str(scanned_js) self.scanned_files["docker"] = str(scanned_docker) self.scanned_files["other"] = str(scanned_other) + self.scanned_files["common"] = str(scanned_all) types = set(types) diff --git a/src/iac_scan_runner/results_summary.py b/src/iac_scan_runner/results_summary.py index 1a108423f1d3f6786d1155c5ae33fe8949dd53ba..84dda91c8690536eeccfbc6d7b3db53103cbad30 100644 --- a/src/iac_scan_runner/results_summary.py +++ b/src/iac_scan_runner/results_summary.py @@ -63,6 +63,14 @@ class ResultsSummary: self.outcomes[check]["status"] = "Problems" return "Problems" + elif check == "git-secrets": + if outcome=="": + self.outcomes[check]["status"] = "Passed" + return "Passed" + else: + self.outcomes[check]["status"] = "Problems" + return "Problems" + elif check == "terrascan": if outcome == "": self.outcomes[check]["status"] = "Passed" @@ -159,6 +167,10 @@ class ResultsSummary: self.outcomes[check]["status"] = "Problems" return "Problems" + elif check == "cloc": + self.outcomes[check]["status"] = "Info" + return "Info" + elif check == "ansible-lint": if outcome=="": self.outcomes[check]["status"] = "Passed" @@ -236,6 +248,17 @@ class ResultsSummary: html_page = html_page + "<td>" + self.outcomes[scan]["log"] + "</td>" html_page = html_page + "</tr>" + for scan in self.outcomes: + + if 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>" + + html_page = html_page + "<td>" + self.outcomes[scan]["files"] + "</td>" + html_page = html_page + "<td>" + self.outcomes[scan]["log"] + "</td>" + html_page = html_page + "</tr>" + for scan in self.outcomes: if self.outcomes[scan]["status"] == "No files":