pulp-python 3.37.1__tar.gz → 3.38.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pulp_python-3.37.1 → pulp_python-3.38.0}/CHANGES.md +76 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/PKG-INFO +1 -1
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/__init__.py +1 -1
- pulp_python-3.38.0/pulp_python/app/provenance.py +212 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/pypi/serializers.py +19 -2
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/settings.py +2 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/utils.py +3 -3
- pulp_python-3.38.0/pulp_python/tests/functional/api/test_key_signed_attestations.py +365 -0
- pulp_python-3.38.0/pulp_python/tests/unit/test_simple_templates.py +56 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python.egg-info/PKG-INFO +1 -1
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python.egg-info/SOURCES.txt +2 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pyproject.toml +2 -2
- pulp_python-3.37.1/pulp_python/app/provenance.py +0 -71
- {pulp_python-3.37.1 → pulp_python-3.38.0}/COMMITMENT +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/COPYRIGHT +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/LICENSE +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/MANIFEST.in +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/README.md +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/functest_requirements.txt +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/__init__.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/cache.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/exceptions.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/global_access_conditions.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/management/__init__.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/management/commands/__init__.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/management/commands/repair-python-metadata.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0001_initial.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0001_squashed_0010_update_json_field.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0002_pythonpackagecontent_python_version.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0003_new_sync_filters.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0004_DATA_swap_distribution_model.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0005_pythonpackagecontent_sha256.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0006_pythonrepository_autopublish.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0007_pythonpackagecontent_mv-2-1.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0008_pythonpackagecontent_unique_sha256.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0009_pythondistribution_allow_uploads.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0010_update_json_field.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0011_alter_pythondistribution_distribution_ptr_and_more.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0012_add_domain.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0013_add_rbac_permissions.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0014_pythonpackagecontent_dynamic_and_more.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0015_alter_pythonpackagecontent_options.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0016_pythonpackagecontent_metadata_sha256.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0017_pythonpackagecontent_size.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0018_packageprovenance.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0019_create_missing_metadata_artifacts.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0020_pythonpackagecontent_name_normalized.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0021_pythonrepository_upload_duplicate_filenames.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0022_pythonblocklistentry.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0023_packageyank.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0024_pythonrepository_error_on_reject.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/0025_pythonremote_vulnerabilities.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/migrations/__init__.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/modelresource.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/models.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/osv.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/pypi/__init__.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/pypi/feeds.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/pypi/views.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/replica.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/serializers.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/tasks/__init__.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/tasks/publish.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/tasks/repair.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/tasks/sync.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/tasks/upload.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/tasks/vulnerability_report.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/tasks/yank.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/urls.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/viewsets.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/webserver_snippets/__init__.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/webserver_snippets/apache.conf +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/app/webserver_snippets/nginx.conf +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/pytest_plugin.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/__init__.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/__init__.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/__init__.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_attestations.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_auto_publish.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_blocklist.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_consume_content.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_crud_content_unit.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_crud_publications.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_crud_remotes.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_domains.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_download_content.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_export_import.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_full_mirror.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_pypi_apis.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_pypi_feeds.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_pypi_json_vulnerabilities.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_pypi_simple_api.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_rbac.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_repair.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_simple_cache.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_sync.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_upload.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_version_specifier_filter.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_vulnerability_report.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/api/test_yank.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/constants.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/functional/utils.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/unit/__init__.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/unit/test_feeds.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/unit/test_models.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python/tests/unit/test_vulnerabilities.py +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python.egg-info/dependency_links.txt +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python.egg-info/entry_points.txt +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python.egg-info/requires.txt +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/pulp_python.egg-info/top_level.txt +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/setup.cfg +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/test_requirements.txt +0 -0
- {pulp_python-3.37.1 → pulp_python-3.38.0}/unittest_requirements.txt +0 -0
|
@@ -8,6 +8,20 @@
|
|
|
8
8
|
|
|
9
9
|
[//]: # (towncrier release notes start)
|
|
10
10
|
|
|
11
|
+
## 3.38.0 (2026-11-02) {: #3.38.0 }
|
|
12
|
+
|
|
13
|
+
#### Features {: #3.38.0-feature }
|
|
14
|
+
|
|
15
|
+
- Added custom (non-PEP 740) support for verifying attestations signed with a per-domain public key configured via `ATTESTATION_VERIFICATION_KEYS`.
|
|
16
|
+
[#1340](https://github.com/pulp/pulp_python/issues/1340)
|
|
17
|
+
|
|
18
|
+
#### Bugfixes {: #3.38.0-bugfix }
|
|
19
|
+
|
|
20
|
+
- Fixed quoting mistake in simple html index pages that can lead to a possible XSS attack given a carefully crafted package name. CVE-2026-103871
|
|
21
|
+
- Remote include and exclude ranges accept matching prerelease versions without deprecation warnings.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
11
25
|
## 3.37.1 (2026-10-08) {: #3.37.1 }
|
|
12
26
|
|
|
13
27
|
#### Bugfixes {: #3.37.1-bugfix }
|
|
@@ -37,6 +51,24 @@
|
|
|
37
51
|
|
|
38
52
|
---
|
|
39
53
|
|
|
54
|
+
## 3.36.4 (2026-10-08) {: #3.36.4 }
|
|
55
|
+
|
|
56
|
+
#### Bugfixes {: #3.36.4-bugfix }
|
|
57
|
+
|
|
58
|
+
- Fixed quoting mistake in simple html index pages that can lead to a possible XSS attack given a carefully crafted package name. CVE-2026-103871
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 3.36.3 (2026-10-07) {: #3.36.3 }
|
|
63
|
+
|
|
64
|
+
#### Bugfixes {: #3.36.3-bugfix }
|
|
65
|
+
|
|
66
|
+
- RSS feed GUIDs are now stable when additional platform wheels arrive for the same release. GUIDs only change when a new PEP 427 build tag is introduced, preventing feed readers from showing duplicate entries for multi-architecture builds.
|
|
67
|
+
[#1381](https://github.com/pulp/pulp_python/issues/1381)
|
|
68
|
+
- Fixed the Integrity API evaluating the entire repository's content query before filtering.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
40
72
|
## 3.36.2 (2026-09-10) {: #3.36.2 }
|
|
41
73
|
|
|
42
74
|
#### Bugfixes {: #3.36.2-bugfix }
|
|
@@ -254,6 +286,14 @@
|
|
|
254
286
|
|
|
255
287
|
---
|
|
256
288
|
|
|
289
|
+
## 3.27.7 (2026-10-08) {: #3.27.7 }
|
|
290
|
+
|
|
291
|
+
#### Bugfixes {: #3.27.7-bugfix }
|
|
292
|
+
|
|
293
|
+
- Fixed quoting mistake in simple html index pages that can lead to a possible XSS attack given a carefully crafted package name. CVE-2026-103871
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
257
297
|
## 3.27.6 (2026-07-16) {: #3.27.6 }
|
|
258
298
|
|
|
259
299
|
#### Bugfixes {: #3.27.6-bugfix }
|
|
@@ -508,6 +548,15 @@
|
|
|
508
548
|
|
|
509
549
|
---
|
|
510
550
|
|
|
551
|
+
## 3.19.5 (2026-10-08) {: #3.19.5 }
|
|
552
|
+
|
|
553
|
+
#### Bugfixes {: #3.19.5-bugfix }
|
|
554
|
+
|
|
555
|
+
- Fixed quoting mistake in simple html detail pages that can lead to a possible XSS attack.
|
|
556
|
+
- Fixed quoting mistake in simple html index pages that can lead to a possible XSS attack given a carefully crafted package name. CVE-2026-103871
|
|
557
|
+
|
|
558
|
+
---
|
|
559
|
+
|
|
511
560
|
## 3.19.4 (2026-06-30) {: #3.19.4 }
|
|
512
561
|
|
|
513
562
|
#### Bugfixes {: #3.19.4-bugfix }
|
|
@@ -639,6 +688,15 @@ No significant changes.
|
|
|
639
688
|
|
|
640
689
|
---
|
|
641
690
|
|
|
691
|
+
## 3.13.8 (2026-10-08) {: #3.13.8 }
|
|
692
|
+
|
|
693
|
+
#### Bugfixes {: #3.13.8-bugfix }
|
|
694
|
+
|
|
695
|
+
- Fixed quoting mistake in simple html detail pages that can lead to a possible XSS attack.
|
|
696
|
+
- Fixed quoting mistake in simple html index pages that can lead to a possible XSS attack given a carefully crafted package name. CVE-2026-103871
|
|
697
|
+
|
|
698
|
+
---
|
|
699
|
+
|
|
642
700
|
## 3.13.7 (2026-06-30) {: #3.13.7 }
|
|
643
701
|
|
|
644
702
|
#### Bugfixes {: #3.13.7-bugfix }
|
|
@@ -721,6 +779,15 @@ No significant changes.
|
|
|
721
779
|
|
|
722
780
|
---
|
|
723
781
|
|
|
782
|
+
## 3.12.10 (2026-10-08) {: #3.12.10 }
|
|
783
|
+
|
|
784
|
+
#### Bugfixes {: #3.12.10-bugfix }
|
|
785
|
+
|
|
786
|
+
- Fixed quoting mistake in simple html detail pages that can lead to a possible XSS attack.
|
|
787
|
+
- Fixed quoting mistake in simple html index pages that can lead to a possible XSS attack given a carefully crafted package name. CVE-2026-103871
|
|
788
|
+
|
|
789
|
+
---
|
|
790
|
+
|
|
724
791
|
## 3.12.9 (2026-04-01) {: #3.12.9 }
|
|
725
792
|
|
|
726
793
|
#### Bugfixes {: #3.12.9-bugfix }
|
|
@@ -821,6 +888,15 @@ No significant changes.
|
|
|
821
888
|
|
|
822
889
|
---
|
|
823
890
|
|
|
891
|
+
## 3.11.9 (2026-10-08) {: #3.11.9 }
|
|
892
|
+
|
|
893
|
+
#### Bugfixes {: #3.11.9-bugfix }
|
|
894
|
+
|
|
895
|
+
- Fixed quoting mistake in simple html detail pages that can lead to a possible XSS attack.
|
|
896
|
+
- Fixed quoting mistake in simple html index pages that can lead to a possible XSS attack given a carefully crafted package name. CVE-2026-103871
|
|
897
|
+
|
|
898
|
+
---
|
|
899
|
+
|
|
824
900
|
## 3.11.8 (2026-04-21) {: #3.11.8 }
|
|
825
901
|
|
|
826
902
|
No significant changes.
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from typing import Annotated, Literal, Union, get_args
|
|
3
|
+
|
|
4
|
+
from cryptography.exceptions import InvalidSignature, UnsupportedAlgorithm
|
|
5
|
+
from cryptography.hazmat.primitives import hashes, serialization
|
|
6
|
+
from cryptography.hazmat.primitives.asymmetric import padding as crypto_padding
|
|
7
|
+
from cryptography.hazmat.primitives.asymmetric import rsa
|
|
8
|
+
from cryptography.x509 import load_der_x509_certificate
|
|
9
|
+
from django.conf import settings
|
|
10
|
+
from pydantic import BaseModel, ConfigDict, Field, ValidationError
|
|
11
|
+
from pydantic.alias_generators import to_snake
|
|
12
|
+
from pypi_attestations import Attestation as _UpstreamAttestation
|
|
13
|
+
from pypi_attestations import (
|
|
14
|
+
Distribution,
|
|
15
|
+
Envelope, # noqa - needed in module namespace for Pydantic model rebuild
|
|
16
|
+
Publisher,
|
|
17
|
+
VerificationError,
|
|
18
|
+
VerificationMaterial,
|
|
19
|
+
)
|
|
20
|
+
from sigstore.dsse import Envelope as DSSEEnvelope
|
|
21
|
+
from sigstore.dsse import _pae
|
|
22
|
+
|
|
23
|
+
from pulpcore.plugin.util import get_domain
|
|
24
|
+
|
|
25
|
+
_verification_key_cache = {}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class _PermissivePolicy:
|
|
29
|
+
"""A permissive verification policy that always succeeds."""
|
|
30
|
+
|
|
31
|
+
def verify(self, cert):
|
|
32
|
+
"""Succeed regardless of the publisher's identity."""
|
|
33
|
+
pass
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class AnyPublisher(BaseModel):
|
|
37
|
+
"""A fallback publisher for any kind not matching other publisher types."""
|
|
38
|
+
|
|
39
|
+
model_config = ConfigDict(alias_generator=to_snake, extra="allow")
|
|
40
|
+
|
|
41
|
+
kind: str
|
|
42
|
+
|
|
43
|
+
def _as_policy(self):
|
|
44
|
+
"""Return a permissive policy that always succeed."""
|
|
45
|
+
return _PermissivePolicy()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# Get the underlying Union type of the original Publisher
|
|
49
|
+
# Publisher is Annotated[Union[...], Field(discriminator="kind")]
|
|
50
|
+
_OriginalPublisherTypes = get_args(Publisher.__origin__)
|
|
51
|
+
# Get the kinds of the original publisher types, they can only be proven by a Sigstore certificate
|
|
52
|
+
_TrustedPublisherKinds = {t.model_fields["kind"].default for t in _OriginalPublisherTypes}
|
|
53
|
+
# Add AnyPublisher to the list of original publisher types
|
|
54
|
+
_ExtendedPublisherTypes = (*_OriginalPublisherTypes, AnyPublisher)
|
|
55
|
+
_ExtendedPublisherUnion = Union[_ExtendedPublisherTypes]
|
|
56
|
+
# Create a new type that fallbacks to AnyPublisher
|
|
57
|
+
ExtendedPublisher = Annotated[_ExtendedPublisherUnion, Field(union_mode="left_to_right")]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class Attestation(_UpstreamAttestation):
|
|
61
|
+
"""
|
|
62
|
+
Attestation object as defined in PEP 740.
|
|
63
|
+
|
|
64
|
+
Inherits from the upstream pypi_attestations.Attestation to keep Sigstore
|
|
65
|
+
verification methods (to_bundle, verify), but makes verification_material
|
|
66
|
+
optional to support attestations signed with a custom key instead of Sigstore.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
verification_material: VerificationMaterial | None = None
|
|
70
|
+
"""
|
|
71
|
+
Cryptographic materials used to verify `message_signature`.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class AttestationBundle(BaseModel):
|
|
76
|
+
"""
|
|
77
|
+
AttestationBundle object as defined in PEP740.
|
|
78
|
+
|
|
79
|
+
PyPI only accepts attestations from TrustedPublishers (GitHub, GitLab, Google), but we will
|
|
80
|
+
accept from any user.
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
publisher: ExtendedPublisher
|
|
84
|
+
attestations: list[Attestation]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class Provenance(BaseModel):
|
|
88
|
+
"""Provenance object as defined in PEP740."""
|
|
89
|
+
|
|
90
|
+
version: Literal[1] = 1
|
|
91
|
+
attestation_bundles: list[AttestationBundle]
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _load_verification_key(domain_name):
|
|
95
|
+
"""Load the attestation verification public key configured for the domain, with caching."""
|
|
96
|
+
keys = settings.ATTESTATION_VERIFICATION_KEYS
|
|
97
|
+
if not isinstance(keys, dict):
|
|
98
|
+
raise VerificationError(
|
|
99
|
+
"ATTESTATION_VERIFICATION_KEYS must map domain names to public key paths"
|
|
100
|
+
)
|
|
101
|
+
key_path = keys.get(domain_name)
|
|
102
|
+
if not key_path:
|
|
103
|
+
return None
|
|
104
|
+
if key_path not in _verification_key_cache:
|
|
105
|
+
try:
|
|
106
|
+
with open(key_path, "rb") as f:
|
|
107
|
+
key = serialization.load_pem_public_key(f.read())
|
|
108
|
+
except (OSError, ValueError, UnsupportedAlgorithm) as e:
|
|
109
|
+
raise VerificationError(
|
|
110
|
+
f"could not load the verification key for domain '{domain_name}' "
|
|
111
|
+
f"from {key_path}: {e}"
|
|
112
|
+
)
|
|
113
|
+
if not isinstance(key, rsa.RSAPublicKey):
|
|
114
|
+
raise VerificationError(
|
|
115
|
+
f"the verification key for domain '{domain_name}' in {key_path} "
|
|
116
|
+
"must be an RSA public key"
|
|
117
|
+
)
|
|
118
|
+
_verification_key_cache[key_path] = key
|
|
119
|
+
return _verification_key_cache[key_path]
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def _has_certificate(attestation):
|
|
123
|
+
"""Check whether the attestation carries a certificate, rejecting unparseable ones."""
|
|
124
|
+
vm = attestation.verification_material
|
|
125
|
+
if vm is None:
|
|
126
|
+
return False
|
|
127
|
+
try:
|
|
128
|
+
load_der_x509_certificate(vm.certificate)
|
|
129
|
+
except ValueError as e:
|
|
130
|
+
raise VerificationError(f"invalid X.509 certificate in verification_material: {e}")
|
|
131
|
+
return True
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _verify_statement_subject(attestation, dist):
|
|
135
|
+
"""Validate that the in-toto statement subject matches the distribution."""
|
|
136
|
+
try:
|
|
137
|
+
stmt = json.loads(attestation.envelope.statement)
|
|
138
|
+
except (json.JSONDecodeError, UnicodeDecodeError) as e:
|
|
139
|
+
raise VerificationError(f"invalid statement: {e}")
|
|
140
|
+
|
|
141
|
+
try:
|
|
142
|
+
subjects = stmt.get("subject", [])
|
|
143
|
+
if len(subjects) != 1:
|
|
144
|
+
raise VerificationError("expected exactly one subject in statement")
|
|
145
|
+
|
|
146
|
+
subject = subjects[0]
|
|
147
|
+
name = subject.get("name", "")
|
|
148
|
+
if name != dist.name:
|
|
149
|
+
raise VerificationError(
|
|
150
|
+
f"subject does not match distribution name: {name} != {dist.name}"
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
digest = subject.get("digest", {}).get("sha256")
|
|
154
|
+
if digest != dist.digest:
|
|
155
|
+
raise VerificationError("subject does not match distribution digest")
|
|
156
|
+
except (AttributeError, TypeError) as e:
|
|
157
|
+
raise VerificationError(f"malformed statement: {e}")
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def _verify_signature(attestation, public_key):
|
|
161
|
+
"""Verify the attestation's RSA signature over the DSSE PAE bytes."""
|
|
162
|
+
statement_bytes = attestation.envelope.statement
|
|
163
|
+
signature_bytes = attestation.envelope.signature
|
|
164
|
+
pae = _pae(DSSEEnvelope._TYPE, statement_bytes)
|
|
165
|
+
try:
|
|
166
|
+
public_key.verify(
|
|
167
|
+
signature_bytes,
|
|
168
|
+
pae,
|
|
169
|
+
crypto_padding.PKCS1v15(),
|
|
170
|
+
hashes.SHA256(),
|
|
171
|
+
)
|
|
172
|
+
except InvalidSignature:
|
|
173
|
+
raise VerificationError("signature verification failed")
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def verify_provenance(filename, sha256, provenance, offline=True):
|
|
177
|
+
"""Verify the provenance object is valid for the package.
|
|
178
|
+
|
|
179
|
+
Each attestation is routed to one of two coexisting verification paths:
|
|
180
|
+
1. Attestations with a valid Sigstore certificate follow the standard PEP 740 path.
|
|
181
|
+
2. Attestations without a certificate are verified against the key configured for the
|
|
182
|
+
current domain in ATTESTATION_VERIFICATION_KEYS using RSA PKCS1v15 signatures.
|
|
183
|
+
Attestations with a certificate that can't be parsed are rejected.
|
|
184
|
+
"""
|
|
185
|
+
try:
|
|
186
|
+
dist = Distribution(name=filename, digest=sha256)
|
|
187
|
+
except ValidationError as e:
|
|
188
|
+
raise VerificationError(f"invalid distribution filename {filename}: {e}")
|
|
189
|
+
for bundle in provenance.attestation_bundles:
|
|
190
|
+
publisher = bundle.publisher
|
|
191
|
+
policy = publisher._as_policy()
|
|
192
|
+
for attestation in bundle.attestations:
|
|
193
|
+
if _has_certificate(attestation):
|
|
194
|
+
sig_bundle = attestation.to_bundle()
|
|
195
|
+
checkpoint = sig_bundle.log_entry._inner.inclusion_proof.checkpoint
|
|
196
|
+
staging = "sigstage.dev" in checkpoint.envelope
|
|
197
|
+
attestation.verify(policy, dist, staging=staging, offline=offline)
|
|
198
|
+
else:
|
|
199
|
+
if publisher.kind in _TrustedPublisherKinds:
|
|
200
|
+
raise VerificationError(
|
|
201
|
+
f"publisher kind '{publisher.kind}' requires a Sigstore certificate"
|
|
202
|
+
)
|
|
203
|
+
domain_name = get_domain().name
|
|
204
|
+
verification_key = _load_verification_key(domain_name)
|
|
205
|
+
if verification_key:
|
|
206
|
+
_verify_statement_subject(attestation, dist)
|
|
207
|
+
_verify_signature(attestation, verification_key)
|
|
208
|
+
else:
|
|
209
|
+
raise VerificationError(
|
|
210
|
+
"attestation has no Sigstore certificate, and "
|
|
211
|
+
f"ATTESTATION_VERIFICATION_KEYS has no key for domain '{domain_name}'"
|
|
212
|
+
)
|
|
@@ -3,12 +3,19 @@ from gettext import gettext as _
|
|
|
3
3
|
|
|
4
4
|
from django.db.utils import IntegrityError
|
|
5
5
|
from pydantic import TypeAdapter, ValidationError
|
|
6
|
+
from pypi_attestations import AttestationError
|
|
6
7
|
from rest_framework import serializers
|
|
7
8
|
|
|
8
9
|
from pulpcore.plugin.models import Artifact
|
|
9
10
|
from pulpcore.plugin.util import get_domain
|
|
10
11
|
|
|
11
|
-
from pulp_python.app.provenance import
|
|
12
|
+
from pulp_python.app.provenance import (
|
|
13
|
+
AnyPublisher,
|
|
14
|
+
Attestation,
|
|
15
|
+
AttestationBundle,
|
|
16
|
+
Provenance,
|
|
17
|
+
verify_provenance,
|
|
18
|
+
)
|
|
12
19
|
from pulp_python.app.utils import DIST_EXTENSIONS, SUPPORTED_METADATA_VERSIONS
|
|
13
20
|
|
|
14
21
|
log = logging.getLogger(__name__)
|
|
@@ -110,6 +117,7 @@ class PackageUploadSerializer(serializers.Serializer):
|
|
|
110
117
|
}
|
|
111
118
|
)
|
|
112
119
|
|
|
120
|
+
sha256 = data.get("sha256_digest")
|
|
113
121
|
if attestations := data.get("attestations"):
|
|
114
122
|
try:
|
|
115
123
|
attestations = TypeAdapter(list[Attestation]).validate_python(attestations)
|
|
@@ -117,8 +125,17 @@ class PackageUploadSerializer(serializers.Serializer):
|
|
|
117
125
|
raise serializers.ValidationError(
|
|
118
126
|
{"attestations": _("The uploaded attestations are not valid: {}").format(e)}
|
|
119
127
|
)
|
|
128
|
+
if attestations and sha256:
|
|
129
|
+
publisher = AnyPublisher(kind="Pulp User")
|
|
130
|
+
att_bundle = AttestationBundle(publisher=publisher, attestations=attestations)
|
|
131
|
+
provenance = Provenance(attestation_bundles=[att_bundle])
|
|
132
|
+
try:
|
|
133
|
+
verify_provenance(file.name, sha256, provenance, offline=True)
|
|
134
|
+
except AttestationError as e:
|
|
135
|
+
raise serializers.ValidationError(
|
|
136
|
+
{"attestations": _("Attestations failed verification: {}").format(e)}
|
|
137
|
+
)
|
|
120
138
|
|
|
121
|
-
sha256 = data.get("sha256_digest")
|
|
122
139
|
digests = {"sha256": sha256} if sha256 else None
|
|
123
140
|
artifact = Artifact.init_and_validate(file, expected_digests=digests)
|
|
124
141
|
try:
|
|
@@ -4,6 +4,8 @@ PYTHON_GROUP_UPLOADS = False
|
|
|
4
4
|
PYPI_API_HOSTNAME = "https://" + socket.getfqdn()
|
|
5
5
|
PYPI_PATH_PREFIX = "/pypi/"
|
|
6
6
|
|
|
7
|
+
ATTESTATION_VERIFICATION_KEYS = {}
|
|
8
|
+
|
|
7
9
|
DRF_ACCESS_POLICY = {
|
|
8
10
|
"dynaconf_merge_unique": True,
|
|
9
11
|
"reusable_conditions": ["pulp_python.app.global_access_conditions"],
|
|
@@ -666,12 +666,12 @@ class PackageIncludeFilter:
|
|
|
666
666
|
self._filter_excludes = self._parse_packages(self.remote.excludes)
|
|
667
667
|
|
|
668
668
|
def _parse_packages(self, packages):
|
|
669
|
+
"""Group requirements by project and whether they specify a version range."""
|
|
669
670
|
config = defaultdict(lambda: defaultdict(list))
|
|
670
671
|
for value in packages:
|
|
671
672
|
requirement = Requirement(value)
|
|
672
673
|
requirement.name = canonicalize_name(requirement.name)
|
|
673
674
|
if requirement.specifier:
|
|
674
|
-
requirement.specifier.prereleases = True
|
|
675
675
|
config["range"][requirement.name].append(requirement)
|
|
676
676
|
else:
|
|
677
677
|
config["full"][requirement.name].append(requirement)
|
|
@@ -706,7 +706,7 @@ class PackageIncludeFilter:
|
|
|
706
706
|
include_range = self._filter_includes.get("range", {})
|
|
707
707
|
if project_name in include_range:
|
|
708
708
|
for req in include_range[project_name]:
|
|
709
|
-
if
|
|
709
|
+
if req.specifier.contains(version, prereleases=True):
|
|
710
710
|
break
|
|
711
711
|
else:
|
|
712
712
|
return False
|
|
@@ -714,7 +714,7 @@ class PackageIncludeFilter:
|
|
|
714
714
|
exclude_range = self._filter_excludes.get("range", {})
|
|
715
715
|
if project_name in exclude_range:
|
|
716
716
|
for req in exclude_range[project_name]:
|
|
717
|
-
if
|
|
717
|
+
if req.specifier.contains(version, prereleases=True):
|
|
718
718
|
return False
|
|
719
719
|
|
|
720
720
|
return True
|