Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for hosting SPDX-2 SBOMs alongside release artifacts #2359

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion downloads/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Meta(GenericResource.Meta):
'creator', 'last_modified_by',
'os', 'release', 'description', 'is_source', 'url', 'gpg_signature_file',
'md5_sum', 'filesize', 'download_button', 'sigstore_signature_file',
'sigstore_cert_file', 'sigstore_bundle_file',
'sigstore_cert_file', 'sigstore_bundle_file', 'sbom_spdx2_file',
]
filtering = {
'name': ('exact',),
Expand Down
18 changes: 18 additions & 0 deletions downloads/migrations/0010_releasefile_sbom_spdx2_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.24 on 2024-01-12 21:04

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('downloads', '0009_releasefile_sigstore_bundle_file'),
]

operations = [
migrations.AddField(
model_name='releasefile',
name='sbom_spdx2_file',
field=models.URLField(blank=True, help_text='SPDX-2 SBOM URL', verbose_name='SPDX-2 SBOM URL'),
),
]
3 changes: 3 additions & 0 deletions downloads/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ class ReleaseFile(ContentManageable, NameSlugModel):
sigstore_bundle_file = models.URLField(
"Sigstore Bundle URL", blank=True, help_text="Sigstore Bundle URL"
)
sbom_spdx2_file = models.URLField(
"SPDX-2 SBOM URL", blank=True, help_text="SPDX-2 SBOM URL"
)
md5_sum = models.CharField('MD5 Sum', max_length=200, blank=True)
filesize = models.IntegerField(default=0)
download_button = models.BooleanField(default=False, help_text="Use for the supernav download button for this OS")
Expand Down
1 change: 1 addition & 0 deletions downloads/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ class Meta:
'sigstore_signature_file',
'sigstore_cert_file',
'sigstore_bundle_file',
'sbom_spdx2_file',
)
5 changes: 5 additions & 0 deletions downloads/templatetags/download_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ def has_sigstore_materials(files):
f.sigstore_bundle_file or f.sigstore_cert_file or f.sigstore_signature_file
for f in files
)


@register.filter
def has_sbom(files):
return any(f.sbom_spdx2_file for f in files)
7 changes: 7 additions & 0 deletions templates/downloads/release_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% load boxes %}
{% load sitetree %}
{% load has_sigstore_materials from download_tags %}
{% load has_sbom from download_tags %}

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

Expand Down Expand Up @@ -53,6 +54,9 @@ <h1 class="page-title">Files</h1>
{% if release_files|has_sigstore_materials %}
<th colspan="2"><a href="https://www.python.org/download/sigstore/">Sigstore</a></th>
{% endif %}
{% if release_files|has_sbom %}
<th>SBOM</th>
{% endif %}
</tr>
</thead>
<tbody>
Expand All @@ -72,6 +76,9 @@ <h1 class="page-title">Files</h1>
<td>{% if f.sigstore_signature_file %}<a href="{{ f.sigstore_signature_file }}">SIG</a>{% endif %}</td>
{% endif %}
{% endif %}
{% if release_files|has_sbom %}
<td>{% if f.sbom_spdx2_file %}<a href="{{ f.sbom_spdx2_file }}">SPDX</a>{% endif %}</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
Expand Down
Loading