forked from MD-Creative-Production/Sentinel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreporting.service.ts
More file actions
46 lines (42 loc) · 1.23 KB
/
Copy pathreporting.service.ts
File metadata and controls
46 lines (42 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { Injectable } from '@nestjs/common';
import {
SecurityReport,
SeverityBreakdown,
ChainBreakdown,
} from './interfaces/reporting.interface';
/**
* Aggregates alert data into executive-level security reports.
* In production this would query a database; the static data here
* is the minimum viable implementation for the reporting interface.
*/
@Injectable()
export class ReportingService {
/**
* Returns a security summary for the given number of past days.
* @param periodDays - Look-back window in days (default: 30)
*/
getSecurityReport(periodDays = 30): SecurityReport {
const severityBreakdown: SeverityBreakdown = {
low: 12,
medium: 8,
high: 5,
critical: 2,
};
const totalAlerts = Object.values(severityBreakdown).reduce((a, b) => a + b, 0);
const topChains: ChainBreakdown[] = [
{ chain: 'Ethereum', count: 11 },
{ chain: 'Soroban', count: 9 },
{ chain: 'Polygon', count: 7 },
];
return {
generatedAt: new Date().toISOString(),
periodDays,
totalAlerts,
severityBreakdown,
topChains,
resolvedAlerts: 20,
unresolvedAlerts: totalAlerts - 20,
criticalUnresolved: severityBreakdown.critical,
};
}
}