Skip to content

Commit 428a0b3

Browse files
committed
Merge branch 'main' into python-3.13
2 parents d11667e + 67e56af commit 428a0b3

File tree

428 files changed

+5462
-2820
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

428 files changed

+5462
-2820
lines changed

.github/workflows/gh-release.yml renamed to .github/workflows/create-github-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
create-github-release:
11-
runs-on: ubuntu-22.04
11+
runs-on: ubuntu-24.04
1212

1313
steps:
1414
- name: Create a GitHub release
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Find dependencies vulnerabilities
2+
3+
on: [push]
4+
5+
jobs:
6+
scan-codebase:
7+
runs-on: ubuntu-24.04
8+
name: Inspect packages with ScanCode.io
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
path: scancode-inputs
13+
sparse-checkout: setup.cfg
14+
sparse-checkout-cone-mode: false
15+
16+
- uses: nexB/scancode-action@alpha
17+
with:
18+
pipelines: "inspect_packages:StaticResolver,find_vulnerabilities"
19+
env:
20+
VULNERABLECODE_URL: https://public.vulnerablecode.io/
21+
22+
- name: Fail in case of vulnerabilities
23+
shell: bash
24+
run: |
25+
scanpipe shell --command '
26+
from scanpipe.models import Project
27+
project = Project.objects.get()
28+
packages_qs = project.discoveredpackages.vulnerable()
29+
dependencies_qs = project.discovereddependencies.vulnerable()
30+
vulnerability_count = packages_qs.count() + dependencies_qs.count()
31+
if vulnerability_count:
32+
print(vulnerability_count, "vulnerabilities found:")
33+
for entry in [*packages_qs, *dependencies_qs]:
34+
print(entry)
35+
exit(1)
36+
else:
37+
print("No vulnerabilities found")
38+
exit(0)
39+
'

.github/workflows/publish-docker.yml renamed to .github/workflows/publish-docker-image.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish Docker image on GHCR
1+
name: Publish Docker image on GitHub Container Registry
22
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions
33

44
on:
@@ -16,7 +16,7 @@ env:
1616

1717
jobs:
1818
build-and-push-image:
19-
runs-on: ubuntu-22.04
19+
runs-on: ubuntu-24.04
2020

2121
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
2222
permissions:

.github/workflows/ci-docker.yml renamed to .github/workflows/run-unit-tests-docker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test on Docker CI
1+
name: Run unit tests on Docker container
22

33
on:
44
push:
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
test:
11-
runs-on: ubuntu-22.04
11+
runs-on: ubuntu-24.04
1212

1313
steps:
1414
- name: Checkout code
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test CI
1+
name: Run unit tests
22

33
on:
44
push:
@@ -14,7 +14,7 @@ env:
1414

1515
jobs:
1616
test:
17-
runs-on: ubuntu-22.04
17+
runs-on: ubuntu-24.04
1818

1919
services:
2020
postgres:
@@ -55,9 +55,6 @@ jobs:
5555
- name: Start Redis
5656
uses: supercharge/[email protected]
5757

58-
# - name: Check Django deployment settings
59-
# run: make check-deploy
60-
6158
- name: Build the documentation
6259
run: make docs
6360

CHANGELOG.rst

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
Release notes
22
=============
33

4-
### Version 5.3.0-dev
4+
### Version 5.3.1-dev (unreleased)
5+
6+
- Add new `is_locked` "Locked inventory" field to the ProductStatus model.
7+
When a Product is locked through his status, its inventory cannot be modified.
8+
https://github.com/aboutcode-org/dejacode/issues/189
9+
10+
### Version 5.3.0
511

612
- Rename ProductDependency is_resolved to is_pinned.
713
https://github.com/aboutcode-org/dejacode/issues/189
@@ -80,6 +86,83 @@ Release notes
8086
Note that those count reflect the current risk threshold.
8187
https://github.com/aboutcode-org/dejacode/issues/102
8288

