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:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user