fix(api): detect registry URL vs image reference for Image provider

The Image provider UID was always passed as images=[uid], causing
registry URLs like docker.io/andoniaf to be treated as a single
image. Reuse the same heuristic from test_connection to pass
registry URLs as registry= instead, enabling image enumeration.
This commit is contained in:
Andoni A. committed 2026-02-20 09:09:29 +01:00
1 parent c1c33cc6d8
commit 0d184b28ff
1 file changed
+26 -6
+26 -6
View File
@@ -228,12 +228,32 @@ def get_prowler_provider_kwargs(
# Keystone API is unavailable on public clouds.
pass
elif provider.provider == Provider.ProviderChoices.IMAGE.value:
# Image provider uses uid as the image reference; registry credentials
# come from the secret (all optional).
prowler_provider_kwargs = {
"images": [provider.uid],
**{k: v for k, v in prowler_provider_kwargs.items() if v},
}
# Detect whether uid is a registry URL (e.g. "docker.io/andoniaf") or
# a concrete image reference (e.g. "docker.io/andoniaf/myimage:latest").
# Uses the same heuristic as ImageProvider.test_connection.
from prowler.providers.image.image_provider import ImageProvider
image_uid = provider.uid
registry_host = ImageProvider._extract_registry(image_uid)
if registry_host:
repo_and_tag = image_uid[len(registry_host) + 1 :]
else:
repo_and_tag = image_uid
is_registry_url = (
registry_host and "/" not in repo_and_tag and ":" not in repo_and_tag
)
if is_registry_url:
prowler_provider_kwargs = {
"registry": image_uid,
**{k: v for k, v in prowler_provider_kwargs.items() if v},
}
else:
prowler_provider_kwargs = {
"images": [image_uid],
**{k: v for k, v in prowler_provider_kwargs.items() if v},
}
if mutelist_processor:
mutelist_content = mutelist_processor.configuration.get("Mutelist", {})