'use client'; import { useState } from 'react'; import { useSecurity } from '@breakpilot/compliance-sdk-react'; import Link from 'next/link'; import { ArrowLeft, Lock, AlertTriangle, AlertCircle, CheckCircle, Play, Loader2, FileCode, Package, Database, Shield, } from 'lucide-react'; export default function SecurityPage() { const { sbom, findings, scan, isScanning, generateSbom, isGeneratingSbom } = useSecurity(); const [scanTarget, setScanTarget] = useState(''); const handleScan = async () => { if (!scanTarget.trim()) return; await scan(scanTarget); setScanTarget(''); }; const tools = [ { id: 'gitleaks', name: 'Gitleaks', description: 'Secret Detection', icon: Lock, }, { id: 'semgrep', name: 'Semgrep', description: 'SAST Analysis', icon: FileCode, }, { id: 'bandit', name: 'Bandit', description: 'Python Security', icon: Shield, }, { id: 'trivy', name: 'Trivy', description: 'Container Scanning', icon: Database, }, { id: 'grype', name: 'Grype', description: 'Dependency Vulnerabilities', icon: Package, }, { id: 'syft', name: 'Syft', description: 'SBOM Generation', icon: FileCode, }, ]; const findingsBySeverity = { critical: findings?.filter((f) => f.severity === 'critical').length ?? 0, high: findings?.filter((f) => f.severity === 'high').length ?? 0, medium: findings?.filter((f) => f.severity === 'medium').length ?? 0, low: findings?.filter((f) => f.severity === 'low').length ?? 0, }; return (
{/* Header */}

Security

Vulnerability Scanning & SBOM

{/* Findings Overview */}
{findingsBySeverity.critical}
Critical
{findingsBySeverity.high}
High
{findingsBySeverity.medium}
Medium
{findingsBySeverity.low}
Low
{/* Left Column - Scan & Tools */}
{/* Run Scan */}

Run Security Scan

setScanTarget(e.target.value)} placeholder="Enter repository path or URL..." className="flex-1 px-4 py-2 border rounded-lg bg-background focus:outline-none focus:ring-2 focus:ring-primary" />
{/* Tools Grid */}

Integrated Tools

{tools.map((tool) => { const Icon = tool.icon; return (
{tool.name}

{tool.description}

); })}
{/* Recent Findings */}

Recent Findings

{findings?.slice(0, 5).map((finding) => (
{finding.severity === 'critical' && ( )} {finding.severity === 'high' && ( )} {finding.severity === 'medium' && ( )} {finding.severity === 'low' && ( )}
{finding.title} {finding.tool}

{finding.description?.substring(0, 100)}...

{finding.filePath && (

{finding.filePath} {finding.lineNumber && `:${finding.lineNumber}`}

)}
))} {(!findings || findings.length === 0) && (
No findings yet. Run a scan to get started.
)}
{/* Right Column - SBOM */}

SBOM

{sbom && (
{sbom.components?.length ?? 0}
Components

By License

{Object.entries( sbom.components?.reduce( (acc: Record, c: any) => { const license = c.license || 'Unknown'; acc[license] = (acc[license] || 0) + 1; return acc; }, {} ) ?? {} ) .slice(0, 5) .map(([license, count]) => (
{license} {count as number}
))}
)} {!sbom && (

No SBOM generated yet

)}
); }