mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-20 18:34:20 +00:00
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:
1 file changed
+26
-6
@@ -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", {})
|
||||
|
||||
Reference in new issue
Block a user