docker-slsa
Verify SLSA provenance attestations for Docker container images using Sigstore.
This library verifies container images built with the SLSA GitHub Generator for containers (generator_container_slsa3.yml).
Features
- Verify SLSA provenance for individual container images
- Batch verification for all images in a docker-compose file
- Built-in support for GitHub Actions SLSA container generator workflow
- Custom verification policies using sigstore's policy API
Installation
pip install docker-slsa
Quick Start
Verify a single container image
from docker_slsa import ContainerSLSAVerifier, build_default_policy
# Create a policy for GitHub Actions SLSA provenance
policy = build_default_policy(
expected_repo="org/repo",
expected_commit="abc123def456", # optional
)
# Verify the image
verifier = ContainerSLSAVerifier()
result = verifier.verify(
image_ref="ghcr.io/org/repo/image@sha256:...",
policy=policy,
)
if result.verified:
print("Verification passed!")
print(f"Provenance: {result.provenance}")
else:
print(f"Verification failed: {result.error}")
Verify all images in a docker-compose file
from docker_slsa import verify_docker_compose_provenance, build_default_policy
# Read your docker-compose file
with open("docker-compose.yml") as f:
docker_compose = f.read()
# Define policies for each service
service_policies = {
"web": build_default_policy("org/web-app"),
"api": build_default_policy("org/api-server"),
}
# Verify all services (raises ProvenanceVerificationError on failure)
result = verify_docker_compose_provenance(
docker_compose=docker_compose,
service_policies=service_policies,
ignore=["redis", "postgres"], # skip third-party images
)
print(f"All {len(result.service_results)} services verified!")
Custom verification policies
For advanced use cases, create custom policies using sigstore's policy API:
from sigstore.verify.policy import AllOf, AnyOf, OIDCIssuer, GitHubWorkflowRepository, Identity
policy = AllOf([
OIDCIssuer("https://token.actions.githubusercontent.com"),
GitHubWorkflowRepository("org/repo"),
AnyOf([
Identity(
identity="https://github.com/slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@refs/tags/v2.0.0",
issuer="https://token.actions.githubusercontent.com",
),
Identity(
identity="https://github.com/slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@refs/tags/v2.1.0",
issuer="https://token.actions.githubusercontent.com",
),
]),
])
API Reference
Classes
ContainerSLSAVerifier- Low-level verifier for individual container imagesDockerComposeProvenanceVerifier- Verifies all images in a docker-compose file
Functions
build_default_policy(expected_repo, expected_commit=None, expected_workflow_name=None)- Create a verification policy for GitHub Actions SLSA workflowsverify_docker_compose_provenance(docker_compose, service_policies, ignore=None)- Convenience function to verify a docker-compose file
Result Types
VerificationResult- Result for a single image verificationServiceVerificationResult- Result for a single service in docker-composeProvenanceVerificationResult- Aggregate result for all services
Exceptions
ProvenanceVerificationError- Raised when verification fails
Requirements
- Python 3.10+
- Network access to container registries and Sigstore services
- Container images must have SLSA provenance attestations generated by the SLSA GitHub Generator
generator_container_slsa3.ymlworkflow
Development
# Install dependencies
uv sync --group dev --group test
# Run tests
make test
# Run tests with coverage (95% required)
make test-coverage
# Format code
make format
# Lint code
make lint
# Run all QA checks
make qa-all
License
MIT
Metadata
Release files for docker-slsa 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| docker_slsa-0.1.0.tar.gz | 9.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| docker_slsa-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.5 kB
Release files / docker_slsa-0.1.0.tar.gz
| Download URL | docker_slsa-0.1.0.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d62cb70bd4599e3d3767bb0d365621eacb89babd6161968fda02f852a9b3038d
|
|
BLAKE2b-256 checksum How to use checksums |
29a78fddd8fcb9dcedfad02abffd675d1ad93caff3149cb9b1401151fdc761bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 7, 2026.
Transparency logRelease files / docker_slsa-0.1.0-py3-none-any.whl
| Download URL | docker_slsa-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
afb0e529fdba8efc1dc6e9d212d8097d7bf3eda6074c109c400b735fc618585e
|
|
BLAKE2b-256 checksum How to use checksums |
308c41c4937a3fd2d85aa65e01a42c3ca70e08c5a175e0eb7253e5beb0fd28a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 7, 2026.
Transparency log