2022-01-27 22:30:57 +01:00
|
|
|
import React from 'react';
|
2022-04-13 11:44:59 +02:00
|
|
|
import { getMemory } from '../../memory';
|
|
|
|
import { StolenDataEntry } from '../../stolen-data-entry';
|
2021-11-07 17:18:17 +01:00
|
|
|
|
2022-04-13 11:44:59 +02:00
|
|
|
import { maskString, useEmitter } from '../../util';
|
2022-01-20 19:03:03 +01:00
|
|
|
|
|
|
|
import './stolen-data-cluster.scss';
|
2021-11-07 10:09:41 +01:00
|
|
|
|
2021-11-21 22:38:32 +01:00
|
|
|
const MAX_STRING_VALUE_LENGTH = 100;
|
|
|
|
|
2022-02-07 15:28:01 +01:00
|
|
|
function StolenDataValue({ entry }: { entry: StolenDataEntry; prefixKey?: string }) {
|
2022-01-19 14:12:52 +01:00
|
|
|
const [version] = useEmitter(entry);
|
|
|
|
let body = null;
|
|
|
|
if (!entry.value) {
|
|
|
|
body = <></>;
|
|
|
|
} else {
|
|
|
|
body = (
|
2022-02-07 15:28:01 +01:00
|
|
|
<div data-version={version}>{maskString(entry.value, 1, MAX_STRING_VALUE_LENGTH)}</div>
|
2022-01-19 14:12:52 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return (
|
2022-01-20 19:03:03 +01:00
|
|
|
<td
|
|
|
|
className="value"
|
2022-01-19 14:12:52 +01:00
|
|
|
onClick={(e) => {
|
|
|
|
entry.toggleMark();
|
2022-02-07 15:28:01 +01:00
|
|
|
getMemory().emit('change', false, entry.request.shorthost, 'clicked value');
|
2022-01-19 14:12:52 +01:00
|
|
|
e.stopPropagation();
|
|
|
|
}}
|
2022-01-20 19:49:27 +01:00
|
|
|
title={maskString(entry.value, 1, MAX_STRING_VALUE_LENGTH)}
|
2022-01-19 14:12:52 +01:00
|
|
|
>
|
|
|
|
{body}
|
2022-01-20 19:03:03 +01:00
|
|
|
</td>
|
2021-11-07 13:01:01 +01:00
|
|
|
);
|
2021-11-07 10:09:41 +01:00
|
|
|
}
|
2021-11-07 09:17:19 +01:00
|
|
|
|
2022-02-07 15:28:01 +01:00
|
|
|
function StolenDataRow({ entry }: { entry: StolenDataEntry }) {
|
2022-01-19 14:12:52 +01:00
|
|
|
const [version] = useEmitter(entry);
|
|
|
|
return (
|
2022-01-20 19:03:03 +01:00
|
|
|
<tr
|
|
|
|
data-key={entry.id}
|
|
|
|
data-version={version}
|
|
|
|
className={`${entry.isMarked ? 'toggled' : 'untoggled'}`}
|
|
|
|
>
|
|
|
|
<td className="checkbox">
|
2022-01-19 14:12:52 +01:00
|
|
|
<input
|
|
|
|
type="checkbox"
|
|
|
|
checked={entry.isMarked}
|
|
|
|
onChange={() => {
|
|
|
|
entry.toggleMark();
|
2022-02-07 15:28:01 +01:00
|
|
|
getMemory().emit(
|
|
|
|
'change',
|
|
|
|
false,
|
|
|
|
entry.request.shorthost,
|
|
|
|
'clicked checkbox'
|
|
|
|
);
|
2022-01-19 14:12:52 +01:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</td>
|
|
|
|
<th
|
2022-01-20 19:49:27 +01:00
|
|
|
title={`Nazwa: ${entry.name}\nŹródło: ${entry.source}`}
|
2022-01-19 14:12:52 +01:00
|
|
|
onClick={() => {
|
|
|
|
entry.toggleMark();
|
2022-02-07 15:28:01 +01:00
|
|
|
getMemory().emit(
|
|
|
|
'change',
|
|
|
|
false,
|
|
|
|
entry.request.shorthost,
|
|
|
|
'Clicked entry name'
|
|
|
|
);
|
2022-01-19 14:12:52 +01:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
{entry.name}
|
|
|
|
</th>
|
2022-01-20 19:03:03 +01:00
|
|
|
<td className="icons">
|
2022-01-19 14:12:52 +01:00
|
|
|
{entry.source === 'cookie' ? (
|
2022-01-20 19:03:03 +01:00
|
|
|
<span title="Dane przechowywane w Cookies">
|
2022-01-29 20:41:03 +01:00
|
|
|
<img
|
|
|
|
src="/assets/icons/cookie.svg"
|
2022-01-20 19:03:03 +01:00
|
|
|
height={16}
|
|
|
|
width={16}
|
|
|
|
className="cookie-data"
|
|
|
|
/>
|
|
|
|
</span>
|
2022-01-19 14:12:52 +01:00
|
|
|
) : entry.request.hasCookie() ? (
|
2022-02-07 15:28:01 +01:00
|
|
|
<span title="Wysłane w zapytaniu opatrzonym Cookies" style={{ opacity: 0.25 }}>
|
2022-01-29 20:41:03 +01:00
|
|
|
<img
|
|
|
|
src="/assets/icons/cookie.svg"
|
2022-01-20 19:03:03 +01:00
|
|
|
height={16}
|
|
|
|
width={16}
|
|
|
|
className="request-with-cookie"
|
|
|
|
/>
|
2022-01-19 14:12:52 +01:00
|
|
|
</span>
|
|
|
|
) : null}
|
|
|
|
{entry.exposesOrigin() ? (
|
2022-01-20 19:03:03 +01:00
|
|
|
<span title="Pokazuje część historii przeglądania">
|
2022-01-29 20:41:03 +01:00
|
|
|
<img
|
|
|
|
src="/assets/icons/warning.svg"
|
2022-01-20 19:03:03 +01:00
|
|
|
height={16}
|
|
|
|
width={16}
|
|
|
|
className="show-history-part"
|
|
|
|
/>
|
|
|
|
</span>
|
2022-01-19 14:12:52 +01:00
|
|
|
) : entry.request.exposesOrigin() ? (
|
|
|
|
<span
|
|
|
|
title="Jest częścią zapytania, które ujawnia historię przeglądania"
|
2022-01-20 19:03:03 +01:00
|
|
|
style={{ opacity: 0.25 }}
|
2022-01-19 14:12:52 +01:00
|
|
|
>
|
2022-01-29 20:41:03 +01:00
|
|
|
<img
|
|
|
|
src="/assets/icons/warning.svg"
|
2022-01-20 19:03:03 +01:00
|
|
|
height={16}
|
|
|
|
width={16}
|
|
|
|
className="request-with-history-part"
|
|
|
|
/>
|
2022-01-19 14:12:52 +01:00
|
|
|
</span>
|
|
|
|
) : null}
|
|
|
|
</td>
|
2022-02-07 15:28:01 +01:00
|
|
|
<StolenDataValue entry={entry} />
|
2022-01-19 14:12:52 +01:00
|
|
|
</tr>
|
|
|
|
);
|
2021-11-21 23:00:55 +01:00
|
|
|
}
|
|
|
|
|
2021-11-07 11:18:53 +01:00
|
|
|
export default function StolenDataCluster({
|
2022-01-19 14:12:52 +01:00
|
|
|
origin,
|
|
|
|
shorthost,
|
|
|
|
minValueLength,
|
|
|
|
cookiesOnly,
|
2022-02-07 15:28:01 +01:00
|
|
|
refreshToken,
|
2022-01-19 14:12:52 +01:00
|
|
|
cookiesOrOriginOnly,
|
2022-04-15 13:58:29 +02:00
|
|
|
detailsVisibility,
|
2021-11-07 09:17:19 +01:00
|
|
|
}: {
|
2022-01-19 14:12:52 +01:00
|
|
|
origin: string;
|
|
|
|
shorthost: string;
|
|
|
|
refreshToken: number;
|
|
|
|
minValueLength: number;
|
|
|
|
cookiesOnly: boolean;
|
|
|
|
cookiesOrOriginOnly: boolean;
|
2022-04-15 13:58:29 +02:00
|
|
|
detailsVisibility: boolean;
|
2021-11-07 09:17:19 +01:00
|
|
|
}) {
|
2022-01-19 14:12:52 +01:00
|
|
|
const cluster = getMemory().getClustersForOrigin(origin)[shorthost];
|
2022-01-20 19:03:03 +01:00
|
|
|
const fullHosts = cluster.getFullHosts();
|
|
|
|
|
2022-02-07 15:28:01 +01:00
|
|
|
/* console.log('Stolen data cluster!', shorthost, refreshToken); */
|
|
|
|
|
2022-01-19 14:12:52 +01:00
|
|
|
return (
|
2022-01-20 19:03:03 +01:00
|
|
|
<div className="stolen-data-cluster-container">
|
|
|
|
<header className="domains-container">
|
|
|
|
<a className="domain" href={'https://' + cluster.id}>
|
|
|
|
{cluster.id}
|
2022-01-19 14:12:52 +01:00
|
|
|
</a>
|
2022-01-20 19:03:03 +01:00
|
|
|
<div className="subdomains-container">
|
|
|
|
{fullHosts.map((host, index) => (
|
2022-02-07 15:28:01 +01:00
|
|
|
<a className="subdomain" key={host} href={`https://${host}`}>
|
|
|
|
{host} {`${fullHosts.length - 1 !== index ? '· ' : ''}`}
|
2022-01-20 19:03:03 +01:00
|
|
|
</a>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</header>
|
2022-04-15 13:58:29 +02:00
|
|
|
|
|
|
|
{detailsVisibility ? (
|
|
|
|
<section>
|
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th className="table-header" colSpan={4}>
|
|
|
|
Wysłane dane:
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{cluster
|
|
|
|
.calculateRepresentativeStolenData({
|
|
|
|
minValueLength,
|
|
|
|
cookiesOnly,
|
|
|
|
cookiesOrOriginOnly,
|
|
|
|
})
|
|
|
|
.map((entry) => (
|
|
|
|
<StolenDataRow
|
|
|
|
{...{
|
|
|
|
entry,
|
|
|
|
key: entry.id,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</section>
|
|
|
|
) : null}
|
2022-01-19 14:12:52 +01:00
|
|
|
</div>
|
|
|
|
);
|
2021-11-07 09:17:19 +01:00
|
|
|
}
|