From 7fdc2a36605cd7f4d47dd7e8f34d9bc6774adb21 Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Sun, 7 Nov 2021 17:18:17 +0100 Subject: [PATCH] Print all the full hosts so they are easier to visit and get tainted with cookies --- extended-request.ts | 4 ++++ request-cluster.ts | 27 ++++++++++++++++++++------- sidebar/stolen-data-cluster.tsx | 7 ++++++- util.ts | 13 +++++++++++++ 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/extended-request.ts b/extended-request.ts index 26a1a5f..9062741 100644 --- a/extended-request.ts +++ b/extended-request.ts @@ -164,4 +164,8 @@ export default class ExtendedRequest { getMarkedEntries() { return this.stolenData.filter((data) => data.hasMark()); } + + getHost() { + return new URL(this.url).host; + } } diff --git a/request-cluster.ts b/request-cluster.ts index dd5dec5..743a720 100644 --- a/request-cluster.ts +++ b/request-cluster.ts @@ -4,7 +4,14 @@ import ExtendedRequest from "./extended-request"; export type Sources = "cookie" | "pathname" | "queryparams" | "header"; import { TCString, TCModel } from "@iabtcf/core"; -import { getMemory, isJSONObject, isURL, parseToObject } from "./util"; +import { + allSubhosts, + getMemory, + isJSONObject, + isURL, + parseToObject, + unique, +} from "./util"; const id = (function* id() { let i = 0; @@ -45,7 +52,7 @@ export class StolenDataEntry { priority += 100; } if (this.source === "cookie") { - priority += 100; + priority += 200; } return priority; } @@ -68,11 +75,9 @@ export class StolenDataEntry { host: url.host, path: url.pathname, ...Object.fromEntries( - ( - url.searchParams as unknown as { - entries: () => Iterable<[string, string]>; - } - ).entries() + ((url.searchParams as unknown) as { + entries: () => Iterable<[string, string]>; + }).entries() ), }; return object; @@ -257,4 +262,12 @@ export class RequestCluster extends EventEmitter { getMarkedRequests() { return this.requests.filter((request) => request.hasMark()); } + + getFullHosts() { + return unique( + this.requests + .map((request) => allSubhosts(request.getHost())) + .reduce((a, b) => a.concat(b), []) + ); + } } diff --git a/sidebar/stolen-data-cluster.tsx b/sidebar/stolen-data-cluster.tsx index 1f62f5d..3b432b7 100644 --- a/sidebar/stolen-data-cluster.tsx +++ b/sidebar/stolen-data-cluster.tsx @@ -1,5 +1,5 @@ import React from "react"; -import memory from "../memory"; + import { MergedStolenDataEntry, Sources } from "../request-cluster"; import { getMemory, hyphenate } from "../util"; @@ -101,6 +101,11 @@ export default function StolenDataCluster({ Wyczyść cookiesy +
+ {cluster.getFullHosts().map((host) => ( + {host}, + ))} +
{cluster diff --git a/util.ts b/util.ts index 06f0809..b4f08b9 100644 --- a/util.ts +++ b/util.ts @@ -86,3 +86,16 @@ export function hyphenate(str: string): string { export function getMemory(): Memory { return (browser.extension.getBackgroundPage().window as any).memory as Memory; } + +export function unique(array: string[]) { + return Array.from(new Set(array)); +} + +export function allSubhosts(host: string) { + const parts = host.split("."); + const result = []; + for (let i = 0; i < parts.length - 2; i++) { + result.push(parts.slice(i).join(".")); + } + return result; +}