Skip to content

ENG-1933: Add support for cookie deletion using wildcards#7047

Merged
guncha merged 9 commits intomainfrom
guncha/wildcard-cookies
Jan 13, 2026
Merged

ENG-1933: Add support for cookie deletion using wildcards#7047
guncha merged 9 commits intomainfrom
guncha/wildcard-cookies

Conversation

@guncha
Copy link
Contributor

@guncha guncha commented Dec 1, 2025

Ticket ENG-1933

Description Of Changes

This PR adds support for deleting cookies using wildcards which will typically be the form of prefix[id] or rarely [id]suffix. The removeCookiesFromBrowser function will now detect these, turn them into a regex pattern and use it to match cookies to be deleted. The attributes are ignored in this implementation since js-cookie doesn't return them when getting all of the cookies, but this could be worked around with some additional complexity.

Code Changes

  • Update removeCookiesFromBrowser function

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
  • UX feedback:
    • No UX review needed
  • Followup issues:
    • No followup issues
  • Database migrations:
    • No migrations
  • Documentation:
  • No documentation updates required

@guncha guncha requested a review from a team as a code owner December 1, 2025 17:23
@guncha guncha requested review from gilluminate and removed request for a team December 1, 2025 17:23
@vercel
Copy link
Contributor

vercel bot commented Dec 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Review Updated (UTC)
fides-plus-nightly Ignored Ignored Preview Jan 13, 2026 2:07am
fides-privacy-center Ignored Ignored Jan 13, 2026 2:07am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 1, 2025

Greptile Overview

Greptile Summary

Adds support for deleting cookies using wildcard patterns (e.g., _ga[id] to match _ga123, _ga456). The implementation separates wildcard cookies from regular cookies, builds a regex pattern by escaping special characters and replacing [id] with .*?, then matches and removes all matching cookies.

Key changes:

  • Added isWildcardCookie helper to detect cookies containing [id] placeholder
  • Modified removeCookiesFromBrowser to handle wildcard cookies separately using regex matching
  • Comprehensive test coverage including special characters and multiple wildcards

Issue found: The regex pattern uses .*? (zero or more characters) for wildcard matching, which would incorrectly match cookies where the wildcard portion is empty (e.g., _ga[id] would match both _ga123 and _ga). Should use .+? (one or more characters) instead.

Confidence Score: 3/5

  • This PR has a logical issue that could cause unintended cookie deletions
  • The wildcard regex pattern uses .*? which matches zero or more characters, potentially matching cookies without the expected ID portion. This could lead to deleting cookies that don't match the intended pattern (e.g., _ga[id] matching _ga exactly). Tests don't cover this edge case.
  • clients/fides-js/src/lib/cookie.ts needs attention for the regex pattern logic

Important Files Changed

File Analysis

Filename Score Overview
clients/fides-js/src/lib/cookie.ts 4/5 Added wildcard cookie detection and removal logic for cookies with [id] placeholder patterns
clients/fides-js/tests/lib/cookie.test.ts 5/5 Added comprehensive test coverage for wildcard cookie functionality including edge cases

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@guncha
Copy link
Contributor Author

guncha commented Jan 7, 2026

@gilluminate ready for another look! The cookies on the notice that are coming from the website monitor will have the domain field so we can always use that, unless the domain overrides are enabled. The cookies will not have path though and will default to /, but not when doing the subdomain cookie deletion? I don't know, that was the existing behavior so I didn't want to change it.

Copy link
Contributor

@gilluminate gilluminate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with one very minor nitpick to prefer arrow functions

guncha and others added 2 commits January 8, 2026 11:54
Co-authored-by: Jason Gill <jason.gill@ethyca.com>
@guncha guncha added this pull request to the merge queue Jan 13, 2026
Merged via the queue into main with commit c3a560c Jan 13, 2026
41 checks passed
@guncha guncha deleted the guncha/wildcard-cookies branch January 13, 2026 02:35
mfbrown pushed a commit that referenced this pull request Jan 27, 2026
Co-authored-by: Jason Gill <jason.gill@ethyca.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants