feat(ecr): add ecr_repository_image_no_secrets check (#12123)

Co-authored-by: Hugo P.Brito <hugopbrit@gmail.com>
This commit is contained in:
Eugene C.
2026-08-18 11:10:07 +01:00
committed by GitHub
co-authored by Hugo P.Brito
parent f6defefb58
commit 0b9791ffdc
14 changed files with 2748 additions and 9 deletions
@@ -31,6 +31,8 @@
"ec2:GetInstanceMetadataDefaults",
"ecr:Describe*",
"ecr:GetRegistryScanningConfiguration",
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer",
"elasticfilesystem:DescribeBackupPolicy",
"glue:GetConnections",
"glue:GetSecurityConfiguration*",
@@ -203,6 +203,8 @@ Resources:
- "ec2:GetInstanceMetadataDefaults"
- "ecr:Describe*"
- "ecr:GetRegistryScanningConfiguration"
- "ecr:BatchGetImage"
- "ecr:GetDownloadUrlForLayer"
- "elasticfilesystem:DescribeBackupPolicy"
- "glue:GetConnections"
- "glue:GetSecurityConfiguration*"
@@ -470,6 +472,8 @@ Resources:
- "ec2:GetInstanceMetadataDefaults"
- "ecr:Describe*"
- "ecr:GetRegistryScanningConfiguration"
- "ecr:BatchGetImage"
- "ecr:GetDownloadUrlForLayer"
- "elasticfilesystem:DescribeBackupPolicy"
- "glue:GetConnections"
- "glue:GetSecurityConfiguration*"
@@ -0,0 +1 @@
`ecr_repository_image_no_secrets` check for AWS provider, scanning the latest ECR repository image's configuration and filesystem layers for hardcoded secrets
@@ -0,0 +1,42 @@
{
"Provider": "aws",
"CheckID": "ecr_repository_image_no_secrets",
"CheckTitle": "ECR repository image contains no hardcoded secrets",
"CheckType": [
"Software and Configuration Checks/AWS Security Best Practices",
"Sensitive Data Identifications/Passwords",
"Effects/Data Exposure"
],
"ServiceName": "ecr",
"SubServiceName": "",
"ResourceIdTemplate": "",
"Severity": "high",
"ResourceType": "AwsEcrRepository",
"ResourceGroup": "container",
"Description": "The **latest image** pushed to each **Amazon ECR repository** is analyzed for **embedded secrets**: environment variables and build history (Dockerfile instructions) recorded in the image configuration, plus the file contents of every filesystem layer. Findings reference the variable, build step, or file, never the secret value.",
"Risk": "Anyone able to pull the image obtains any **credentials, tokens, or keys** embedded at build time via `ENV`, `ARG`, inline `RUN` commands, or files copied into the image (e.g. `COPY .env .`).\n\nLeaked credentials enable unauthorized access to databases, APIs, or cloud resources, and rotation is harder once secrets are baked into distributed image artifacts.",
"RelatedUrl": "",
"AdditionalURLs": [
"https://docs.aws.amazon.com/AmazonECR/latest/userguide/security-best-practices.html",
"https://docs.aws.amazon.com/secretsmanager/latest/userguide/best-practices.html",
"https://docs.docker.com/build/building/secrets/"
],
"Remediation": {
"Code": {
"CLI": "aws ecr batch-delete-image --repository-name <repository-name> --image-ids imageDigest=<image-digest>",
"NativeIaC": "",
"Other": "1. Remove the secret from the Dockerfile (ENV/ARG/RUN) or from any file copied into the build context, and rebuild the image without it.\n2. Provide the secret at runtime instead: reference AWS Secrets Manager or SSM Parameter Store from your ECS task definition, EKS pod (Secrets Store CSI driver), or application code.\n3. Push the rebuilt image and delete the compromised image versions from the repository.\n4. Rotate the exposed credential immediately.",
"Terraform": ""
},
"Recommendation": {
"Text": "Never bake secrets into images with `ENV`, `ARG`, inline `RUN` commands, or copied files. Use **BuildKit build secrets** (`--mount=type=secret`) at build time and **AWS Secrets Manager**/Parameter Store at runtime. Add secret scanning to CI/CD before pushing images.",
"Url": "https://hub.prowler.com/check/ecr_repository_image_no_secrets"
}
},
"Categories": [
"secrets"
],
"DependsOn": [],
"RelatedTo": [],
"Notes": "Only the most recently pushed image in each repository is scanned; older tagged images are not scanned. The latest scannable image is evaluated in every repository regardless of whether scan-on-push is enabled. The scanned image's configuration (environment variables and build history) plus every filesystem layer's file contents are analyzed. A multi-architecture image resolves to a single platform's manifest; other architectures in the same manifest list are not scanned. To bound cost, a single layer over 100 MB (compressed) is not downloaded, an individual file over 1 MB is not scanned, and scanning of an image stops after 5000 files or 500 MB (decompressed). When part of an image cannot be scanned this way, a clean result is reported as MANUAL (coverage was incomplete) rather than PASS, and a FAIL still discloses that some content was skipped. Requires the ecr:BatchGetImage and ecr:GetDownloadUrlForLayer permissions in addition to SecurityAudit."
}
@@ -0,0 +1,244 @@
import re
from prowler.lib.check.models import Check, Check_Report_AWS
from prowler.lib.utils.utils import (
SecretsScanError,
annotate_verified_secrets,
detect_secrets_scan_batch,
)
from prowler.providers.aws.services.ecr.ecr_client import ecr_client
_SAFE_ENVIRONMENT_VARIABLE_NAME = re.compile(r"[A-Za-z_][A-Za-z0-9_]*")
class ecr_repository_image_no_secrets(Check):
"""Ensure the latest ECR repository image embeds no hardcoded secrets.
The most recently pushed image in every ECR repository is resolved to a
single scannable manifest (a multi-arch image resolves to one platform's
manifest; other architectures in the same manifest list are not
scanned) and scanned for plaintext secrets in its configuration
(environment variables, build history) and every filesystem layer's
file contents. Older tagged images are not scanned.
- PASS: no secrets detected and the whole image was scanned.
- FAIL: a potential secret was detected; the variable, build step, or
file is reported, never the secret value.
- MANUAL: the image could not be scanned in full, so a clean result would
be misleading -- the manifest could not be retrieved or resolved, the
scan itself failed, or part of the image exceeded configured size limits
or could not be retrieved.
"""
def execute(self) -> list[Check_Report_AWS]:
"""Execute the check logic.
Returns:
A list of reports containing the result of the check.
"""
findings = []
secrets_ignore_patterns = ecr_client.audit_config.get(
"secrets_ignore_patterns", []
)
validate = ecr_client.audit_config.get("secrets_validate", False)
# Phase 1: collect. The service yields (repository, image, scan_data)
# lazily, downloading each image's manifest, config, and layers; each
# image contributes an env/history/file payload per scannable unit so
# a finding's key maps back to a variable, build step, or file.
scanned = []
def image_payloads():
"""Yield keyed scan payloads, recording each image into `scanned`."""
for repository, image, scan_data in ecr_client._get_image_scan_data():
index = len(scanned)
scanned.append((repository, image, scan_data))
if scan_data is None or isinstance(scan_data, Exception):
continue
for env_index, entry in enumerate(scan_data.env):
yield (index, f"environment:{env_index}"), entry
for history_index, entry in enumerate(scan_data.history):
yield (index, f"history:{history_index}"), entry
for file_index, scanned_file in enumerate(scan_data.files):
yield (index, f"file:{file_index}"), scanned_file.content
# Free the file's contents once handed to the scanner. The
# report phase needs only its path and layer digest, so
# retained memory stays flat instead of growing with the
# number of repositories scanned.
scanned_file.content = ""
# Phase 2: batch — one call, chunked Kingfisher subprocesses. This
# must fully consume image_payloads() so every image is appended to
# `scanned` before Phase 3 runs; detect_secrets_scan_batch does so
# today, but a future short-circuit there would silently drop images
# from the report loop.
scan_error = None
try:
batch_results = detect_secrets_scan_batch(
image_payloads(),
excluded_secrets=secrets_ignore_patterns,
validate=validate,
)
except SecretsScanError as error:
batch_results = {}
scan_error = error
if scan_error:
# The scan failed and the payload generator may not have been
# consumed, so build the MANUAL reports from the repositories
# themselves rather than risk a false PASS or a missing finding.
for registry in ecr_client.registries.values():
for repository in registry.repositories:
image = ecr_client._get_scan_target_image(repository)
if isinstance(image, Exception):
findings.append(
self._build_scan_error_report(repository, image)
)
elif image is not None:
report = self._build_report(repository, image)
report.status = "MANUAL"
report.status_extended = (
f"Could not scan image '{image.latest_tag}' "
f"({image.latest_digest}) of ECR repository "
f"{repository.name} for secrets: {scan_error}; "
f"manual review is required."
)
findings.append(report)
return findings
# Phase 3: report — one finding per scanned image.
for index, (repository, image, scan_data) in enumerate(scanned):
if isinstance(scan_data, Exception):
findings.append(self._build_scan_error_report(repository, scan_data))
continue
report = self._build_report(repository, image)
image_reference = (
f"image '{image.latest_tag}' ({image.latest_digest}) of ECR "
f"repository {repository.name}"
)
if scan_data is None:
report.status = "MANUAL"
report.status_extended = (
f"Could not resolve or retrieve the manifest of the "
f"{image_reference} to scan it for secrets; manual "
f"review is required."
)
findings.append(report)
continue
env_findings_by_index = {
int(key[1].split(":", 1)[1]): entry_secrets
for key, entry_secrets in batch_results.items()
if key[0] == index and key[1].startswith("environment:")
}
history_findings_by_index = {
int(key[1].split(":", 1)[1]): entry_secrets
for key, entry_secrets in batch_results.items()
if key[0] == index and key[1].startswith("history:")
}
file_findings_by_index = {
int(key[1].split(":", 1)[1]): file_secrets
for key, file_secrets in batch_results.items()
if key[0] == index and key[1].startswith("file:")
}
if (
env_findings_by_index
or history_findings_by_index
or file_findings_by_index
):
secrets_found = []
all_secrets = []
for env_index, env_findings in env_findings_by_index.items():
variable = None
if 0 <= env_index < len(scan_data.env):
entry = scan_data.env[env_index]
# Only a well-formed "NAME=value" entry has a name safe
# to report; an entry with no "=" may itself be the
# secret, so it is never echoed back.
if "=" in entry:
candidate = entry.split("=", 1)[0]
if _SAFE_ENVIRONMENT_VARIABLE_NAME.fullmatch(candidate):
variable = candidate
all_secrets.extend(env_findings)
for secret in env_findings:
if variable is not None:
secrets_found.append(
f"{secret['type']} in environment variable {variable}"
)
else:
secrets_found.append(
f"{secret['type']} in image environment variables"
)
for (
history_index,
history_findings,
) in history_findings_by_index.items():
all_secrets.extend(history_findings)
for secret in history_findings:
secrets_found.append(
f"{secret['type']} in image history step {history_index + 1}"
)
for file_index, file_secrets in file_findings_by_index.items():
scanned_file = scan_data.files[file_index]
all_secrets.extend(file_secrets)
for secret in file_secrets:
secrets_found.append(
f"{secret['type']} in file {scanned_file.path} "
f"(layer {scanned_file.layer_digest})"
)
report.status = "FAIL"
report.status_extended = (
f"Potential {'secrets' if len(secrets_found) > 1 else 'secret'} "
f"found in the {image_reference} -> {', '.join(secrets_found)}."
)
if scan_data.truncated:
report.status_extended += (
" Some of the image could not be retrieved or exceeded "
"configured size limits and was not scanned."
)
annotate_verified_secrets(report, all_secrets)
elif scan_data.truncated:
# No secrets in what was scanned, but coverage was incomplete
# (size/count limits, or the config could not be retrieved), so
# a clean result would be misleading.
report.status = "MANUAL"
report.status_extended = (
f"No secrets were found in the scanned portion of the "
f"{image_reference}, but part of it could not be retrieved "
f"or exceeded configured size limits and was not scanned; "
f"manual review is required."
)
else:
report.status = "PASS"
report.status_extended = f"No secrets found in the {image_reference}."
findings.append(report)
return findings
def _build_scan_error_report(self, repository, error) -> Check_Report_AWS:
"""Build a repository-level report for a latest-image lookup failure."""
report = Check_Report_AWS(metadata=self.metadata(), resource=repository)
report.status = "MANUAL"
report.status_extended = (
f"Could not determine the latest image of ECR repository "
f"{repository.name}: {error}; manual review is required."
)
return report
def _build_report(self, repository, image) -> Check_Report_AWS:
"""Build a report scoped to a single image within a repository.
ECR images have no ARN of their own, so the repository's ARN is
reused with the image digest appended as a synthetic suffix,
mirroring how other sub-resource checks (e.g. CodeArtifact packages
within a repository) identify per-item findings.
"""
report = Check_Report_AWS(metadata=self.metadata(), resource=repository)
digest_short = image.latest_digest.split(":")[-1][:12]
report.resource_id = f"{repository.name}:{image.latest_tag}@{digest_short}"
report.resource_arn = f"{repository.arn}/image/{digest_short}"
return report
@@ -1,3 +1,4 @@
from concurrent.futures import FIRST_COMPLETED, Future, ThreadPoolExecutor, wait
from datetime import datetime
from json import loads
from typing import Optional
@@ -8,10 +9,21 @@ from pydantic.v1 import BaseModel
from prowler.lib.logger import logger
from prowler.lib.scan_filters.scan_filters import is_resource_filtered
from prowler.providers.aws.lib.service.service import AWSService
from prowler.providers.aws.services.ecr.image_inspection import ImageInspector
# Concurrency for the image-scan pipeline (_get_image_scan_data). Kept smaller
# than the shared MAX_WORKERS metadata pool because each task can retain up to
# MAX_LAYER_DOWNLOAD_BYTES compressed plus MAX_TOTAL_BYTES_PER_IMAGE decompressed
# content (see image_inspection), so a high worker count would multiply peak
# memory into several GB.
IMAGE_SCAN_MAX_WORKERS = 4
class ECR(AWSService):
"""AWS Elastic Container Registry service."""
def __init__(self, provider):
"""Discover registries, repositories, policies, and image metadata."""
# Call AWSService's __init__
super().__init__(__class__.__name__, provider)
self.registry_id = self.audited_account
@@ -24,6 +36,7 @@ class ECR(AWSService):
self.__threading_call__(self._list_tags_for_resource)
def _describe_registries_and_repositories(self, regional_client):
"""Populate the registry and its repositories for one region."""
logger.info("ECR - Describing registries and repositories...")
regional_registry_repositories = []
try:
@@ -68,6 +81,7 @@ class ECR(AWSService):
)
def _describe_repository_policies(self, regional_client):
"""Fetch and attach each repository's resource policy, if any."""
logger.info("ECR - Describing repository policies...")
try:
if regional_client.region in self.registries:
@@ -96,6 +110,7 @@ class ECR(AWSService):
)
def _get_repository_lifecycle_policy(self, regional_client):
"""Fetch and attach each repository's lifecycle policy, if any."""
logger.info("ECR - Getting repository lifecycle policy...")
try:
if regional_client.region in self.registries:
@@ -124,6 +139,7 @@ class ECR(AWSService):
)
def _get_image_details(self, regional_client):
"""Populate each scan-on-push repository's scannable, tagged images."""
logger.info("ECR - Getting images details...")
try:
if regional_client.region in self.registries:
@@ -158,12 +174,7 @@ class ECR(AWSService):
image_scan_findings_field_name = (
"imageScanFindingsSummary"
)
if "docker" in artifact_media_type:
type = "Docker"
elif "oci" in artifact_media_type:
type = "OCI"
else:
type = ""
type = ECR._artifact_type(artifact_media_type)
# If imageScanStatus is not present or imageScanFindingsSummary is missing,
# we need to call DescribeImageScanFindings because AWS' new version of
@@ -252,6 +263,7 @@ class ECR(AWSService):
)
def _list_tags_for_resource(self, regional_client):
"""Fetch and attach each repository's resource tags."""
logger.info("ECR - List Tags...")
try:
if regional_client.region in self.registries:
@@ -280,6 +292,7 @@ class ECR(AWSService):
)
def _get_registry_scanning_configuration(self, regional_client):
"""Fetch and attach the registry's image-scanning configuration."""
logger.info("ECR - Getting Registry Scanning Configuration...")
try:
if regional_client.region in self.registries:
@@ -315,6 +328,155 @@ class ECR(AWSService):
f"{regional_client.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
)
def _get_image_scan_data(self):
"""Lazily fetch manifest, config, and layer file contents for the latest image.
Only the most recently pushed scannable image in each repository is
scanned (resolved via _get_scan_target_image, which also covers
scan-on-push-disabled repositories) to bound cost on repositories
with many tags.
Not called from __init__: this is only invoked by the
ecr_repository_image_no_secrets check, since it downloads and
decompresses image layers and is significantly more expensive than
the metadata gathered above. A dedicated, smaller thread pool bounds
the concurrency (and therefore the peak memory) of this heavy
pipeline independently of the shared metadata pool.
Yields:
Tuple of repository, optional image, and scan data. The third item
is an exception when the authoritative image lookup failed.
"""
logger.info("ECR - Fetching image manifests, configs, and layers...")
inspector = ImageInspector()
def images_to_fetch():
for registry in self.registries.values():
for repository in registry.repositories:
image = self._get_scan_target_image(repository)
if isinstance(image, Exception):
yield repository, None, image
elif image is not None:
yield repository, image, None
with ThreadPoolExecutor(max_workers=IMAGE_SCAN_MAX_WORKERS) as executor:
pending = {}
targets = iter(images_to_fetch())
def submit_next():
try:
repository, image, error = next(targets)
except StopIteration:
return False
if error:
future = Future()
future.set_result(error)
else:
client = self.regional_clients[repository.region]
registry_id = self.registries[repository.region].id
future = executor.submit(
inspector.fetch_image_scan_data,
client,
registry_id,
repository.name,
image.latest_digest,
)
pending[future] = (repository, image)
return True
for _ in range(IMAGE_SCAN_MAX_WORKERS):
if not submit_next():
break
while pending:
completed, _ = wait(pending, return_when=FIRST_COMPLETED)
for future in completed:
repository, image = pending.pop(future)
scan_data = None
try:
scan_data = future.result()
except Exception as error:
logger.error(
f"{repository.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
)
yield repository, image, scan_data
submit_next()
@staticmethod
def _artifact_type(artifact_media_type: Optional[str]) -> str:
"""Map an image's artifact media type to a short image type label.
Returns:
"Docker", "OCI", or "" for an unrecognized/absent media type.
"""
if artifact_media_type:
if "docker" in artifact_media_type:
return "Docker"
if "oci" in artifact_media_type:
return "OCI"
return ""
def _get_scan_target_image(self, repository) -> Optional["ImageDetails"]:
"""Resolve the latest scannable image to scan for secrets.
Secret scanning is independent of ECR's vulnerability scanning
configuration, but `_get_image_details` only populates
`images_details` for scan-on-push-enabled repositories. For a
repository with scan-on-push disabled (empty `images_details`), this
performs a dedicated `describe_images` lookup to find the most
recently pushed scannable image, so those repositories are not
silently skipped.
The synthesized ImageDetails is deliberately NOT appended to
`repository.images_details`: other checks (e.g.
ecr_repositories_scan_vulnerabilities_in_latest_image) treat any
entry there as a scanned image and would FAIL scan-on-push-disabled
repositories that currently produce no finding.
Returns:
The latest scannable ImageDetails, or None if the repository has
no scannable image; an exception if the lookup failed.
"""
latest = repository.images_details[-1] if repository.images_details else None
try:
client = self.regional_clients[repository.region]
describe_images_paginator = client.get_paginator("describe_images")
for page in describe_images_paginator.paginate(
registryId=self.registries[repository.region].id,
repositoryName=repository.name,
PaginationConfig={"PageSize": 1000},
):
for image in page["imageDetails"]:
if image is None:
continue
artifact_media_type = image.get("artifactMediaType", None)
tags = image.get("imageTags", [])
if not ECR._is_artifact_scannable(artifact_media_type, tags):
continue
image_pushed_at = image.get("imagePushedAt")
if image_pushed_at is None:
continue
# Match _get_image_details' "sort ascending, take last"
# selection: on equal push dates the later-listed image
# wins, so `<` (not `<=`) is used to replace on ties.
if latest is not None and image_pushed_at < latest.image_pushed_at:
continue
latest = ImageDetails(
latest_tag=image.get("imageTags", ["None"])[0],
image_pushed_at=image_pushed_at,
latest_digest=image.get("imageDigest"),
scan_findings_status=None,
scan_findings_severity_count=None,
artifact_media_type=artifact_media_type,
type=ECR._artifact_type(artifact_media_type),
)
return latest
except Exception as error:
logger.error(
f"{repository.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
)
return error
@staticmethod
def _is_artifact_scannable(artifact_media_type: str, tags: list[str] = []) -> bool:
"""
@@ -355,12 +517,16 @@ class ECR(AWSService):
class FindingSeverityCounts(BaseModel):
"""Count of an image's vulnerability scan findings by severity."""
critical: int
high: int
medium: int
class ImageDetails(BaseModel):
"""A single scannable, tagged image within an ECR repository."""
latest_tag: str
latest_digest: str
image_pushed_at: datetime
@@ -371,6 +537,8 @@ class ImageDetails(BaseModel):
class Repository(BaseModel):
"""An ECR repository and its policies, images, and tags."""
name: str
arn: str
region: str
@@ -384,11 +552,15 @@ class Repository(BaseModel):
class ScanningRule(BaseModel):
"""A registry-level image-scanning rule and its repository filters."""
scan_frequency: str
scan_filters: list[dict]
class Registry(BaseModel):
"""An ECR registry: its repositories and scanning configuration."""
id: str
arn: str
region: str
@@ -0,0 +1,494 @@
import gzip
import tarfile
from contextlib import contextmanager
from json import loads
from typing import Optional
import requests
import zstandard
from pydantic.v1 import BaseModel
from prowler.lib.logger import logger
# Manifest media types that wrap several per-architecture manifests (a "fat
# manifest") rather than a single scannable image.
_MANIFEST_LIST_MEDIA_TYPES = {
"application/vnd.docker.distribution.manifest.list.v2+json",
"application/vnd.oci.image.index.v1+json",
}
# Compressed size of a single layer, checked against the manifest-declared
# size before downloading, and re-checked against actual bytes received.
MAX_LAYER_DOWNLOAD_BYTES = 100 * 1024 * 1024
# Size of a single extracted file considered for scanning.
MAX_FILE_BYTES = 1 * 1024 * 1024
# Hard cap on the number of files scanned per image, across all its layers.
MAX_FILES_PER_IMAGE = 5000
# Hard cap on total decompressed bytes read per image, across all its layers.
MAX_TOTAL_BYTES_PER_IMAGE = 500 * 1024 * 1024
LAYER_DOWNLOAD_TIMEOUT_SECONDS = 30
class _LayerTooLargeError(Exception):
"""Raised when a streamed layer exceeds MAX_LAYER_DOWNLOAD_BYTES."""
class _ImageTooLargeError(Exception):
"""Raised when decompressed image streams exceed their shared budget."""
class _CappedLayerReader:
"""A minimal read-only file object that caps the bytes it will yield.
Wraps a streaming HTTP body (urllib3's ``response.raw``) so ``tarfile`` can
read a gzip/uncompressed layer incrementally while enforcing an upper bound
on the compressed bytes consumed. A manifest that under-declares a layer's
size (the declared size is pre-checked separately) cannot make this buffer
an unbounded amount of untrusted data: once ``max_bytes`` is exceeded the
read raises ``_LayerTooLargeError`` instead of continuing.
"""
def __init__(self, raw, max_bytes: int):
"""Store the underlying raw stream and the remaining byte budget."""
self._raw = raw
self._remaining = max_bytes
def read(self, size: int = -1) -> bytes:
"""Read up to ``size`` bytes, never exceeding the remaining budget.
A negative/None ``size`` (``read all``) is treated as "read what's left
of the budget, plus one" so a lying stream can never pull an unbounded
amount into memory and an over-cap layer is still detected.
"""
if size is None or size < 0:
size = self._remaining + 1
to_read = min(size, self._remaining + 1)
chunk = self._raw.read(to_read)
self._remaining -= len(chunk)
if self._remaining < 0:
raise _LayerTooLargeError()
return chunk
class _DecompressedByteBudget:
"""Track every decompressed byte consumed across an image's tar streams."""
def __init__(self, max_bytes: int):
"""Set the shared decompressed-byte allowance."""
self.remaining = max_bytes
def wrap(self, raw):
"""Return a reader that charges bytes consumed from ``raw``."""
return _BudgetedReader(raw, self)
class _BudgetedReader:
"""Charge all stream reads against a shared decompressed-byte budget."""
def __init__(self, raw, budget: _DecompressedByteBudget):
self._raw = raw
self._budget = budget
def read(self, size: int = -1) -> bytes:
"""Read without allowing the shared budget to be exceeded."""
if size is None or size < 0:
size = self._budget.remaining + 1
chunk = self._raw.read(min(size, self._budget.remaining + 1))
self._budget.remaining -= len(chunk)
if self._budget.remaining < 0:
raise _ImageTooLargeError()
return chunk
class ImageScanFile(BaseModel):
"""A single file extracted from an image layer for secret scanning."""
path: str
layer_digest: str
content: str
class ImageScanData(BaseModel):
"""An image's scannable content: config env/history and layer files."""
env: list[str] = []
history: list[str] = []
files: list[ImageScanFile] = []
# True when part of the image was not scanned -- a layer/file exceeded a
# configured size or count limit, or the config blob could not be
# retrieved/parsed -- so a clean result can be reported as MANUAL
# (coverage incomplete) rather than a false PASS.
truncated: bool = False
class ImageInspector:
"""Bounded, opt-in extraction of an ECR image's scannable content.
Given a boto3 ECR client and an image digest, resolves the image's
manifest (handling multi-arch manifest lists and skipping attestation
manifests) and returns its configuration (environment variables, build
history) and every filesystem layer's file contents, subject to this
module's size and count limits.
This is deliberately isolated from the ECR service so a future check can
reuse the bounded extraction without the service downloading and
decompressing image layers by default: the service only pays this cost
when a check explicitly drives the inspector.
"""
def fetch_image_scan_data(
self, client, registry_id, repository_name, image_digest
) -> Optional[ImageScanData]:
"""Resolve one image's manifest and return its scannable content.
Downloads the config blob (environment variables, build history)
and every filesystem layer's file contents, bounded by the module's
size/count limits.
Returns:
An ImageScanData, or None if the manifest could not be resolved.
"""
manifest, truncated = self._resolve_image_manifest(
client, registry_id, repository_name, image_digest
)
if manifest is None:
return None
env = []
history = []
config_digest = (manifest.get("config") or {}).get("digest")
if config_digest:
config_bytes = self._download_layer(
client,
registry_id,
repository_name,
config_digest,
max_bytes=MAX_FILE_BYTES,
)
if config_bytes is None:
# The config blob (env vars, build history) could not be
# retrieved. Empty env/history would be indistinguishable
# from a clean config, so mark coverage incomplete instead
# of risking a false PASS.
truncated = True
else:
try:
config_json = loads(config_bytes)
env = config_json.get("config", {}).get("Env", []) or []
history = [
step.get("created_by", "")
for step in config_json.get("history", [])
if step.get("created_by")
]
except Exception as error:
logger.warning(
f"{repository_name} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
)
truncated = True
files = []
decompressed_budget = _DecompressedByteBudget(MAX_TOTAL_BYTES_PER_IMAGE)
for layer in manifest.get("layers", []):
if len(files) >= MAX_FILES_PER_IMAGE or decompressed_budget.remaining <= 0:
truncated = True
break
layer_digest = layer.get("digest")
layer_size = layer.get("size", 0)
if layer_size and layer_size > MAX_LAYER_DOWNLOAD_BYTES:
truncated = True
continue
try:
with self._open_layer_tar_stream(
client,
registry_id,
repository_name,
layer_digest,
layer.get("mediaType", ""),
decompressed_budget,
) as tar_stream:
if tar_stream is None:
truncated = True
continue
for member in tar_stream:
if len(files) >= MAX_FILES_PER_IMAGE:
truncated = True
break
if not member.isfile():
continue
base_name = member.name.rsplit("/", 1)[-1]
if base_name.startswith(".wh."):
# Whiteout marker: a deletion recorded by the union
# filesystem, not real file content.
continue
if member.size > MAX_FILE_BYTES:
truncated = True
continue
try:
content = (
tar_stream.extractfile(member).read().decode("latin-1")
)
except _LayerTooLargeError:
# Over-cap while reading this member: truncate the
# whole layer rather than silently skipping one file.
raise
except Exception:
continue
files.append(
ImageScanFile(
path=member.name,
layer_digest=layer_digest,
content=content,
)
)
except _LayerTooLargeError:
# The layer streamed more bytes than MAX_LAYER_DOWNLOAD_BYTES
# (a manifest under-declaring its size); skip it and disclose
# the partial coverage rather than buffer unbounded data.
truncated = True
continue
except _ImageTooLargeError:
truncated = True
break
return ImageScanData(env=env, history=history, files=files, truncated=truncated)
def _resolve_image_manifest(
self, client, registry_id, repository_name, image_digest
) -> tuple[Optional[dict], bool]:
"""Resolve an image digest to a single scannable image manifest.
Multi-arch images are stored as a manifest list/image index pointing
at one manifest per platform (plus, often, an attestation manifest
that isn't a real image). This picks one real platform manifest to
scan; the other architectures in the same list are not scanned.
"""
try:
manifest, media_type = self._batch_get_manifest(
client, registry_id, repository_name, image_digest
)
if manifest is None:
return None, False
truncated = False
if media_type in _MANIFEST_LIST_MEDIA_TYPES:
truncated = True
child_digest = self._select_child_manifest_digest(manifest)
if not child_digest:
return None, truncated
manifest, _ = self._batch_get_manifest(
client, registry_id, repository_name, child_digest
)
if manifest is not None and not (
manifest.get("config") or manifest.get("layers")
):
# A resolved manifest with neither a config nor layers has
# nothing to scan (e.g. a nested manifest list, or an
# unsupported manifest shape) -- treat it as unresolvable so
# the caller reports MANUAL instead of a false PASS.
return None, truncated
return manifest, truncated
except Exception as error:
logger.error(
f"{client.meta.region_name} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
)
return None, False
@staticmethod
def _batch_get_manifest(client, registry_id, repository_name, image_digest):
"""Fetch and parse the raw manifest JSON for a single image digest.
Returns:
A (manifest, media_type) tuple, or (None, None) if not found.
"""
response = client.batch_get_image(
registryId=registry_id,
repositoryName=repository_name,
imageIds=[{"imageDigest": image_digest}],
)
images = response.get("images", [])
if not images:
return None, None
manifest = loads(images[0]["imageManifest"])
media_type = manifest.get("mediaType") or images[0].get(
"imageManifestMediaType"
)
return manifest, media_type
@staticmethod
def _select_child_manifest_digest(manifest_list: dict) -> Optional[str]:
"""Pick one real platform manifest's digest from a manifest list.
Prefers linux/amd64, falling back to the first remaining candidate
once attestation manifests (platform "unknown/unknown", or
annotated as an attestation manifest) are excluded.
Returns:
The chosen manifest's digest, or None if no candidate remains.
"""
candidates = []
for entry in manifest_list.get("manifests", []):
platform = entry.get("platform", {}) or {}
annotations = entry.get("annotations", {}) or {}
if (
platform.get("architecture") == "unknown"
or platform.get("os") == "unknown"
):
# Attestation manifests (SBOMs, provenance, signatures) are
# attached to the index as "unknown/unknown" platform entries.
continue
if annotations.get("vnd.docker.reference.type") == "attestation-manifest":
continue
candidates.append(entry)
for entry in candidates:
platform = entry.get("platform", {}) or {}
if (
platform.get("architecture") == "amd64"
and platform.get("os") == "linux"
):
return entry.get("digest")
return candidates[0].get("digest") if candidates else None
@staticmethod
def _get_layer_download_url(
client, registry_id, repository_name, layer_digest
) -> Optional[str]:
"""Resolve the presigned download URL for one layer or config blob.
Returns:
The presigned URL, or None if ECR did not return one.
"""
response = client.get_download_url_for_layer(
registryId=registry_id,
repositoryName=repository_name,
layerDigest=layer_digest,
)
return response.get("downloadUrl")
@staticmethod
def _download_layer(
client, registry_id, repository_name, layer_digest, max_bytes=None
) -> Optional[bytes]:
"""Download one layer or config blob via its presigned URL.
Streams the response, aborting once `max_bytes` is exceeded, so a
lying or oversized blob is never buffered in full. Used for the config
blob and for zstd layers (which cannot be streamed into tarfile);
gzip/uncompressed layers are streamed by `_open_layer_tar_stream`.
Returns:
The blob's bytes, or None if it could not be downloaded or
exceeded `max_bytes`.
"""
try:
download_url = ImageInspector._get_layer_download_url(
client, registry_id, repository_name, layer_digest
)
if not download_url:
return None
downloaded = bytearray()
with requests.get(
download_url,
stream=True,
timeout=LAYER_DOWNLOAD_TIMEOUT_SECONDS,
allow_redirects=False,
) as http_response:
http_response.raise_for_status()
for chunk in http_response.iter_content(chunk_size=1024 * 1024):
downloaded.extend(chunk)
if max_bytes and len(downloaded) > max_bytes:
return None
return bytes(downloaded)
except Exception as error:
logger.warning(
f"{repository_name} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
)
return None
@contextmanager
def _open_layer_tar_stream(
self,
client,
registry_id,
repository_name,
layer_digest,
media_type: str,
decompressed_budget: _DecompressedByteBudget,
):
"""Yield an open TarFile for one layer, streamed from the download.
gzip, zstd, and uncompressed tar layers are all streamed straight from
the download into `tarfile` (streaming mode reads a file-like object
sequentially), so neither the compressed blob nor a decompressed copy is
ever buffered in full. A `_CappedLayerReader` enforces
`MAX_LAYER_DOWNLOAD_BYTES` on the compressed bytes (guarding a manifest
that under-declares the layer size); zstd is decompressed incrementally
via `zstandard`'s streaming reader, so a crafted frame can no longer
expand unbounded in memory, and the decompressed side is bounded by the
caller's per-image budget as it iterates members.
Yields:
An open TarFile, or None for an unrecognized media type or a
download/decompression failure. Raises `_LayerTooLargeError` if a
streamed layer's compressed bytes exceed `MAX_LAYER_DOWNLOAD_BYTES`.
"""
if media_type.endswith("gzip"):
decompress = "gzip"
elif media_type.endswith("zstd"):
decompress = "zstd"
elif media_type.endswith("tar"):
decompress = None
else:
yield None
return
# Only the setup (URL resolution, connection, tar-header parse) is
# guarded here; a failure yields None. The `yield tar_stream` below is
# kept out of this try so exceptions raised while the caller iterates
# members (e.g. _LayerTooLargeError) propagate instead of triggering a
# forbidden second yield.
try:
download_url = ImageInspector._get_layer_download_url(
client, registry_id, repository_name, layer_digest
)
if not download_url:
yield None
return
http_response = requests.get(
download_url,
stream=True,
timeout=LAYER_DOWNLOAD_TIMEOUT_SECONDS,
allow_redirects=False,
)
try:
http_response.raise_for_status()
# Cap the compressed bytes read from the network; for zstd,
# decompress that capped stream incrementally so the decompressed
# data is never materialized in full.
source = _CappedLayerReader(http_response.raw, MAX_LAYER_DOWNLOAD_BYTES)
if decompress == "gzip":
source = gzip.GzipFile(fileobj=source)
elif decompress == "zstd":
source = zstandard.ZstdDecompressor().stream_reader(source)
source = decompressed_budget.wrap(source)
tar_stream = tarfile.open(fileobj=source, mode="r|")
except (_LayerTooLargeError, _ImageTooLargeError):
http_response.close()
raise
except Exception:
http_response.close()
raise
except Exception as error:
logger.warning(
f"{repository_name} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
)
yield None
return
with http_response, tar_stream:
yield tar_stream
+2 -1
View File
@@ -132,7 +132,8 @@ dependencies = [
"huaweicloudsdkobs==3.1.204",
"huaweicloudsdkrds==3.1.204",
"huaweicloudsdkvpc==3.1.204",
"huaweicloudsdkwaf==3.1.204"
"huaweicloudsdkwaf==3.1.204",
"zstandard==0.25.0"
]
description = "Prowler is an Open Source security tool to perform AWS, GCP and Azure security best practices assessments, audits, incident response, continuous monitoring, hardening and forensics readiness. It contains hundreds of controls covering CIS, NIST 800, NIST CSF, CISA, RBI, FedRAMP, PCI-DSS, GDPR, HIPAA, FFIEC, SOC2, GXP, AWS Well-Architected Framework Security Pillar, AWS Foundational Technical Review (FTR), ENS (Spanish National Security Scheme) and your custom security frameworks."
license = "Apache-2.0"
@@ -0,0 +1,837 @@
from datetime import datetime
from unittest import mock
from prowler.providers.aws.services.ecr.ecr_service import (
ImageDetails,
Registry,
Repository,
)
from prowler.providers.aws.services.ecr.image_inspection import (
ImageScanData,
ImageScanFile,
)
from tests.providers.aws.utils import (
AWS_ACCOUNT_NUMBER,
AWS_REGION_US_EAST_1,
set_mocked_aws_provider,
)
# A real JWT: Kingfisher detects this regardless of the surrounding key name
# or format (env-style KEY=value, Dockerfile RUN step, or source file).
SECRET_VALUE = (
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
".eyJzdWIiOiIxMjM0NTY3ODkwIn0"
".dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U"
)
def create_repository(name="test-repo", region=AWS_REGION_US_EAST_1) -> Repository:
"""Build a minimal ECR Repository fixture."""
return Repository(
name=name,
arn=f"arn:aws:ecr:{region}:{AWS_ACCOUNT_NUMBER}:repository/{name}",
region=region,
scan_on_push=True,
images_details=[],
)
def create_image(tag="latest", digest=None) -> ImageDetails:
"""Build a minimal ImageDetails fixture."""
return ImageDetails(
latest_tag=tag,
latest_digest=digest or f"sha256:{'0' * 64}",
image_pushed_at=datetime.now(),
scan_findings_status=None,
scan_findings_severity_count=None,
artifact_media_type="application/vnd.docker.container.image.v1+json",
type="Docker",
)
def mock_image_scan_data(pairs):
"""Build a fake _get_image_scan_data generator yielding the given pairs."""
def _generator():
"""Yield each (repository, image, scan_data) pair once."""
for entry in pairs:
yield entry
return _generator
class Test_ecr_repository_image_no_secrets:
"""Tests for the ecr_repository_image_no_secrets check."""
def test_no_repositories(self):
"""No repositories yields no findings."""
ecr_client = mock.MagicMock()
ecr_client.registries = {}
ecr_client.audit_config = {
"secrets_ignore_patterns": [],
"secrets_validate": False,
}
ecr_client._get_image_scan_data = mock_image_scan_data([])
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
check = ecr_repository_image_no_secrets()
result = check.execute()
assert len(result) == 0
def test_clean_image(self):
"""An image with no secrets passes."""
repository = create_repository()
image = create_image()
scan_data = ImageScanData(
env=["PATH=/usr/bin"],
history=["RUN echo hello"],
files=[],
truncated=False,
)
ecr_client = mock.MagicMock()
ecr_client.registries = {}
ecr_client.audit_config = {
"secrets_ignore_patterns": [],
"secrets_validate": False,
}
ecr_client._get_image_scan_data = mock_image_scan_data(
[(repository, image, scan_data)]
)
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
check = ecr_repository_image_no_secrets()
result = check.execute()
digest_short = image.latest_digest.split(":")[-1][:12]
assert len(result) == 1
assert result[0].status == "PASS"
assert result[0].status_extended == (
f"No secrets found in the image '{image.latest_tag}' "
f"({image.latest_digest}) of ECR repository {repository.name}."
)
assert result[0].region == AWS_REGION_US_EAST_1
assert (
result[0].resource_id
== f"{repository.name}:{image.latest_tag}@{digest_short}"
)
assert result[0].resource_arn == f"{repository.arn}/image/{digest_short}"
def test_truncated_image_reports_manual(self):
"""A clean but truncated image is MANUAL, since part was not scanned."""
repository = create_repository()
image = create_image()
scan_data = ImageScanData(env=[], history=[], files=[], truncated=True)
ecr_client = mock.MagicMock()
ecr_client.registries = {}
ecr_client.audit_config = {
"secrets_ignore_patterns": [],
"secrets_validate": False,
}
ecr_client._get_image_scan_data = mock_image_scan_data(
[(repository, image, scan_data)]
)
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
check = ecr_repository_image_no_secrets()
result = check.execute()
assert len(result) == 1
assert result[0].status == "MANUAL"
assert (
"part of it could not be retrieved or exceeded configured size "
"limits and was not scanned" in result[0].status_extended
)
def test_secret_in_environment_variable(self):
"""A secret in an environment variable fails, naming the variable."""
from prowler.lib.check.models import Severity
repository = create_repository()
image = create_image()
scan_data = ImageScanData(
env=["PATH=/usr/bin", f"DB_PASSWORD={SECRET_VALUE}"],
history=[],
files=[],
truncated=False,
)
ecr_client = mock.MagicMock()
ecr_client.registries = {}
ecr_client.audit_config = {
"secrets_ignore_patterns": [],
"secrets_validate": False,
}
ecr_client._get_image_scan_data = mock_image_scan_data(
[(repository, image, scan_data)]
)
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
check = ecr_repository_image_no_secrets()
result = check.execute()
assert len(result) == 1
assert result[0].status == "FAIL"
assert "environment variable DB_PASSWORD" in result[0].status_extended
assert SECRET_VALUE not in result[0].status_extended
assert result[0].check_metadata.Severity == Severity.high
def test_secret_in_malformed_env_entry_is_redacted(self):
"""An env entry without '=' is reported generically, never echoed."""
repository = create_repository()
image = create_image()
# The entry has no "=" so no variable name can be split out; the entry
# itself is the secret and must not appear in the finding.
scan_data = ImageScanData(
env=[SECRET_VALUE],
history=[],
files=[],
truncated=False,
)
ecr_client = mock.MagicMock()
ecr_client.registries = {}
ecr_client.audit_config = {
"secrets_ignore_patterns": [],
"secrets_validate": False,
}
ecr_client._get_image_scan_data = mock_image_scan_data(
[(repository, image, scan_data)]
)
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
check = ecr_repository_image_no_secrets()
result = check.execute()
assert len(result) == 1
assert result[0].status == "FAIL"
assert "in image environment variables" in result[0].status_extended
assert SECRET_VALUE not in result[0].status_extended
def test_secret_in_unsafe_environment_name_is_redacted(self):
"""An unsafe name before '=' is never included in report text."""
repository = create_repository()
image = create_image()
scan_data = ImageScanData(
env=[f"{SECRET_VALUE}=safe-value"],
history=[],
files=[],
truncated=False,
)
ecr_client = mock.MagicMock()
ecr_client.registries = {}
ecr_client.audit_config = {
"secrets_ignore_patterns": [],
"secrets_validate": False,
}
ecr_client._get_image_scan_data = mock_image_scan_data(
[(repository, image, scan_data)]
)
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
result = ecr_repository_image_no_secrets().execute()
assert len(result) == 1
assert result[0].status == "FAIL"
assert "in image environment variables" in result[0].status_extended
assert SECRET_VALUE not in str(vars(result[0]))
def test_scanned_file_content_is_freed_after_execute(self):
"""File contents are released after scanning so memory stays flat."""
repository = create_repository()
image = create_image()
scanned_file = ImageScanFile(
path="app/config.py",
layer_digest=f"sha256:{'a' * 64}",
content="nothing secret here",
)
scan_data = ImageScanData(
env=[], history=[], files=[scanned_file], truncated=False
)
ecr_client = mock.MagicMock()
ecr_client.registries = {}
ecr_client.audit_config = {
"secrets_ignore_patterns": [],
"secrets_validate": False,
}
ecr_client._get_image_scan_data = mock_image_scan_data(
[(repository, image, scan_data)]
)
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
check = ecr_repository_image_no_secrets()
result = check.execute()
assert len(result) == 1
assert result[0].status == "PASS"
# The check empties each file's content once it is handed to the
# scanner; only path and layer digest are needed thereafter.
assert scanned_file.content == ""
def test_secrets_ignore_patterns_suppresses_finding(self):
"""A secret matching an ignore pattern is suppressed."""
repository = create_repository()
image = create_image()
scan_data = ImageScanData(
env=["PATH=/usr/bin", f"DB_PASSWORD={SECRET_VALUE}"],
history=[],
files=[],
truncated=False,
)
ecr_client = mock.MagicMock()
ecr_client.registries = {}
ecr_client.audit_config = {
"secrets_ignore_patterns": [SECRET_VALUE],
"secrets_validate": False,
}
ecr_client._get_image_scan_data = mock_image_scan_data(
[(repository, image, scan_data)]
)
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
check = ecr_repository_image_no_secrets()
result = check.execute()
assert len(result) == 1
assert result[0].status == "PASS"
def test_secret_in_build_history(self):
"""A secret in a build history step fails, naming the step."""
repository = create_repository()
image = create_image()
scan_data = ImageScanData(
env=[],
history=["RUN apt-get update", f'RUN export TOKEN="{SECRET_VALUE}"'],
files=[],
truncated=False,
)
ecr_client = mock.MagicMock()
ecr_client.registries = {}
ecr_client.audit_config = {
"secrets_ignore_patterns": [],
"secrets_validate": False,
}
ecr_client._get_image_scan_data = mock_image_scan_data(
[(repository, image, scan_data)]
)
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
check = ecr_repository_image_no_secrets()
result = check.execute()
assert len(result) == 1
assert result[0].status == "FAIL"
assert "image history step 2" in result[0].status_extended
assert SECRET_VALUE not in result[0].status_extended
def test_multiline_environment_secret_keeps_entry_attribution(self):
"""Embedded newlines do not shift an env finding to another entry."""
repository = create_repository()
image = create_image()
scan_data = ImageScanData(
env=[f"MULTILINE=prefix\r\n{SECRET_VALUE}", "WRONG=value"],
history=[],
files=[],
truncated=False,
)
ecr_client = mock.MagicMock()
ecr_client.registries = {}
ecr_client.audit_config = {
"secrets_ignore_patterns": [],
"secrets_validate": False,
}
ecr_client._get_image_scan_data = mock_image_scan_data(
[(repository, image, scan_data)]
)
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
result = ecr_repository_image_no_secrets().execute()
assert "environment variable MULTILINE" in result[0].status_extended
assert "environment variable WRONG" not in result[0].status_extended
def test_multiline_history_secret_keeps_step_attribution(self):
"""Embedded newlines do not shift a history finding to another step."""
repository = create_repository()
image = create_image()
scan_data = ImageScanData(
env=[],
history=[f"RUN first\nexport TOKEN={SECRET_VALUE}", "RUN second"],
files=[],
truncated=False,
)
ecr_client = mock.MagicMock()
ecr_client.registries = {}
ecr_client.audit_config = {
"secrets_ignore_patterns": [],
"secrets_validate": False,
}
ecr_client._get_image_scan_data = mock_image_scan_data(
[(repository, image, scan_data)]
)
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
result = ecr_repository_image_no_secrets().execute()
assert "image history step 1" in result[0].status_extended
assert "image history step 2" not in result[0].status_extended
def test_secret_in_layer_file(self):
"""A secret in a layer file fails, naming the file and layer."""
repository = create_repository()
image = create_image()
layer_digest = f"sha256:{'a' * 64}"
scan_data = ImageScanData(
env=[],
history=[],
files=[
ImageScanFile(
path="app/config.py",
layer_digest=layer_digest,
content=f'TOKEN = "{SECRET_VALUE}"',
)
],
truncated=False,
)
ecr_client = mock.MagicMock()
ecr_client.registries = {}
ecr_client.audit_config = {
"secrets_ignore_patterns": [],
"secrets_validate": False,
}
ecr_client._get_image_scan_data = mock_image_scan_data(
[(repository, image, scan_data)]
)
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
check = ecr_repository_image_no_secrets()
result = check.execute()
assert len(result) == 1
assert result[0].status == "FAIL"
assert "file app/config.py" in result[0].status_extended
assert layer_digest in result[0].status_extended
assert SECRET_VALUE not in result[0].status_extended
def test_manifest_unresolvable(self):
"""An unresolvable manifest is reported as MANUAL."""
repository = create_repository()
image = create_image()
ecr_client = mock.MagicMock()
ecr_client.registries = {}
ecr_client.audit_config = {
"secrets_ignore_patterns": [],
"secrets_validate": False,
}
ecr_client._get_image_scan_data = mock_image_scan_data(
[(repository, image, None)]
)
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
check = ecr_repository_image_no_secrets()
result = check.execute()
assert len(result) == 1
assert result[0].status == "MANUAL"
assert (
"Could not resolve or retrieve the manifest"
in result[0].status_extended
)
def test_latest_image_lookup_error_reports_repository_manual(self):
"""A failed authoritative image lookup is reported for the repository."""
repository = create_repository()
lookup_error = RuntimeError("authoritative lookup failed")
ecr_client = mock.MagicMock()
ecr_client.audit_config = {
"secrets_ignore_patterns": [],
"secrets_validate": False,
}
ecr_client._get_image_scan_data = mock_image_scan_data(
[(repository, None, lookup_error)]
)
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
result = ecr_repository_image_no_secrets().execute()
assert result[0].status == "MANUAL"
assert "Could not determine the latest image" in result[0].status_extended
def test_scan_error_reports_manual_for_latest_image_per_repository(self):
"""A scanner failure reports MANUAL once per repository's latest image."""
from prowler.lib.utils.utils import SecretsScanError
# Each repository has multiple images; the scan-error fallback must
# scope to the latest image per repository only, mirroring the
# success-path scope, not emit one MANUAL per image.
repo1 = create_repository(name="repo-1")
repo1.images_details = [
create_image(tag="v1", digest=f"sha256:{'1' * 64}"),
create_image(tag="v2", digest=f"sha256:{'2' * 64}"),
]
repo2 = create_repository(name="repo-2")
repo2.images_details = [
create_image(tag="v1", digest=f"sha256:{'3' * 64}"),
create_image(tag="v2", digest=f"sha256:{'4' * 64}"),
]
registry = Registry(
id=AWS_ACCOUNT_NUMBER,
arn=f"arn:aws:ecr:{AWS_REGION_US_EAST_1}:{AWS_ACCOUNT_NUMBER}:registry/{AWS_ACCOUNT_NUMBER}",
region=AWS_REGION_US_EAST_1,
repositories=[repo1, repo2],
)
ecr_client = mock.MagicMock()
ecr_client.registries = {AWS_REGION_US_EAST_1: registry}
ecr_client.audit_config = {
"secrets_ignore_patterns": [],
"secrets_validate": False,
}
# Not consumed on this path, but must be a real generator to iterate.
ecr_client._get_image_scan_data = mock_image_scan_data([])
# The error fallback resolves each repository's scan target via
# _get_scan_target_image; mirror the real method's latest-image scope.
ecr_client._get_scan_target_image.side_effect = lambda repository: (
repository.images_details[-1] if repository.images_details else None
)
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.detect_secrets_scan_batch",
side_effect=SecretsScanError("Scanner failure"),
),
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
check = ecr_repository_image_no_secrets()
result = check.execute()
# One MANUAL per repository (its latest image), not one per image.
assert len(result) == 2
for report in result:
assert report.status == "MANUAL"
assert "Could not scan image" in report.status_extended
assert "Scanner failure" in report.status_extended
digests_reported = {report.resource_id.split("@")[-1] for report in result}
latest_digest_repo1 = repo1.images_details[-1].latest_digest.split(":")[-1][
:12
]
latest_digest_repo2 = repo2.images_details[-1].latest_digest.split(":")[-1][
:12
]
assert digests_reported == {latest_digest_repo1, latest_digest_repo2}
assert "Scanner failure" in result[0].status_extended
def test_verified_secret_escalates_to_critical(self):
"""A verified secret escalates severity to critical."""
from prowler.lib.check.models import Severity
repository = create_repository()
image = create_image()
scan_data = ImageScanData(
env=[f"TOKEN={SECRET_VALUE}"], history=[], files=[], truncated=False
)
ecr_client = mock.MagicMock()
ecr_client.registries = {}
ecr_client.audit_config = {
"secrets_ignore_patterns": [],
"secrets_validate": True,
}
ecr_client._get_image_scan_data = mock_image_scan_data(
[(repository, image, scan_data)]
)
def fake_scan_batch(payloads, **kwargs):
# The real detect_secrets_scan_batch consumes the lazily-yielded
# payloads generator as a side effect (that's what populates the
# check's `scanned` list); replicate that here while returning
# a controlled, pre-verified finding.
"""Drain the payload generator like the real scanner, then return canned findings."""
list(payloads)
return {
(0, "environment:0"): [
{
"type": "JSON Web Token (base64url-encoded)",
"line_number": 1,
"is_verified": True,
}
]
}
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.detect_secrets_scan_batch",
side_effect=fake_scan_batch,
) as mock_scan,
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
check = ecr_repository_image_no_secrets()
result = check.execute()
assert mock_scan.call_args.kwargs.get("validate") is True
assert len(result) == 1
assert result[0].status == "FAIL"
assert result[0].check_metadata.Severity == Severity.critical
assert "confirmed to be live" in result[0].status_extended
def test_multiple_repositories_and_images(self):
"""Mixed pass/fail results are reported across multiple repositories."""
repo1 = create_repository(name="repo-1")
repo2 = create_repository(name="repo-2")
image1 = create_image(tag="v1", digest=f"sha256:{'1' * 64}")
image2 = create_image(tag="v2", digest=f"sha256:{'2' * 64}")
clean_scan = ImageScanData(env=[], history=[], files=[], truncated=False)
fail_scan = ImageScanData(
env=[f"DB_PASSWORD={SECRET_VALUE}"],
history=[],
files=[],
truncated=False,
)
ecr_client = mock.MagicMock()
ecr_client.registries = {}
ecr_client.audit_config = {
"secrets_ignore_patterns": [],
"secrets_validate": False,
}
ecr_client._get_image_scan_data = mock_image_scan_data(
[(repo1, image1, clean_scan), (repo2, image2, fail_scan)]
)
with (
mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=set_mocked_aws_provider(),
),
mock.patch(
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
new=ecr_client,
),
):
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
ecr_repository_image_no_secrets,
)
check = ecr_repository_image_no_secrets()
result = check.execute()
assert len(result) == 2
statuses_by_repo = {r.resource_id.split(":")[0]: r.status for r in result}
assert statuses_by_repo["repo-1"] == "PASS"
assert statuses_by_repo["repo-2"] == "FAIL"
report_by_repo = {r.resource_id.split(":")[0]: r for r in result}
assert SECRET_VALUE not in report_by_repo["repo-2"].status_extended
@@ -1,11 +1,21 @@
import json
from concurrent.futures import Future
from datetime import datetime
from unittest.mock import patch
from unittest.mock import MagicMock, patch
import botocore
import pytest
from boto3 import client
from moto import mock_aws
from prowler.providers.aws.services.ecr.ecr_service import ECR, ScanningRule
from prowler.providers.aws.services.ecr.ecr_service import (
ECR,
ScanningRule,
)
from tests.providers.aws.services.ecr.image_scan_fixtures import (
MANIFESTS_BY_DIGEST,
reset_image_fixtures,
)
from tests.providers.aws.utils import (
AWS_ACCOUNT_NUMBER,
AWS_REGION_EU_WEST_1,
@@ -18,8 +28,20 @@ repo_name = "test-repo"
# Mocking Access Analyzer Calls
make_api_call = botocore.client.BaseClient._make_api_call
# BatchGetImage / GetDownloadUrlForLayer fixtures (which moto does not
# implement) live in image_scan_fixtures and are served by mock_make_api_call.
@pytest.fixture(autouse=True)
def _reset_image_fixtures():
"""Isolate the BatchGetImage/GetDownloadUrlForLayer fixtures per test."""
reset_image_fixtures()
yield
reset_image_fixtures()
def mock_make_api_call(self, operation_name, kwarg):
"""Fake botocore responses for the ECR operations this suite exercises."""
if operation_name == "DescribeImages":
return {
"imageDetails": [
@@ -150,10 +172,37 @@ def mock_make_api_call(self, operation_name, kwarg):
},
}
if operation_name == "BatchGetImage":
digest = kwarg["imageIds"][0]["imageDigest"]
manifest = MANIFESTS_BY_DIGEST.get(digest)
if manifest is None:
return {
"images": [],
"failures": [
{
"imageId": {"imageDigest": digest},
"failureCode": "ImageNotFound",
}
],
}
return {
"images": [
{
"imageManifest": json.dumps(manifest),
"imageManifestMediaType": manifest.get("mediaType", ""),
}
]
}
if operation_name == "GetDownloadUrlForLayer":
digest = kwarg["layerDigest"]
return {"downloadUrl": f"https://layers.example.com/{digest}"}
return make_api_call(self, operation_name, kwarg)
def mock_generate_regional_clients(provider, service):
"""Return a single regional client for every requested region."""
regional_client = provider._session.current_session.client(
service, region_name=AWS_REGION_EU_WEST_1
)
@@ -169,13 +218,17 @@ def mock_generate_regional_clients(provider, service):
)
class Test_ECR_Service:
# Test ECR Service
"""Tests for the ECR service."""
def test_service(self):
"""The service name is set correctly."""
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
ecr = ECR(aws_provider)
assert ecr.service == "ecr"
# Test ECR client
def test_client(self):
"""Each regional client is an ECR client."""
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
ecr = ECR(aws_provider)
for regional_client in ecr.regional_clients.values():
@@ -183,6 +236,7 @@ class Test_ECR_Service:
# Test ECR session
def test_get_session(self):
"""The session is set correctly."""
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
ecr = ECR(aws_provider)
assert ecr.session.__class__.__name__ == "Session"
@@ -190,6 +244,7 @@ class Test_ECR_Service:
# Test describe ECR repositories
@mock_aws
def test_describe_registries_and_repositories(self):
"""Registries and repositories are discovered."""
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
ecr_client.create_repository(
repositoryName=repo_name,
@@ -220,6 +275,7 @@ class Test_ECR_Service:
# Test describe ECR repository policies
@mock_aws
def test_describe_repository_policies(self):
"""Repository policies are fetched and parsed."""
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
ecr_client.create_repository(
repositoryName=repo_name,
@@ -249,6 +305,7 @@ class Test_ECR_Service:
# Test describe ECR repository lifecycle policies
@mock_aws
def test_get_lifecycle_policies(self):
"""Repository lifecycle policies are fetched."""
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
ecr_client.create_repository(
repositoryName=repo_name,
@@ -268,6 +325,7 @@ class Test_ECR_Service:
# Test get image details
@mock_aws
def test_get_image_details(self):
"""Scannable, tagged images are collected and sorted by push date."""
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
ecr_client.create_repository(
repositoryName=repo_name,
@@ -366,6 +424,7 @@ class Test_ECR_Service:
# Test get ECR Registries Scanning Configuration
@mock_aws
def test_get_registry_scanning_configuration(self):
"""The registry's scanning configuration is fetched."""
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
ecr = ECR(aws_provider)
assert len(ecr.registries) == 1
@@ -379,39 +438,188 @@ class Test_ECR_Service:
]
def test_is_artifact_scannable_docker(self):
"""A Docker image config is scannable."""
assert ECR._is_artifact_scannable(
"application/vnd.docker.container.image.v1+json"
)
def test_is_artifact_scannable_layer_tar(self):
"""An uncompressed Docker layer is scannable."""
assert ECR._is_artifact_scannable(
"application/vnd.docker.image.rootfs.diff.tar"
)
def test_is_artifact_scannable_layer_gzip(self):
"""A gzip-compressed Docker layer is scannable."""
assert ECR._is_artifact_scannable(
"application/vnd.docker.image.rootfs.diff.tar.gzip"
)
def test_is_artifact_scannable_oci(self):
"""An OCI image config is scannable."""
assert ECR._is_artifact_scannable("application/vnd.oci.image.config.v1+json")
def test_is_artifact_scannable_oci_tar(self):
"""An uncompressed OCI layer is scannable."""
assert ECR._is_artifact_scannable("application/vnd.oci.image.layer.v1.tar")
def test_is_artifact_scannable_oci_compressed(self):
"""A gzip-compressed OCI layer is scannable."""
assert ECR._is_artifact_scannable("application/vnd.oci.image.layer.v1.tar+gzip")
def test_is_artifact_scannable_none(self):
"""A missing media type is not scannable."""
assert not ECR._is_artifact_scannable(None)
def test_is_artifact_scannable_empty(self):
"""An empty media type is not scannable."""
assert not ECR._is_artifact_scannable("")
def test_is_artifact_scannable_non_scannable_tags(self):
"""A signature-tagged artifact is not scannable."""
assert not ECR._is_artifact_scannable("", ["sha256-abcdefg123456.sig"])
def test_is_artifact_scannable_scannable_tags(self):
"""A normally-tagged artifact is scannable."""
assert ECR._is_artifact_scannable(
"application/vnd.docker.container.image.v1+json", ["abcdefg123456"]
)
@mock_aws
def test_get_image_scan_data_selects_only_latest_image_per_repository(self):
"""Only the latest image per repository is selected for scanning."""
ecr_client_boto = client("ecr", region_name=AWS_REGION_EU_WEST_1)
ecr_client_boto.create_repository(
repositoryName=repo_name,
imageScanningConfiguration={"scanOnPush": True},
)
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
ecr = ECR(aws_provider)
repository = ecr.registries[AWS_REGION_EU_WEST_1].repositories[0]
# Sanity check: this repository has several scannable tagged images.
assert len(repository.images_details) == 4
results = list(ecr._get_image_scan_data())
# Only the most recently pushed image is selected, not all four.
assert len(results) == 1
fetched_repository, fetched_image, _ = results[0]
assert fetched_repository.name == repo_name
assert fetched_image.latest_tag == "test-tag4"
assert (
fetched_image.latest_digest
== "sha256:43251ac64627fc331584f6c498b3aba5badc01574e2c70b2499af3af16630eed"
)
@mock_aws
def test_get_image_scan_data_covers_scan_on_push_disabled_repository(self):
"""A scan-on-push-disabled repo (empty images_details) is still scanned."""
ecr_client_boto = client("ecr", region_name=AWS_REGION_EU_WEST_1)
ecr_client_boto.create_repository(
repositoryName=repo_name,
imageScanningConfiguration={"scanOnPush": False},
)
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
ecr = ECR(aws_provider)
repository = ecr.registries[AWS_REGION_EU_WEST_1].repositories[0]
# Scan-on-push disabled: the metadata pass leaves images_details empty...
assert repository.scan_on_push is False
assert repository.images_details == []
# ...yet the secret-scan path resolves the latest image via a dedicated
# describe_images lookup, so the repository is not silently skipped.
results = list(ecr._get_image_scan_data())
assert len(results) == 1
fetched_repository, fetched_image, _ = results[0]
assert fetched_repository.name == repo_name
assert fetched_image.latest_tag == "test-tag4"
# The dedicated lookup must NOT mutate the shared images_details, or
# other checks would treat this repo as having a scanned image.
assert repository.images_details == []
@mock_aws
def test_get_image_scan_data_bounds_submitted_futures(self):
"""Image fetches are submitted only as earlier results are consumed."""
ecr_client_boto = client("ecr", region_name=AWS_REGION_EU_WEST_1)
for index in range(10):
ecr_client_boto.create_repository(
repositoryName=f"{repo_name}-{index}",
imageScanningConfiguration={"scanOnPush": True},
)
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
ecr = ECR(aws_provider)
repositories = ecr.registries[AWS_REGION_EU_WEST_1].repositories
executor = MagicMock()
executor.__enter__.return_value = executor
futures = []
def submit(*_args):
future = Future()
futures.append(future)
if len(futures) == 1:
future.set_result(None)
return future
executor.submit.side_effect = submit
with patch(
"prowler.providers.aws.services.ecr.ecr_service.ThreadPoolExecutor",
return_value=executor,
):
results = ecr._get_image_scan_data()
first_result = next(results)
assert first_result[0] == repositories[0]
assert (
first_result[1].latest_digest
== repositories[0].images_details[-1].latest_digest
)
assert executor.submit.call_count == 4
@mock_aws
def test_get_scan_target_image_ignores_stale_scanned_image(self):
"""Secret scanning selects a newer image absent from scan findings."""
ecr_client_boto = client("ecr", region_name=AWS_REGION_EU_WEST_1)
ecr_client_boto.create_repository(
repositoryName=repo_name,
imageScanningConfiguration={"scanOnPush": True},
)
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
ecr = ECR(aws_provider)
repository = ecr.registries[AWS_REGION_EU_WEST_1].repositories[0]
older_scanned_image = repository.images_details[0]
repository.images_details = [older_scanned_image]
target = ecr._get_scan_target_image(repository)
assert target.latest_tag == "test-tag4"
assert target.image_pushed_at > older_scanned_image.image_pushed_at
@mock_aws
def test_get_scan_target_image_lookup_failure_rejects_stale_image(self):
"""A failed authoritative lookup does not select cached scan metadata."""
ecr_client_boto = client("ecr", region_name=AWS_REGION_EU_WEST_1)
ecr_client_boto.create_repository(
repositoryName=repo_name,
imageScanningConfiguration={"scanOnPush": True},
)
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
ecr = ECR(aws_provider)
repository = ecr.registries[AWS_REGION_EU_WEST_1].repositories[0]
repository.images_details = [repository.images_details[0]]
with patch.object(
ecr.regional_clients[AWS_REGION_EU_WEST_1],
"get_paginator",
side_effect=RuntimeError("authoritative lookup failed"),
):
target = ecr._get_scan_target_image(repository)
scan_results = list(ecr._get_image_scan_data())
assert isinstance(target, RuntimeError)
assert len(scan_results) == 1
_, result_image, result_error = scan_results[0]
assert result_image is None and isinstance(result_error, RuntimeError)
@@ -0,0 +1,512 @@
import gzip
import json
import random
import tarfile
from io import BytesIO
from unittest.mock import patch
import botocore
import pytest
import zstandard
from boto3 import client
from moto import mock_aws
from prowler.providers.aws.services.ecr.image_inspection import (
MAX_FILE_BYTES,
MAX_LAYER_DOWNLOAD_BYTES,
ImageInspector,
_CappedLayerReader,
_LayerTooLargeError,
)
from tests.providers.aws.services.ecr.image_scan_fixtures import (
BLOBS_BY_DIGEST,
CHILD_AMD64_DIGEST,
CHILD_ARM64_DIGEST,
CONFIG_DIGEST,
CONFIG_JSON,
IMAGE_DIGEST,
LAYER_DIGEST,
MANIFESTS_BY_DIGEST,
MULTI_ARCH_INDEX_DIGEST,
MULTI_ARCH_MANIFEST_LIST,
SIMPLE_MANIFEST,
build_gzip_tar,
build_tar,
mock_requests_get,
reset_image_fixtures,
)
from tests.providers.aws.utils import (
AWS_ACCOUNT_NUMBER,
AWS_REGION_EU_WEST_1,
)
REPO_NAME = "test-repo"
_original_make_api_call = botocore.client.BaseClient._make_api_call
_REQUESTS_GET = "prowler.providers.aws.services.ecr.image_inspection.requests.get"
def mock_make_api_call(self, operation_name, kwarg):
"""Serve BatchGetImage/GetDownloadUrlForLayer from fixtures; delegate the rest.
moto implements neither operation, so they are answered from the per-test
``MANIFESTS_BY_DIGEST`` fixtures; every other call falls through to the real
(moto-backed) implementation.
"""
if operation_name == "BatchGetImage":
digest = kwarg["imageIds"][0]["imageDigest"]
manifest = MANIFESTS_BY_DIGEST.get(digest)
if manifest is None:
return {
"images": [],
"failures": [
{
"imageId": {"imageDigest": digest},
"failureCode": "ImageNotFound",
}
],
}
return {
"images": [
{
"imageManifest": json.dumps(manifest),
"imageManifestMediaType": manifest.get("mediaType", ""),
}
]
}
if operation_name == "GetDownloadUrlForLayer":
digest = kwarg["layerDigest"]
return {"downloadUrl": f"https://layers.example.com/{digest}"}
return _original_make_api_call(self, operation_name, kwarg)
@patch("botocore.client.BaseClient._make_api_call", new=mock_make_api_call)
class Test_ImageInspector:
"""Tests for the bounded image-content extraction in image_inspection."""
@pytest.fixture(autouse=True)
def _reset_image_fixtures(self):
"""Isolate the BatchGetImage/GetDownloadUrlForLayer fixtures per test."""
reset_image_fixtures()
yield
reset_image_fixtures()
@staticmethod
def _fetch(digest=IMAGE_DIGEST):
"""Fetch scan data for one image, with the layer download stubbed."""
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
with patch(_REQUESTS_GET, new=mock_requests_get):
return ImageInspector().fetch_image_scan_data(
ecr_client, AWS_ACCOUNT_NUMBER, REPO_NAME, digest
)
@mock_aws
def test_fetch_image_scan_data_simple_image(self):
"""A single-manifest image's config and layer file are scanned."""
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = SIMPLE_MANIFEST
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
BLOBS_BY_DIGEST[LAYER_DIGEST] = build_gzip_tar({"app/config.py": "TOKEN = 'x'"})
scan_data = self._fetch()
assert scan_data is not None
assert scan_data.env == ["PATH=/usr/bin", "TOKEN=super-secret-value"]
assert scan_data.history == ["/bin/sh -c #(nop) ADD file", "RUN echo hi"]
assert len(scan_data.files) == 1
assert scan_data.files[0].path == "app/config.py"
assert scan_data.files[0].layer_digest == LAYER_DIGEST
assert scan_data.files[0].content == "TOKEN = 'x'"
assert scan_data.truncated is False
@mock_aws
def test_fetch_image_scan_data_resolves_multi_arch_manifest(self):
"""A multi-arch scan is incomplete when only one child is inspected."""
MANIFESTS_BY_DIGEST[MULTI_ARCH_INDEX_DIGEST] = MULTI_ARCH_MANIFEST_LIST
MANIFESTS_BY_DIGEST[CHILD_AMD64_DIGEST] = SIMPLE_MANIFEST
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
BLOBS_BY_DIGEST[LAYER_DIGEST] = build_gzip_tar({"app/config.py": "TOKEN = 'x'"})
scan_data = self._fetch(digest=MULTI_ARCH_INDEX_DIGEST)
# Only the amd64/linux child manifest is resolved and scanned; the
# arm64 and attestation entries in the manifest list are ignored.
assert scan_data is not None
assert scan_data.env == ["PATH=/usr/bin", "TOKEN=super-secret-value"]
assert len(scan_data.files) == 1
assert scan_data.files[0].path == "app/config.py"
assert scan_data.truncated is True
@mock_aws
def test_fetch_image_scan_data_skips_oversized_layer(self):
"""A layer over the size cap is skipped, not downloaded."""
oversized_manifest = {
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"config": {"digest": CONFIG_DIGEST, "size": 10},
"layers": [
{
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
"digest": LAYER_DIGEST,
"size": MAX_LAYER_DOWNLOAD_BYTES + 1,
}
],
}
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = oversized_manifest
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
scan_data = self._fetch()
# The oversized layer is never downloaded (only the config blob is in
# BLOBS_BY_DIGEST), yet the fetch completes without raising.
assert scan_data is not None
assert scan_data.files == []
assert scan_data.truncated is True
@mock_aws
def test_fetch_image_scan_data_manifest_not_found_returns_none(self):
"""An unknown digest resolves to no scan data."""
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
scan_data = ImageInspector().fetch_image_scan_data(
ecr_client, AWS_ACCOUNT_NUMBER, REPO_NAME, f"sha256:{'f' * 64}"
)
assert scan_data is None
@mock_aws
def test_fetch_image_scan_data_config_download_failure_marks_truncated(self):
"""A config blob that cannot be retrieved marks coverage incomplete.
Empty env/history would otherwise be indistinguishable from a clean
config, so the fetch flags the result as truncated rather than risking
a false PASS at the check level.
"""
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = SIMPLE_MANIFEST
# Register the layer but NOT the config blob, so the config download
# fails while the layer is still scanned cleanly.
BLOBS_BY_DIGEST[LAYER_DIGEST] = build_gzip_tar({"app/config.py": "clean"})
scan_data = self._fetch()
assert scan_data is not None
assert scan_data.env == []
assert scan_data.history == []
assert scan_data.truncated is True
assert [f.path for f in scan_data.files] == ["app/config.py"]
@mock_aws
def test_fetch_image_scan_data_member_over_remaining_budget_is_truncated(self):
"""A layer exceeding the remaining stream budget is truncated.
Tar headers and padding consume the authoritative decompressed-byte
budget before member payloads are exposed for scanning.
"""
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = SIMPLE_MANIFEST
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
BLOBS_BY_DIGEST[LAYER_DIGEST] = build_gzip_tar(
{"app/first.txt": "a" * 100, "app/second.txt": "b" * 5000}
)
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
with (
patch(_REQUESTS_GET, new=mock_requests_get),
patch(
"prowler.providers.aws.services.ecr.image_inspection.MAX_TOTAL_BYTES_PER_IMAGE",
1000,
),
):
scan_data = ImageInspector().fetch_image_scan_data(
ecr_client, AWS_ACCOUNT_NUMBER, REPO_NAME, IMAGE_DIGEST
)
assert scan_data is not None
assert scan_data.files == []
assert scan_data.truncated is True
@mock_aws
def test_fetch_image_scan_data_oversized_members_count_toward_budget(self):
"""Members skipped for size still count toward the per-image budget.
A streaming reader must decompress each member to advance past it, so
oversized-and-skipped members must still consume budget; otherwise a
layer of many just-over-limit files would decompress unbounded. The
loop must stop before reaching a later scannable member.
"""
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = SIMPLE_MANIFEST
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
# Ten 300-byte members (each over the patched 100-byte MAX_FILE_BYTES,
# so each is skipped for content) followed by a small, scannable file.
layer = {f"app/big{i}.bin": "x" * 300 for i in range(10)}
layer["app/reachable.txt"] = "hello"
BLOBS_BY_DIGEST[LAYER_DIGEST] = build_gzip_tar(layer)
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
with (
patch(_REQUESTS_GET, new=mock_requests_get),
patch(
"prowler.providers.aws.services.ecr.image_inspection.MAX_FILE_BYTES",
100,
),
patch(
"prowler.providers.aws.services.ecr.image_inspection.MAX_TOTAL_BYTES_PER_IMAGE",
1000,
),
):
scan_data = ImageInspector().fetch_image_scan_data(
ecr_client, AWS_ACCOUNT_NUMBER, REPO_NAME, IMAGE_DIGEST
)
assert scan_data is not None
# The oversized members exhaust the 1000-byte budget after ~3 of them,
# so the loop stops before ever reaching app/reachable.txt. If skipped
# members were not counted, reachable.txt would be scanned.
assert scan_data.files == []
assert scan_data.truncated is True
@mock_aws
def test_fetch_image_scan_data_tar_over_stream_budget_is_truncated(self):
"""Tar headers, padding, and non-files consume the image byte budget."""
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = SIMPLE_MANIFEST
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
layer = BytesIO()
with tarfile.open(fileobj=layer, mode="w") as archive:
for index in range(20):
directory = tarfile.TarInfo(f"metadata-{index}/")
directory.type = tarfile.DIRTYPE
archive.addfile(directory)
content = b"x"
member = tarfile.TarInfo("app/reachable.txt")
member.size = len(content)
archive.addfile(member, BytesIO(content))
BLOBS_BY_DIGEST[LAYER_DIGEST] = gzip.compress(layer.getvalue())
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
with (
patch(_REQUESTS_GET, new=mock_requests_get),
patch(
"prowler.providers.aws.services.ecr.image_inspection.MAX_TOTAL_BYTES_PER_IMAGE",
10 * 1024 - 1,
),
):
scan_data = ImageInspector().fetch_image_scan_data(
ecr_client, AWS_ACCOUNT_NUMBER, REPO_NAME, IMAGE_DIGEST
)
assert scan_data is not None
assert scan_data.files == []
assert scan_data.truncated is True
def test_select_child_manifest_digest_falls_back_to_non_amd64(self):
"""With no amd64/linux entry, the first non-attestation candidate is picked."""
manifest_list = {
"manifests": [
{
"digest": CHILD_ARM64_DIGEST,
"platform": {"architecture": "arm64", "os": "linux"},
},
{
"digest": f"sha256:{'5' * 64}",
"platform": {"architecture": "unknown", "os": "unknown"},
"annotations": {
"vnd.docker.reference.type": "attestation-manifest"
},
},
]
}
digest = ImageInspector._select_child_manifest_digest(manifest_list)
assert digest == CHILD_ARM64_DIGEST
@mock_aws
def test_fetch_image_scan_data_zstd_layer(self):
"""A zstd-compressed layer is streamed, decompressed, and scanned."""
zstd_manifest = {
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"config": {"digest": CONFIG_DIGEST, "size": 100},
"layers": [
{
"mediaType": "application/vnd.oci.image.layer.v1.tar+zstd",
"digest": LAYER_DIGEST,
"size": 200,
}
],
}
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = zstd_manifest
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
BLOBS_BY_DIGEST[LAYER_DIGEST] = zstandard.ZstdCompressor().compress(
build_tar({"app/config.py": "TOKEN = 'x'"})
)
scan_data = self._fetch()
assert scan_data is not None
assert len(scan_data.files) == 1
assert scan_data.files[0].content == "TOKEN = 'x'"
@mock_aws
def test_fetch_image_scan_data_zstd_layer_over_compressed_cap_is_truncated(self):
"""A zstd layer whose compressed bytes exceed the cap is truncated.
The streaming decompressor reads through a _CappedLayerReader, so a
layer whose compressed size exceeds MAX_LAYER_DOWNLOAD_BYTES (patched
here) is cut off and disclosed via truncated instead of being buffered
or decompressed unbounded.
"""
zstd_manifest = {
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"config": {"digest": CONFIG_DIGEST, "size": 100},
"layers": [
{
"mediaType": "application/vnd.oci.image.layer.v1.tar+zstd",
"digest": LAYER_DIGEST,
# Declares zero size so it passes the pre-download check;
# the actual compressed bytes exceed the (patched) cap.
"size": 0,
}
],
}
# Incompressible payload (so the compressed frame stays large), split
# across two members so the first is read before the cap trips while
# the second is streamed.
rng = random.Random(0)
incompressible = bytes(rng.randrange(256) for _ in range(64 * 1024)).decode(
"latin-1"
)
layer_blob = zstandard.ZstdCompressor().compress(
build_tar({"app/config.py": "TOKEN = 'x'", "app/big.bin": incompressible})
)
assert len(layer_blob) > 10 * 1024
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = zstd_manifest
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
BLOBS_BY_DIGEST[LAYER_DIGEST] = layer_blob
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
with (
patch(_REQUESTS_GET, new=mock_requests_get),
patch(
"prowler.providers.aws.services.ecr.image_inspection.MAX_LAYER_DOWNLOAD_BYTES",
len(layer_blob) - 1,
),
):
scan_data = ImageInspector().fetch_image_scan_data(
ecr_client, AWS_ACCOUNT_NUMBER, REPO_NAME, IMAGE_DIGEST
)
assert scan_data is not None
assert scan_data.truncated is True
@mock_aws
def test_fetch_image_scan_data_uncompressed_tar_layer(self):
"""An uncompressed tar layer is read and scanned directly."""
tar_manifest = {
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"config": {"digest": CONFIG_DIGEST, "size": 100},
"layers": [
{
"mediaType": "application/vnd.oci.image.layer.v1.tar",
"digest": LAYER_DIGEST,
"size": 200,
}
],
}
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = tar_manifest
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
BLOBS_BY_DIGEST[LAYER_DIGEST] = build_tar({"app/config.py": "TOKEN = 'x'"})
scan_data = self._fetch()
assert scan_data is not None
assert len(scan_data.files) == 1
assert scan_data.files[0].content == "TOKEN = 'x'"
@mock_aws
def test_fetch_image_scan_data_skips_whiteout_and_oversized_file(self):
"""Whiteout markers and oversized files are skipped, not scanned."""
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = SIMPLE_MANIFEST
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
BLOBS_BY_DIGEST[LAYER_DIGEST] = build_gzip_tar(
{
".wh.deleted": "should never appear",
"app/config.py": "TOKEN = 'x'",
"app/oversized.bin": "x" * (MAX_FILE_BYTES + 1),
}
)
scan_data = self._fetch()
assert scan_data is not None
assert [f.path for f in scan_data.files] == ["app/config.py"]
assert scan_data.truncated is True
def test_capped_layer_reader_allows_up_to_max(self):
"""Reading exactly the byte budget succeeds and then reports EOF."""
import io
reader = _CappedLayerReader(io.BytesIO(b"x" * 10), max_bytes=10)
assert reader.read() == b"x" * 10
assert reader.read() == b""
def test_capped_layer_reader_raises_when_exceeding_max(self):
"""A stream longer than the byte budget raises _LayerTooLargeError."""
import io
reader = _CappedLayerReader(io.BytesIO(b"x" * 100), max_bytes=10)
with pytest.raises(_LayerTooLargeError):
reader.read()
@mock_aws
def test_fetch_image_scan_data_streamed_layer_over_cap_is_truncated(self):
"""A layer streaming past MAX_LAYER_DOWNLOAD_BYTES is skipped, not buffered."""
undersized_manifest = {
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"config": {"digest": CONFIG_DIGEST, "size": 100},
"layers": [
{
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
"digest": LAYER_DIGEST,
# Declares zero size so it passes the pre-download check;
# the actual streamed bytes exceed the (patched) cap.
"size": 0,
}
],
}
# Two-member layer: a small first file that is scanned, then a large
# incompressible second file. The blob must exceed tarfile's internal
# read buffer (~10 KB) so tarfile.open() consumes only part of it and
# the cap (set one byte below the full layer) is instead exceeded while
# the second member's content is read during archive iteration.
rng = random.Random(0)
incompressible = bytes(rng.randrange(256) for _ in range(64 * 1024)).decode(
"latin-1"
)
layer_blob = build_gzip_tar(
{"app/config.py": "TOKEN = 'x'", "app/big.bin": incompressible}
)
assert len(layer_blob) > 10 * 1024 # larger than tarfile's read buffer
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = undersized_manifest
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
BLOBS_BY_DIGEST[LAYER_DIGEST] = layer_blob
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
with (
patch(_REQUESTS_GET, new=mock_requests_get),
patch(
"prowler.providers.aws.services.ecr.image_inspection.MAX_LAYER_DOWNLOAD_BYTES",
len(layer_blob) - 1,
),
):
scan_data = ImageInspector().fetch_image_scan_data(
ecr_client, AWS_ACCOUNT_NUMBER, REPO_NAME, IMAGE_DIGEST
)
# The over-cap layer is disclosed via truncated, and the config-derived
# env/history (fetched independently of the layer) are still returned.
assert scan_data is not None
assert scan_data.truncated is True
assert scan_data.env == ["PATH=/usr/bin", "TOKEN=super-secret-value"]
@@ -0,0 +1,145 @@
"""Shared fixtures for ECR image-scanning tests.
Used by both the ECR service tests (orchestration) and the image_inspection
tests (bounded extraction), so the manifest/layer fixtures and the fake layer
download live in one place. moto implements neither BatchGetImage nor
GetDownloadUrlForLayer, so each test registers the manifests/blobs it needs in
``MANIFESTS_BY_DIGEST``/``BLOBS_BY_DIGEST`` and a patched ``_make_api_call``
serves them.
"""
import io
import tarfile
IMAGE_DIGEST = f"sha256:{'1' * 64}"
CONFIG_DIGEST = f"sha256:{'c' * 64}"
LAYER_DIGEST = f"sha256:{'d' * 64}"
MULTI_ARCH_INDEX_DIGEST = f"sha256:{'2' * 64}"
CHILD_AMD64_DIGEST = f"sha256:{'3' * 64}"
CHILD_ARM64_DIGEST = f"sha256:{'4' * 64}"
ATTESTATION_DIGEST = f"sha256:{'5' * 64}"
SIMPLE_MANIFEST = {
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"config": {
"mediaType": "application/vnd.docker.container.image.v1+json",
"digest": CONFIG_DIGEST,
"size": 100,
},
"layers": [
{
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
"digest": LAYER_DIGEST,
"size": 200,
}
],
}
MULTI_ARCH_MANIFEST_LIST = {
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"manifests": [
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"digest": CHILD_AMD64_DIGEST,
"size": 10,
"platform": {"architecture": "amd64", "os": "linux"},
},
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"digest": CHILD_ARM64_DIGEST,
"size": 10,
"platform": {"architecture": "arm64", "os": "linux"},
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": ATTESTATION_DIGEST,
"size": 10,
"platform": {"architecture": "unknown", "os": "unknown"},
"annotations": {"vnd.docker.reference.type": "attestation-manifest"},
},
],
}
CONFIG_JSON = {
"config": {"Env": ["PATH=/usr/bin", "TOKEN=super-secret-value"]},
"history": [
{"created_by": "/bin/sh -c #(nop) ADD file"},
{"created_by": "RUN echo hi"},
],
}
# Per-test fixtures keyed by digest. moto implements neither BatchGetImage nor
# GetDownloadUrlForLayer, so tests populate these and a patched _make_api_call /
# requests.get serves them. Cleared between tests via reset_image_fixtures().
MANIFESTS_BY_DIGEST = {}
BLOBS_BY_DIGEST = {}
def reset_image_fixtures():
"""Clear the per-test manifest/blob fixtures."""
MANIFESTS_BY_DIGEST.clear()
BLOBS_BY_DIGEST.clear()
def build_tar(files: dict) -> bytes:
"""Build an uncompressed tar archive from the given files."""
tar_buffer = io.BytesIO()
with tarfile.open(fileobj=tar_buffer, mode="w") as tar:
for name, content in files.items():
data = content.encode("latin-1")
info = tarfile.TarInfo(name=name)
info.size = len(data)
tar.addfile(info, io.BytesIO(data))
return tar_buffer.getvalue()
def build_gzip_tar(files: dict) -> bytes:
"""Build a gzip-compressed tar archive from the given files."""
tar_buffer = io.BytesIO()
with tarfile.open(fileobj=tar_buffer, mode="w:gz") as tar:
for name, content in files.items():
data = content.encode("latin-1")
info = tarfile.TarInfo(name=name)
info.size = len(data)
tar.addfile(info, io.BytesIO(data))
return tar_buffer.getvalue()
class FakeLayerResponse:
"""A minimal stand-in for a requests.Response over a layer download."""
def __init__(self, data: bytes):
"""Store the fixture bytes to serve (via iter_content and .raw)."""
self._data = data
# Streaming gzip/tar layers read the compressed bytes straight from
# response.raw; the buffered config/zstd path uses iter_content.
self.raw = io.BytesIO(data)
def raise_for_status(self):
"""No-op: fixture responses are always successful."""
def iter_content(self, chunk_size=1024 * 1024):
"""Yield the fixture bytes in chunks."""
for start in range(0, len(self._data), chunk_size):
yield self._data[start : start + chunk_size]
def close(self):
"""Close the backing raw stream, mirroring requests.Response.close."""
self.raw.close()
def __enter__(self):
"""Support use as a context manager."""
return self
def __exit__(self, *_):
"""Close on exit, mirroring requests.Response context-manager use."""
self.close()
return False
def mock_requests_get(url, **_):
"""Return the fixture bytes registered for the requested layer's URL."""
digest = url.rsplit("/", 1)[-1]
return FakeLayerResponse(BLOBS_BY_DIGEST[digest])
Generated
+77
View File
@@ -3848,6 +3848,7 @@ dependencies = [
{ name = "tabulate" },
{ name = "tzlocal" },
{ name = "uuid6" },
{ name = "zstandard" },
]
[package.dev-dependencies]
@@ -3968,6 +3969,7 @@ requires-dist = [
{ name = "tabulate", specifier = "==0.9.0" },
{ name = "tzlocal", specifier = "==5.3.1" },
{ name = "uuid6", specifier = "==2024.7.10" },
{ name = "zstandard", specifier = "==0.25.0" },
]
[package.metadata.requires-dev]
@@ -5515,6 +5517,81 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/08/8a/0861bec20485572fbddf3dfba2910e38fe249796cb73ecdeb74e07eeb8d3/zipp-3.23.1-py3-none-any.whl", hash = "sha256:0b3596c50a5c700c9cb40ba8d86d9f2cc4807e9bedb06bcdf7fac85633e444dc", size = 10378, upload-time = "2026-04-13T23:21:45.386Z" },
]
[[package]]
name = "zstandard"
version = "0.25.0"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/fd/aa/3e0508d5a5dd96529cdc5a97011299056e14c6505b678fd58938792794b1/zstandard-0.25.0.tar.gz", hash = "sha256:7713e1179d162cf5c7906da876ec2ccb9c3a9dcbdffef0cc7f70c3667a205f0b", size = 711513, upload-time = "2025-09-14T22:15:54.002Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/56/7a/28efd1d371f1acd037ac64ed1c5e2b41514a6cc937dd6ab6a13ab9f0702f/zstandard-0.25.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e59fdc271772f6686e01e1b3b74537259800f57e24280be3f29c8a0deb1904dd", size = 795256, upload-time = "2025-09-14T22:15:56.415Z" },
{ url = "https://files.pythonhosted.org/packages/96/34/ef34ef77f1ee38fc8e4f9775217a613b452916e633c4f1d98f31db52c4a5/zstandard-0.25.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4d441506e9b372386a5271c64125f72d5df6d2a8e8a2a45a0ae09b03cb781ef7", size = 640565, upload-time = "2025-09-14T22:15:58.177Z" },
{ url = "https://files.pythonhosted.org/packages/9d/1b/4fdb2c12eb58f31f28c4d28e8dc36611dd7205df8452e63f52fb6261d13e/zstandard-0.25.0-cp310-cp310-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:ab85470ab54c2cb96e176f40342d9ed41e58ca5733be6a893b730e7af9c40550", size = 5345306, upload-time = "2025-09-14T22:16:00.165Z" },
{ url = "https://files.pythonhosted.org/packages/73/28/a44bdece01bca027b079f0e00be3b6bd89a4df180071da59a3dd7381665b/zstandard-0.25.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:e05ab82ea7753354bb054b92e2f288afb750e6b439ff6ca78af52939ebbc476d", size = 5055561, upload-time = "2025-09-14T22:16:02.22Z" },
{ url = "https://files.pythonhosted.org/packages/e9/74/68341185a4f32b274e0fc3410d5ad0750497e1acc20bd0f5b5f64ce17785/zstandard-0.25.0-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:78228d8a6a1c177a96b94f7e2e8d012c55f9c760761980da16ae7546a15a8e9b", size = 5402214, upload-time = "2025-09-14T22:16:04.109Z" },
{ url = "https://files.pythonhosted.org/packages/8b/67/f92e64e748fd6aaffe01e2b75a083c0c4fd27abe1c8747fee4555fcee7dd/zstandard-0.25.0-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:2b6bd67528ee8b5c5f10255735abc21aa106931f0dbaf297c7be0c886353c3d0", size = 5449703, upload-time = "2025-09-14T22:16:06.312Z" },
{ url = "https://files.pythonhosted.org/packages/fd/e5/6d36f92a197c3c17729a2125e29c169f460538a7d939a27eaaa6dcfcba8e/zstandard-0.25.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:4b6d83057e713ff235a12e73916b6d356e3084fd3d14ced499d84240f3eecee0", size = 5556583, upload-time = "2025-09-14T22:16:08.457Z" },
{ url = "https://files.pythonhosted.org/packages/d7/83/41939e60d8d7ebfe2b747be022d0806953799140a702b90ffe214d557638/zstandard-0.25.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:9174f4ed06f790a6869b41cba05b43eeb9a35f8993c4422ab853b705e8112bbd", size = 5045332, upload-time = "2025-09-14T22:16:10.444Z" },
{ url = "https://files.pythonhosted.org/packages/b3/87/d3ee185e3d1aa0133399893697ae91f221fda79deb61adbe998a7235c43f/zstandard-0.25.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:25f8f3cd45087d089aef5ba3848cd9efe3ad41163d3400862fb42f81a3a46701", size = 5572283, upload-time = "2025-09-14T22:16:12.128Z" },
{ url = "https://files.pythonhosted.org/packages/0a/1d/58635ae6104df96671076ac7d4ae7816838ce7debd94aecf83e30b7121b0/zstandard-0.25.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:3756b3e9da9b83da1796f8809dd57cb024f838b9eeafde28f3cb472012797ac1", size = 4959754, upload-time = "2025-09-14T22:16:14.225Z" },
{ url = "https://files.pythonhosted.org/packages/75/d6/57e9cb0a9983e9a229dd8fd2e6e96593ef2aa82a3907188436f22b111ccd/zstandard-0.25.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:81dad8d145d8fd981b2962b686b2241d3a1ea07733e76a2f15435dfb7fb60150", size = 5266477, upload-time = "2025-09-14T22:16:16.343Z" },
{ url = "https://files.pythonhosted.org/packages/d1/a9/ee891e5edf33a6ebce0a028726f0bbd8567effe20fe3d5808c42323e8542/zstandard-0.25.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:a5a419712cf88862a45a23def0ae063686db3d324cec7edbe40509d1a79a0aab", size = 5440914, upload-time = "2025-09-14T22:16:18.453Z" },
{ url = "https://files.pythonhosted.org/packages/58/08/a8522c28c08031a9521f27abc6f78dbdee7312a7463dd2cfc658b813323b/zstandard-0.25.0-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:e7360eae90809efd19b886e59a09dad07da4ca9ba096752e61a2e03c8aca188e", size = 5819847, upload-time = "2025-09-14T22:16:20.559Z" },
{ url = "https://files.pythonhosted.org/packages/6f/11/4c91411805c3f7b6f31c60e78ce347ca48f6f16d552fc659af6ec3b73202/zstandard-0.25.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:75ffc32a569fb049499e63ce68c743155477610532da1eb38e7f24bf7cd29e74", size = 5363131, upload-time = "2025-09-14T22:16:22.206Z" },
{ url = "https://files.pythonhosted.org/packages/ef/d6/8c4bd38a3b24c4c7676a7a3d8de85d6ee7a983602a734b9f9cdefb04a5d6/zstandard-0.25.0-cp310-cp310-win32.whl", hash = "sha256:106281ae350e494f4ac8a80470e66d1fe27e497052c8d9c3b95dc4cf1ade81aa", size = 436469, upload-time = "2025-09-14T22:16:25.002Z" },
{ url = "https://files.pythonhosted.org/packages/93/90/96d50ad417a8ace5f841b3228e93d1bb13e6ad356737f42e2dde30d8bd68/zstandard-0.25.0-cp310-cp310-win_amd64.whl", hash = "sha256:ea9d54cc3d8064260114a0bbf3479fc4a98b21dffc89b3459edd506b69262f6e", size = 506100, upload-time = "2025-09-14T22:16:23.569Z" },
{ url = "https://files.pythonhosted.org/packages/2a/83/c3ca27c363d104980f1c9cee1101cc8ba724ac8c28a033ede6aab89585b1/zstandard-0.25.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:933b65d7680ea337180733cf9e87293cc5500cc0eb3fc8769f4d3c88d724ec5c", size = 795254, upload-time = "2025-09-14T22:16:26.137Z" },
{ url = "https://files.pythonhosted.org/packages/ac/4d/e66465c5411a7cf4866aeadc7d108081d8ceba9bc7abe6b14aa21c671ec3/zstandard-0.25.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a3f79487c687b1fc69f19e487cd949bf3aae653d181dfb5fde3bf6d18894706f", size = 640559, upload-time = "2025-09-14T22:16:27.973Z" },
{ url = "https://files.pythonhosted.org/packages/12/56/354fe655905f290d3b147b33fe946b0f27e791e4b50a5f004c802cb3eb7b/zstandard-0.25.0-cp311-cp311-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:0bbc9a0c65ce0eea3c34a691e3c4b6889f5f3909ba4822ab385fab9057099431", size = 5348020, upload-time = "2025-09-14T22:16:29.523Z" },
{ url = "https://files.pythonhosted.org/packages/3b/13/2b7ed68bd85e69a2069bcc72141d378f22cae5a0f3b353a2c8f50ef30c1b/zstandard-0.25.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:01582723b3ccd6939ab7b3a78622c573799d5d8737b534b86d0e06ac18dbde4a", size = 5058126, upload-time = "2025-09-14T22:16:31.811Z" },
{ url = "https://files.pythonhosted.org/packages/c9/dd/fdaf0674f4b10d92cb120ccff58bbb6626bf8368f00ebfd2a41ba4a0dc99/zstandard-0.25.0-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:5f1ad7bf88535edcf30038f6919abe087f606f62c00a87d7e33e7fc57cb69fcc", size = 5405390, upload-time = "2025-09-14T22:16:33.486Z" },
{ url = "https://files.pythonhosted.org/packages/0f/67/354d1555575bc2490435f90d67ca4dd65238ff2f119f30f72d5cde09c2ad/zstandard-0.25.0-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:06acb75eebeedb77b69048031282737717a63e71e4ae3f77cc0c3b9508320df6", size = 5452914, upload-time = "2025-09-14T22:16:35.277Z" },
{ url = "https://files.pythonhosted.org/packages/bb/1f/e9cfd801a3f9190bf3e759c422bbfd2247db9d7f3d54a56ecde70137791a/zstandard-0.25.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:9300d02ea7c6506f00e627e287e0492a5eb0371ec1670ae852fefffa6164b072", size = 5559635, upload-time = "2025-09-14T22:16:37.141Z" },
{ url = "https://files.pythonhosted.org/packages/21/88/5ba550f797ca953a52d708c8e4f380959e7e3280af029e38fbf47b55916e/zstandard-0.25.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:bfd06b1c5584b657a2892a6014c2f4c20e0db0208c159148fa78c65f7e0b0277", size = 5048277, upload-time = "2025-09-14T22:16:38.807Z" },
{ url = "https://files.pythonhosted.org/packages/46/c0/ca3e533b4fa03112facbe7fbe7779cb1ebec215688e5df576fe5429172e0/zstandard-0.25.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:f373da2c1757bb7f1acaf09369cdc1d51d84131e50d5fa9863982fd626466313", size = 5574377, upload-time = "2025-09-14T22:16:40.523Z" },
{ url = "https://files.pythonhosted.org/packages/12/9b/3fb626390113f272abd0799fd677ea33d5fc3ec185e62e6be534493c4b60/zstandard-0.25.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:6c0e5a65158a7946e7a7affa6418878ef97ab66636f13353b8502d7ea03c8097", size = 4961493, upload-time = "2025-09-14T22:16:43.3Z" },
{ url = "https://files.pythonhosted.org/packages/cb/d3/23094a6b6a4b1343b27ae68249daa17ae0651fcfec9ed4de09d14b940285/zstandard-0.25.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:c8e167d5adf59476fa3e37bee730890e389410c354771a62e3c076c86f9f7778", size = 5269018, upload-time = "2025-09-14T22:16:45.292Z" },
{ url = "https://files.pythonhosted.org/packages/8c/a7/bb5a0c1c0f3f4b5e9d5b55198e39de91e04ba7c205cc46fcb0f95f0383c1/zstandard-0.25.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:98750a309eb2f020da61e727de7d7ba3c57c97cf6213f6f6277bb7fb42a8e065", size = 5443672, upload-time = "2025-09-14T22:16:47.076Z" },
{ url = "https://files.pythonhosted.org/packages/27/22/503347aa08d073993f25109c36c8d9f029c7d5949198050962cb568dfa5e/zstandard-0.25.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:22a086cff1b6ceca18a8dd6096ec631e430e93a8e70a9ca5efa7561a00f826fa", size = 5822753, upload-time = "2025-09-14T22:16:49.316Z" },
{ url = "https://files.pythonhosted.org/packages/e2/be/94267dc6ee64f0f8ba2b2ae7c7a2df934a816baaa7291db9e1aa77394c3c/zstandard-0.25.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:72d35d7aa0bba323965da807a462b0966c91608ef3a48ba761678cb20ce5d8b7", size = 5366047, upload-time = "2025-09-14T22:16:51.328Z" },
{ url = "https://files.pythonhosted.org/packages/7b/a3/732893eab0a3a7aecff8b99052fecf9f605cf0fb5fb6d0290e36beee47a4/zstandard-0.25.0-cp311-cp311-win32.whl", hash = "sha256:f5aeea11ded7320a84dcdd62a3d95b5186834224a9e55b92ccae35d21a8b63d4", size = 436484, upload-time = "2025-09-14T22:16:55.005Z" },
{ url = "https://files.pythonhosted.org/packages/43/a3/c6155f5c1cce691cb80dfd38627046e50af3ee9ddc5d0b45b9b063bfb8c9/zstandard-0.25.0-cp311-cp311-win_amd64.whl", hash = "sha256:daab68faadb847063d0c56f361a289c4f268706b598afbf9ad113cbe5c38b6b2", size = 506183, upload-time = "2025-09-14T22:16:52.753Z" },
{ url = "https://files.pythonhosted.org/packages/8c/3e/8945ab86a0820cc0e0cdbf38086a92868a9172020fdab8a03ac19662b0e5/zstandard-0.25.0-cp311-cp311-win_arm64.whl", hash = "sha256:22a06c5df3751bb7dc67406f5374734ccee8ed37fc5981bf1ad7041831fa1137", size = 462533, upload-time = "2025-09-14T22:16:53.878Z" },
{ url = "https://files.pythonhosted.org/packages/82/fc/f26eb6ef91ae723a03e16eddb198abcfce2bc5a42e224d44cc8b6765e57e/zstandard-0.25.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7b3c3a3ab9daa3eed242d6ecceead93aebbb8f5f84318d82cee643e019c4b73b", size = 795738, upload-time = "2025-09-14T22:16:56.237Z" },
{ url = "https://files.pythonhosted.org/packages/aa/1c/d920d64b22f8dd028a8b90e2d756e431a5d86194caa78e3819c7bf53b4b3/zstandard-0.25.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:913cbd31a400febff93b564a23e17c3ed2d56c064006f54efec210d586171c00", size = 640436, upload-time = "2025-09-14T22:16:57.774Z" },
{ url = "https://files.pythonhosted.org/packages/53/6c/288c3f0bd9fcfe9ca41e2c2fbfd17b2097f6af57b62a81161941f09afa76/zstandard-0.25.0-cp312-cp312-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:011d388c76b11a0c165374ce660ce2c8efa8e5d87f34996aa80f9c0816698b64", size = 5343019, upload-time = "2025-09-14T22:16:59.302Z" },
{ url = "https://files.pythonhosted.org/packages/1e/15/efef5a2f204a64bdb5571e6161d49f7ef0fffdbca953a615efbec045f60f/zstandard-0.25.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:6dffecc361d079bb48d7caef5d673c88c8988d3d33fb74ab95b7ee6da42652ea", size = 5063012, upload-time = "2025-09-14T22:17:01.156Z" },
{ url = "https://files.pythonhosted.org/packages/b7/37/a6ce629ffdb43959e92e87ebdaeebb5ac81c944b6a75c9c47e300f85abdf/zstandard-0.25.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:7149623bba7fdf7e7f24312953bcf73cae103db8cae49f8154dd1eadc8a29ecb", size = 5394148, upload-time = "2025-09-14T22:17:03.091Z" },
{ url = "https://files.pythonhosted.org/packages/e3/79/2bf870b3abeb5c070fe2d670a5a8d1057a8270f125ef7676d29ea900f496/zstandard-0.25.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:6a573a35693e03cf1d67799fd01b50ff578515a8aeadd4595d2a7fa9f3ec002a", size = 5451652, upload-time = "2025-09-14T22:17:04.979Z" },
{ url = "https://files.pythonhosted.org/packages/53/60/7be26e610767316c028a2cbedb9a3beabdbe33e2182c373f71a1c0b88f36/zstandard-0.25.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:5a56ba0db2d244117ed744dfa8f6f5b366e14148e00de44723413b2f3938a902", size = 5546993, upload-time = "2025-09-14T22:17:06.781Z" },
{ url = "https://files.pythonhosted.org/packages/85/c7/3483ad9ff0662623f3648479b0380d2de5510abf00990468c286c6b04017/zstandard-0.25.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:10ef2a79ab8e2974e2075fb984e5b9806c64134810fac21576f0668e7ea19f8f", size = 5046806, upload-time = "2025-09-14T22:17:08.415Z" },
{ url = "https://files.pythonhosted.org/packages/08/b3/206883dd25b8d1591a1caa44b54c2aad84badccf2f1de9e2d60a446f9a25/zstandard-0.25.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:aaf21ba8fb76d102b696781bddaa0954b782536446083ae3fdaa6f16b25a1c4b", size = 5576659, upload-time = "2025-09-14T22:17:10.164Z" },
{ url = "https://files.pythonhosted.org/packages/9d/31/76c0779101453e6c117b0ff22565865c54f48f8bd807df2b00c2c404b8e0/zstandard-0.25.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1869da9571d5e94a85a5e8d57e4e8807b175c9e4a6294e3b66fa4efb074d90f6", size = 4953933, upload-time = "2025-09-14T22:17:11.857Z" },
{ url = "https://files.pythonhosted.org/packages/18/e1/97680c664a1bf9a247a280a053d98e251424af51f1b196c6d52f117c9720/zstandard-0.25.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:809c5bcb2c67cd0ed81e9229d227d4ca28f82d0f778fc5fea624a9def3963f91", size = 5268008, upload-time = "2025-09-14T22:17:13.627Z" },
{ url = "https://files.pythonhosted.org/packages/1e/73/316e4010de585ac798e154e88fd81bb16afc5c5cb1a72eeb16dd37e8024a/zstandard-0.25.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:f27662e4f7dbf9f9c12391cb37b4c4c3cb90ffbd3b1fb9284dadbbb8935fa708", size = 5433517, upload-time = "2025-09-14T22:17:16.103Z" },
{ url = "https://files.pythonhosted.org/packages/5b/60/dd0f8cfa8129c5a0ce3ea6b7f70be5b33d2618013a161e1ff26c2b39787c/zstandard-0.25.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:99c0c846e6e61718715a3c9437ccc625de26593fea60189567f0118dc9db7512", size = 5814292, upload-time = "2025-09-14T22:17:17.827Z" },
{ url = "https://files.pythonhosted.org/packages/fc/5f/75aafd4b9d11b5407b641b8e41a57864097663699f23e9ad4dbb91dc6bfe/zstandard-0.25.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:474d2596a2dbc241a556e965fb76002c1ce655445e4e3bf38e5477d413165ffa", size = 5360237, upload-time = "2025-09-14T22:17:19.954Z" },
{ url = "https://files.pythonhosted.org/packages/ff/8d/0309daffea4fcac7981021dbf21cdb2e3427a9e76bafbcdbdf5392ff99a4/zstandard-0.25.0-cp312-cp312-win32.whl", hash = "sha256:23ebc8f17a03133b4426bcc04aabd68f8236eb78c3760f12783385171b0fd8bd", size = 436922, upload-time = "2025-09-14T22:17:24.398Z" },
{ url = "https://files.pythonhosted.org/packages/79/3b/fa54d9015f945330510cb5d0b0501e8253c127cca7ebe8ba46a965df18c5/zstandard-0.25.0-cp312-cp312-win_amd64.whl", hash = "sha256:ffef5a74088f1e09947aecf91011136665152e0b4b359c42be3373897fb39b01", size = 506276, upload-time = "2025-09-14T22:17:21.429Z" },
{ url = "https://files.pythonhosted.org/packages/ea/6b/8b51697e5319b1f9ac71087b0af9a40d8a6288ff8025c36486e0c12abcc4/zstandard-0.25.0-cp312-cp312-win_arm64.whl", hash = "sha256:181eb40e0b6a29b3cd2849f825e0fa34397f649170673d385f3598ae17cca2e9", size = 462679, upload-time = "2025-09-14T22:17:23.147Z" },
{ url = "https://files.pythonhosted.org/packages/35/0b/8df9c4ad06af91d39e94fa96cc010a24ac4ef1378d3efab9223cc8593d40/zstandard-0.25.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ec996f12524f88e151c339688c3897194821d7f03081ab35d31d1e12ec975e94", size = 795735, upload-time = "2025-09-14T22:17:26.042Z" },
{ url = "https://files.pythonhosted.org/packages/3f/06/9ae96a3e5dcfd119377ba33d4c42a7d89da1efabd5cb3e366b156c45ff4d/zstandard-0.25.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a1a4ae2dec3993a32247995bdfe367fc3266da832d82f8438c8570f989753de1", size = 640440, upload-time = "2025-09-14T22:17:27.366Z" },
{ url = "https://files.pythonhosted.org/packages/d9/14/933d27204c2bd404229c69f445862454dcc101cd69ef8c6068f15aaec12c/zstandard-0.25.0-cp313-cp313-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:e96594a5537722fdfb79951672a2a63aec5ebfb823e7560586f7484819f2a08f", size = 5343070, upload-time = "2025-09-14T22:17:28.896Z" },
{ url = "https://files.pythonhosted.org/packages/6d/db/ddb11011826ed7db9d0e485d13df79b58586bfdec56e5c84a928a9a78c1c/zstandard-0.25.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:bfc4e20784722098822e3eee42b8e576b379ed72cca4a7cb856ae733e62192ea", size = 5063001, upload-time = "2025-09-14T22:17:31.044Z" },
{ url = "https://files.pythonhosted.org/packages/db/00/87466ea3f99599d02a5238498b87bf84a6348290c19571051839ca943777/zstandard-0.25.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:457ed498fc58cdc12fc48f7950e02740d4f7ae9493dd4ab2168a47c93c31298e", size = 5394120, upload-time = "2025-09-14T22:17:32.711Z" },
{ url = "https://files.pythonhosted.org/packages/2b/95/fc5531d9c618a679a20ff6c29e2b3ef1d1f4ad66c5e161ae6ff847d102a9/zstandard-0.25.0-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:fd7a5004eb1980d3cefe26b2685bcb0b17989901a70a1040d1ac86f1d898c551", size = 5451230, upload-time = "2025-09-14T22:17:34.41Z" },
{ url = "https://files.pythonhosted.org/packages/63/4b/e3678b4e776db00f9f7b2fe58e547e8928ef32727d7a1ff01dea010f3f13/zstandard-0.25.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:8e735494da3db08694d26480f1493ad2cf86e99bdd53e8e9771b2752a5c0246a", size = 5547173, upload-time = "2025-09-14T22:17:36.084Z" },
{ url = "https://files.pythonhosted.org/packages/4e/d5/ba05ed95c6b8ec30bd468dfeab20589f2cf709b5c940483e31d991f2ca58/zstandard-0.25.0-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:3a39c94ad7866160a4a46d772e43311a743c316942037671beb264e395bdd611", size = 5046736, upload-time = "2025-09-14T22:17:37.891Z" },
{ url = "https://files.pythonhosted.org/packages/50/d5/870aa06b3a76c73eced65c044b92286a3c4e00554005ff51962deef28e28/zstandard-0.25.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:172de1f06947577d3a3005416977cce6168f2261284c02080e7ad0185faeced3", size = 5576368, upload-time = "2025-09-14T22:17:40.206Z" },
{ url = "https://files.pythonhosted.org/packages/5d/35/398dc2ffc89d304d59bc12f0fdd931b4ce455bddf7038a0a67733a25f550/zstandard-0.25.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:3c83b0188c852a47cd13ef3bf9209fb0a77fa5374958b8c53aaa699398c6bd7b", size = 4954022, upload-time = "2025-09-14T22:17:41.879Z" },
{ url = "https://files.pythonhosted.org/packages/9a/5c/36ba1e5507d56d2213202ec2b05e8541734af5f2ce378c5d1ceaf4d88dc4/zstandard-0.25.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:1673b7199bbe763365b81a4f3252b8e80f44c9e323fc42940dc8843bfeaf9851", size = 5267889, upload-time = "2025-09-14T22:17:43.577Z" },
{ url = "https://files.pythonhosted.org/packages/70/e8/2ec6b6fb7358b2ec0113ae202647ca7c0e9d15b61c005ae5225ad0995df5/zstandard-0.25.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:0be7622c37c183406f3dbf0cba104118eb16a4ea7359eeb5752f0794882fc250", size = 5433952, upload-time = "2025-09-14T22:17:45.271Z" },
{ url = "https://files.pythonhosted.org/packages/7b/01/b5f4d4dbc59ef193e870495c6f1275f5b2928e01ff5a81fecb22a06e22fb/zstandard-0.25.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:5f5e4c2a23ca271c218ac025bd7d635597048b366d6f31f420aaeb715239fc98", size = 5814054, upload-time = "2025-09-14T22:17:47.08Z" },
{ url = "https://files.pythonhosted.org/packages/b2/e5/fbd822d5c6f427cf158316d012c5a12f233473c2f9c5fe5ab1ae5d21f3d8/zstandard-0.25.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4f187a0bb61b35119d1926aee039524d1f93aaf38a9916b8c4b78ac8514a0aaf", size = 5360113, upload-time = "2025-09-14T22:17:48.893Z" },
{ url = "https://files.pythonhosted.org/packages/8e/e0/69a553d2047f9a2c7347caa225bb3a63b6d7704ad74610cb7823baa08ed7/zstandard-0.25.0-cp313-cp313-win32.whl", hash = "sha256:7030defa83eef3e51ff26f0b7bfb229f0204b66fe18e04359ce3474ac33cbc09", size = 436936, upload-time = "2025-09-14T22:17:52.658Z" },
{ url = "https://files.pythonhosted.org/packages/d9/82/b9c06c870f3bd8767c201f1edbdf9e8dc34be5b0fbc5682c4f80fe948475/zstandard-0.25.0-cp313-cp313-win_amd64.whl", hash = "sha256:1f830a0dac88719af0ae43b8b2d6aef487d437036468ef3c2ea59c51f9d55fd5", size = 506232, upload-time = "2025-09-14T22:17:50.402Z" },
{ url = "https://files.pythonhosted.org/packages/d4/57/60c3c01243bb81d381c9916e2a6d9e149ab8627c0c7d7abb2d73384b3c0c/zstandard-0.25.0-cp313-cp313-win_arm64.whl", hash = "sha256:85304a43f4d513f5464ceb938aa02c1e78c2943b29f44a750b48b25ac999a049", size = 462671, upload-time = "2025-09-14T22:17:51.533Z" },
]
[[package]]
name = "zstd"
version = "1.5.7.2"