2021-11-08 20:14:28 +01:00
|
|
|
import React from "react";
|
2021-11-07 13:57:24 +01:00
|
|
|
import ReactDOM from "react-dom";
|
2021-11-07 17:23:48 +01:00
|
|
|
import { getMemory } from "../memory";
|
2021-11-11 20:25:06 +01:00
|
|
|
import { Classifications } from "../stolen-data-entry";
|
2021-11-21 18:21:31 +01:00
|
|
|
import { reduceConcat, useEmitter } from "../util";
|
2021-11-08 20:14:28 +01:00
|
|
|
import EmailTemplate from "./email-template";
|
|
|
|
import HARConverter from "./har-converter";
|
2021-11-07 13:57:24 +01:00
|
|
|
|
|
|
|
function Report() {
|
2021-11-07 15:45:26 +01:00
|
|
|
const origin = new URL(document.location.toString()).searchParams.get(
|
|
|
|
"origin"
|
|
|
|
);
|
2021-11-11 20:25:06 +01:00
|
|
|
const [counter, setCounter] = useEmitter(getMemory());
|
|
|
|
function refresh() {
|
|
|
|
setCounter((c) => c + 1);
|
|
|
|
}
|
2021-11-07 15:45:26 +01:00
|
|
|
const clusters = getMemory().getClustersForOrigin(origin);
|
2021-11-22 17:54:15 +01:00
|
|
|
const entries = Object.values(clusters)
|
|
|
|
.map((cluster) => cluster.getRepresentativeStolenData())
|
|
|
|
.reduce(reduceConcat, [])
|
|
|
|
.filter((entry) => entry.isMarked);
|
2021-11-07 13:57:24 +01:00
|
|
|
return (
|
2021-11-21 18:21:31 +01:00
|
|
|
<div {...{ "data-version": counter }}>
|
2021-11-07 15:45:26 +01:00
|
|
|
<h1>Generuj treść maila dla {origin}</h1>
|
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Adres docelowy</th>
|
|
|
|
<th>Źródło danych</th>
|
|
|
|
<th>Treść danych</th>
|
2021-11-07 17:44:22 +01:00
|
|
|
<th>Klasyfikacja</th>
|
2021-11-07 15:45:26 +01:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2021-11-22 17:54:15 +01:00
|
|
|
{entries.map((entry) => (
|
2021-11-07 17:51:30 +01:00
|
|
|
<tr
|
2021-11-22 17:54:15 +01:00
|
|
|
key={entry.id}
|
2021-11-07 17:51:30 +01:00
|
|
|
style={{
|
|
|
|
backgroundColor:
|
2021-11-22 17:54:15 +01:00
|
|
|
entry.classification == "id" ? "yellow" : "white",
|
2021-11-07 17:51:30 +01:00
|
|
|
}}
|
|
|
|
>
|
2021-11-22 17:54:15 +01:00
|
|
|
<td>{entry.request.shorthost}</td>
|
2021-11-07 17:44:22 +01:00
|
|
|
<td style={{ overflowWrap: "anywhere" }}>
|
2021-11-22 17:54:15 +01:00
|
|
|
{entry.source}:{entry.name}
|
2021-11-07 15:45:26 +01:00
|
|
|
</td>
|
2021-11-07 17:51:30 +01:00
|
|
|
<td
|
|
|
|
style={{
|
|
|
|
width: "400px",
|
|
|
|
overflowWrap: "anywhere",
|
2021-11-22 17:54:15 +01:00
|
|
|
backgroundColor: entry.isRelatedToID()
|
2021-11-07 17:59:16 +01:00
|
|
|
? "#ffff0054"
|
|
|
|
: "white",
|
2021-11-07 17:51:30 +01:00
|
|
|
}}
|
|
|
|
>
|
2021-11-22 17:54:15 +01:00
|
|
|
{entry.getValuePreview()}
|
2021-11-21 18:21:31 +01:00
|
|
|
{/* always gonna have
|
2021-11-21 22:38:32 +01:00
|
|
|
one key, because unwrapEntry is called above */}
|
2021-11-07 17:44:22 +01:00
|
|
|
</td>
|
2021-11-07 15:45:26 +01:00
|
|
|
<td>
|
2021-11-11 20:25:06 +01:00
|
|
|
<select
|
2021-11-22 17:54:15 +01:00
|
|
|
value={entry.classification}
|
2021-11-11 20:25:06 +01:00
|
|
|
onChange={(e) => {
|
2021-11-22 17:54:15 +01:00
|
|
|
entry.classification = e.target
|
2021-11-11 20:25:06 +01:00
|
|
|
.value as keyof typeof Classifications;
|
|
|
|
refresh();
|
|
|
|
}}
|
|
|
|
>
|
2021-11-07 15:45:26 +01:00
|
|
|
{[
|
|
|
|
["history", "Historia przeglądania"],
|
|
|
|
["id", "Sztucznie nadane id"],
|
2021-11-21 18:21:31 +01:00
|
|
|
["location", "Lokalizacja"],
|
2021-11-07 15:45:26 +01:00
|
|
|
].map(([key, name]) => (
|
|
|
|
<option key={key} value={key}>
|
|
|
|
{name}
|
|
|
|
</option>
|
|
|
|
))}
|
|
|
|
</select>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
))}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2021-11-22 17:54:15 +01:00
|
|
|
<EmailTemplate {...{ entries, clusters, version: counter }} />
|
|
|
|
<HARConverter {...{ entries }} />
|
2021-11-07 13:57:24 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(<Report />, document.getElementById("app"));
|