Compare commits

..

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

4 changed files with 18 additions and 20 deletions

View File

@ -16,7 +16,7 @@ export default class ExtendedRequest {
public url: string; public url: string;
public shorthost: string; public shorthost: string;
public requestHeaders: Request["requestHeaders"]; public requestHeaders: Request["requestHeaders"];
public originalURL: string; public origin: string;
public initialized = false; public initialized = false;
public stolenData: StolenDataEntry[]; public stolenData: StolenDataEntry[];
@ -34,19 +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 = new URL(url).origin; this.origin = new URL(url).origin;
} }
getOriginalURL(): string { getOrigin(): string {
if (!this.initialized) { if (!this.initialized) {
throw new Error("initialize first!!"); throw new Error("initialize first!!");
} }
return this.originalURL; return this.origin;
} }
isThirdParty() { isThirdParty() {
const request_url = new URL(this.data.url); const request_url = new URL(this.data.url);
const origin_url = new URL(this.getOriginalURL()); const origin_url = new URL(this.getOrigin());
if (request_url.host.includes(origin_url.host)) { if (request_url.host.includes(origin_url.host)) {
return false; return false;
} }
@ -65,7 +65,7 @@ export default class ExtendedRequest {
} }
exposesOrigin() { exposesOrigin() {
const url = new URL(this.getOriginalURL()); const url = new URL(this.getOrigin());
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.originalURL); console.log("registering request for", request.origin);
if (!request.isThirdParty()) { if (!request.isThirdParty()) {
return; return;
} }
if (!this.origin_to_history[request.originalURL]) { if (!this.origin_to_history[request.origin]) {
this.origin_to_history[request.originalURL] = {}; this.origin_to_history[request.origin] = {};
} }
const shorthost = getshorthost(new URL(request.url).host); 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); 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"); this.emit("change");
} }

View File

@ -41,9 +41,7 @@ function Report() {
style={{ style={{
width: "400px", width: "400px",
overflowWrap: "anywhere", overflowWrap: "anywhere",
backgroundColor: entry.isRelatedToID() backgroundColor: entry.isRelatedToID() ? "yellow" : "white",
? "#ffff0054"
: "white",
}} }}
> >
{entry.value} {entry.value}

View File

@ -49,7 +49,7 @@ export class StolenDataEntry {
getPriority() { getPriority() {
let priority = 0; let priority = 0;
priority += Math.min(this.value.length, 50); priority += Math.min(this.value.length, 50);
const url = new URL(this.request.originalURL); const url = new URL(this.request.getOrigin());
if (this.value.includes(url.host)) { if (this.value.includes(url.host)) {
priority += 100; priority += 100;
} }
@ -127,7 +127,7 @@ export class StolenDataEntry {
} }
private classify(): keyof typeof Classifications { private classify(): keyof typeof Classifications {
if (this.value.includes(this.request.originalURL)) { if (this.value.includes(this.request.origin)) {
return "history"; return "history";
} else { } else {
return "id"; return "id";
@ -172,15 +172,15 @@ export class MergedStolenDataEntry {
} }
getNames(): string[] { getNames(): string[] {
return unique(this.entries.map((e) => e.name)); return Array.from(new Set(this.entries.map((e) => e.name)));
} }
getSources(): string[] { getSources(): string[] {
return unique(this.entries.map((e) => e.source)); return Array.from(new Set(this.entries.map((e) => e.source)));
} }
getValues() { getValues() {
return unique(this.entries.map((e) => e.value)); return Array.from(new Set(this.entries.map((e) => e.value)));
} }
getParsedValues(key_path: string) { getParsedValues(key_path: string) {