From fb1ac2b87a43ec2ec9a918a847618250cf5ad1f0 Mon Sep 17 00:00:00 2001 From: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com> Date: Thu, 5 Nov 2026 20:05:04 +0100 Subject: [PATCH 1/2] PULP-2642: upgrade pulp_python to 3.38.0 with per-domain attestation keys Atomic upgrade combining the version bump (PULP-2643) and the per-domain attestation key config (PULP-2647), which must ship together: pulp_python 3.36.2 reads ATTESTATION_VERIFICATION_KEY (single) while 3.38.0 reads ATTESTATION_VERIFICATION_KEYS (per-domain map), and stage auto-deploys main. PULP-2643 (bump + drop patch): - Bump pulp-python 3.36.2 -> 3.38.0 (requirements + version table in CLAUDE.md). - Remove patch 0048 (upstreamed in pulp/pulp_python#1327): the .patch file, its Dockerfile COPY/RUN, and its docs entry; the vendored key copy is retained. - Bump image Python 3.11 -> 3.12 (3.38.0 requires >=3.12). PULP-2647 (per-domain config): - Replace the single PULP_ATTESTATION_VERIFICATION_KEY with the per-domain ATTESTATION_VERIFICATION_KEYS map in the api/content/worker containers and the template parameter. The map covers the three prod domains that use key-signed attestations (public-trusted-libraries, lightwell, lightwell-stage), each mapped to the existing vendored key path /etc/pki/sigstore/SIGSTORE-redhat-release3. Functional tests: - Migrate the test deployment (.tekton), dev-container settings, and the attestation test fixture to the per-domain map (default domain), and update the content-upload assertions to 3.38.0 behavior (Pulp User publisher; assert the submitted attestation is stored). - Update the Tekton binding shims and PYTHONPATH from python3.11 to python3.12. Co-Authored-By: Claude Opus 4.8 --- .tekton/pulp-deploy-and-test.yaml | 20 +- Dockerfile | 4 +- deploy/clowdapp.yaml | 19 +- dev-container/settings.py | 2 +- ...ation-verification-with-vendored-key.patch | 276 ------------------ images/assets/patches/CLAUDE.md | 8 +- .../test_attestation_verification.py | 19 +- pulp_service/requirements.txt | 2 +- 8 files changed, 35 insertions(+), 315 deletions(-) delete mode 100644 images/assets/patches/0048-Re-enable-attestation-verification-with-vendored-key.patch diff --git a/.tekton/pulp-deploy-and-test.yaml b/.tekton/pulp-deploy-and-test.yaml index 18941cb31..6141ef188 100644 --- a/.tekton/pulp-deploy-and-test.yaml +++ b/.tekton/pulp-deploy-and-test.yaml @@ -605,7 +605,7 @@ spec: { "name": "pulp-api", "env": [ - {"name": "PULP_ATTESTATION_VERIFICATION_KEY", "value": "/etc/pki/attestation/test-key.pem"} + {"name": "PULP_ATTESTATION_VERIFICATION_KEYS", "value": "@json {\"default\": \"/etc/pki/attestation/test-key.pem\"}"} ], "volumeMounts": [ {"mountPath": "/data","name": "bindings"}, @@ -635,7 +635,7 @@ spec: { "name": "pulp-worker", "env": [ - {"name": "PULP_ATTESTATION_VERIFICATION_KEY", "value": "/etc/pki/attestation/test-key.pem"} + {"name": "PULP_ATTESTATION_VERIFICATION_KEYS", "value": "@json {\"default\": \"/etc/pki/attestation/test-key.pem\"}"} ], "volumeMounts": [ {"mountPath": "/etc/pki/attestation","name": "attestation-test-keys","readOnly": true} @@ -694,8 +694,8 @@ spec: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) EOF - cat __tmp_init__.py | cmd_stdin_prefix bash -c "cat > /tmp/home/.local/lib/python3.11/site-packages/pulpcore/__init__.py" - cat __tmp_init__.py | cmd_stdin_prefix bash -c "cat > /tmp/home/.local/lib/python3.11/site-packages/pulpcore/client/__init__.py" + cat __tmp_init__.py | cmd_stdin_prefix bash -c "cat > /tmp/home/.local/lib/python3.12/site-packages/pulpcore/__init__.py" + cat __tmp_init__.py | cmd_stdin_prefix bash -c "cat > /tmp/home/.local/lib/python3.12/site-packages/pulpcore/client/__init__.py" - name: pulp-functional-tests when: @@ -806,25 +806,25 @@ spec: oc_wrapper get route set +e # Only testing test_download_content because it is a very thorough test that tests that all the components of pulp can work - cmd_prefix bash -c "HOME=/tmp/home PYTHONPATH=/tmp/home/.local/lib/python3.11/site-packages/ XDG_CONFIG_HOME=/tmp/home/.config API_PROTOCOL=http API_HOST=pulp-api API_PORT=8000 ADMIN_USERNAME=admin ADMIN_PASSWORD=$PASSWORD /tmp/home/.local/bin/pytest -o cache_dir=/tmp/home/.cache/pytest_cache -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulp_rpm.tests.functional -m parallel -n 8 -k 'test_download_content' --junitxml=/tmp/home/junit-pulp-parallel.xml" || debug_and_fail + cmd_prefix bash -c "HOME=/tmp/home PYTHONPATH=/tmp/home/.local/lib/python3.12/site-packages/ XDG_CONFIG_HOME=/tmp/home/.config API_PROTOCOL=http API_HOST=pulp-api API_PORT=8000 ADMIN_USERNAME=admin ADMIN_PASSWORD=$PASSWORD /tmp/home/.local/bin/pytest -o cache_dir=/tmp/home/.cache/pytest_cache -v -r sx --color=yes --suppress-no-test-exit-code --pyargs pulp_rpm.tests.functional -m parallel -n 8 -k 'test_download_content' --junitxml=/tmp/home/junit-pulp-parallel.xml" || debug_and_fail # Never test test_package_manager_consume because they require sudo # Do not test test_domain_create because it requires more than 2GB of RAM # Only testing test_download_policies because they are very thorough tests that test that all the components of pulp can work - cmd_prefix bash -c "HOME=/tmp/home PYTHONPATH=/tmp/home/.local/lib/python3.11/site-packages/ XDG_CONFIG_HOME=/tmp/home/.config API_PROTOCOL=http API_HOST=pulp-api API_PORT=8000 ADMIN_USERNAME=admin ADMIN_PASSWORD=$PASSWORD /tmp/home/.local/bin/pytest -o cache_dir=/tmp/home/.cache/pytest_cache -v -r sx --color=yes --pyargs pulp_rpm.tests.functional -m 'not parallel' -k 'test_download_policies' --junitxml=/tmp/home/junit-pulp-serial.xml" || debug_and_fail + cmd_prefix bash -c "HOME=/tmp/home PYTHONPATH=/tmp/home/.local/lib/python3.12/site-packages/ XDG_CONFIG_HOME=/tmp/home/.config API_PROTOCOL=http API_HOST=pulp-api API_PORT=8000 ADMIN_USERNAME=admin ADMIN_PASSWORD=$PASSWORD /tmp/home/.local/bin/pytest -o cache_dir=/tmp/home/.cache/pytest_cache -v -r sx --color=yes --pyargs pulp_rpm.tests.functional -m 'not parallel' -k 'test_download_policies' --junitxml=/tmp/home/junit-pulp-serial.xml" || debug_and_fail # Run the jq header auth test - cmd_prefix bash -c "HOME=/tmp/home PYTHONPATH=/tmp/home/.local/lib/python3.11/site-packages/ XDG_CONFIG_HOME=/tmp/home/.config API_PROTOCOL=http API_HOST=pulp-api API_PORT=8000 ADMIN_USERNAME=admin ADMIN_PASSWORD=$PASSWORD /tmp/home/.local/bin/pytest -o cache_dir=/tmp/home/.cache/pytest_cache -v -r sx --color=yes --pyargs pulpcore.tests.functional -m 'parallel' -n 8 -k 'test_jq_header_remote_auth' --junitxml=/tmp/home/junit-pulp-serial.xml" || debug_and_fail + cmd_prefix bash -c "HOME=/tmp/home PYTHONPATH=/tmp/home/.local/lib/python3.12/site-packages/ XDG_CONFIG_HOME=/tmp/home/.config API_PROTOCOL=http API_HOST=pulp-api API_PORT=8000 ADMIN_USERNAME=admin ADMIN_PASSWORD=$PASSWORD /tmp/home/.local/bin/pytest -o cache_dir=/tmp/home/.cache/pytest_cache -v -r sx --color=yes --pyargs pulpcore.tests.functional -m 'parallel' -n 8 -k 'test_jq_header_remote_auth' --junitxml=/tmp/home/junit-pulp-serial.xml" || debug_and_fail ### END Adapted from ./.github/workflows/scripts/script.sh # Run pulp_maven functional tests - cmd_prefix bash -c "HOME=/tmp/home PYTHONPATH=/tmp/home/.local/lib/python3.11/site-packages/ XDG_CONFIG_HOME=/tmp/home/.config API_PROTOCOL=http API_HOST=pulp-api API_PORT=8000 ADMIN_USERNAME=admin ADMIN_PASSWORD=$PASSWORD /tmp/home/.local/bin/pytest -o cache_dir=/tmp/home/.cache/pytest_cache -v -r sx --color=yes --pyargs pulp_maven.tests.functional.api.test_download_content --junitxml=/tmp/home/junit-pulp-serial.xml" || debug_and_fail + cmd_prefix bash -c "HOME=/tmp/home PYTHONPATH=/tmp/home/.local/lib/python3.12/site-packages/ XDG_CONFIG_HOME=/tmp/home/.config API_PROTOCOL=http API_HOST=pulp-api API_PORT=8000 ADMIN_USERNAME=admin ADMIN_PASSWORD=$PASSWORD /tmp/home/.local/bin/pytest -o cache_dir=/tmp/home/.cache/pytest_cache -v -r sx --color=yes --pyargs pulp_maven.tests.functional.api.test_download_content --junitxml=/tmp/home/junit-pulp-serial.xml" || debug_and_fail # Run pulp_npm functional tests - cmd_prefix bash -c "HOME=/tmp/home PYTHONPATH=/tmp/home/.local/lib/python3.11/site-packages/ XDG_CONFIG_HOME=/tmp/home/.config API_PROTOCOL=http API_HOST=pulp-api API_PORT=8000 ADMIN_USERNAME=admin ADMIN_PASSWORD=$PASSWORD /tmp/home/.local/bin/pytest -o cache_dir=/tmp/home/.cache/pytest_cache -v -r sx --color=yes --pyargs pulp_npm.tests.functional -k 'test_pull_through_install' --junitxml=/tmp/home/junit-pulp-serial.xml" || debug_and_fail + cmd_prefix bash -c "HOME=/tmp/home PYTHONPATH=/tmp/home/.local/lib/python3.12/site-packages/ XDG_CONFIG_HOME=/tmp/home/.config API_PROTOCOL=http API_HOST=pulp-api API_PORT=8000 ADMIN_USERNAME=admin ADMIN_PASSWORD=$PASSWORD /tmp/home/.local/bin/pytest -o cache_dir=/tmp/home/.cache/pytest_cache -v -r sx --color=yes --pyargs pulp_npm.tests.functional -k 'test_pull_through_install' --junitxml=/tmp/home/junit-pulp-serial.xml" || debug_and_fail # Run pulp_service functional tests - cmd_prefix bash -c "HOME=/tmp/home PYTHONPATH=/tmp/home/.local/lib/python3.11/site-packages/ XDG_CONFIG_HOME=/tmp/home/.config API_PROTOCOL=http API_HOST=pulp-api API_PORT=8000 ADMIN_USERNAME=admin ADMIN_PASSWORD=$PASSWORD /tmp/home/.local/bin/pytest -o cache_dir=/tmp/home/.cache/pytest_cache -v -r sx --color=yes --pyargs pulp_service.tests.functional -m 'not parallel' --junitxml=/tmp/home/junit-pulp-serial.xml" || debug_and_fail + cmd_prefix bash -c "HOME=/tmp/home PYTHONPATH=/tmp/home/.local/lib/python3.12/site-packages/ XDG_CONFIG_HOME=/tmp/home/.config API_PROTOCOL=http API_HOST=pulp-api API_PORT=8000 ADMIN_USERNAME=admin ADMIN_PASSWORD=$PASSWORD /tmp/home/.local/bin/pytest -o cache_dir=/tmp/home/.cache/pytest_cache -v -r sx --color=yes --pyargs pulp_service.tests.functional -m 'not parallel' --junitxml=/tmp/home/junit-pulp-serial.xml" || debug_and_fail - name: push-api-json-files-to-pulp when: diff --git a/Dockerfile b/Dockerfile index d4aafe80f..30df1665b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM registry.access.redhat.com/ubi9/ubi -ARG PYTHON_VERSION=3.11 +ARG PYTHON_VERSION=3.12 ENV PYTHONUNBUFFERED=0 ENV DJANGO_SETTINGS_MODULE=pulpcore.app.settings ENV PULP_SETTINGS=/etc/pulp/settings.py @@ -133,8 +133,6 @@ RUN patch -p1 -d /usr/local/lib/pulp/lib/python${PYTHON_VERSION}/site-packages < COPY images/assets/keys/SIGSTORE-redhat-release3.pem /etc/pki/sigstore/SIGSTORE-redhat-release3 -COPY images/assets/patches/0048-Re-enable-attestation-verification-with-vendored-key.patch /tmp/ -RUN patch -p1 -d /usr/local/lib/pulp/lib/python${PYTHON_VERSION}/site-packages < /tmp/0048-Re-enable-attestation-verification-with-vendored-key.patch COPY images/assets/patches/0049-Skip-content-units-validation.patch /tmp/ RUN patch -p1 -d /usr/local/lib/pulp/lib/python${PYTHON_VERSION}/site-packages < /tmp/0049-Skip-content-units-validation.patch diff --git a/deploy/clowdapp.yaml b/deploy/clowdapp.yaml index 5d1abeba9..ffbc6babd 100644 --- a/deploy/clowdapp.yaml +++ b/deploy/clowdapp.yaml @@ -387,8 +387,8 @@ objects: value: ${{PULP_API_ROOT}} - name: PULP_DB_ENCRYPTION_KEY value: ${{PULP_DB_ENCRYPTION_KEY}} - - name: PULP_ATTESTATION_VERIFICATION_KEY - value: ${{PULP_ATTESTATION_VERIFICATION_KEY}} + - name: PULP_ATTESTATION_VERIFICATION_KEYS + value: ${{PULP_ATTESTATION_VERIFICATION_KEYS}} - name: PULP_CACHE_ENABLED value: ${PULP_CACHE_ENABLED} - name: PULP_STORAGES__default__OPTIONS__default_acl @@ -590,8 +590,8 @@ objects: value: ${{PULP_API_ROOT}} - name: PULP_DB_ENCRYPTION_KEY value: ${{PULP_DB_ENCRYPTION_KEY}} - - name: PULP_ATTESTATION_VERIFICATION_KEY - value: ${{PULP_ATTESTATION_VERIFICATION_KEY}} + - name: PULP_ATTESTATION_VERIFICATION_KEYS + value: ${{PULP_ATTESTATION_VERIFICATION_KEYS}} - name: PULP_CACHE_ENABLED value: ${PULP_CACHE_ENABLED} - name: PULP_STORAGES__default__OPTIONS__default_acl @@ -748,8 +748,8 @@ objects: value: ${{PULP_API_ROOT}} - name: PULP_DB_ENCRYPTION_KEY value: ${{PULP_DB_ENCRYPTION_KEY}} - - name: PULP_ATTESTATION_VERIFICATION_KEY - value: ${{PULP_ATTESTATION_VERIFICATION_KEY}} + - name: PULP_ATTESTATION_VERIFICATION_KEYS + value: ${{PULP_ATTESTATION_VERIFICATION_KEYS}} - name: PULP_CACHE_ENABLED value: ${PULP_CACHE_ENABLED} - name: PULP_STORAGES__default__OPTIONS__default_acl @@ -1804,9 +1804,10 @@ parameters: - name: PULP_DB_ENCRYPTION_KEY description: Path to DB encryption key value: "/etc/pulp/keys/database_fields.symmetric.key" - - name: PULP_ATTESTATION_VERIFICATION_KEY - description: Path to attestation verification key - value: "/etc/pki/sigstore/SIGSTORE-redhat-release3" + - name: PULP_ATTESTATION_VERIFICATION_KEYS + description: Per-domain map of domain name to attestation verification key file path (pulp_python 3.38.0+) + value: > + '@json {"public-trusted-libraries": "/etc/pki/sigstore/SIGSTORE-redhat-release3", "lightwell": "/etc/pki/sigstore/SIGSTORE-redhat-release3", "lightwell-stage": "/etc/pki/sigstore/SIGSTORE-redhat-release3"}' - name: PULP_CACHE_ENABLED description: Enable CACHE. Need REDIS installed. value: "true" diff --git a/dev-container/settings.py b/dev-container/settings.py index c23e3e466..f38d7afaf 100644 --- a/dev-container/settings.py +++ b/dev-container/settings.py @@ -52,7 +52,7 @@ AUTHENTICATION_JSON_HEADER = "HTTP_X_RH_IDENTITY" AUTHENTICATION_JSON_HEADER_JQ_FILTER = ".identity.user.username" -ATTESTATION_VERIFICATION_KEY = "/etc/pki/attestation/test-key.pem" +ATTESTATION_VERIFICATION_KEYS = {"default": "/etc/pki/attestation/test-key.pem"} DOMAIN_ACCESS_POLICIES = { "lightwell": { diff --git a/images/assets/patches/0048-Re-enable-attestation-verification-with-vendored-key.patch b/images/assets/patches/0048-Re-enable-attestation-verification-with-vendored-key.patch deleted file mode 100644 index 466e47b14..000000000 --- a/images/assets/patches/0048-Re-enable-attestation-verification-with-vendored-key.patch +++ /dev/null @@ -1,276 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: pulp-service -Date: Mon, 3 Mar 2026 00:00:00 +0000 -Subject: [PATCH] Re-enable attestation verification with vendored Konflux key - -Add support for verifying Konflux-style attestations that carry an RSA -signature instead of a full Sigstore certificate chain. When the -ATTESTATION_VERIFICATION_KEY setting points to a PEM public key file, -the signature on the DSSE PAE-encoded statement is verified against that -key. Standard Sigstore-based attestations continue to use the existing -verification path. - -Defines a custom Attestation model that allows nullable -verification_material, replacing the strict upstream model. - -For SLSA v0.2 provenance attestations the publisher is automatically -enriched with builder_id, build_type, and kind (hostname from builder -URL) extracted from the in-toto statement predicate. - -Also wires up attestation verification in the PyPI upload serializer -so that attestations uploaded alongside packages are verified at -upload time. - -This patch supersedes 0046-Ignore-attestation-verification.patch, which -disabled all attestation verification. - ---- - pulp_python/app/provenance.py | 130 ++++++++++++++++++++++++++++-- - pulp_python/app/pypi/serializers.py | 19 ++++- - pulp_python/app/settings.py | 2 + - 3 files changed, 147 insertions(+), 4 deletions(-) - -diff --git a/pulp_python/app/provenance.py b/pulp_python/app/provenance.py -index 0000001..0000002 100644 ---- a/pulp_python/app/provenance.py -+++ b/pulp_python/app/provenance.py -@@ -1,12 +1,30 @@ -+import json -+import logging - from typing import Annotated, Literal, Union, get_args -+from urllib.parse import urlparse - -+from cryptography.exceptions import InvalidSignature -+from cryptography.hazmat.primitives import hashes, serialization -+from cryptography.hazmat.primitives.asymmetric import padding as crypto_padding -+from cryptography.x509 import load_der_x509_certificate -+from django.conf import settings - from pydantic import BaseModel, ConfigDict, Field - from pydantic.alias_generators import to_snake - from pypi_attestations import ( -- Attestation, -+ Envelope, -+ VerificationMaterial, - Distribution, - Publisher, -+ VerificationError, - ) -+from sigstore.dsse import _pae -+from sigstore.dsse import Envelope as DSSEEnvelope -+ -+log = logging.getLogger(__name__) -+ -+_verification_key_cache = {} -+ -+SLSA_PROVENANCE_V02 = "https://slsa.dev/provenance/v0.2" - - - class _PermissivePolicy: -@@ -38,6 +56,24 @@ _ExtendedPublisherUnion = Union[_ExtendedPublisherTypes] - # Create a new type that fallbacks to AnyPublisher - ExtendedPublisher = Annotated[_ExtendedPublisherUnion, Field(union_mode="left_to_right")] - -+class Attestation(BaseModel): -+ """Attestation object as defined in PEP 740.""" -+ -+ version: Literal[1] -+ """ -+ The attestation format's version, which is always 1. -+ """ -+ -+ verification_material: VerificationMaterial | None = None -+ """ -+ Cryptographic materials used to verify `message_signature`. -+ """ -+ -+ envelope: Envelope -+ """ -+ The enveloped attestation statement and signature. -+ """ -+ - - class AttestationBundle(BaseModel): - """ -@@ -58,14 +94,116 @@ class Provenance(BaseModel): - attestation_bundles: list[AttestationBundle] - - -+def _load_verification_key(): -+ """Load the configured attestation verification public key, with caching.""" -+ key_path = getattr(settings, "ATTESTATION_VERIFICATION_KEY", None) -+ if not key_path: -+ return None -+ if key_path not in _verification_key_cache: -+ with open(key_path, "rb") as f: -+ _verification_key_cache[key_path] = serialization.load_pem_public_key(f.read()) -+ return _verification_key_cache[key_path] -+ -+ -+def _has_valid_certificate(attestation): -+ """Check whether the attestation contains a valid X.509 certificate.""" -+ try: -+ vm = attestation.verification_material -+ if vm is None: -+ return False -+ cert_bytes = vm.certificate -+ load_der_x509_certificate(cert_bytes) -+ return True -+ except (ValueError, Exception): -+ return False -+ -+ -+def _verify_statement_subject(attestation, dist): -+ """Validate that the in-toto statement subject matches the distribution. -+ -+ Returns the parsed statement dict for downstream use. -+ """ -+ try: -+ stmt = json.loads(attestation.envelope.statement) -+ except (json.JSONDecodeError, UnicodeDecodeError) as e: -+ raise VerificationError(f"invalid statement: {e}") -+ -+ subjects = stmt.get("subject", []) -+ if len(subjects) != 1: -+ raise VerificationError("expected exactly one subject in statement") -+ -+ subject = subjects[0] -+ name = subject.get("name", "") -+ if name != dist.name: -+ raise VerificationError( -+ f"subject does not match distribution name: {name} != {dist.name}" -+ ) -+ -+ digest = subject.get("digest", {}).get("sha256") -+ if digest != dist.digest: -+ raise VerificationError("subject does not match distribution digest") -+ -+ return stmt -+ -+ -+def _enrich_publisher_from_statement(stmt, publisher): -+ """Populate publisher fields from an SLSA v0.2 provenance statement.""" -+ if stmt.get("predicateType") != SLSA_PROVENANCE_V02: -+ return -+ -+ predicate = stmt.get("predicate", {}) -+ builder_id = predicate.get("builder", {}).get("id") -+ build_type = predicate.get("buildType") -+ -+ if builder_id: -+ publisher.builder_id = builder_id -+ try: -+ hostname = urlparse(builder_id).hostname -+ if hostname: -+ publisher.kind = hostname -+ except Exception: -+ pass -+ -+ if build_type: -+ publisher.build_type = build_type -+ -+ -+def _verify_signature(attestation, public_key): -+ """Verify the attestation's RSA signature over the DSSE PAE bytes.""" -+ statement_bytes = attestation.envelope.statement -+ signature_bytes = attestation.envelope.signature -+ pae = _pae(DSSEEnvelope._TYPE, statement_bytes) -+ try: -+ public_key.verify( -+ signature_bytes, -+ pae, -+ crypto_padding.PKCS1v15(), -+ hashes.SHA256(), -+ ) -+ except InvalidSignature as e: -+ raise VerificationError(f"signature verification failed: {e}") -+ -+ - def verify_provenance(filename, sha256, provenance, offline=True): - """Verify the provenance object is valid for the package.""" - dist = Distribution(name=filename, digest=sha256) -+ verification_key = _load_verification_key() - for bundle in provenance.attestation_bundles: - publisher = bundle.publisher -- policy = publisher._as_policy() - for attestation in bundle.attestations: -- sig_bundle = attestation.to_bundle() -- checkpoint = sig_bundle.log_entry._inner.inclusion_proof.checkpoint -- staging = "sigstage.dev" in checkpoint.envelope -- attestation.verify(policy, dist, staging=staging, offline=offline) -+ if _has_valid_certificate(attestation): -+ policy = publisher._as_policy() -+ sig_bundle = attestation.to_bundle() -+ checkpoint = sig_bundle.log_entry._inner.inclusion_proof.checkpoint -+ staging = "sigstage.dev" in checkpoint.envelope -+ attestation.verify(policy, dist, staging=staging, offline=offline) -+ else: -+ stmt = _verify_statement_subject(attestation, dist) -+ _enrich_publisher_from_statement(stmt, publisher) -+ if verification_key: -+ _verify_signature(attestation, verification_key) -+ else: -+ log.warning( -+ "Attestation without valid certificate accepted without " -+ "signature verification (ATTESTATION_VERIFICATION_KEY not set)" -+ ) -diff --git a/pulp_python/app/pypi/serializers.py b/pulp_python/app/pypi/serializers.py -index 0000005..0000006 100644 ---- a/pulp_python/app/pypi/serializers.py -+++ b/pulp_python/app/pypi/serializers.py -@@ -3,10 +3,11 @@ - - from django.db.utils import IntegrityError - from pydantic import TypeAdapter, ValidationError -+from pypi_attestations import AttestationError - from rest_framework import serializers - - from pulpcore.plugin.models import Artifact - from pulpcore.plugin.util import get_domain - --from pulp_python.app.provenance import Attestation -+from pulp_python.app.provenance import Attestation, AnyPublisher, AttestationBundle, Provenance, verify_provenance - from pulp_python.app.utils import DIST_EXTENSIONS, SUPPORTED_METADATA_VERSIONS - - log = logging.getLogger(__name__) -@@ -105,6 +106,7 @@ - } - ) - -+ sha256 = data.get("sha256_digest") - if attestations := data.get("attestations"): - try: - attestations = TypeAdapter(list[Attestation]).validate_python(attestations) -@@ -112,8 +114,17 @@ - raise serializers.ValidationError( - {"attestations": _("The uploaded attestations are not valid: {}".format(e))} - ) -+ if attestations and sha256: -+ publisher = AnyPublisher(kind="Pulp User") -+ att_bundle = AttestationBundle(publisher=publisher, attestations=attestations) -+ provenance = Provenance(attestation_bundles=[att_bundle]) -+ try: -+ verify_provenance(file.name, sha256, provenance, offline=True) -+ except AttestationError as e: -+ raise serializers.ValidationError( -+ {"attestations": _("Attestations failed verification: {}".format(e))} -+ ) - -- sha256 = data.get("sha256_digest") - digests = {"sha256": sha256} if sha256 else None - artifact = Artifact.init_and_validate(file, expected_digests=digests) - try: -diff --git a/pulp_python/app/settings.py b/pulp_python/app/settings.py -index 0000003..0000004 100644 ---- a/pulp_python/app/settings.py -+++ b/pulp_python/app/settings.py -@@ -3,6 +3,8 @@ - PYTHON_GROUP_UPLOADS = False - PYPI_API_HOSTNAME = "https://" + socket.getfqdn() - -+ATTESTATION_VERIFICATION_KEY = None -+ - DRF_ACCESS_POLICY = { - "dynaconf_merge_unique": True, - "reusable_conditions": ["pulp_python.app.global_access_conditions"], --- -2.47.0 diff --git a/images/assets/patches/CLAUDE.md b/images/assets/patches/CLAUDE.md index 47080978e..9a691a1f7 100644 --- a/images/assets/patches/CLAUDE.md +++ b/images/assets/patches/CLAUDE.md @@ -17,7 +17,7 @@ after `sudo -u pulp`; sudo can remove it even with `-E`. | `pulpcore/` | [pulp/pulpcore](https://github.com/pulp/pulpcore) | pulpcore | 3.123.1 | | `pulp_file/` | [pulp/pulpcore](https://github.com/pulp/pulpcore) | (bundled) | 3.112.0 | | `pulp_container/`| [pulp/pulp_container](https://github.com/pulp/pulp_container) | pulp-container | 2.28.0 | -| `pulp_python/` | [pulp/pulp_python](https://github.com/pulp/pulp_python) | pulp-python | 3.36.2 | +| `pulp_python/` | [pulp/pulp_python](https://github.com/pulp/pulp_python) | pulp-python | 3.38.0 | | `pulp_maven/` | [pulp/pulp_maven](https://github.com/pulp/pulp_maven) | pulp-maven | 0.37.2 | | `pulp_rpm/` | [pulp/pulp_rpm](https://github.com/pulp/pulp_rpm) | pulp-rpm | 3.39.0 | | `storages/` | [jschneier/django-storages](https://github.com/jschneier/django-storages) | django-storages | 1.14.6 | @@ -88,12 +88,6 @@ The separate `oci-storage-backup-setup` repository is unaffected. - **Files:** `pulpcore/content/__init__.py` - **Description:** Converts the content app heartbeat from an async coroutine to a synchronous thread with a shutdown event. Replaces `asyncio.sleep` with `threading.Event.wait` and async ORM calls with synchronous ones. -### 0048 — Re-enable attestation verification with vendored Konflux key - -- **Package:** pulp_python -- **Files:** `pulp_python/app/provenance.py`, `pulp_python/app/pypi/serializers.py`, `pulp_python/app/settings.py` -- **Description:** Replaces the upstream sigstore-based attestation verification with a custom implementation that uses a vendored Konflux signing key for PEP 740 attestation validation. Adds DER certificate-based signature verification and a configurable attestation keys directory. - ### 0049 — Skip content units validation - **Package:** pulpcore diff --git a/pulp_service/pulp_service/tests/functional/test_attestation_verification.py b/pulp_service/pulp_service/tests/functional/test_attestation_verification.py index 4557a4384..e0ba97036 100644 --- a/pulp_service/pulp_service/tests/functional/test_attestation_verification.py +++ b/pulp_service/pulp_service/tests/functional/test_attestation_verification.py @@ -5,8 +5,9 @@ mirroring the format produced by Konflux / Calunga builds. The test signing key is generated at image build time and the matching -public key is configured as PULP_ATTESTATION_VERIFICATION_KEY so that -signature verification is fully exercised end-to-end. +public key is configured for the default domain in +PULP_ATTESTATION_VERIFICATION_KEYS so that signature verification is +fully exercised end-to-end. """ import base64 @@ -103,8 +104,8 @@ def test_private_key(pulp_settings): """Load the CI-generated test attestation signing key.""" if not os.path.exists(TEST_PRIVATE_KEY_PATH): pytest.skip(f"Test attestation private key not found at {TEST_PRIVATE_KEY_PATH} (not running in CI container?)") - if pulp_settings.ATTESTATION_VERIFICATION_KEY != TEST_PUBLIC_KEY_PATH: - pytest.fail(f"ATTESTATION_VERIFICATION_KEY is not set to {TEST_PUBLIC_KEY_PATH}") + if pulp_settings.ATTESTATION_VERIFICATION_KEYS.get("default") != TEST_PUBLIC_KEY_PATH: + pytest.fail(f"ATTESTATION_VERIFICATION_KEYS does not map the default domain to {TEST_PUBLIC_KEY_PATH}") with open(TEST_PRIVATE_KEY_PATH, "rb") as f: return serialization.load_pem_private_key(f.read(), password=None) @@ -240,7 +241,9 @@ def test_konflux_attestation_via_content_upload( assert len(result.created_resources) == 2 prov_obj = python_bindings.ContentProvenanceApi.read(result.created_resources[1]) - publisher = prov_obj.provenance["attestation_bundles"][0]["publisher"] - assert publisher["builder_id"] == "https://konflux-ci.dev/calunga" - assert publisher["build_type"] == "https://konflux-ci.dev/PythonWheelBuild@v1" - assert publisher["kind"] == "konflux-ci.dev" + bundle = prov_obj.provenance["attestation_bundles"][0] + assert bundle["publisher"]["kind"] == "Pulp User" + # the submitted attestation must actually be stored, not silently dropped + stored_atts = bundle["attestations"] + assert len(stored_atts) == 1 + assert stored_atts[0]["envelope"]["statement"] == _b64(stmt) diff --git a/pulp_service/requirements.txt b/pulp_service/requirements.txt index e0bba28e4..2353144d0 100644 --- a/pulp_service/requirements.txt +++ b/pulp_service/requirements.txt @@ -1,7 +1,7 @@ pulpcore==3.123.1 pulp-rpm==3.39.2 solv>=0.7.21,<0.7.38 -pulp-python==3.36.2 +pulp-python==3.38.0 pulp-npm==0.10.2 pulp-container==2.29.0 pulp-maven==0.37.2 From 46d4d1f051ac9f9956bc23125b7a41a71e843bea Mon Sep 17 00:00:00 2001 From: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com> Date: Fri, 6 Nov 2026 08:32:48 +0100 Subject: [PATCH 2/2] PULP-2647: default ATTESTATION_VERIFICATION_KEYS to empty map Per review feedback: the clowdapp template parameter carries a safe empty default ('@json {}', matching pulp_python's own ATTESTATION_VERIFICATION_KEYS default) instead of hardcoding the prod domain map. The real per-environment maps (stage and prod) are set as app-interface saas parameters, following the same per-target override pattern used for the other PULP_* settings. Co-Authored-By: Claude Opus 4.8 --- deploy/clowdapp.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy/clowdapp.yaml b/deploy/clowdapp.yaml index ffbc6babd..d1fe66542 100644 --- a/deploy/clowdapp.yaml +++ b/deploy/clowdapp.yaml @@ -1805,9 +1805,9 @@ parameters: description: Path to DB encryption key value: "/etc/pulp/keys/database_fields.symmetric.key" - name: PULP_ATTESTATION_VERIFICATION_KEYS - description: Per-domain map of domain name to attestation verification key file path (pulp_python 3.38.0+) + description: Per-domain map of domain name to attestation verification key file path (pulp_python 3.38.0+). Empty by default; the real per-environment maps are set as app-interface parameters for the stage and prod deployments. value: > - '@json {"public-trusted-libraries": "/etc/pki/sigstore/SIGSTORE-redhat-release3", "lightwell": "/etc/pki/sigstore/SIGSTORE-redhat-release3", "lightwell-stage": "/etc/pki/sigstore/SIGSTORE-redhat-release3"}' + '@json {}' - name: PULP_CACHE_ENABLED description: Enable CACHE. Need REDIS installed. value: "true"