feat(audit): P79 Pre-Scan-Wizard (8 Pflichtfelder) + P99 erweitert + P102 Replay-Fix
CI / guardrail-integrity (push) Has been skipped
CI / secret-scan (push) Has been skipped
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / validate-canonical-controls (push) Successful in 14s
CI / nodejs-lint (push) Has been skipped
CI / detect-changes (push) Successful in 11s
CI / branch-name (push) Has been skipped
CI / loc-budget (push) Failing after 17s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-build (push) Successful in 2m56s
CI / test-go (push) Has been skipped
CI / iace-gt-coverage (push) Has been skipped
CI / test-python-backend (push) Successful in 40s
CI / test-python-document-crawler (push) Has been skipped
CI / test-python-dsms-gateway (push) Has been skipped

P79: PreScanWizard.tsx mit 8 Pflichtfeldern (Branche, B2B/B2C,
Direkt-Vertrieb, Rechtsform, Konzern-Struktur, MA-Zahl, Besondere
Daten, Drittland). Scan-Button disabled bis alle 8 ausgefuellt. Werte
landen in scan_context und ueber Backend in compliance_check_snapshots.

P99: DOC_TYPES um dsa + legal_notice + lizenzhinweise + nutzungsbedingungen
erweitert. URL-hinzufuegen-Button war schon da.

P102 (Replay-Bug): check_replay.py liest jetzt e.get('text') statt
nur full_text — Snapshot-Schema verwendet 'text'. Library-Mismatch-
Block wird damit auch im Replay angezeigt.

