cookiebanner: detect service workers and Cache Storage buckets

A registered service worker is a URL-shaped artifact (origin+path of
the worker script), so it goes in tracker_resources as a new
SERVICE_WORKER resource type. A Cache Storage bucket is an opaque
named string with no URL, so it goes in detected_trackers as a new
CACHE_STORAGE tracker type.

Frontend:
  - StorageDetector wraps caches.open() and enumerates caches.keys()
    on start to surface pre-existing buckets that pre-date the SDK
    load (service workers commonly populate caches eagerly on
    install).
  - ThirdPartyDetector wraps navigator.serviceWorker.register() and
    enumerates getRegistrations() on start.

Both wrappers degrade silently on insecure contexts where these APIs
are unavailable.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-05-11 10:54:05 +04:00
parent 2b3449de1a
commit caac9c76db
12 changed files with 177 additions and 17 deletions

View File

@@ -96,6 +96,7 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
huh.NewOption("Beacon", "BEACON"),
huh.NewOption("Fetch / XHR", "FETCH"),
huh.NewOption("Media", "MEDIA"),
huh.NewOption("Service Worker", "SERVICE_WORKER"),
).
Value(&flagResourceType).Run(); err != nil {
return err
@@ -161,7 +162,7 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
cmd.Flags().StringVar(&flagCategoryID, "category-id", "", "Cookie category ID (required)")
_ = cmd.MarkFlagRequired("category-id")
cmd.Flags().StringVar(&flagResourceType, "resource-type", "", "Resource type: SCRIPT, IFRAME, IMAGE, STYLESHEET, FONT, BEACON, FETCH or MEDIA (required)")
cmd.Flags().StringVar(&flagResourceType, "resource-type", "", "Resource type: SCRIPT, IFRAME, IMAGE, STYLESHEET, FONT, BEACON, FETCH, MEDIA or SERVICE_WORKER (required)")
cmd.Flags().StringVar(&flagOrigin, "origin", "", "Origin URL (required)")
cmd.Flags().StringVar(&flagPath, "path", "", "Resource path (required)")
cmd.Flags().StringVar(&flagDisplayName, "display-name", "", "Display name (required)")