Skip to content

Commit 9f967f2

Browse files
authored
Add support for Sigstore verification materials (#2113)
* Add Sigstore verification materials * Use Django template syntax * Add link to verification documentation * Load custom filter
1 parent a13dd81 commit 9f967f2

File tree

6 files changed

+46
-1
lines changed

6 files changed

+46
-1
lines changed

downloads/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class Meta(GenericResource.Meta):
6868
'name', 'slug',
6969
'creator', 'last_modified_by',
7070
'os', 'release', 'description', 'is_source', 'url', 'gpg_signature_file',
71-
'md5_sum', 'filesize', 'download_button',
71+
'md5_sum', 'filesize', 'download_button', 'sigstore_signature_file',
72+
'sigstore_cert_file',
7273
]
7374
filtering = {
7475
'name': ('exact',),
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 2.2.24 on 2022-08-09 16:55
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('downloads', '0006_auto_20180705_0352'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='releasefile',
15+
name='sigstore_cert_file',
16+
field=models.URLField(blank=True, help_text='Sigstore Cert URL', verbose_name='Sigstore Cert URL'),
17+
),
18+
migrations.AddField(
19+
model_name='releasefile',
20+
name='sigstore_signature_file',
21+
field=models.URLField(blank=True, help_text='Sigstore Signature URL', verbose_name='Sigstore Signature URL'),
22+
),
23+
]

downloads/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,12 @@ class ReleaseFile(ContentManageable, NameSlugModel):
322322
blank=True,
323323
help_text="GPG Signature URL"
324324
)
325+
sigstore_signature_file = models.URLField(
326+
"Sigstore Signature URL", blank=True, help_text="Sigstore Signature URL"
327+
)
328+
sigstore_cert_file = models.URLField(
329+
"Sigstore Cert URL", blank=True, help_text="Sigstore Cert URL"
330+
)
325331
md5_sum = models.CharField('MD5 Sum', max_length=200, blank=True)
326332
filesize = models.IntegerField(default=0)
327333
download_button = models.BooleanField(default=False, help_text="Use for the supernav download button for this OS")

downloads/serializers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@ class Meta:
4646
'filesize',
4747
'download_button',
4848
'resource_uri',
49+
'sigstore_signature_file',
50+
'sigstore_cert_file',
4951
)

downloads/templatetags/download_tags.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@
66
@register.filter
77
def strip_minor_version(version):
88
return '.'.join(version.split('.')[:2])
9+
10+
11+
@register.filter
12+
def has_sigstore_materials(files):
13+
return any(f.sigstore_cert_file or f.sigstore_signature_file for f in files)

templates/downloads/release_detail.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{% extends "base.html" %}
22
{% load boxes %}
33
{% load sitetree %}
4+
{% load has_sigstore_materials from download_tags %}
45

56
{% block body_attributes %}class="python downloads"{% endblock %}
67

@@ -49,6 +50,9 @@ <h1 class="page-title">Files</h1>
4950
<th>MD5 Sum</th>
5051
<th>File Size</th>
5152
<th>GPG</th>
53+
{% if release_files|has_sigstore_materials %}
54+
<th colspan="2"><a href="https://www.python.org/download/sigstore/">Sigstore</a></th>
55+
{% endif %}
5256
</tr>
5357
</thead>
5458
<tbody>
@@ -60,6 +64,10 @@ <h1 class="page-title">Files</h1>
6064
<td>{{ f.md5_sum }}</td>
6165
<td>{{ f.filesize }}</td>
6266
<td>{% if f.gpg_signature_file %}<a href="{{ f.gpg_signature_file }}">SIG</a>{% endif %}</td>
67+
{% if release_files|has_sigstore_materials %}
68+
<td>{% if f.sigstore_cert_file %}<a href="{{ f.sigstore_cert_file}}">CRT</a>{% endif %}</td>
69+
<td>{% if f.sigstore_signature_file %}<a href="{{ f.sigstore_signature_file }}">SIG</a>{% endif %}</td>
70+
{% endif %}
6371
</tr>
6472
{% endfor %}
6573
</tbody>

0 commit comments

Comments
 (0)