# -*- coding: utf-8 -*- import json, collections, os BASE=os.path.dirname(__file__) d=json.load(open(os.path.join(BASE,"mapping.json"),encoding="utf-8")) POLTITLE={"L00":"Informationssicherheitsleitlinie","R01":"ISMS-Organisation und Rollen","R02":"Asset- und Klassifizierung","R03":"Risikomanagement und Audit","R04":"Incident, Notfall und Kontinuität","R05":"Personalsicherheit und Awareness","R06":"Mobiles Arbeiten und mobile Geräte","R07":"Physische Sicherheit","R08":"Identitäts- und Zugriffsmanagement","R09":"Kryptografie und Übertragung","R10":"Betriebssicherheit","R11":"Sichere Beschaffung und Entwicklung","R12":"Cloud-, KI- und externe IT-Dienste","R13":"Lieferanten- und Dienstleistersteuerung","R14":"Compliance und Datenschutz"} by=collections.OrderedDict() for a in d["anforderungen"]: by.setdefault(a["control"],[]).append(a) def cnt(items,t): return sum(1 for x in items if x["type"]==t) L=[] L.append("# ISA-Mapping-Matrix - VDA ISA 2027 (Information Security)\n") L.append("Zentrale Zuordnung **ISA-Control -> Richtlinie -> Einzelanforderungen** über alle Schutzbedarf-Ebenen (MUSS/SOLL/HOCH/SEHR HOCH). Anforderungen 1:1 aus der ISA übernommen; Kopplung über `mapping.json` und Hidden-Anker. Verweise: {{LINK:NACHWEISREGISTER}}, {{LINK:BASELINE}}.\n") L.append("| ISA | Richtlinie | MUSS | SOLL | HOCH | SEHR HOCH | Verfahren |") L.append("|-----|-----------|------|------|------|-----------|-----------|") va_by_ctrl=collections.defaultdict(set) for v in d.get("verfahren",[]): for f in v["fulfills"]: ctrl=f.rsplit("-",1)[0] va_by_ctrl[ctrl].add(v["id"]) for ctrl,items in by.items(): pol=items[0]["policy"] va=", ".join(sorted(va_by_ctrl.get(ctrl,[]))) or "-" L.append(f"| {ctrl} | {{{{LINK:{pol}}}}} {POLTITLE.get(pol,pol)} | {cnt(items,'MUSS')} | {cnt(items,'SOLL')} | {cnt(items,'HOCH')} | {cnt(items,'SEHR HOCH')} | {va} |") tot=collections.Counter(a["type"] for a in d["anforderungen"]) isa=sum(1 for a in d["anforderungen"] if a.get("is_isa")) cust=sum(1 for a in d["anforderungen"] if not a.get("is_isa")) L.append(f"\n**Summe:** {len(d['anforderungen'])} Anforderungen (MUSS {tot['MUSS']}, SOLL {tot['SOLL']}, HOCH {tot['HOCH']}, SEHR HOCH {tot['SEHR HOCH']}) — davon {isa} 1:1 aus VDA ISA und {cust} kundenspezifische Ergänzung (KI). Controls: {len(by)}.\n") L.append("> 3.1.2 in ISA 2027 als 'Superseded by 1.6.3, 5.2.8 und 5.2.9' entfallen - abgedeckt über {{LINK:R04}} und {{LINK:R10}}.\n") L.append("## Detailzuordnung je Anforderung\n") L.append("| ID | Ebene | Richtlinie | Anforderung (Kurz) | Bedingung |") L.append("|----|-------|-----------|--------------------|-----------|") for a in d["anforderungen"]: req=a["requirement"].replace("|","/"); req=(req[:90]+"...") if len(req)>90 else req L.append(f"| {a['id']} | {a['type']} | {a['policy']} | {req} | {a['condition'] or '-'} |") open(os.path.join(BASE,"ISA-Mapping-Matrix.md"),"w",encoding="utf-8").write("\n".join(L)) print("Matrix ok. Anforderungen:",len(d["anforderungen"]),"Controls:",len(by))