cookiebanner: broaden resource detection via PerformanceObserver

ThirdPartyDetector previously only saw <script src> and <iframe src>
because it scanned the DOM and watched mutations. Add a single
PerformanceObserver({type:'resource', buffered:true}) that picks up
everything the browser actually loaded:

  - tracking pixels (<img>, <picture>, srcset)
  - cross-origin stylesheets and web fonts
  - fetch / XHR / sendBeacon / ping calls (SDK call-homes)
  - video, audio, embed, object media

initiatorType is mapped to six new tracker_resource_type enum values
(IMAGE, STYLESHEET, FONT, BEACON, FETCH, MEDIA) and the existing
upsert path in tracker_resources picks them up unchanged.

Closes a real gap with headless cookie scanners: most SDKs phone home
via beacons after their script is gone, and the DOM scan never saw it.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-05-11 10:46:11 +04:00
parent d17c8ba044
commit 2b3449de1a
9 changed files with 201 additions and 15 deletions

View File

@@ -90,6 +90,12 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
Options(
huh.NewOption("Script", "SCRIPT"),
huh.NewOption("Iframe", "IFRAME"),
huh.NewOption("Image", "IMAGE"),
huh.NewOption("Stylesheet", "STYLESHEET"),
huh.NewOption("Font", "FONT"),
huh.NewOption("Beacon", "BEACON"),
huh.NewOption("Fetch / XHR", "FETCH"),
huh.NewOption("Media", "MEDIA"),
).
Value(&flagResourceType).Run(); err != nil {
return err
@@ -155,7 +161,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 or IFRAME (required)")
cmd.Flags().StringVar(&flagResourceType, "resource-type", "", "Resource type: SCRIPT, IFRAME, IMAGE, STYLESHEET, FONT, BEACON, FETCH or MEDIA (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)")