89+
- Enable the delete_selected action on RequestTemplateAdmin.
90+
https://github.com/aboutcode-org/dejacode/issues/243
91+
92+
- The data rendering format was simplified for improved readability from
93+
"Jan. 27, 2025, 07:55:54 a.m. UTC" to "Jan 27, 2025, 7:55 AM UTC".
94+
The dates are now always rendered using this same format across the app.
95+
The user timezone is automatically discovered and activated to the whole app using
96+
the browser JavaScript `timeZone` API
97+
The user's automatic timezone can be overridden using the new
98+
``DejacodeUser.timezone`` database field.
99+
The timezone value can be defined from the User > "Profile Settings" form.
100+
This value always takes precedence when defined.
101+
In case the timezone is not defined by the user, or cannot be detected from the
102+
browser, the date rendering always fallback to UTC.
103+
Note: all the "humanized dates" such as "Modified 23 hours ago" have the whole
104+
date syntax available in their `title` option, available on hovering the text with
105+
the cursor for a couple seconds.
106+
https://github.com/aboutcode-org/dejacode/issues/243
107+
108+
- Set the "usage_policy" in update_fields list in SetPolicyFromLicenseMixin.
109+
The associated package/license policy was properly set on the model in
110+
SetPolicyFromLicenseMixin but the usage_policy entry was missing from the
111+
update_fields. As a result the usage_policy value was not included in the UPDATE.
112+
https://github.com/aboutcode-org/dejacode/issues/200
113+
114+
- Improve the Owner assignment process on a Product/Component form.
115+
Owner not found in the Dataspace are now automatically created.
116+
https://github.com/aboutcode-org/dejacode/issues/239
117+
118+
- Updated the label of the following Product actions.
119+
The labels were updated everywhere in the UI (page title, documentation,
120+
import log, etc...) for consistency:
121+
- Import data from Scan -> Import ScanCode scan results
122+
- Load Packages from SBOMs -> Import SBOM
123+
- Import Packages from manifests -> Import Package manifests
124+
- Pull ScanCode.io Project data -> Import ScanCode.io project
125+
Improve the rendering and layout of the Import related forms for consistency,
126+
simplicity, and readability.
127+
https://github.com/aboutcode-org/dejacode/issues/241
128+
129+
- Refine the way the PURL fragments are handled in searches.
130+
https://github.com/aboutcode-org/dejacode/issues/286
131+
132+
- Fix an issue with ``urlize_target_blank`` when the URL contains curly braces.
133+
134+
- Add the ability to download Product "Imports" input file.
135+
https://github.com/aboutcode-org/dejacode/issues/156
136+
137+
- Fix a logic issue in the ``ImportPackageFromScanCodeIO.import_package`` that occurs when
138+
multiple packages with the same PURL, but different download_url or filename,
139+
are present in the Dataspace.
140+
https://github.com/aboutcode-org/dejacode/issues/295
141+
142+
- Fix a logic issue in the ``ImportPackageFromScanCodeIO.import_dependencies`` to
143+
prevent the creation of duplicated "resolved" dependencies.
144+
https://github.com/aboutcode-org/dejacode/issues/297
145+
146+
- Display the filename/download_url in the Inventory tab.
147+
https://github.com/aboutcode-org/dejacode/issues/303
148+
149+
- Improve exception support in improve_packages_from_purldb task.
150+
In case of an exception, the error is properly logged on the Import instance.
151+
https://github.com/aboutcode-org/dejacode/issues/303
152+
153+
- Refine the ``update_from_purldb`` function to avoid any IntegrityError.
154+
Also, when multiple entries are returned from the PurlDB, only the common values are
155+
merged and kept for the data update.
156+
https://github.com/aboutcode-org/dejacode/issues/303
157+
158+
- Add a new "Package Set" tab to the Package details view.
159+
This tab displays related packages grouped by their normalized ("plain") Package URL.
160+
https://github.com/aboutcode-org/dejacode/issues/276
161+
162+
- Refine get_purldb_entries to compare on plain PackageURL.
163+
Including the qualifiers and subpaths in the comparison was too restrictive.
164+
https://github.com/aboutcode-org/dejacode/issues/307
165+
83166
### Version 5.2.1
84167

85168
- Fix the models documentation navigation.
@@ -88,6 +171,9 @@ Release notes
88171
- Fix the validity of SPDX outputs.
89172
https://github.com/aboutcode-org/dejacode/issues/180
90173

174+
- Add ability to start and delete package scans from the Product inventory tab.
175+
https://github.com/aboutcode-org/dejacode/pull/281
176+
91177
### Version 5.2.0
92178

93179
- Add visual indicator in hierarchy views, when an object on the far left or far right

Dockerfile

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,23 @@ LABEL org.opencontainers.image.source="https://github.com/aboutcode-org/dejacode
1212
LABEL org.opencontainers.image.description="DejaCode"
1313
LABEL org.opencontainers.image.licenses="AGPL-3.0-only"
1414

15-
ENV APP_NAME dejacode
16-
ENV APP_USER app
17-
ENV APP_DIR /opt/$APP_NAME
18-
ENV VENV_LOCATION /opt/$APP_NAME/.venv
15+
# Set default values for APP_UID and APP_GID at build-time
16+
ARG APP_UID=1000
17+
ARG APP_GID=1000
18+
19+
ENV APP_NAME=dejacode
20+
ENV APP_USER=app
21+
ENV APP_UID=${APP_UID}
22+
ENV APP_GID=${APP_GID}
23+
ENV APP_DIR=/opt/$APP_NAME
24+
ENV VENV_LOCATION=/opt/$APP_NAME/.venv
1925

2026
# Force Python unbuffered stdout and stderr (they are flushed to terminal immediately)
21-
ENV PYTHONUNBUFFERED 1
27+
ENV PYTHONUNBUFFERED=1
2228
# Do not write Python .pyc files
23-
ENV PYTHONDONTWRITEBYTECODE 1
29+
ENV PYTHONDONTWRITEBYTECODE=1
2430
# Add the app dir in the Python path for entry points availability
25-
ENV PYTHONPATH $PYTHONPATH:$APP_DIR
31+
ENV PYTHONPATH=$PYTHONPATH:$APP_DIR
2632

