From 62aa4a2dc4ecf4b736abd1f9865e751026e7a6da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Fri, 29 May 2026 01:29:40 +0200 Subject: [PATCH] Re-trigger mapping when a tracker source is promoted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A tracker pattern's source ratchets PRE_EXISTING -> EXTENSION -> SCRIPT as stronger detections arrive, but that promotion was never reflected back to the mapping pipeline. The detection that promotes the source also brings a fresh initiator domain that matchByDomain and matchBySiblingOrigin can use, and an EXTENSION -> SCRIPT promotion lifts the creationAllowed gate that blocks org third-party creation. Yet the pattern's mapping_requested_at was already cleared after its first pass, so the worker never revisited it. Re-arm mapping_requested_at via SetMappingRequested at each source-promotion site (reportDetectedTracker plus the glob-merge and adoption paths in the pattern-analysis worker). Update's SET clause does not cover mapping_requested_at, so assigning the field before Update would be a silent no-op; SetMappingRequested only writes when the column is NULL, keeping already-queued patterns from being double-enqueued. Signed-off-by: Émile Ré --- pkg/cookiebanner/pattern_analysis_worker.go | 14 ++++++++++++++ pkg/cookiebanner/service.go | 9 +++++++++ pkg/cookiebanner/tracker_mapping_worker.go | 3 --- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/pkg/cookiebanner/pattern_analysis_worker.go b/pkg/cookiebanner/pattern_analysis_worker.go index 16d7e4e18..bac0f6be5 100644 --- a/pkg/cookiebanner/pattern_analysis_worker.go +++ b/pkg/cookiebanner/pattern_analysis_worker.go @@ -208,6 +208,13 @@ func (h *patternAnalysisHandler) Process(ctx context.Context, banner coredata.Co if err := globPattern.Update(ctx, tx, scope); err != nil { return fmt.Errorf("cannot promote source on glob pattern %q: %w", key.template, err) } + + // A stronger source can unblock mapping (e.g. + // EXTENSION->SCRIPT lifts the creationAllowed + // gate), so re-arm mapping on the existing glob. + if err := globPattern.SetMappingRequested(ctx, tx); err != nil { + return fmt.Errorf("cannot request mapping after source promotion on glob pattern %q: %w", key.template, err) + } } } @@ -798,6 +805,13 @@ func (h *patternAnalysisHandler) adoptUncategorisedPatterns( if err := match.Update(ctx, tx, scope); err != nil { return false, fmt.Errorf("cannot promote source on glob pattern %q: %w", match.Pattern, err) } + + // A stronger source can unblock mapping (e.g. + // EXTENSION->SCRIPT lifts the creationAllowed gate), so + // re-arm mapping on the adopted glob. + if err := match.SetMappingRequested(ctx, tx); err != nil { + return false, fmt.Errorf("cannot request mapping after source promotion on glob pattern %q: %w", match.Pattern, err) + } } if err := ep.Delete(ctx, tx, scope); err != nil { diff --git a/pkg/cookiebanner/service.go b/pkg/cookiebanner/service.go index 12067126c..599b73a25 100644 --- a/pkg/cookiebanner/service.go +++ b/pkg/cookiebanner/service.go @@ -2229,6 +2229,15 @@ func (s *Service) reportDetectedTracker( if err := matchedPattern.Update(ctx, tx, scope); err != nil { return fmt.Errorf("cannot promote source on matched tracker pattern %q: %w", matchedPattern.Pattern, err) } + + // A stronger source can unblock mapping: the detection + // upserted below carries a fresh initiator domain that + // matchByDomain/matchBySiblingOrigin can now use, and an + // EXTENSION->SCRIPT promotion lifts the creationAllowed + // gate. Re-arm mapping so the worker revisits the pattern. + if err := matchedPattern.SetMappingRequested(ctx, tx); err != nil { + return fmt.Errorf("cannot request mapping after source promotion on tracker pattern %q: %w", matchedPattern.Pattern, err) + } } } else { newPattern := &coredata.TrackerPattern{ diff --git a/pkg/cookiebanner/tracker_mapping_worker.go b/pkg/cookiebanner/tracker_mapping_worker.go index d0e94d851..0a070e630 100644 --- a/pkg/cookiebanner/tracker_mapping_worker.go +++ b/pkg/cookiebanner/tracker_mapping_worker.go @@ -131,9 +131,6 @@ func (h *trackerMappingHandler) Process(ctx context.Context, tp coredata.Tracker return fmt.Errorf("cannot load cookie banner for domain filtering: %w", err) } - // FIXME: remove - banner.Origin = "https://t.probo.com" - var ( commonPatternID *gid.GID commonThirdPartyID *gid.GID