'use client'
import React, { useState } from 'react'
import { useSDK, ScreeningResult, SecurityIssue, SBOMComponent } from '@/lib/sdk'
// =============================================================================
// MOCK DATA
// =============================================================================
const mockSBOMComponents: SBOMComponent[] = [
{
name: 'react',
version: '18.3.0',
type: 'library',
purl: 'pkg:npm/react@18.3.0',
licenses: ['MIT'],
vulnerabilities: [],
},
{
name: 'next',
version: '15.1.0',
type: 'framework',
purl: 'pkg:npm/next@15.1.0',
licenses: ['MIT'],
vulnerabilities: [],
},
{
name: 'lodash',
version: '4.17.21',
type: 'library',
purl: 'pkg:npm/lodash@4.17.21',
licenses: ['MIT'],
vulnerabilities: [
{
id: 'CVE-2021-23337',
cve: 'CVE-2021-23337',
severity: 'HIGH',
title: 'Prototype Pollution',
description: 'Lodash versions prior to 4.17.21 are vulnerable to Command Injection via the template function.',
cvss: 7.2,
fixedIn: '4.17.21',
},
],
},
]
const mockSecurityIssues: SecurityIssue[] = [
{
id: 'issue-1',
severity: 'CRITICAL',
title: 'SQL Injection Vulnerability',
description: 'Unvalidated user input in database queries',
cve: 'CVE-2024-12345',
cvss: 9.8,
affectedComponent: 'database-connector',
remediation: 'Use parameterized queries',
status: 'OPEN',
},
{
id: 'issue-2',
severity: 'HIGH',
title: 'Cross-Site Scripting (XSS)',
description: 'Reflected XSS in search functionality',
cve: 'CVE-2024-12346',
cvss: 7.5,
affectedComponent: 'search-module',
remediation: 'Sanitize and encode user input',
status: 'IN_PROGRESS',
},
{
id: 'issue-3',
severity: 'MEDIUM',
title: 'Insecure Cookie Configuration',
description: 'Session cookies missing Secure and HttpOnly flags',
cve: null,
cvss: 5.3,
affectedComponent: 'auth-service',
remediation: 'Set Secure and HttpOnly flags on cookies',
status: 'OPEN',
},
]
// =============================================================================
// COMPONENTS
// =============================================================================
function ScanProgress({ progress, status }: { progress: number; status: string }) {
return (
)
}
function SBOMViewer({ components }: { components: SBOMComponent[] }) {
return (
Software Bill of Materials (SBOM)
{components.length} Komponenten gefunden
| Name |
Version |
Typ |
Lizenz |
Vulnerabilities |
{components.map(component => (
|
{component.name}
{component.purl}
|
{component.version} |
{component.type}
|
{component.licenses.join(', ')} |
{component.vulnerabilities.length > 0 ? (
{component.vulnerabilities.length} gefunden
) : (
Keine
)}
|
))}
)
}
function SecurityIssueCard({ issue }: { issue: SecurityIssue }) {
const severityColors = {
CRITICAL: 'bg-red-100 text-red-700 border-red-200',
HIGH: 'bg-orange-100 text-orange-700 border-orange-200',
MEDIUM: 'bg-yellow-100 text-yellow-700 border-yellow-200',
LOW: 'bg-blue-100 text-blue-700 border-blue-200',
}
const statusColors = {
OPEN: 'bg-red-50 text-red-700',
IN_PROGRESS: 'bg-yellow-50 text-yellow-700',
RESOLVED: 'bg-green-50 text-green-700',
ACCEPTED: 'bg-gray-50 text-gray-700',
}
return (
{issue.title}
{issue.description}
{issue.severity}
{issue.cve && (
{issue.cve}
)}
{issue.cvss && (
CVSS: {issue.cvss}
)}
{issue.status}
Betroffene Komponente: {issue.affectedComponent}
Empfehlung: {issue.remediation}
)
}
// =============================================================================
// MAIN PAGE
// =============================================================================
export default function ScreeningPage() {
const { state, dispatch } = useSDK()
const [isScanning, setIsScanning] = useState(false)
const [scanProgress, setScanProgress] = useState(0)
const [scanStatus, setScanStatus] = useState('')
const [repositoryUrl, setRepositoryUrl] = useState('')
const startScan = async () => {
if (!repositoryUrl) return
setIsScanning(true)
setScanProgress(0)
setScanStatus('Initialisierung...')
// Simulate scan progress
const steps = [
{ progress: 10, status: 'Repository wird geklont...' },
{ progress: 25, status: 'Abhängigkeiten werden analysiert...' },
{ progress: 40, status: 'SBOM wird generiert...' },
{ progress: 60, status: 'Schwachstellenscan läuft...' },
{ progress: 80, status: 'Lizenzprüfung...' },
{ progress: 95, status: 'Bericht wird erstellt...' },
{ progress: 100, status: 'Abgeschlossen!' },
]
for (const step of steps) {
await new Promise(r => setTimeout(r, 800))
setScanProgress(step.progress)
setScanStatus(step.status)
}
// Set mock results
const result: ScreeningResult = {
id: `scan-${Date.now()}`,
status: 'COMPLETED',
startedAt: new Date(Date.now() - 30000),
completedAt: new Date(),
sbom: {
format: 'CycloneDX',
version: '1.5',
components: mockSBOMComponents,
dependencies: [],
generatedAt: new Date(),
},
securityScan: {
totalIssues: mockSecurityIssues.length,
critical: mockSecurityIssues.filter(i => i.severity === 'CRITICAL').length,
high: mockSecurityIssues.filter(i => i.severity === 'HIGH').length,
medium: mockSecurityIssues.filter(i => i.severity === 'MEDIUM').length,
low: mockSecurityIssues.filter(i => i.severity === 'LOW').length,
issues: mockSecurityIssues,
},
error: null,
}
dispatch({ type: 'SET_SCREENING', payload: result })
mockSecurityIssues.forEach(issue => {
dispatch({ type: 'ADD_SECURITY_ISSUE', payload: issue })
})
setIsScanning(false)
}
return (
{/* Header */}
System Screening
Generieren Sie ein SBOM und scannen Sie Ihr System auf Sicherheitslücken
{/* Scan Input */}
{!state.screening && !isScanning && (
)}
{/* Scan Progress */}
{isScanning &&
}
{/* Results */}
{state.screening && state.screening.status === 'COMPLETED' && (
<>
{/* Summary */}
Komponenten
{state.screening.sbom?.components.length || 0}
Kritisch
{state.screening.securityScan?.critical || 0}
Hoch
{state.screening.securityScan?.high || 0}
Mittel
{state.screening.securityScan?.medium || 0}
{/* SBOM */}
{state.screening.sbom &&
}
{/* Security Issues */}
Sicherheitsprobleme
{state.screening.securityScan?.issues.map(issue => (
))}
{/* Actions */}
>
)}
)
}