2733
# OS requirements
2834
RUN apt-get update \
@@ -36,9 +42,9 @@ RUN apt-get update \
3642
&& apt-get clean \
3743
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
3844

39-
# Create the APP_USER group, user, and directory with proper permissions
40-
RUN addgroup --system $APP_USER \
41-
&& adduser --system --group --home=$APP_DIR $APP_USER \
45+
# Create the APP_USER group, user, and directory with specific UID and GID
46+
RUN groupadd --gid $APP_GID --system $APP_USER \
47+
&& useradd --uid $APP_UID --gid $APP_GID --home-dir $APP_DIR --system --create-home $APP_USER \
4248
&& chown $APP_USER:$APP_USER $APP_DIR \
4349
&& mkdir -p /var/$APP_NAME \
4450
&& chown $APP_USER:$APP_USER /var/$APP_NAME
@@ -53,7 +59,7 @@ RUN mkdir -p /var/$APP_NAME/static/ /var/$APP_NAME/media/
5359
# Create the virtualenv
5460
RUN python -m venv $VENV_LOCATION
5561
# Enable the virtualenv, similar effect as "source activate"
56-
ENV PATH $VENV_LOCATION/bin:$PATH
62+
ENV PATH=$VENV_LOCATION/bin:$PATH
5763

5864
# Install the dependencies before the codebase COPY for proper Docker layer caching
5965
COPY --chown=$APP_USER:$APP_USER setup.cfg setup.py $APP_DIR/

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ postgresdb_clean:
136136
@${SUDO_POSTGRES} dropuser '${DB_USERNAME}' || true
137137

138138
run:
139-
${MANAGE} runserver 8000 --insecure
139+
DJANGO_RUNSERVER_HIDE_WARNING=true ${MANAGE} runserver 8000 --insecure
140140

141141
worker:
142142
${MANAGE} rqworker

RELEASE.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Release instructions for `DejaCode
2+
3+
### Automated release workflow
4+
5+
- Create a new `release-x.x.x` branch
6+
- Update the version in:
7+
- `setup.cfg`
8+
- `dejacode/__init__.py`
9+
- `CHANGELOG.rst` (set date)
10+
- Commit and push this branch
11+
- Create a PR and merge once approved
12+
- Tag and push that tag. This will trigger the `create-github-release.yml`
13+
and `publish-docker-image.yml` GitHub workflows:
14+
```
15+
VERSION=vx.x.x # <- Set the new version here
16+
git tag -a $VERSION -m ""
17+
git push origin $VERSION
18+
```
19+
- Review the GitHub release created by the workflow at
20+
https://github.com/aboutcode-org/dejacode/releases/

component_catalog/admin.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
from dje.templatetags.dje_tags import urlize_target_blank
7272
from dje.utils import CHANGELIST_LINK_TEMPLATE
7373
from dje.utils import get_instance_from_referer
74+
from dje.utils import is_purl_fragment
7475
from license_library.models import License
7576
from reporting.filters import ReportingQueryListFilter
7677

@@ -774,7 +775,17 @@ class PackageAdmin(
774775
"get_dataspace",
775776
)
776777
list_display_links = ("identifier",)
777-
search_fields = ("filename", "download_url", "project")
778+
search_fields = (
779+
"type",
780+
"namespace",
781+
"name",
782+
"version",
783+
"filename",
784+
"download_url",
785+
"sha1",
786+
"md5",
787+
"project",
788+
)
778789
ordering = ("-last_modified_date",)
779790
list_filter = (
780791
("component", HierarchyRelatedLookupListFilter),
@@ -912,6 +923,7 @@ def get_queryset(self, request):
912923
return (
913924
super()
914925
.get_queryset(request)
926+
.annotate_sortable_identifier()
915927
.select_related(
916928
"usage_policy",
917929
)
@@ -938,6 +950,16 @@ def get_urls(self):
938950

939951
return urls + super().get_urls()
940952

953+
def get_search_results(self, request, queryset, search_term):
954+
"""Add searching on provided PackageURL identifier."""
955+
use_distinct = False
956+
957+
if is_purl_fragment(search_term):
958+
if results := queryset.for_package_url(search_term):
959+
return results, use_distinct
960+
961+
return super().get_search_results(request, queryset, search_term)
962+
941963
def changeform_view(self, request, object_id=None, form_url="", extra_context=None):
942964
"""
943965
Add the `show_save_and_collect_data` in the context.
@@ -1053,6 +1075,10 @@ def inferred_url(self, obj):
10531075
return urlize_target_blank(inferred_url)
10541076
return ""
10551077

1078+
@admin.display(ordering="sortable_identifier")
1079+
def identifier(self, obj):
1080+
return obj.identifier
1081+
10561082
def save_formset(self, request, form, formset, change):
10571083
"""
10581084
Update the completion_level on the related Component at the end of the saving process.

0 commit comments

Comments
 (0)