Performance improvements
This commit is contained in:
parent
acaa9430a1
commit
de13980609
|
@ -1,6 +1,10 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { RequestCluster } from "../request-cluster";
|
import { RequestCluster } from "../request-cluster";
|
||||||
import { Classifications, Sources } from "../stolen-data-entry";
|
import {
|
||||||
|
Classifications,
|
||||||
|
Sources,
|
||||||
|
StolenDataEntry,
|
||||||
|
} from "../stolen-data-entry";
|
||||||
|
|
||||||
const emailClassifications: Record<keyof typeof Classifications, string> = {
|
const emailClassifications: Record<keyof typeof Classifications, string> = {
|
||||||
id: "sztucznie nadane mi ID",
|
id: "sztucznie nadane mi ID",
|
||||||
|
@ -25,11 +29,10 @@ export default function DomainSummary({
|
||||||
Właścicielowi domeny <strong>{cluster.id}</strong> zostały ujawnione:{" "}
|
Właścicielowi domeny <strong>{cluster.id}</strong> zostały ujawnione:{" "}
|
||||||
<ul>
|
<ul>
|
||||||
<li>Mój adres IP</li>
|
<li>Mój adres IP</li>
|
||||||
{cluster
|
{cluster.representativeStolenData
|
||||||
.getRepresentativeStolenData()
|
|
||||||
.filter((entry) => entry.isMarked)
|
.filter((entry) => entry.isMarked)
|
||||||
.map((entry) => (
|
.map((entry) => (
|
||||||
<li>
|
<li key={entry.id}>
|
||||||
{emailClassifications[entry.classification]}{" "}
|
{emailClassifications[entry.classification]}{" "}
|
||||||
{emailSources[entry.source]} (nazwa: <code>{entry.name}</code>,{" "}
|
{emailSources[entry.source]} (nazwa: <code>{entry.name}</code>,{" "}
|
||||||
wartość: <code>{entry.getValuePreview()}</code>)
|
wartość: <code>{entry.getValuePreview()}</code>)
|
||||||
|
|
|
@ -1,90 +1,123 @@
|
||||||
import React from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import ReactDOM from "react-dom";
|
import ReactDOM from "react-dom";
|
||||||
import { getMemory } from "../memory";
|
import { getMemory } from "../memory";
|
||||||
import { Classifications } from "../stolen-data-entry";
|
import { Classifications, StolenDataEntry } from "../stolen-data-entry";
|
||||||
import { reduceConcat, useEmitter } from "../util";
|
import { reduceConcat, useEmitter } from "../util";
|
||||||
import EmailTemplate from "./email-template";
|
import EmailTemplate from "./email-template";
|
||||||
import HARConverter from "./har-converter";
|
import HARConverter from "./har-converter";
|
||||||
|
|
||||||
|
function DataPreview({
|
||||||
|
entries,
|
||||||
|
refresh,
|
||||||
|
}: {
|
||||||
|
entries: StolenDataEntry[];
|
||||||
|
refresh: () => void;
|
||||||
|
}) {
|
||||||
|
// currently not used, maybe scraped entirely in the future
|
||||||
|
return (
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Adres docelowy</th>
|
||||||
|
<th>Źródło danych</th>
|
||||||
|
<th>Treść danych</th>
|
||||||
|
<th>Klasyfikacja</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{entries.map((entry) => (
|
||||||
|
<tr
|
||||||
|
key={entry.id}
|
||||||
|
style={{
|
||||||
|
backgroundColor:
|
||||||
|
entry.classification == "id" ? "yellow" : "white",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<td>{entry.request.shorthost}</td>
|
||||||
|
<td style={{ overflowWrap: "anywhere" }}>
|
||||||
|
{entry.source}:{entry.name}
|
||||||
|
</td>
|
||||||
|
<td
|
||||||
|
style={{
|
||||||
|
width: "400px",
|
||||||
|
overflowWrap: "anywhere",
|
||||||
|
backgroundColor: entry.isRelatedToID() ? "#ffff0054" : "white",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{entry.getValuePreview()}
|
||||||
|
{/* always gonna have
|
||||||
|
one key, because unwrapEntry is called above */}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select
|
||||||
|
value={entry.classification}
|
||||||
|
onChange={(e) => {
|
||||||
|
entry.classification = e.target
|
||||||
|
.value as keyof typeof Classifications;
|
||||||
|
refresh();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{[
|
||||||
|
["history", "Historia przeglądania"],
|
||||||
|
["id", "Sztucznie nadane id"],
|
||||||
|
["location", "Lokalizacja"],
|
||||||
|
].map(([key, name]) => (
|
||||||
|
<option key={key} value={key}>
|
||||||
|
{name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function Report() {
|
function Report() {
|
||||||
|
console.time("getOrigin");
|
||||||
const origin = new URL(document.location.toString()).searchParams.get(
|
const origin = new URL(document.location.toString()).searchParams.get(
|
||||||
"origin"
|
"origin"
|
||||||
);
|
);
|
||||||
|
console.timeEnd("getOrigin");
|
||||||
|
console.time("useMemory");
|
||||||
const [counter, setCounter] = useEmitter(getMemory());
|
const [counter, setCounter] = useEmitter(getMemory());
|
||||||
|
console.timeEnd("useMemory");
|
||||||
function refresh() {
|
function refresh() {
|
||||||
setCounter((c) => c + 1);
|
setCounter((c) => c + 1);
|
||||||
}
|
}
|
||||||
|
console.time("getClustersForOrigin");
|
||||||
const clusters = getMemory().getClustersForOrigin(origin);
|
const clusters = getMemory().getClustersForOrigin(origin);
|
||||||
const entries = Object.values(clusters)
|
console.timeEnd("getClustersForOrigin");
|
||||||
.map((cluster) => cluster.getRepresentativeStolenData())
|
const [entries, setEntries] = useState<StolenDataEntry[]>([]);
|
||||||
.reduce(reduceConcat, [])
|
console.time("useEffect report-window");
|
||||||
.filter((entry) => entry.isMarked);
|
useEffect(() => {
|
||||||
return (
|
setEntries(
|
||||||
|
Object.values(clusters)
|
||||||
|
.map((cluster) => {
|
||||||
|
cluster.calculatetRepresentativeStolenData();
|
||||||
|
return cluster.representativeStolenData;
|
||||||
|
})
|
||||||
|
.reduce(reduceConcat, [])
|
||||||
|
.filter((entry) => entry.isMarked)
|
||||||
|
);
|
||||||
|
}, []);
|
||||||
|
console.timeEnd("useEffect report-window");
|
||||||
|
if (entries.length == 0) {
|
||||||
|
return <>Wczytywanie...</>;
|
||||||
|
}
|
||||||
|
console.time("rendering template");
|
||||||
|
const result = (
|
||||||
<div {...{ "data-version": counter }}>
|
<div {...{ "data-version": counter }}>
|
||||||
|
{/*<DataPreview {...{entries, refresh}} */}
|
||||||
<h1>Generuj treść maila dla {origin}</h1>
|
<h1>Generuj treść maila dla {origin}</h1>
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Adres docelowy</th>
|
|
||||||
<th>Źródło danych</th>
|
|
||||||
<th>Treść danych</th>
|
|
||||||
<th>Klasyfikacja</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{entries.map((entry) => (
|
|
||||||
<tr
|
|
||||||
key={entry.id}
|
|
||||||
style={{
|
|
||||||
backgroundColor:
|
|
||||||
entry.classification == "id" ? "yellow" : "white",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<td>{entry.request.shorthost}</td>
|
|
||||||
<td style={{ overflowWrap: "anywhere" }}>
|
|
||||||
{entry.source}:{entry.name}
|
|
||||||
</td>
|
|
||||||
<td
|
|
||||||
style={{
|
|
||||||
width: "400px",
|
|
||||||
overflowWrap: "anywhere",
|
|
||||||
backgroundColor: entry.isRelatedToID()
|
|
||||||
? "#ffff0054"
|
|
||||||
: "white",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{entry.getValuePreview()}
|
|
||||||
{/* always gonna have
|
|
||||||
one key, because unwrapEntry is called above */}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<select
|
|
||||||
value={entry.classification}
|
|
||||||
onChange={(e) => {
|
|
||||||
entry.classification = e.target
|
|
||||||
.value as keyof typeof Classifications;
|
|
||||||
refresh();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{[
|
|
||||||
["history", "Historia przeglądania"],
|
|
||||||
["id", "Sztucznie nadane id"],
|
|
||||||
["location", "Lokalizacja"],
|
|
||||||
].map(([key, name]) => (
|
|
||||||
<option key={key} value={key}>
|
|
||||||
{name}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<EmailTemplate {...{ entries, clusters, version: counter }} />
|
<EmailTemplate {...{ entries, clusters, version: counter }} />
|
||||||
<HARConverter {...{ entries }} />
|
<HARConverter {...{ entries }} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
console.timeEnd("rendering template");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactDOM.render(<Report />, document.getElementById("app"));
|
ReactDOM.render(<Report />, document.getElementById("app"));
|
||||||
|
|
|
@ -13,6 +13,7 @@ const source_priority: Array<Sources> = [
|
||||||
|
|
||||||
export class RequestCluster extends EventEmitter {
|
export class RequestCluster extends EventEmitter {
|
||||||
public requests: ExtendedRequest[] = [];
|
public requests: ExtendedRequest[] = [];
|
||||||
|
public representativeStolenData: StolenDataEntry[] = [];
|
||||||
constructor(public id: string) {
|
constructor(public id: string) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -30,14 +31,14 @@ export class RequestCluster extends EventEmitter {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
getRepresentativeStolenData(
|
calculatetRepresentativeStolenData(
|
||||||
filter: {
|
filter: {
|
||||||
minValueLength: number;
|
minValueLength: number;
|
||||||
cookiesOnly: boolean;
|
cookiesOnly: boolean;
|
||||||
cookiesOrOriginOnly: boolean;
|
cookiesOrOriginOnly: boolean;
|
||||||
} = { minValueLength: 0, cookiesOnly: false, cookiesOrOriginOnly: false }
|
} = { minValueLength: 0, cookiesOnly: false, cookiesOrOriginOnly: false }
|
||||||
): StolenDataEntry[] {
|
): StolenDataEntry[] {
|
||||||
return this.requests
|
this.representativeStolenData = this.requests
|
||||||
.map((request) => request.stolenData)
|
.map((request) => request.stolenData)
|
||||||
|
|
||||||
.reduce((a, b) => a.concat(b), [])
|
.reduce((a, b) => a.concat(b), [])
|
||||||
|
@ -120,6 +121,7 @@ export class RequestCluster extends EventEmitter {
|
||||||
.sort((entry1, entry2) =>
|
.sort((entry1, entry2) =>
|
||||||
entry1.getPriority() > entry2.getPriority() ? -1 : 1
|
entry1.getPriority() > entry2.getPriority() ? -1 : 1
|
||||||
);
|
);
|
||||||
|
return this.representativeStolenData;
|
||||||
}
|
}
|
||||||
|
|
||||||
static sortCompare(a: RequestCluster, b: RequestCluster) {
|
static sortCompare(a: RequestCluster, b: RequestCluster) {
|
||||||
|
@ -165,7 +167,8 @@ export class RequestCluster extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
autoMark() {
|
autoMark() {
|
||||||
this.getRepresentativeStolenData().forEach((entry) => {
|
this.calculatetRepresentativeStolenData();
|
||||||
|
this.representativeStolenData.forEach((entry) => {
|
||||||
entry.autoMark();
|
entry.autoMark();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,13 +125,15 @@ export default function StolenDataCluster({
|
||||||
</h2>
|
</h2>
|
||||||
<div>
|
<div>
|
||||||
{cluster.getFullHosts().map((host) => (
|
{cluster.getFullHosts().map((host) => (
|
||||||
<a href={`https://${host}`}>{host}, </a>
|
<a key={host} href={`https://${host}`}>
|
||||||
|
{host},{" "}
|
||||||
|
</a>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
{cluster
|
{cluster
|
||||||
.getRepresentativeStolenData({
|
.calculatetRepresentativeStolenData({
|
||||||
minValueLength,
|
minValueLength,
|
||||||
cookiesOnly,
|
cookiesOnly,
|
||||||
cookiesOrOriginOnly,
|
cookiesOrOriginOnly,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user