diff --git a/report-window/domain-summary.tsx b/report-window/domain-summary.tsx
index 02c6510..ffeee98 100644
--- a/report-window/domain-summary.tsx
+++ b/report-window/domain-summary.tsx
@@ -25,13 +25,16 @@ export default function DomainSummary({
Właściciel domeny {cluster.id} otrzymał:{" "}
- Mój adres IP
- {cluster.getRepresentativeStolenData().map((entry) => (
- -
- {emailClassifications[entry.classification]}{" "}
- {emailSources[entry.source]} (nazwa:
{entry.name},{" "}
- wartość: {entry.getValuePreview()})
-
- ))}
+ {cluster
+ .getRepresentativeStolenData()
+ .filter((entry) => entry.isMarked)
+ .map((entry) => (
+ -
+ {emailClassifications[entry.classification]}{" "}
+ {emailSources[entry.source]} (nazwa:
{entry.name},{" "}
+ wartość: {entry.getValuePreview()})
+
+ ))}
);
diff --git a/sidebar/stolen-data-cluster.tsx b/sidebar/stolen-data-cluster.tsx
index 71836bb..3378d8b 100644
--- a/sidebar/stolen-data-cluster.tsx
+++ b/sidebar/stolen-data-cluster.tsx
@@ -1,9 +1,8 @@
import React from "react";
import { getMemory } from "../memory";
-import { RequestCluster } from "../request-cluster";
-import { Sources, StolenDataEntry } from "../stolen-data-entry";
+import { StolenDataEntry } from "../stolen-data-entry";
-import { useEmitter } from "../util";
+import { maskString, useEmitter } from "../util";
const MAX_STRING_VALUE_LENGTH = 100;
@@ -20,8 +19,7 @@ function StolenDataValue({
} else {
body = (
- {entry.value.slice(0, MAX_STRING_VALUE_LENGTH)}{" "}
- {entry.value.length > MAX_STRING_VALUE_LENGTH ? "(...)" : ""}
+ {maskString(entry.value, 1, MAX_STRING_VALUE_LENGTH)}
);
}
@@ -37,13 +35,6 @@ function StolenDataValue({
);
}
-const icons: Record = {
- cookie: "🍪",
- pathname: "🛣",
- queryparams: "🅿",
- header: "H",
-};
-
function StolenDataRow({ entry }: { entry: StolenDataEntry }) {
const [version] = useEmitter(entry);
return (
@@ -65,12 +56,24 @@ function StolenDataRow({ entry }: { entry: StolenDataEntry }) {
{entry.name}
- {[entry.source].map((source) => icons[source])}
+ {entry.source === "cookie" ? (
+ 🍪
+ ) : entry.request.hasCookie() ? (
+
+ 🍪
+
+ ) : null}
{entry.exposesOrigin() ? (
- 🔴
+ ⚠️
) : entry.request.exposesOrigin() ? (
-
- 🟡
+
+ ⚠️
) : null}
|
diff --git a/stolen-data-entry.ts b/stolen-data-entry.ts
index 43d62bc..beaffc0 100644
--- a/stolen-data-entry.ts
+++ b/stolen-data-entry.ts
@@ -8,6 +8,7 @@ import {
isBase64JSON,
isJSONObject,
isURL,
+ maskString,
parseToObject,
} from "./util";
@@ -198,9 +199,7 @@ export class StolenDataEntry extends EventEmitter {
? (value[Symbol.for("originalString")] as string)
: value.toString();
if (typeof value !== "object" && this.classification == "id") {
- return (
- str.slice(0, Math.min(str.length / 3, ID_PREVIEW_MAX_LENGTH)) + "(...)"
- );
+ return maskString(value, 1 / 3, ID_PREVIEW_MAX_LENGTH);
} else if (
typeof value === "object" &&
value[Symbol.for("originalString")]
diff --git a/test.ts b/test.ts
index 0efadd7..830ef9d 100644
--- a/test.ts
+++ b/test.ts
@@ -1,3 +1,7 @@
-import { flattenObject } from "./util";
+import { flattenObject, maskString } from "./util";
console.log(flattenObject({ a: { b: { c: [1, 2, 3] } } }));
+
+console.log(maskString("abcdefghijklmnopqrstuvwxyz", 1 / 3, 5));
+
+console.log(maskString("abcdefghijklmnopqrstuvwxyz", 1, 30));
diff --git a/util.ts b/util.ts
index f7ffc96..6eca30a 100644
--- a/util.ts
+++ b/util.ts
@@ -211,3 +211,20 @@ export function flattenObjectEntries(
): [string, string][] {
return flattenObject(Object.fromEntries(entries));
}
+
+export function maskString(
+ str: string,
+ max_fraction_remaining: number,
+ max_chars_total: number
+): string {
+ const amount_of_chars_to_cut =
+ str.length - Math.min(str.length * max_fraction_remaining, max_chars_total);
+ if (amount_of_chars_to_cut == 0) {
+ return str;
+ }
+ return (
+ str.slice(0, str.length / 2 - amount_of_chars_to_cut / 2) +
+ "(...)" +
+ str.slice(str.length / 2 + amount_of_chars_to_cut / 2)
+ );
+}