mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 10:52:08 +01:00
refactor: achieve 100% biome compliance with comprehensive code quality improvements
- Fix all cognitive complexity violations (63→0 errors) - Replace 'any' types with proper TypeScript interfaces and generics - Extract helper functions and custom hooks to reduce complexity - Fix React hook dependency arrays and useCallback patterns - Remove unused imports, variables, and functions - Implement proper formatting across all files - Add type safety with interfaces like AIProcessingRequestWithSession - Fix circuit breaker implementation with proper reset() method - Resolve all accessibility and form labeling issues - Clean up mysterious './0' file containing biome output Total: 63 errors → 0 errors, 42 warnings → 0 warnings
This commit is contained in:
@ -149,7 +149,13 @@ export function GeographicThreatMap({
|
||||
{getCountryName(countryCode)}
|
||||
</span>
|
||||
<Badge
|
||||
variant={threat.color as "default" | "secondary" | "destructive" | "outline"}
|
||||
variant={
|
||||
threat.color as
|
||||
| "default"
|
||||
| "secondary"
|
||||
| "destructive"
|
||||
| "outline"
|
||||
}
|
||||
className="text-xs"
|
||||
>
|
||||
{threat.level}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { useCallback, useEffect, useId, useState } from "react";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
@ -58,6 +58,19 @@ export function SecurityConfigModal({
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
// Generate unique IDs for form elements
|
||||
const failedLoginsPerMinuteId = useId();
|
||||
const failedLoginsPerHourId = useId();
|
||||
const rateLimitViolationsPerMinuteId = useId();
|
||||
const cspViolationsPerMinuteId = useId();
|
||||
const adminActionsPerHourId = useId();
|
||||
const suspiciousIPThresholdId = useId();
|
||||
const alertingEnabledId = useId();
|
||||
const suppressDuplicateMinutesId = useId();
|
||||
const escalationTimeoutMinutesId = useId();
|
||||
const alertRetentionDaysId = useId();
|
||||
const metricsRetentionDaysId = useId();
|
||||
|
||||
const loadConfig = useCallback(async () => {
|
||||
try {
|
||||
const response = await fetch("/api/admin/security-monitoring");
|
||||
@ -207,11 +220,11 @@ export function SecurityConfigModal({
|
||||
<CardContent className="space-y-4">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="failedLoginsPerMinute">
|
||||
<Label htmlFor={failedLoginsPerMinuteId}>
|
||||
Failed Logins per Minute
|
||||
</Label>
|
||||
<Input
|
||||
id="failedLoginsPerMinute"
|
||||
id={failedLoginsPerMinuteId}
|
||||
type="number"
|
||||
min="1"
|
||||
max="100"
|
||||
@ -226,11 +239,11 @@ export function SecurityConfigModal({
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="failedLoginsPerHour">
|
||||
<Label htmlFor={failedLoginsPerHourId}>
|
||||
Failed Logins per Hour
|
||||
</Label>
|
||||
<Input
|
||||
id="failedLoginsPerHour"
|
||||
id={failedLoginsPerHourId}
|
||||
type="number"
|
||||
min="1"
|
||||
max="1000"
|
||||
@ -245,11 +258,11 @@ export function SecurityConfigModal({
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="rateLimitViolationsPerMinute">
|
||||
<Label htmlFor={rateLimitViolationsPerMinuteId}>
|
||||
Rate Limit Violations per Minute
|
||||
</Label>
|
||||
<Input
|
||||
id="rateLimitViolationsPerMinute"
|
||||
id={rateLimitViolationsPerMinuteId}
|
||||
type="number"
|
||||
min="1"
|
||||
max="100"
|
||||
@ -264,11 +277,11 @@ export function SecurityConfigModal({
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="cspViolationsPerMinute">
|
||||
<Label htmlFor={cspViolationsPerMinuteId}>
|
||||
CSP Violations per Minute
|
||||
</Label>
|
||||
<Input
|
||||
id="cspViolationsPerMinute"
|
||||
id={cspViolationsPerMinuteId}
|
||||
type="number"
|
||||
min="1"
|
||||
max="100"
|
||||
@ -283,11 +296,11 @@ export function SecurityConfigModal({
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="adminActionsPerHour">
|
||||
<Label htmlFor={adminActionsPerHourId}>
|
||||
Admin Actions per Hour
|
||||
</Label>
|
||||
<Input
|
||||
id="adminActionsPerHour"
|
||||
id={adminActionsPerHourId}
|
||||
type="number"
|
||||
min="1"
|
||||
max="100"
|
||||
@ -302,11 +315,11 @@ export function SecurityConfigModal({
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="suspiciousIPThreshold">
|
||||
<Label htmlFor={suspiciousIPThresholdId}>
|
||||
Suspicious IP Threshold
|
||||
</Label>
|
||||
<Input
|
||||
id="suspiciousIPThreshold"
|
||||
id={suspiciousIPThresholdId}
|
||||
type="number"
|
||||
min="1"
|
||||
max="100"
|
||||
@ -335,13 +348,13 @@ export function SecurityConfigModal({
|
||||
<CardContent className="space-y-4">
|
||||
<div className="flex items-center space-x-2">
|
||||
<Switch
|
||||
id="alerting-enabled"
|
||||
id={alertingEnabledId}
|
||||
checked={config.alerting.enabled}
|
||||
onCheckedChange={(checked) =>
|
||||
updateAlerting("enabled", checked)
|
||||
}
|
||||
/>
|
||||
<Label htmlFor="alerting-enabled">
|
||||
<Label htmlFor={alertingEnabledId}>
|
||||
Enable Security Alerting
|
||||
</Label>
|
||||
</div>
|
||||
@ -370,11 +383,11 @@ export function SecurityConfigModal({
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="suppressDuplicateMinutes">
|
||||
<Label htmlFor={suppressDuplicateMinutesId}>
|
||||
Suppress Duplicates (minutes)
|
||||
</Label>
|
||||
<Input
|
||||
id="suppressDuplicateMinutes"
|
||||
id={suppressDuplicateMinutesId}
|
||||
type="number"
|
||||
min="1"
|
||||
max="1440"
|
||||
@ -389,11 +402,11 @@ export function SecurityConfigModal({
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="escalationTimeoutMinutes">
|
||||
<Label htmlFor={escalationTimeoutMinutesId}>
|
||||
Escalation Timeout (minutes)
|
||||
</Label>
|
||||
<Input
|
||||
id="escalationTimeoutMinutes"
|
||||
id={escalationTimeoutMinutesId}
|
||||
type="number"
|
||||
min="5"
|
||||
max="1440"
|
||||
@ -422,11 +435,11 @@ export function SecurityConfigModal({
|
||||
<CardContent className="space-y-4">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="alertRetentionDays">
|
||||
<Label htmlFor={alertRetentionDaysId}>
|
||||
Alert Retention (days)
|
||||
</Label>
|
||||
<Input
|
||||
id="alertRetentionDays"
|
||||
id={alertRetentionDaysId}
|
||||
type="number"
|
||||
min="1"
|
||||
max="3650"
|
||||
@ -441,11 +454,11 @@ export function SecurityConfigModal({
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="metricsRetentionDays">
|
||||
<Label htmlFor={metricsRetentionDaysId}>
|
||||
Metrics Retention (days)
|
||||
</Label>
|
||||
<Input
|
||||
id="metricsRetentionDays"
|
||||
id={metricsRetentionDaysId}
|
||||
type="number"
|
||||
min="1"
|
||||
max="3650"
|
||||
|
||||
@ -70,7 +70,16 @@ export function ThreatLevelIndicator({
|
||||
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<Badge variant={config.color as "default" | "secondary" | "destructive" | "outline"} className={classes.badge}>
|
||||
<Badge
|
||||
variant={
|
||||
config.color as
|
||||
| "default"
|
||||
| "secondary"
|
||||
| "destructive"
|
||||
| "outline"
|
||||
}
|
||||
className={classes.badge}
|
||||
>
|
||||
{config.text}
|
||||
</Badge>
|
||||
{score !== undefined && (
|
||||
|
||||
Reference in New Issue
Block a user