Report full URL instead of bare origin for detected scripts and iframes

Strip query params and send origin+pathname so the backend can
distinguish resources served from the same domain but different paths
(e.g. gtm.js vs recaptcha/api.js on googletagmanager.com).

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-05-06 18:34:12 +04:00
parent 179e041e2f
commit a4cb61366f
3 changed files with 14 additions and 16 deletions

View File

@@ -31,6 +31,7 @@ import (
"go.probo.inc/probo/pkg/gid"
"go.probo.inc/probo/pkg/server/api/clientip"
"go.probo.inc/probo/pkg/server/jsonutil"
"go.probo.inc/probo/pkg/uri"
)
type Handler struct {
@@ -309,8 +310,8 @@ type detectedStorageEntry struct {
}
type detectedResourceEntry struct {
Origin string `json:"origin"`
ResourceType string `json:"resource_type"`
URL uri.URI `json:"url"`
ResourceType string `json:"resource_type"`
}
type reportDetectedTrackersBody struct {
@@ -400,11 +401,6 @@ func (h *Handler) handleReportDetectedTrackers(w http.ResponseWriter, r *http.Re
}
for _, res := range body.Resources {
origin := strings.TrimSpace(res.Origin)
if origin == "" {
continue
}
var resourceType coredata.TrackerType
switch strings.TrimSpace(res.ResourceType) {
case "script":
@@ -418,7 +414,7 @@ func (h *Handler) handleReportDetectedTrackers(w http.ResponseWriter, r *http.Re
req.Resources = append(
req.Resources,
cookiebanner.DetectedResourceItem{
Origin: origin,
URL: res.URL,
ResourceType: resourceType,
},
)