import { useEffect, useState } from 'react' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table' import { apiClient, IgnoreRule } from '@/lib/api' import { Settings, RefreshCw, Plus, Trash2 } from 'lucide-react' const ignoreTypeColors = { image: 'default', file: 'secondary', project: 'outline', } as const export function IgnoreRules() { const [ignoreRules, setIgnoreRules] = useState([]) const [isLoading, setIsLoading] = useState(true) const [selectedType, setSelectedType] = useState('') const fetchIgnoreRules = async (ignoreType?: string) => { try { const data = await apiClient.getIgnoreRules({ ignore_type: ignoreType || undefined }) setIgnoreRules(data) } catch (error) { console.error('Failed to fetch ignore rules:', error) } finally { setIsLoading(false) } } const handleDeleteRule = async (id: number) => { try { await apiClient.deleteIgnoreRule(id) await fetchIgnoreRules(selectedType) } catch (error) { console.error('Failed to delete ignore rule:', error) } } useEffect(() => { fetchIgnoreRules(selectedType) }, [selectedType]) if (isLoading) { return (
) } return (

Ignore Rules

Manage rules to exclude projects, files, or images from scanning

{/* Type Filter */} Filter by Type
{Object.keys(ignoreTypeColors).map((type) => ( ))}
Active Ignore Rules Rules that exclude items from scanning and vulnerability checking Type Target Reason Created By Created Actions {ignoreRules.map((rule) => ( {rule.ignore_type.charAt(0).toUpperCase() + rule.ignore_type.slice(1)}
{rule.target}
{rule.reason || ( No reason provided )}
{rule.created_by || ( Unknown )} {new Date(rule.created_at).toLocaleDateString()}
))}
{ignoreRules.length === 0 && (
{selectedType ? `No ${selectedType} ignore rules found.` : 'No ignore rules configured. Add rules to exclude items from scanning.' }
)}
) }