From dc3c2701ace7973a28861aad806631af794c3065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Fri, 1 May 2026 16:25:02 +0400 Subject: [PATCH] Skip excluded patterns in detection and snapshots MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In ReportDetectedCookies, silently skip cookies that match an excluded pattern instead of recording them. Filter excluded patterns in SQL when building version snapshots so they never appear in the published banner config. Add Excluded field to UpdateCookiePatternRequest. Signed-off-by: Émile Ré --- pkg/cookiebanner/service.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/cookiebanner/service.go b/pkg/cookiebanner/service.go index 8d777c876..e731084a2 100644 --- a/pkg/cookiebanner/service.go +++ b/pkg/cookiebanner/service.go @@ -97,6 +97,7 @@ type ( DisplayName *string MaxAgeSeconds **int Description *string + Excluded *bool } MoveCookiePatternToCategoryRequest struct { @@ -531,7 +532,13 @@ func (s *Service) ensureDraftVersionForBanner( } var allPatterns coredata.CookiePatterns - if err := allPatterns.LoadAllByCookieBannerID(ctx, tx, scope, bannerID, nil); err != nil { + if err := allPatterns.LoadAllByCookieBannerID( + ctx, + tx, + scope, + bannerID, + coredata.NewCookiePatternFilter(nil, nil, new(false)), + ); err != nil { return nil, fmt.Errorf("cannot load cookie patterns: %w", err) } @@ -1326,6 +1333,9 @@ func (s *Service) UpdateCookiePattern( if req.Description != nil { pattern.Description = *req.Description } + if req.Excluded != nil { + pattern.Excluded = *req.Excluded + } pattern.UpdatedAt = time.Now() @@ -2266,6 +2276,10 @@ func (s *Service) ReportDetectedCookies( return fmt.Errorf("cannot find matching pattern: %w", err) } + if err == nil && matchedPattern.Excluded { + continue + } + patternID := matchedPattern.ID if errors.Is(err, coredata.ErrResourceNotFound) { newPattern := &coredata.CookiePattern{