From 46e55a3351c7530d96e1e649bfb3bc55e96da232 Mon Sep 17 00:00:00 2001 From: "Andoni A." <14891798+andoniaf@users.noreply.github.com> Date: Tue, 17 Feb 2026 09:39:52 +0100 Subject: [PATCH] test(image): add --registry-list validation tests and factory comment - Add test_registry_list_without_registry_fails: validates that --registry-list without --registry returns an error - Add test_registry_list_with_registry_passes: validates the happy path - Add clarifying comment in factory.py about ECR using OCI adapter --- prowler/providers/image/lib/registry/factory.py | 2 ++ tests/providers/image/lib/registry/test_arguments.py | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/prowler/providers/image/lib/registry/factory.py b/prowler/providers/image/lib/registry/factory.py index fdb7ad1adc..4c351705ee 100644 --- a/prowler/providers/image/lib/registry/factory.py +++ b/prowler/providers/image/lib/registry/factory.py @@ -27,6 +27,8 @@ def create_registry_adapter( token=token, verify_ssl=verify_ssl, ) + # ECR and other non-Docker-Hub registries implement the OCI Distribution Spec, + # so they are handled by the generic OCI adapter. return OciRegistryAdapter( registry_url=registry_url, username=username, diff --git a/tests/providers/image/lib/registry/test_arguments.py b/tests/providers/image/lib/registry/test_arguments.py index 416c3792da..974a41e0d0 100644 --- a/tests/providers/image/lib/registry/test_arguments.py +++ b/tests/providers/image/lib/registry/test_arguments.py @@ -73,6 +73,17 @@ class TestValidateArguments: ok, _ = validate_arguments(args) assert ok + def test_registry_list_without_registry_fails(self): + args = Namespace(images=["nginx:latest"], image_list_file=None, registry=None, image_filter=None, tag_filter=None, max_images=0, registry_insecure=False, registry_list_images=True) + ok, msg = validate_arguments(args) + assert not ok + assert "--registry-list requires --registry" in msg + + def test_registry_list_with_registry_passes(self): + args = Namespace(images=[], image_list_file=None, registry="myregistry.io", image_filter=None, tag_filter=None, max_images=0, registry_insecure=False, registry_list_images=True) + ok, _ = validate_arguments(args) + assert ok + def test_combined_registry_and_image_passes(self): args = Namespace(images=["nginx:latest"], image_list_file=None, registry="myregistry.io", image_filter=None, tag_filter=None, max_images=0, registry_insecure=False) ok, _ = validate_arguments(args)