Skip to content

Commit 0d5432a

Browse files
authored
Add support for hosting SPDX-2 SBOMs alongside release artifacts (#2359)
1 parent 04751c8 commit 0d5432a

File tree

6 files changed

+35
-1
lines changed

6 files changed

+35
-1
lines changed

downloads/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class Meta(GenericResource.Meta):
6969
'creator', 'last_modified_by',
7070
'os', 'release', 'description', 'is_source', 'url', 'gpg_signature_file',
7171
'md5_sum', 'filesize', 'download_button', 'sigstore_signature_file',
72-
'sigstore_cert_file', 'sigstore_bundle_file',
72+
'sigstore_cert_file', 'sigstore_bundle_file', 'sbom_spdx2_file',
7373
]
7474
filtering = {
7575
'name': ('exact',),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.2.24 on 2024-01-12 21:04
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('downloads', '0009_releasefile_sigstore_bundle_file'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='releasefile',
15+
name='sbom_spdx2_file',
16+
field=models.URLField(blank=True, help_text='SPDX-2 SBOM URL', verbose_name='SPDX-2 SBOM URL'),
17+
),
18+
]

downloads/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,9 @@ class ReleaseFile(ContentManageable, NameSlugModel):
332332
sigstore_bundle_file = models.URLField(
333333
"Sigstore Bundle URL", blank=True, help_text="Sigstore Bundle URL"
334334
)
335+
sbom_spdx2_file = models.URLField(
336+
"SPDX-2 SBOM URL", blank=True, help_text="SPDX-2 SBOM URL"
337+
)
335338
md5_sum = models.CharField('MD5 Sum', max_length=200, blank=True)
336339
filesize = models.IntegerField(default=0)
337340
download_button = models.BooleanField(default=False, help_text="Use for the supernav download button for this OS")

downloads/serializers.py

+1
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ class Meta:
4949
'sigstore_signature_file',
5050
'sigstore_cert_file',
5151
'sigstore_bundle_file',
52+
'sbom_spdx2_file',
5253
)

downloads/templatetags/download_tags.py

+5
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ def has_sigstore_materials(files):
1414
f.sigstore_bundle_file or f.sigstore_cert_file or f.sigstore_signature_file
1515
for f in files
1616
)
17+
18+
19+
@register.filter
20+
def has_sbom(files):
21+
return any(f.sbom_spdx2_file for f in files)

templates/downloads/release_detail.html

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{% load boxes %}
33
{% load sitetree %}
44
{% load has_sigstore_materials from download_tags %}
5+
{% load has_sbom from download_tags %}
56

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

@@ -53,6 +54,9 @@ <h1 class="page-title">Files</h1>
5354
{% if release_files|has_sigstore_materials %}
5455
<th colspan="2"><a href="https://www.python.org/download/sigstore/">Sigstore</a></th>
5556
{% endif %}
57+
{% if release_files|has_sbom %}
58+
<th>SBOM</th>
59+
{% endif %}
5660
</tr>
5761
</thead>
5862
<tbody>
@@ -72,6 +76,9 @@ <h1 class="page-title">Files</h1>
7276
<td>{% if f.sigstore_signature_file %}<a href="{{ f.sigstore_signature_file }}">SIG</a>{% endif %}</td>
7377
{% endif %}
7478
{% endif %}
79+
{% if release_files|has_sbom %}
80+
<td>{% if f.sbom_spdx2_file %}<a href="{{ f.sbom_spdx2_file }}">SPDX</a>{% endif %}</td>
81+
{% endif %}
7582
</tr>
7683
{% endfor %}
7784
</tbody>

0 commit comments

Comments
 (0)