Basic email summary
This commit is contained in:
parent
e8075b384d
commit
c9bc0c3a41
|
@ -17,6 +17,7 @@ export default class ExtendedRequest {
|
|||
public shorthost: string;
|
||||
public requestHeaders: Request["requestHeaders"];
|
||||
public originalURL: string;
|
||||
public origin: string;
|
||||
public initialized = false;
|
||||
public stolenData: StolenDataEntry[];
|
||||
|
||||
|
@ -34,19 +35,13 @@ export default class ExtendedRequest {
|
|||
} else {
|
||||
url = (this.data as any).frameAncestors[0].url;
|
||||
}
|
||||
this.originalURL = new URL(url).origin;
|
||||
}
|
||||
|
||||
getOriginalURL(): string {
|
||||
if (!this.initialized) {
|
||||
throw new Error("initialize first!!");
|
||||
}
|
||||
return this.originalURL;
|
||||
this.originalURL = url;
|
||||
this.origin = new URL(url).origin;
|
||||
}
|
||||
|
||||
isThirdParty() {
|
||||
const request_url = new URL(this.data.url);
|
||||
const origin_url = new URL(this.getOriginalURL());
|
||||
const origin_url = new URL(this.originalURL);
|
||||
if (request_url.host.includes(origin_url.host)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -65,7 +60,7 @@ export default class ExtendedRequest {
|
|||
}
|
||||
|
||||
exposesOrigin() {
|
||||
const url = new URL(this.getOriginalURL());
|
||||
const url = new URL(this.origin);
|
||||
const host = url.host;
|
||||
const path = url.pathname;
|
||||
return (
|
||||
|
|
12
memory.ts
12
memory.ts
|
@ -7,19 +7,19 @@ export default class Memory extends EventEmitter {
|
|||
origin_to_history = {} as Record<string, Record<string, RequestCluster>>;
|
||||
async register(request: ExtendedRequest) {
|
||||
await request.init();
|
||||
console.log("registering request for", request.originalURL);
|
||||
console.log("registering request for", request.origin);
|
||||
if (!request.isThirdParty()) {
|
||||
return;
|
||||
}
|
||||
if (!this.origin_to_history[request.originalURL]) {
|
||||
this.origin_to_history[request.originalURL] = {};
|
||||
if (!this.origin_to_history[request.origin]) {
|
||||
this.origin_to_history[request.origin] = {};
|
||||
}
|
||||
const shorthost = getshorthost(new URL(request.url).host);
|
||||
if (!this.origin_to_history[request.originalURL][shorthost]) {
|
||||
if (!this.origin_to_history[request.origin][shorthost]) {
|
||||
const cluster = new RequestCluster(shorthost);
|
||||
this.origin_to_history[request.originalURL][shorthost] = cluster;
|
||||
this.origin_to_history[request.origin][shorthost] = cluster;
|
||||
}
|
||||
this.origin_to_history[request.originalURL][shorthost].add(request);
|
||||
this.origin_to_history[request.origin][shorthost].add(request);
|
||||
this.emit("change");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,47 @@
|
|||
import React from "react";
|
||||
import React, { useState } from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
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}
|
||||
(<code>{entry.name.trim()}</code>)
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
function Report() {
|
||||
const [popupState, setPopupState] = useState<PopupState>("not_clicked");
|
||||
const origin = new URL(document.location.toString()).searchParams.get(
|
||||
"origin"
|
||||
);
|
||||
|
@ -64,6 +103,35 @@ function Report() {
|
|||
))}
|
||||
</tbody>
|
||||
</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>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import { EventEmitter } from "events";
|
|||
import ExtendedRequest from "./extended-request";
|
||||
import { MergedStolenDataEntry, StolenDataEntry } from "./stolen-data-entry";
|
||||
|
||||
import { allSubhosts, unique } from "./util";
|
||||
import { allSubhosts, reduceConcat, unique } from "./util";
|
||||
|
||||
export class RequestCluster extends EventEmitter {
|
||||
public requests: ExtendedRequest[] = [];
|
||||
|
@ -93,4 +93,14 @@ export class RequestCluster extends EventEmitter {
|
|||
.reduce((a, b) => a.concat(b), [])
|
||||
);
|
||||
}
|
||||
|
||||
hasMarks() {
|
||||
return this.requests.some((request) => request.hasMark());
|
||||
}
|
||||
|
||||
getMarkedEntries() {
|
||||
return this.requests
|
||||
.map((request) => request.getMarkedEntries())
|
||||
.reduce(reduceConcat, []);
|
||||
}
|
||||
}
|
||||
|
|
7
util.ts
7
util.ts
|
@ -99,3 +99,10 @@ export function allSubhosts(host: string) {
|
|||
export function reduceConcat<T>(a: T[], b: T[]): T[] {
|
||||
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")}`;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user