From 8fe368507e3a8f279bbc7c051fde344fba82c562 Mon Sep 17 00:00:00 2001 From: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com> Date: Mon, 17 Aug 2026 14:10:40 +0200 Subject: [PATCH] fix(api): register Trustify endpoints under the domain-aware API root Hardcoded pulp/api/v3 paths 404 when DOMAIN_ENABLED or a custom API_ROOT is set, so scan tasks never inherit the request domain. Co-authored-by: Cursor --- changes/+domain-aware-endpoints.fixed.md | 1 + pulp_trustify/app/urls.py | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 changes/+domain-aware-endpoints.fixed.md diff --git a/changes/+domain-aware-endpoints.fixed.md b/changes/+domain-aware-endpoints.fixed.md new file mode 100644 index 0000000..7b69493 --- /dev/null +++ b/changes/+domain-aware-endpoints.fixed.md @@ -0,0 +1 @@ +Trustify REST endpoints (`scan`, `advisories`, `gate-advisories`, npm audit) are now registered under the domain-aware API root, so they resolve at domain-scoped paths and scan tasks run within the target repository's domain. diff --git a/pulp_trustify/app/urls.py b/pulp_trustify/app/urls.py index 34d1c70..b0d1d2e 100644 --- a/pulp_trustify/app/urls.py +++ b/pulp_trustify/app/urls.py @@ -1,5 +1,6 @@ """URL configuration for pulp_trustify plugin.""" +from django.conf import settings from django.urls import path from pulp_trustify.app.viewsets import ( @@ -9,24 +10,30 @@ ScanViewSet, ) +if settings.DOMAIN_ENABLED: + API_ROOT = "//api/v3/" +else: + API_ROOT = "/api/v3/" +API_ROOT = settings.API_ROOT.strip("/") + API_ROOT + urlpatterns = [ path( - "pulp/api/v3/trustify/scan/", + API_ROOT + "trustify/scan/", ScanViewSet.as_view({"post": "create"}), name="scan", ), path( - "pulp/api/v3/trustify/advisories/", + API_ROOT + "trustify/advisories/", ScanAdvisoryViewSet.as_view({"get": "list"}), name="advisories", ), path( - "pulp/api/v3/trustify/gate-advisories/", + API_ROOT + "trustify/gate-advisories/", GateAdvisoryViewSet.as_view({"get": "list"}), name="gate-advisories", ), path( - "pulp/api/v3/trustify/-/npm/v1/security/advisories/bulk", + API_ROOT + "trustify/-/npm/v1/security/advisories/bulk", NpmBulkAdvisoryView.as_view(), name="npm-audit-bulk", ),