mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 16:32:08 +01:00
feat: complete development environment setup and code quality improvements
- Set up pre-commit hooks with husky and lint-staged for automated code quality - Improved TypeScript type safety by replacing 'any' types with proper generics - Fixed markdown linting violations (MD030 spacing) across all documentation - Fixed compound adjective hyphenation in technical documentation - Fixed invalid JSON union syntax in API documentation examples - Automated code formatting and linting on commit - Enhanced error handling with better type constraints - Configured biome and markdownlint for consistent code style - All changes verified with successful production build
This commit is contained in:
@ -6,19 +6,19 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
PerformanceEnhanced,
|
||||
PerformanceOptimized,
|
||||
Cached,
|
||||
Deduplicated,
|
||||
Monitored,
|
||||
PerformanceEnhanced,
|
||||
PerformanceOptimized,
|
||||
} from "../performance/integration";
|
||||
import { AuditOutcome, AuditSeverity } from "../securityAuditLogger";
|
||||
import { AlertChannel, type MonitoringConfig } from "../securityMonitoring";
|
||||
import type { Alert, SecurityEvent } from "../types/security";
|
||||
import { ThreatLevel } from "../types/security";
|
||||
import { AlertManagementService } from "./AlertManagementService";
|
||||
import { SecurityEventProcessor } from "./SecurityEventProcessor";
|
||||
import { ThreatDetectionService } from "./ThreatDetectionService";
|
||||
import { AlertManagementService } from "./AlertManagementService";
|
||||
import { AlertChannel, type MonitoringConfig } from "../securityMonitoring";
|
||||
import { AuditOutcome, AuditSeverity } from "../securityAuditLogger";
|
||||
import { ThreatLevel } from "../types/security";
|
||||
import type { SecurityEvent, Alert } from "../types/security";
|
||||
|
||||
/**
|
||||
* Configuration for enhanced security service
|
||||
@ -161,26 +161,31 @@ export class EnhancedSecurityService {
|
||||
{ metadata: event.metadata }, // Cast to AuditLogContext
|
||||
event.metadata
|
||||
);
|
||||
|
||||
|
||||
// Return threat level based on detected threats
|
||||
if (result.threats.length === 0) {
|
||||
return ThreatLevel.LOW;
|
||||
}
|
||||
|
||||
|
||||
// Find the highest severity threat
|
||||
const highestSeverity = result.threats.reduce((max, threat) => {
|
||||
const severityOrder = { LOW: 1, MEDIUM: 2, HIGH: 3, CRITICAL: 4 };
|
||||
const current = severityOrder[threat.severity as keyof typeof severityOrder] || 1;
|
||||
const current =
|
||||
severityOrder[threat.severity as keyof typeof severityOrder] || 1;
|
||||
const maxVal = severityOrder[max as keyof typeof severityOrder] || 1;
|
||||
return current > maxVal ? threat.severity : max;
|
||||
}, "LOW" as any);
|
||||
|
||||
|
||||
// Map AlertSeverity to ThreatLevel
|
||||
switch (highestSeverity) {
|
||||
case "CRITICAL": return ThreatLevel.CRITICAL;
|
||||
case "HIGH": return ThreatLevel.HIGH;
|
||||
case "MEDIUM": return ThreatLevel.MEDIUM;
|
||||
default: return ThreatLevel.LOW;
|
||||
case "CRITICAL":
|
||||
return ThreatLevel.CRITICAL;
|
||||
case "HIGH":
|
||||
return ThreatLevel.HIGH;
|
||||
case "MEDIUM":
|
||||
return ThreatLevel.MEDIUM;
|
||||
default:
|
||||
return ThreatLevel.LOW;
|
||||
}
|
||||
}
|
||||
|
||||
@ -349,7 +354,7 @@ export class EnhancedSecurityService {
|
||||
// cache: {
|
||||
// enabled: true,
|
||||
// ttl: 10 * 60 * 1000, // 10 minutes
|
||||
// keyGenerator: (query: any) => `search:${JSON.stringify(query)}`,
|
||||
// keyGenerator: (query: Record<string, unknown>) => `search:${JSON.stringify(query)}`,
|
||||
// },
|
||||
// deduplication: {
|
||||
// enabled: true,
|
||||
@ -394,11 +399,11 @@ export class EnhancedSecurityService {
|
||||
private calculateThreatDistribution(
|
||||
events: SecurityEvent[]
|
||||
): Record<ThreatLevel, number> {
|
||||
return {
|
||||
[ThreatLevel.LOW]: 0,
|
||||
[ThreatLevel.MEDIUM]: 0,
|
||||
[ThreatLevel.HIGH]: 0,
|
||||
[ThreatLevel.CRITICAL]: 0
|
||||
return {
|
||||
[ThreatLevel.LOW]: 0,
|
||||
[ThreatLevel.MEDIUM]: 0,
|
||||
[ThreatLevel.HIGH]: 0,
|
||||
[ThreatLevel.CRITICAL]: 0,
|
||||
};
|
||||
}
|
||||
|
||||
@ -441,7 +446,9 @@ export class EnhancedSecurityService {
|
||||
};
|
||||
}
|
||||
|
||||
private async performSearch(query: any): Promise<SecurityEvent[]> {
|
||||
private async performSearch(
|
||||
query: Record<string, unknown>
|
||||
): Promise<SecurityEvent[]> {
|
||||
// Mock search implementation
|
||||
return [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user