Skip excluded patterns in detection and snapshots

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é <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-05-01 16:25:02 +04:00
parent 2192c854a0
commit dc3c2701ac

View File

@@ -97,6 +97,7 @@ type (
DisplayName *string DisplayName *string
MaxAgeSeconds **int MaxAgeSeconds **int
Description *string Description *string
Excluded *bool
} }
MoveCookiePatternToCategoryRequest struct { MoveCookiePatternToCategoryRequest struct {
@@ -531,7 +532,13 @@ func (s *Service) ensureDraftVersionForBanner(
} }
var allPatterns coredata.CookiePatterns 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) return nil, fmt.Errorf("cannot load cookie patterns: %w", err)
} }
@@ -1326,6 +1333,9 @@ func (s *Service) UpdateCookiePattern(
if req.Description != nil { if req.Description != nil {
pattern.Description = *req.Description pattern.Description = *req.Description
} }
if req.Excluded != nil {
pattern.Excluded = *req.Excluded
}
pattern.UpdatedAt = time.Now() pattern.UpdatedAt = time.Now()
@@ -2266,6 +2276,10 @@ func (s *Service) ReportDetectedCookies(
return fmt.Errorf("cannot find matching pattern: %w", err) return fmt.Errorf("cannot find matching pattern: %w", err)
} }
if err == nil && matchedPattern.Excluded {
continue
}
patternID := matchedPattern.ID patternID := matchedPattern.ID
if errors.Is(err, coredata.ErrResourceNotFound) { if errors.Is(err, coredata.ErrResourceNotFound) {
newPattern := &coredata.CookiePattern{ newPattern := &coredata.CookiePattern{