From c81239e00bdedab67555cb0d4dc0131d9e9366d5 Mon Sep 17 00:00:00 2001 From: "Andoni A." <14891798+andoniaf@users.noreply.github.com> Date: Fri, 20 Feb 2026 10:23:16 +0100 Subject: [PATCH] feat(sdk): add Image provider HTML assessment summary - Add get_image_assessment_summary static method to HTML class - Support registry URL and image list display modes - Add tests for both registry and image list scenarios --- prowler/lib/outputs/html/html.py | 50 ++++++++++++++++ tests/lib/outputs/html/html_test.py | 88 ++++++++++++++++++++++++++++- 2 files changed, 137 insertions(+), 1 deletion(-) diff --git a/prowler/lib/outputs/html/html.py b/prowler/lib/outputs/html/html.py index 779fa2d776..26ee798021 100644 --- a/prowler/lib/outputs/html/html.py +++ b/prowler/lib/outputs/html/html.py @@ -930,6 +930,56 @@ class HTML(Output): ) return "" + @staticmethod + def get_image_assessment_summary(provider: Provider) -> str: + """ + get_image_assessment_summary gets the HTML assessment summary for the Image provider + + Args: + provider (Provider): the Image provider object + + Returns: + str: the HTML assessment summary + """ + try: + if provider.registry: + target_info = f"Registry URL: {provider.registry}" + else: + target_info = f'Images: {", ".join(provider.images)}' + + return f""" +
+
+
+ Image Assessment Summary +
+ +
+
+
+
+
+ Image Credentials +
+ +
+
""" + except Exception as error: + logger.error( + f"{error.__class__.__name__}[{error.__traceback__.tb_lineno}] -- {error}" + ) + return "" + @staticmethod def get_llm_assessment_summary(provider: Provider) -> str: """ diff --git a/tests/lib/outputs/html/html_test.py b/tests/lib/outputs/html/html_test.py index 727138d4b1..09e3038744 100644 --- a/tests/lib/outputs/html/html_test.py +++ b/tests/lib/outputs/html/html_test.py @@ -1,7 +1,7 @@ import sys from io import StringIO -from mock import patch +from mock import MagicMock, patch from prowler.config.config import prowler_version, timestamp from prowler.lib.logger import logger @@ -350,6 +350,62 @@ mongodbatlas_html_assessment_summary = """ """ +image_registry_html_assessment_summary = """ +
+
+
+ Image Assessment Summary +
+ +
+
+
+
+
+ Image Credentials +
+ +
+
""" + +image_list_html_assessment_summary = """ +
+
+
+ Image Assessment Summary +
+ +
+
+
+
+
+ Image Credentials +
+ +
+
""" + def get_aws_html_header(args: list) -> str: """ @@ -854,6 +910,36 @@ class TestHTML: assert summary == mongodbatlas_html_assessment_summary + def test_image_get_assessment_summary_with_registry(self): + """Test Image HTML assessment summary with registry URL.""" + findings = [generate_finding_output()] + output = HTML(findings) + + provider = MagicMock() + provider.type = "image" + provider.registry = "myregistry.io" + provider.images = ["nginx:latest", "alpine:3.18"] + provider.auth_method = "Docker login" + + summary = output.get_assessment_summary(provider) + + assert summary == image_registry_html_assessment_summary + + def test_image_get_assessment_summary_with_images(self): + """Test Image HTML assessment summary with image list.""" + findings = [generate_finding_output()] + output = HTML(findings) + + provider = MagicMock() + provider.type = "image" + provider.registry = None + provider.images = ["nginx:latest", "alpine:3.18"] + provider.auth_method = "No auth" + + summary = output.get_assessment_summary(provider) + + assert summary == image_list_html_assessment_summary + def test_process_markdown_bold_text(self): """Test that **text** is converted to text""" test_text = "This is **bold text** and this is **also bold**"