Backend: ComplianceCheckRequest.scan_context optional; save_snapshot
persistiert ihn in compliance_check_snapshots.scan_context.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-05-21 15:59:01 +02:00
parent 94057b1536
commit 50fc0ecc59
4 changed files with 298 additions and 9 deletions
@@ -2,6 +2,7 @@
import React, { useState } from 'react'
import { ChecklistView } from './ChecklistView'
import { PreScanWizard, useScanContext, isContextComplete } from './PreScanWizard'
interface DocEntry {
id: string
@@ -11,13 +12,17 @@ interface DocEntry {
}
const DOC_TYPES = [
{ id: 'dse', label: 'DSI (Datenschutzinformation)' },
{ id: 'dse', label: 'Datenschutzerklärung / DSI' },
{ id: 'cookie', label: 'Cookie-Richtlinie' },
{ id: 'impressum', label: 'Impressum' },
{ id: 'agb', label: 'AGB' },
{ id: 'nutzungsbedingungen', label: 'Nutzungsbedingungen' },
{ id: 'widerruf', label: 'Widerrufsbelehrung' },
{ id: 'social_media', label: 'DSE Social Media (Art. 26)' },
{ id: 'dsfa', label: 'DSFA (Art. 35)' },
{ id: 'agb', label: 'AGB / Nutzungsbedingungen' },
{ id: 'impressum', label: 'Impressum' },
{ id: 'cookie', label: 'Cookie-Richtlinie' },
{ id: 'widerruf', label: 'Widerrufsbelehrung' },
{ id: 'dsa', label: 'DSA / Digital Services Act' },
{ id: 'legal_notice', label: 'Rechtliche Hinweise (IP, Forward-Looking)' },
{ id: 'lizenzhinweise', label: 'Lizenzhinweise Dritter (OSS)' },
{ id: 'other', label: 'Sonstiges' },
]
@@ -26,6 +31,7 @@ function newEntry(): DocEntry {
}
export function DocCheckTab() {
const [scanContext, setScanContext] = useScanContext()
const [entries, setEntries] = useState<DocEntry[]>(() => {
if (typeof window === 'undefined') return [newEntry()]
try { const s = localStorage.getItem('doc-check-entries'); return s ? JSON.parse(s) : [newEntry()] } catch { return [newEntry()] }
@@ -94,6 +100,7 @@ export function DocCheckTab() {
})),
check_cookie_banner: checkCookieBanner,
use_agent: useAgent,
scan_context: scanContext,
}),
})
if (!startRes.ok) throw new Error(`Pruefung konnte nicht gestartet werden: ${startRes.status}`)
@@ -133,8 +140,13 @@ export function DocCheckTab() {
}
}
const contextReady = isContextComplete(scanContext)
return (
<div className="space-y-4">
{/* P79 Pre-Scan-Wizard — 8 Pflichtfelder */}
<PreScanWizard value={scanContext} onChange={setScanContext} />
{/* URL Entries */}
<div className="space-y-2">
{entries.map((entry, i) => (
@@ -212,8 +224,9 @@ export function DocCheckTab() {
{/* Submit */}
<button
onClick={handleSubmit}
disabled={loading || entries.every(e => !e.url.trim())}
disabled={loading || entries.every(e => !e.url.trim()) || !contextReady}
className="w-full px-4 py-3 bg-purple-600 text-white rounded-lg font-medium hover:bg-purple-700 disabled:opacity-50 transition-colors text-sm flex items-center justify-center gap-2"
title={!contextReady ? 'Bitte zuerst die 8 Pflichtfelder ausfüllen' : undefined}
>
{loading ? (
<>
@@ -223,6 +236,8 @@ export function DocCheckTab() {
</svg>
Pruefe...
</>
) : !contextReady ? (
`Klassifizierung unvollständig (8 Pflichtfelder)`
) : (
`${entries.filter(e => e.url.trim()).length} Dokument${entries.filter(e => e.url.trim()).length !== 1 ? 'e' : ''} pruefen`
)}
@@ -0,0 +1,269 @@
'use client'
/**
* P79 — Pre-Scan-Wizard (8 Pflichtfelder).
*
* 8 Pflichtfelder die vor dem Lauf abgefragt werden. Werte landen im
* scan_context und filtern später die MC-Auswertung (zusammen mit P72
* scope_doc_type + applicable_industries). Erwartete Noise-Reduktion:
* 70-80% bei falsch zugeordneten HIGH-MCs.
*/
import React, { useState, useEffect } from 'react'
export interface ScanContext {
industry: string
business_model: string
direct_sales: string
legal_form: string
group_structure: string
employee_count: string
special_data: string[]
third_country_transfer: string
}
const INDUSTRIES = [
{ id: '', label: '— bitte wählen —' },
{ id: 'automotive', label: 'Automotive / OEM' },
{ id: 'ecommerce', label: 'E-Commerce / Online-Handel' },
{ id: 'saas', label: 'SaaS / Software' },
{ id: 'banking', label: 'Banking / Finance' },
{ id: 'insurance', label: 'Insurance / Versicherung' },
{ id: 'healthcare', label: 'Healthcare / Gesundheit' },
{ id: 'education', label: 'Bildung / Schule' },
{ id: 'public', label: 'Öffentliche Verwaltung' },
{ id: 'manufacturing', label: 'Industrie / Manufacturing' },
{ id: 'media', label: 'Medien / Verlag' },
{ id: 'other', label: 'Sonstige' },
]
const LEGAL_FORMS = [
{ id: '', label: '— bitte wählen —' },
{ id: 'ag', label: 'AG (Aktiengesellschaft)' },
{ id: 'gmbh', label: 'GmbH' },
{ id: 'gmbh_co_kg', label: 'GmbH & Co. KG' },
{ id: 'kg', label: 'KG' },
{ id: 'ohg', label: 'OHG' },
{ id: 'ug', label: 'UG (haftungsbeschränkt)' },
{ id: 'ek', label: 'e.K. / Einzelunternehmen' },
{ id: 'verein', label: 'Verein' },
{ id: 'stiftung', label: 'Stiftung' },
{ id: 'behoerde', label: 'Behörde / Körperschaft öff. Rechts' },
{ id: 'other', label: 'Sonstige' },
]
const GROUP_STRUCTURES = [
{ id: '', label: '— bitte wählen —' },
{ id: 'standalone', label: 'Eigenständig' },
{ id: 'parent', label: 'Konzern-Mutter' },
{ id: 'subsidiary', label: 'Konzern-Tochter' },
{ id: 'joint_venture', label: 'Joint Venture' },
{ id: 'processor', label: 'Reiner Auftragsverarbeiter' },
]
const EMPLOYEE_COUNTS = [
{ id: '', label: '— bitte wählen —' },
{ id: 'lt10', label: 'unter 10' },
{ id: '10_19', label: '10-19' },
{ id: '20_49', label: '20-49 (DSB ab 20 Pflicht)' },
{ id: '50_249', label: '50-249 (Whistleblower-Pflicht)' },
{ id: '250_499', label: '250-499' },
{ id: '500_999', label: '500-999' },
{ id: '1000_plus', label: '1.000+ (Konzern)' },
]
const SPECIAL_DATA_OPTIONS = [
{ id: 'health', label: 'Gesundheitsdaten' },
{ id: 'biometric', label: 'Biometrische Daten' },
{ id: 'ethnicity', label: 'Religiöse / ethnische Herkunft' },
{ id: 'sexual', label: 'Sexuelle Orientierung' },
{ id: 'criminal', label: 'Strafrechtliche Daten' },
{ id: 'minors', label: 'Minderjährige (<16)' },
{ id: 'none', label: 'Keine besonderen Daten' },
]
const STORAGE_KEY = 'compliance-scan-context'
function emptyContext(): ScanContext {
return {
industry: '',
business_model: '',
direct_sales: '',
legal_form: '',
group_structure: '',
employee_count: '',
special_data: [],
third_country_transfer: '',
}
}
export function isContextComplete(ctx: ScanContext): boolean {
return Boolean(
ctx.industry &&
ctx.business_model &&
ctx.direct_sales &&
ctx.legal_form &&
ctx.group_structure &&
ctx.employee_count &&
ctx.special_data.length > 0 &&
ctx.third_country_transfer
)
}
export function PreScanWizard({
value,
onChange,
}: {
value: ScanContext
onChange: (ctx: ScanContext) => void
}) {
const update = <K extends keyof ScanContext>(key: K, val: ScanContext[K]) => {
onChange({ ...value, [key]: val })
}
const toggleSpecialData = (id: string) => {
const next = value.special_data.includes(id)
? value.special_data.filter(x => x !== id)
: [...value.special_data.filter(x => x !== 'none' || id === 'none'), id]
onChange({ ...value, special_data: id === 'none' ? ['none'] : next.filter(x => x !== 'none') })
}
return (
<div style={{
background: '#f0f9ff',
border: '1px solid #bfdbfe',
borderRadius: 8,
padding: '14px 16px',
marginBottom: 14,
}}>
<div style={{ fontSize: 11, color: '#1e40af', textTransform: 'uppercase',
letterSpacing: 1.2, marginBottom: 4, fontWeight: 600 }}>
Pflichtangaben zur Klassifizierung des Audits
</div>
<h3 style={{ margin: '0 0 6px', fontSize: 14, color: '#1e293b' }}>
Vor dem Scan: 8 Angaben zum Unternehmen
</h3>
<p style={{ margin: '0 0 12px', fontSize: 11, color: '#475569', lineHeight: 1.5 }}>
Diese Angaben filtern irrelevante Compliance-Themen heraus (z.B. eHealth-
Vorschriften bei einem Autobauer) und liefern eine realistische
Einschätzung statt pauschaler Verstoss-Listen.
</p>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 10 }}>
<Field label="1. Branche*">
<select value={value.industry} onChange={e => update('industry', e.target.value)} style={inputStyle}>
{INDUSTRIES.map(o => <option key={o.id} value={o.id}>{o.label}</option>)}
</select>
</Field>
<Field label="2. Geschäftsmodell*">
<select value={value.business_model} onChange={e => update('business_model', e.target.value)} style={inputStyle}>
<option value=""> bitte wählen </option>
<option value="b2b">B2B</option>
<option value="b2c">B2C</option>
<option value="both">Beides (B2B + B2C)</option>
</select>
</Field>
<Field label="3. Direkt-Vertrieb (Webshop/Buchung)*">
<select value={value.direct_sales} onChange={e => update('direct_sales', e.target.value)} style={inputStyle}>
<option value=""> bitte wählen </option>
<option value="yes">Ja</option>
<option value="no">Nein</option>
<option value="lead_funnel">Nur Lead-Funnel (Probefahrten, Anfragen)</option>
</select>
</Field>
<Field label="4. Rechtsform*">
<select value={value.legal_form} onChange={e => update('legal_form', e.target.value)} style={inputStyle}>
{LEGAL_FORMS.map(o => <option key={o.id} value={o.id}>{o.label}</option>)}
</select>
</Field>
<Field label="5. Konzern-Struktur*">
<select value={value.group_structure} onChange={e => update('group_structure', e.target.value)} style={inputStyle}>
{GROUP_STRUCTURES.map(o => <option key={o.id} value={o.id}>{o.label}</option>)}
</select>
</Field>
<Field label="6. Mitarbeiterzahl*">
<select value={value.employee_count} onChange={e => update('employee_count', e.target.value)} style={inputStyle}>
{EMPLOYEE_COUNTS.map(o => <option key={o.id} value={o.id}>{o.label}</option>)}
</select>
</Field>
<Field label="7. Besondere Datenkategorien*" colSpan={2}>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
{SPECIAL_DATA_OPTIONS.map(o => (
<label key={o.id} style={{ fontSize: 12, display: 'inline-flex',
alignItems: 'center', gap: 4,
padding: '4px 8px', background: '#fff',
border: '1px solid #cbd5e1',
borderRadius: 4 }}>
<input type="checkbox"
checked={value.special_data.includes(o.id)}
onChange={() => toggleSpecialData(o.id)} />
{o.label}
</label>
))}
</div>
</Field>
<Field label="8. Bekannter Drittland-Transfer*" colSpan={2}>
<select value={value.third_country_transfer} onChange={e => update('third_country_transfer', e.target.value)} style={inputStyle}>
<option value=""> bitte wählen </option>
<option value="yes">Ja (USA, CN, IN, UK, ...)</option>
<option value="no">Nein (nur EU/EWR)</option>
<option value="unknown">Weiß nicht (bitte automatisch prüfen)</option>
</select>
</Field>
</div>
{!isContextComplete(value) && (
<div style={{ marginTop: 10, fontSize: 11, color: '#92400e',
background: '#fef3c7', padding: '6px 10px',
borderRadius: 4, border: '1px solid #fde68a' }}>
Bitte alle 8 Pflichtfelder ausfüllen der Scan-Button wird erst aktiv,
wenn die Klassifizierung komplett ist.
</div>
)}
</div>
)
}
const inputStyle: React.CSSProperties = {
width: '100%',
padding: '6px 8px',
fontSize: 12,
border: '1px solid #cbd5e1',
borderRadius: 4,
background: '#fff',
}
function Field({ label, children, colSpan }: { label: string; children: React.ReactNode; colSpan?: number }) {
return (
<div style={{ gridColumn: colSpan ? `span ${colSpan}` : undefined }}>
<label style={{ display: 'block', fontSize: 11, color: '#475569',
marginBottom: 4, fontWeight: 600 }}>
{label}
</label>
{children}
</div>
)
}
export function useScanContext(): [ScanContext, (ctx: ScanContext) => void] {
const [ctx, setCtx] = useState<ScanContext>(() => {
if (typeof window === 'undefined') return emptyContext()
try {
const s = localStorage.getItem(STORAGE_KEY)
return s ? { ...emptyContext(), ...JSON.parse(s) } : emptyContext()
} catch {
return emptyContext()
}
})
useEffect(() => {
try { localStorage.setItem(STORAGE_KEY, JSON.stringify(ctx)) } catch {}
}, [ctx])
return [ctx, setCtx]
}
@@ -51,6 +51,10 @@ class ComplianceCheckRequest(BaseModel):
# (z.B. "Auftragsbeziehung Safetykon GmbH, Email Hr. X 18.05.2026").
tdm_override: bool = False
tdm_override_reason: str = ""
# P79: 8-Feld Pre-Scan-Wizard (Branche, B2B/B2C, Direkt-Vertrieb,
# Rechtsform, Konzern, MA, Besondere Daten, Drittland). Wird im
# Snapshot persistiert und filtert die MC-Auswertung (P72).
scan_context: dict | None = None
class ComplianceCheckStartResponse(BaseModel):
@@ -1149,7 +1153,7 @@ async def _run_compliance_check(check_id: str, req: ComplianceCheckRequest):
banner_result=banner_result,
profile=profile,
cmp_vendors=cmp_vendors,
scan_context=None, # P79 will fill this
scan_context=req.scan_context, # P79
site_label=site_name,
notes=f"recipient={req.recipient}",
)
@@ -56,11 +56,12 @@ def replay_from_snapshot(
cmp_vendors = snap.get("cmp_vendors") or []
site_label = snap.get("site_label") or snap.get("site_domain")
# Reconstruct doc_texts mapping (was the input to mail-render)
# Reconstruct doc_texts mapping (was the input to mail-render).
# Snapshot-Schema speichert text unter "text" (nicht full_text).
doc_texts: dict[str, str] = {}
for e in doc_entries:
dt = e.get("doc_type", "")
txt = (e.get("full_text") or e.get("text_preview") or "").strip()
txt = (e.get("text") or e.get("full_text") or e.get("text_preview") or "").strip()
if dt and txt:
doc_texts[dt] = txt