Commit Graph
17 Commits
Author SHA1 Message Date
Andoni A. ed97fcd059 fix(image): add None guard, top-level import, and 401-retry to registry adapters
Add early return in _resolve_basic_credentials when password is None
to prevent TypeError on base64.b64decode. Move DockerHubAdapter import
from local scope to top-level in image_provider.py per PEP 8. Add
one-time 401 retry with token refresh in _authed_request to handle
per-repository-scoped bearer tokens on strict OCI registries.
2026-02-17 10:59:49 +01:00
Andoni A. b9060bebb0 style(image): apply black formatting to image provider files 2026-02-17 10:33:48 +01:00
Andoni A. e8ab331dff refactor(image): remove dead code from registry adapter layer
Remove unused detect_registry_type() function and _ECR_PATTERN constant
from factory.py, along with their corresponding tests. Move requests
import behind TYPE_CHECKING guard in oci_adapter.py and
dockerhub_adapter.py since it is only used for type annotations.
2026-02-17 10:17:46 +01:00
Andoni A. d9e451489d fix(image): harden registry adapter layer
- Fix shared dict mutation in ImageBaseException (thread-safety)
- Handle unexpected status codes in OCI adapter auth flow
- Force TLS verification for Docker Hub endpoints
- Add credential-safe __repr__ to RegistryAdapter
- Rename _next_page_url override to _next_tag_page_url in DockerHubAdapter
- Distinguish rate-limit from connection errors in retry logic
- Add type hints to all public adapter methods
- Remove unused imports in test files (flake8)
2026-02-17 10:01:35 +01:00
Andoni A. b00c76acf2 test(image): update mock patch targets after base class refactor
Update test patches from adapter-level to base-level module paths since
requests and time are now imported in base.py. Consolidate separate
requests.post/requests.get patches into requests.request since all HTTP
calls now go through _request_with_retry.
2026-02-17 09:41:57 +01:00
Andoni A. 46e55a3351 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
2026-02-17 09:39:52 +01:00
Andoni A. 103f71c215 fix(image): use correct singular/plural in registry listing output
Handle "1 repository" vs "2 repositories" and "1 image" vs "2 images"
in _print_registry_listing output.
2026-02-17 09:39:29 +01:00
Andoni A. 304fa25f25 feat(image): support public Docker Hub registry scan without credentials
- Use public /v2/repositories/{ns}/ endpoint when unauthenticated
- Fall back to namespace API when JWT is available for private repos
- Add test for unauthenticated public namespace listing
2026-02-17 08:43:01 +01:00
Andoni A. 876702fd22 feat(image): add --registry-list flag for image discovery
Add --registry-list flag that enumerates registry repositories and tags,
then prints a structured listing and exits without scanning. This helps
users discover available images before building --image-filter or
--tag-filter regexes.
2026-02-17 07:44:41 +01:00
Andoni A. 326def4a17 fix(image): handle Basic auth challenge and pre-encoded ECR credentials
- Detect Basic auth challenges (non-Bearer) in _ensure_auth()
- Decode base64-wrapped credentials from aws ecr get-authorization-token
- Add unit tests for credential resolution and Basic auth flow
2026-02-16 17:50:05 +01:00
Andoni A. aa284b8b24 test(image): add comprehensive registry scan mode unit tests
69 tests covering:
- Factory auto-detection (OCI, Docker Hub, ECR URL patterns)
- OCI adapter (auth flows, pagination, retry, error handling)
- Docker Hub adapter (namespace extraction, Hub API, token exchange)
- Argument validation (registry flags, Docker Hub namespace)
- Provider integration (enumeration, filtering, max-images, dedup)
2026-02-16 15:42:02 +01:00
Andoni A. ace36fe76e feat(image): add registry scan mode with OCI, Docker Hub, and ECR support
Add pluggable registry adapter pattern for enumerating and scanning all
container images in a private registry. Supports:
- Generic OCI registries (Harbor, GitLab, JFrog) via /v2/_catalog
- Docker Hub via Hub REST API with namespace-based enumeration
- AWS ECR via standard OCI endpoints with ECR auth token

New CLI flags: --registry, --image-filter, --tag-filter, --max-images,
--registry-insecure
2026-02-16 15:35:55 +01:00
Andoni A. 6b0a139361 Merge remote-tracking branch 'origin/master' into feat/PROWLER-939-stage-2-registry-auth
# Conflicts:
#	prowler/CHANGELOG.md
#	prowler/lib/check/models.py
#	prowler/providers/common/provider.py
#	prowler/providers/image/exceptions/exceptions.py
#	prowler/providers/image/image_provider.py
#	tests/providers/image/image_provider_test.py
2026-02-13 13:09:51 +01:00
Andoni A. 0589721505 fix(image): include missing merge changes from stage-1 and docs branches
The pre-commit hook stash/restore cycle during the first merge caused
some auto-merged changes to be excluded from the merge commits. This
commit includes the remaining changes: error code renumbering (9000→11000
range), input validation, image config scanners, and docs branch updates.
2026-02-12 22:38:11 +01:00
Andoni Alonso aa7490aab4 feat(image): add container image provider for CLI scanning (#9984) 2026-02-12 16:36:48 +01:00
Andoni A. f7adbc2dcf feat(image): add docker login and pull for private registry authentication
Trivy's remote source cannot authenticate against Docker Hub (and some
other registries) even after docker login. This adds a docker login +
docker pull flow before scanning so Trivy can access private images
from the local Docker daemon.

- Add _docker_login, _docker_pull, _docker_logout, cleanup methods
- Add _extract_registry to determine registry from image reference
- Wrap run() in try/finally to ensure cleanup on success or error
- Wire registry credentials from CLI args to ImageProvider
- Add ImageDockerLoginError and ImageDockerNotFoundError exceptions
2026-02-06 15:08:42 +01:00
Andoni A. 31d9a23225 feat(image): add container image provider for CLI scanning
Add a new Image provider that uses Trivy for container image vulnerability
and secret scanning, integrated into the Prowler CLI.

- ImageProvider class with Trivy integration for vuln/secret/misconfig scanning
- CLI support via `prowler image -I <image>` with severity filters, timeout,
  ignore-unfixed, and image-list-file options
- CheckReportImage model for image-specific findings
- Custom exceptions (9000-9005) with clear remediation messages
- Error handling for Trivy failures (non-zero exit, binary not found)
- Batch processing of findings with progress bar
- test_connection() for registry accessibility checks
- Comprehensive test coverage
2026-02-06 13:59:48 +01:00