feat: add Fail2ban security detection console
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { request, withQuery } from '../core/httpClient';
|
||||
import type { SecurityAlert, SecurityBlock, SecurityOverview, SecurityProtectedNetwork, SecurityRule } from '../types';
|
||||
|
||||
export const adminSecurityDetectionApi = {
|
||||
getSecurityOverview: (range = '24h') => request<SecurityOverview>(withQuery('/admin/security-detection/overview', { range })),
|
||||
listSecurityAlerts: (query: Record<string, string | number | undefined> = {}) => request<{ items: SecurityAlert[]; total: number }> (withQuery('/admin/security-detection/alerts', query)),
|
||||
listSecurityRules: () => request<SecurityRule[]>('/admin/security-detection/rules'),
|
||||
updateSecurityRule: (id: string, body: Partial<SecurityRule>) => request<SecurityRule>(`/admin/security-detection/rules/${id}`, { method: 'PUT', body: JSON.stringify(body) }),
|
||||
blockSecurityAlert: (id: string, body: { durationSeconds: number; reason: string }) => request<SecurityBlock>(`/admin/security-detection/alerts/${id}/block`, { method: 'POST', body: JSON.stringify(body) }),
|
||||
ignoreSecurityAlert: (id: string, reason: string) => request<{ success: boolean }>(`/admin/security-detection/alerts/${id}/ignore`, { method: 'POST', body: JSON.stringify({ reason }) }),
|
||||
listSecurityBlocks: () => request<SecurityBlock[]>('/admin/security-detection/blocks'),
|
||||
unblockSecurityBlock: (id: string, reason: string) => request<SecurityBlock>(`/admin/security-detection/blocks/${id}/unblock`, { method: 'POST', body: JSON.stringify({ reason }) }),
|
||||
listProtectedNetworks: () => request<SecurityProtectedNetwork[]>('/admin/security-detection/protected-networks'),
|
||||
addProtectedNetwork: (body: { network: string; name: string; reason: string }) => request<SecurityProtectedNetwork>('/admin/security-detection/protected-networks', { method: 'POST', body: JSON.stringify(body) }),
|
||||
};
|
||||
@@ -11,6 +11,7 @@ import { adminGovernanceApi } from './admin/governance.api';
|
||||
import { adminFilesApi } from './admin/files.api';
|
||||
import { adminSignatureRetirementApi } from './admin/signature-retirement.api';
|
||||
import { adminInfrastructureMonitoringApi } from './admin/infrastructure-monitoring.api';
|
||||
import { adminSecurityDetectionApi } from './admin/security-detection.api';
|
||||
|
||||
export const adminApi = {
|
||||
...adminIdentityApi,
|
||||
@@ -20,4 +21,5 @@ export const adminApi = {
|
||||
...adminFilesApi,
|
||||
...adminSignatureRetirementApi,
|
||||
...adminInfrastructureMonitoringApi,
|
||||
...adminSecurityDetectionApi,
|
||||
};
|
||||
|
||||
@@ -5,3 +5,4 @@ export * from './operations';
|
||||
export * from './governance';
|
||||
export * from './signature-retirement';
|
||||
export * from './infrastructure-monitoring';
|
||||
export * from './security-detection';
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
export type SecurityRule = {
|
||||
id: string; code: string; name: string; sourceType: string; enabled: boolean;
|
||||
threshold: number; windowSeconds: number; cooldownSeconds: number; severity: string;
|
||||
defaultBlockSeconds: number; maximumBlockSeconds: number; configVersion: number;
|
||||
effectiveVersion: number; applyStatus: string; lastApplyError?: string | null;
|
||||
};
|
||||
export type SecurityAlert = {
|
||||
id: string; fingerprint: string; sourceIp: string; severity: string; status: string;
|
||||
eventCount: number; firstOccurredAt: string; lastOccurredAt: string; rule: SecurityRule;
|
||||
};
|
||||
export type SecurityBlock = { id: string; sourceIp: string; executor: string; status: string; durationSeconds: number; reason: string; requestedAt: string; expiresAt?: string | null; lastError?: string | null };
|
||||
export type SecurityProtectedNetwork = { id: string; network: string; name: string; reason: string; enabled: boolean; createdAt: string };
|
||||
export type SecurityOverview = {
|
||||
range: string; collectedAt: string; totalEvents: number; activeAlerts: number; criticalAlerts: number; activeBlocks: number;
|
||||
health: { agent: string; agentError?: string; rulesEffective: number; rulesTotal: number };
|
||||
sourceDistribution: Array<{ name: string; value: number }>;
|
||||
alerts: SecurityAlert[];
|
||||
};
|
||||
Reference in New Issue
Block a user