Compare commits

..

No commits in common. "e989d6d33dd49eeb07bcf6185d9e3b03ab9a9755" and "e8075b384dd31f8226be68a266bba8fa50d8a00e" have entirely different histories.

6 changed files with 21 additions and 113 deletions

View File

@ -17,7 +17,6 @@ export default class ExtendedRequest {
public shorthost: string; public shorthost: string;
public requestHeaders: Request["requestHeaders"]; public requestHeaders: Request["requestHeaders"];
public originalURL: string; public originalURL: string;
public origin: string;
public initialized = false; public initialized = false;
public stolenData: StolenDataEntry[]; public stolenData: StolenDataEntry[];
@ -35,13 +34,19 @@ export default class ExtendedRequest {
} else { } else {
url = (this.data as any).frameAncestors[0].url; url = (this.data as any).frameAncestors[0].url;
} }
this.originalURL = url; this.originalURL = new URL(url).origin;
this.origin = new URL(url).origin; }
getOriginalURL(): string {
if (!this.initialized) {
throw new Error("initialize first!!");
}
return this.originalURL;
} }
isThirdParty() { isThirdParty() {
const request_url = new URL(this.data.url); const request_url = new URL(this.data.url);
const origin_url = new URL(this.originalURL); const origin_url = new URL(this.getOriginalURL());
if (request_url.host.includes(origin_url.host)) { if (request_url.host.includes(origin_url.host)) {
return false; return false;
} }
@ -60,7 +65,7 @@ export default class ExtendedRequest {
} }
exposesOrigin() { exposesOrigin() {
const url = new URL(this.origin); const url = new URL(this.getOriginalURL());
const host = url.host; const host = url.host;
const path = url.pathname; const path = url.pathname;
return ( return (

View File

@ -7,19 +7,19 @@ export default class Memory extends EventEmitter {
origin_to_history = {} as Record<string, Record<string, RequestCluster>>; origin_to_history = {} as Record<string, Record<string, RequestCluster>>;
async register(request: ExtendedRequest) { async register(request: ExtendedRequest) {
await request.init(); await request.init();
console.log("registering request for", request.origin); console.log("registering request for", request.originalURL);
if (!request.isThirdParty()) { if (!request.isThirdParty()) {
return; return;
} }
if (!this.origin_to_history[request.origin]) { if (!this.origin_to_history[request.originalURL]) {
this.origin_to_history[request.origin] = {}; this.origin_to_history[request.originalURL] = {};
} }
const shorthost = getshorthost(new URL(request.url).host); const shorthost = getshorthost(new URL(request.url).host);
if (!this.origin_to_history[request.origin][shorthost]) { if (!this.origin_to_history[request.originalURL][shorthost]) {
const cluster = new RequestCluster(shorthost); const cluster = new RequestCluster(shorthost);
this.origin_to_history[request.origin][shorthost] = cluster; this.origin_to_history[request.originalURL][shorthost] = cluster;
} }
this.origin_to_history[request.origin][shorthost].add(request); this.origin_to_history[request.originalURL][shorthost].add(request);
this.emit("change"); this.emit("change");
} }

View File

@ -1,47 +1,8 @@
import React, { useState } from "react"; import React from "react";
import ReactDOM from "react-dom"; import ReactDOM from "react-dom";
import { getMemory } from "../memory"; import { getMemory } from "../memory";
import { RequestCluster } from "../request-cluster";
import { Classifications } from "../stolen-data-entry";
import { getDate } from "../util";
const emailClassifications: Record<keyof typeof Classifications, string> = {
id: "sztucznie nadane mi ID",
history: "część mojej historii przeglądania",
};
type PopupState = "not_clicked" | "clicked_but_invalid";
function DomainSummary({ cluster }: { cluster: RequestCluster }) {
return (
<li>
Właściciel domeny {cluster.id} otrzymał:{" "}
<ul>
{cluster
.getMarkedEntries()
.sort((entryA, entryB) => (entryA.value > entryB.value ? -1 : 1))
.reduce((acc, entry, index, arr) => {
if (index === 0) {
return [entry];
}
if (entry.value != arr[index - 1].value) {
acc.push(entry);
}
return acc;
}, [])
.map((entry) => (
<li>
{emailClassifications[entry.classification]} w {entry.source}
&nbsp;(<code>{entry.name.trim()}</code>)
</li>
))}
</ul>
</li>
);
}
function Report() { function Report() {
const [popupState, setPopupState] = useState<PopupState>("not_clicked");
const origin = new URL(document.location.toString()).searchParams.get( const origin = new URL(document.location.toString()).searchParams.get(
"origin" "origin"
); );
@ -103,35 +64,6 @@ function Report() {
))} ))}
</tbody> </tbody>
</table> </table>
<label htmlFor="popupState">Status okienka o rodo:</label>
<select
id="popupState"
value={popupState}
onChange={(e) => setPopupState(e.target.value as PopupState)}
>
<option value="not_clicked">Nic nie kliknięte</option>
<option value="clicked_but_invalid">Kliknięte, ale nieważne</option>
</select>
<div>
<p>
Dzień dobry, w dniu {getDate()} odwiedziłem stronę{" "}
{marked_entries[0].request.originalURL}. Strona ta wysłała moje dane
osobowe do podmiotów trzecich - bez mojej zgody.{" "}
</p>
<ul>
{Object.values(clusters)
.filter((cluster) => cluster.hasMarks())
.map((cluster) => (
<DomainSummary cluster={cluster} />
))}
</ul>
{popupState === "not_clicked" ? (
<p>
Dane te zostały wysłane przez Państwa stronę zanim zdążyłem w ogóle
przeczytać treść wyskakującego okienka ze zgodami.
</p>
) : null}
</div>
</div> </div>
); );
} }

