mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-04-26 23:49:59 -07:00
show informational logs, skipped reasons, and some formatting fixes
This commit is contained in:
@@ -4,8 +4,15 @@ import { req } from "./utils.svelte";
|
||||
export type AnalysisReport = {
|
||||
metadata: ReportMetadata;
|
||||
rows: AnalysisRow[];
|
||||
statistics: ReportStatistics;
|
||||
};
|
||||
|
||||
export type ReportStatistics = {
|
||||
num_warnings: number;
|
||||
num_informational_logs: number;
|
||||
num_skipped_packets: number;
|
||||
}
|
||||
|
||||
export type ReportMetadata = {
|
||||
analyzers: AnalyzerMetadata[];
|
||||
rayhunter: RayhunterMetadata;
|
||||
@@ -57,17 +64,22 @@ export type InformationalEvent = {
|
||||
|
||||
export function parse_finished_report(report_json: NewlineDeliminatedJson): AnalysisReport {
|
||||
const metadata: ReportMetadata = report_json[0]; // this can be cast directly
|
||||
let num_warnings = 0;
|
||||
let num_informational_logs = 0;
|
||||
let num_skipped_packets = 0;
|
||||
const rows: AnalysisRow[] = report_json.slice(1).map((row_json: any) => {
|
||||
const analysis: PacketAnalysis[] = row_json.analysis.map((analysis_json: any) => {
|
||||
const events: Event[] = analysis_json.events.map((event_json: any): Event | null => {
|
||||
if (event_json === null) {
|
||||
return null;
|
||||
} else if (event_json.event_type === "Informational") {
|
||||
num_informational_logs += 1;
|
||||
return {
|
||||
type: EventType.Informational,
|
||||
message: event_json.message,
|
||||
};
|
||||
} else {
|
||||
num_warnings += 1;
|
||||
return {
|
||||
type: EventType.Warning,
|
||||
severity: event_json.severity === "High" ? Severity.High :
|
||||
@@ -82,6 +94,7 @@ export function parse_finished_report(report_json: NewlineDeliminatedJson): Anal
|
||||
events,
|
||||
};
|
||||
});
|
||||
num_skipped_packets += row_json.skipped_message_reasons.length;
|
||||
return {
|
||||
timestamp: new Date(row_json.timestamp),
|
||||
skipped_message_reasons: row_json.skipped_message_reasons,
|
||||
@@ -89,6 +102,11 @@ export function parse_finished_report(report_json: NewlineDeliminatedJson): Anal
|
||||
};
|
||||
});
|
||||
return {
|
||||
statistics: {
|
||||
num_informational_logs,
|
||||
num_warnings,
|
||||
num_skipped_packets,
|
||||
},
|
||||
metadata,
|
||||
rows,
|
||||
};
|
||||
|
||||
@@ -10,32 +10,75 @@
|
||||
timeStyle: "long",
|
||||
dateStyle: "short",
|
||||
});
|
||||
|
||||
const skipped_messages: Map<string, number> = $derived.by(() => {
|
||||
let map = new Map();
|
||||
for (const row of report.rows) {
|
||||
for (const message of row.skipped_message_reasons) {
|
||||
let count = map.get(message);
|
||||
if (count === undefined) {
|
||||
count = 0;
|
||||
}
|
||||
map.set(message, count + 1);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
});
|
||||
</script>
|
||||
|
||||
<p class="text-lg underline">Warnings</p>
|
||||
<table class="table-auto text-left border">
|
||||
<thead class="p-2">
|
||||
<tr class="bg-gray-300">
|
||||
<th scope="col">Timestamp</th>
|
||||
<th scope="col">Warning</th>
|
||||
<th scope="col">Severity</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each report.rows as row, row_idx}
|
||||
{#each row.analysis as analysis}
|
||||
{@const parsed_date = new Date(analysis.timestamp)}
|
||||
{@const warnings = analysis.events.filter(e => e.type === EventType.Warning)}
|
||||
{#each warnings as warning}
|
||||
{@const severity = ['Low', 'Medium', 'High'][warning.severity]}
|
||||
{@const severity_class = ['bg-red-200', 'bg-red-400', 'bg-red-600'][warning.severity]}
|
||||
<tr class="even:bg-gray-400 border-b">
|
||||
<th class="p-2">{date_formatter.format(parsed_date)}</th>
|
||||
<td class="p-2">{warning.message}</td>
|
||||
<td class="p-2 {severity_class}">{severity}</td>
|
||||
</tr>
|
||||
<p class="text-lg underline">Warnings and Informational Logs</p>
|
||||
{#if report.statistics.num_warnings === 0 && report.statistics.num_informational_logs === 0}
|
||||
<p>Nothing to show!</p>
|
||||
{:else}
|
||||
<table class="table-auto text-left border">
|
||||
<thead class="p-2">
|
||||
<tr class="bg-gray-300">
|
||||
<th scope="col">Timestamp</th>
|
||||
<th scope="col">Warning</th>
|
||||
<th scope="col">Severity</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each report.rows as row, row_idx}
|
||||
{#each row.analysis as analysis}
|
||||
{@const parsed_date = new Date(analysis.timestamp)}
|
||||
{#each analysis.events.filter(e => e !== null) as event}
|
||||
<tr class="even:bg-gray-200 border-b">
|
||||
{#if event.type === EventType.Warning}
|
||||
{@const severity = ['Low', 'Medium', 'High'][event.severity]}
|
||||
{@const severity_class = ['bg-red-200', 'bg-red-400', 'bg-red-600'][event.severity]}
|
||||
<th class="p-2">{date_formatter.format(parsed_date)}</th>
|
||||
<td class="p-2">{event.message}</td>
|
||||
<td class="p-2 {severity_class}">{severity}</td>
|
||||
{:else if event.type === EventType.Informational}
|
||||
<th class="p-2">{date_formatter.format(parsed_date)}</th>
|
||||
<td class="p-2">{event.message}</td>
|
||||
<td class="p-2">Info</td>
|
||||
{/if}
|
||||
</tr>
|
||||
{/each}
|
||||
{/each}
|
||||
{/each}
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
{#if report.statistics.num_skipped_packets > 0}
|
||||
<p class="text-lg underline">Unparsed Messages</p>
|
||||
<p>These are due to a limitation or bug in Rayhunter's parser, and aren't ususally a problem.</p>
|
||||
<table class="table-auto text-left border">
|
||||
<thead class="p-2">
|
||||
<tr class="bg-gray-300">
|
||||
<th scope="col"># of messages affected</th>
|
||||
<th scope="col">Reason/Error</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each skipped_messages.entries() as [message, count]}
|
||||
<tr class="even:bg-gray-200 border-b">
|
||||
<td>{count}</td>
|
||||
<td>{message}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<p>Error getting analysis report: {entry.analysis_report}</p>
|
||||
{:else}
|
||||
{@const metadata: ReportMetadata = entry.analysis_report.metadata}
|
||||
<div class="flex flex-col p-2 w-3/4">
|
||||
<div class="flex flex-col pl-2 pr-10 w-full">
|
||||
{#if entry.analysis_report.rows.length > 0}
|
||||
<AnalysisTable report={entry.analysis_report} />
|
||||
{:else}
|
||||
@@ -28,7 +28,7 @@
|
||||
{/if}
|
||||
<div>
|
||||
<p class="text-lg underline">Metadata</p>
|
||||
<p><b>Rayhunter version:</b> {metadata.rayhunter.rayhunter_version}</p>
|
||||
<p>Analysis by Rayhunter version {metadata.rayhunter.rayhunter_version}</p>
|
||||
<p><b>Device system OS:</b> {metadata.rayhunter.system_os}</p>
|
||||
<p class="text-lg underline">Analyzers</p>
|
||||
{#each metadata.analyzers as analyzer}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</td>
|
||||
{/if}
|
||||
</tr>
|
||||
<tr class="{row_color} border-b {analysis_visible ? '' : 'collapse'}">
|
||||
<tr class="{normal_row_color} border-b {analysis_visible ? '' : 'collapse'}">
|
||||
<td class="font-bold p-2 bg-blue-100"></td>
|
||||
<td class="border-t border-dashed p-2" colspan="7">
|
||||
<AnalysisView {entry} />
|
||||
|
||||
Reference in New Issue
Block a user