View File

@ -2,7 +2,7 @@ import { EventEmitter } from "events";
import ExtendedRequest from "./extended-request"; import ExtendedRequest from "./extended-request";
import { MergedStolenDataEntry, StolenDataEntry } from "./stolen-data-entry"; import { MergedStolenDataEntry, StolenDataEntry } from "./stolen-data-entry";
import { allSubhosts, reduceConcat, unique } from "./util"; import { allSubhosts, unique } from "./util";
export class RequestCluster extends EventEmitter { export class RequestCluster extends EventEmitter {
public requests: ExtendedRequest[] = []; public requests: ExtendedRequest[] = [];
@ -93,14 +93,4 @@ export class RequestCluster extends EventEmitter {
.reduce((a, b) => a.concat(b), []) .reduce((a, b) => a.concat(b), [])
); );
} }
hasMarks() {
return this.requests.some((request) => request.hasMark());
}
getMarkedEntries() {
return this.requests
.map((request) => request.getMarkedEntries())
.reduce(reduceConcat, []);
}
} }

View File

@ -2,7 +2,6 @@ import { TCModel } from "@iabtcf/core";
import ExtendedRequest from "./extended-request"; import ExtendedRequest from "./extended-request";
import { getMemory } from "./memory"; import { getMemory } from "./memory";
import { import {
getshorthost,
isJSONObject, isJSONObject,
isURL, isURL,
parseToObject, parseToObject,
@ -128,22 +127,11 @@ export class StolenDataEntry {
} }
private classify(): keyof typeof Classifications { private classify(): keyof typeof Classifications {
let result: keyof typeof Classifications; if (this.value.includes(this.request.originalURL)) {
if ( return "history";
[this.value, decodeURIComponent(this.value)].some((haystack) =>
[
this.request.origin,
this.request.originalURL,
getshorthost(this.request.origin),
].some((needle) => haystack.includes(needle))
)
) {
result = "history";
} else { } else {
result = "id"; return "id";
} }
console.log("classifying", this.value, result, this.request.origin);
return result;
} }
isRelatedToID() { isRelatedToID() {

View File

@ -99,10 +99,3 @@ export function allSubhosts(host: string) {
export function reduceConcat<T>(a: T[], b: T[]): T[] { export function reduceConcat<T>(a: T[], b: T[]): T[] {
return a.concat(b); return a.concat(b);
} }
export function getDate() {
const d = new Date();
return `${d.getFullYear()}-${(d.getMonth() + 1)
.toString()
.padStart(2, "0")}-${d.getDate().toString().padStart(2, "0")}`;
}