Richtlinien & Verfahren (Phase 1): Import, Rendering-Engine, Bibliothek, Coverage
Fundament des VDA-ISA-2027-Richtlinienmoduls (Spec §1–9):
- Datenmodell: PolicyDocument, PolicyRequirement, PolicyVariable (Variablen +
Feature-Flags), PolicyBaselineParam, PolicyEvidence — inkl. RLS + Tenant-Guard
- Seed-Importer (import-policies.ts): liest die echten .md-Dateien (15 Richtlinien
L00/R01–R14 + 11 Verfahren), mapping.json (120 Anforderungen/46 Controls),
variables.schema.json (53 Variablen/Flags), Technische-Sicherheits-Baseline
(31 BL-Parameter) und Nachweisregister; idempotent pro Mandant
- 6 im Vorlagenpaket beschädigte Variablen-Tokens (VA-08/09/10/12/13) repariert
(dokumentiert im README des Übergabepakets)
- Rendering-Engine (policy-render.ts, Handlebars + marked): verschachtelte
{{#if FLAG}}, {{VARIABLE}}, {{LINK:…}}-Deeplinks, Hidden-Anker + BL-Referenzen
im Lesemodus entfernt (Wert bleibt), zentral verwaltete Abschnitte unterdrückt,
wiederholtes „Umsetzung bei <Org>" reduziert (§7a); lenienter Fallback +
Residue-Check über alle Flag-Kombinationen (analog _verify.py)
- UI: Bibliothek mit Typ-Chips/KPIs, Lesemodus-Popup (einklappbare Info-Tabelle,
Control-Chips, Richtlinie↔Verfahren-Verlinkung), Coverage-Matrix
(Control → Richtlinie → MUSS/SOLL → Verfahren → Anforderungs-IDs)
- Nav-Punkt „Richtlinien" aktiviert; de/en-Übersetzungen
Verifiziert: Import 28 Dokumente/120 Anforderungen; Rendering rückstandsfrei
über alle Flag-Kombinationen; Bibliothek, Lesemodus (R08 nested flags), Coverage
im Browser.
Später (Phase 2+): Bearbeiten/Freigabe-Workflow mit Versionierung, verwaltete
Tabellen (Krypto-/Risiko-/Klassifizierungsregister), Anwender-Handbuch,
DOCX/PDF-Export, Word-Upload, KI-Wizard, zentrale Baseline-/Variablen-Einstellseite.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
import { readFileSync, readdirSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import type { PrismaClient } from "@prisma/client";
|
||||
|
||||
/**
|
||||
* Importer für das VDA-ISA-2027-Vorlagenpaket (§6 der Spezifikation).
|
||||
* Liest die echten .md-Dateien, mapping.json, variables.schema.json,
|
||||
* Technische-Sicherheits-Baseline.md und Nachweisregister_zentral.md in die
|
||||
* Policy-Tabellen. Idempotent pro Mandant (löscht + legt neu an).
|
||||
*/
|
||||
|
||||
type DocType = "LEITLINIE" | "RICHTLINIE" | "VERFAHREN" | "REGISTER";
|
||||
|
||||
function docCodeFromFile(file: string): string {
|
||||
return file.split("_")[0]; // "R08_….md" → "R08", "VA-03_….md" → "VA-03"
|
||||
}
|
||||
function titleOf(md: string): string {
|
||||
const m = md.match(/^#\s+(.+?)\s*$/m);
|
||||
return m ? m[1].trim() : "(ohne Titel)";
|
||||
}
|
||||
function varGroup(key: string): string {
|
||||
if (key.startsWith("FLAG_")) return "Feature-Flags";
|
||||
if (key.startsWith("ORG_") || key.startsWith("ISMS_")) return "Organisation";
|
||||
if (key.startsWith("ROLE_")) return "Rollen";
|
||||
if (key.startsWith("DOC_")) return "Metadaten";
|
||||
if (key.startsWith("TECH_") || key.startsWith("TOOL_")) return "Technik/Werkzeuge";
|
||||
if (/^(PW_|MFA_|SESSION_|ACCOUNT_|RECERT_)/.test(key)) return "IAM-Baseline";
|
||||
if (key.startsWith("TLS_") || key.startsWith("CRYPTO_")) return "Krypto-Baseline";
|
||||
if (/^(PATCH_|VULN_|MALWARE_|LOG_|BACKUP_|PENTEST_)/.test(key)) return "Betriebs-Baseline";
|
||||
return "Sonstige";
|
||||
}
|
||||
|
||||
interface SchemaProp {
|
||||
type?: string;
|
||||
title?: string;
|
||||
default?: string | boolean;
|
||||
example?: string;
|
||||
}
|
||||
|
||||
export async function importPolicies(prisma: PrismaClient, tenantId: string, seedDir: string) {
|
||||
// Sauberer Neuimport pro Mandant
|
||||
await prisma.policyRequirement.deleteMany({ where: { tenantId } });
|
||||
await prisma.policyDocument.deleteMany({ where: { tenantId } });
|
||||
await prisma.policyVariable.deleteMany({ where: { tenantId } });
|
||||
await prisma.policyBaselineParam.deleteMany({ where: { tenantId } });
|
||||
await prisma.policyEvidence.deleteMany({ where: { tenantId } });
|
||||
|
||||
// ── 1. mapping.json → FULFILLS-Rückwärtsmapping vorbereiten ──────────────
|
||||
const mapping = JSON.parse(readFileSync(join(seedDir, "mapping.json"), "utf-8")) as {
|
||||
anforderungen: Array<{
|
||||
id: string; policy: string; control: string; type: string;
|
||||
condition: string | null; requirement: string; implementation: string; nachweis_link?: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
// ── 2. Dokumente einlesen (Richtlinien + Verfahren) ──────────────────────
|
||||
const reqToVas = new Map<string, Set<string>>();
|
||||
const docs: Array<{ code: string; type: DocType; title: string; policyCode: string | null; fulfills: string[]; raw: string; orderIdx: number }> = [];
|
||||
|
||||
const richtDir = join(seedDir, "richtlinien");
|
||||
for (const file of readdirSync(richtDir).filter((f) => f.endsWith(".md")).sort()) {
|
||||
const raw = readFileSync(join(richtDir, file), "utf-8");
|
||||
const code = docCodeFromFile(file);
|
||||
const type: DocType = code === "L00" ? "LEITLINIE" : "RICHTLINIE";
|
||||
const orderIdx = code === "L00" ? 0 : parseInt(code.replace(/\D/g, ""), 10);
|
||||
docs.push({ code, type, title: titleOf(raw), policyCode: null, fulfills: [], raw, orderIdx });
|
||||
}
|
||||
|
||||
const verfDir = join(seedDir, "verfahren");
|
||||
for (const file of readdirSync(verfDir).filter((f) => f.endsWith(".md")).sort()) {
|
||||
const raw = readFileSync(join(verfDir, file), "utf-8");
|
||||
const code = docCodeFromFile(file);
|
||||
const fh = raw.match(/<!--\s*FULFILLS\s+([^|]+?)\s*\|\s*POLICY\s+(\S+)\s*-->/);
|
||||
const fulfills = fh ? fh[1].split(",").map((s) => s.trim()).filter(Boolean) : [];
|
||||
const policyCode = fh ? fh[2].trim() : null;
|
||||
for (const req of fulfills) {
|
||||
if (!reqToVas.has(req)) reqToVas.set(req, new Set());
|
||||
reqToVas.get(req)!.add(code);
|
||||
}
|
||||
const orderIdx = 100 + parseInt(code.replace(/\D/g, ""), 10);
|
||||
docs.push({ code, type: "VERFAHREN", title: titleOf(raw), policyCode, fulfills, raw, orderIdx });
|
||||
}
|
||||
|
||||
// Register-Dokumente (Baseline + Nachweisregister) mitführen
|
||||
const baselineRaw = readFileSync(join(seedDir, "Technische-Sicherheits-Baseline.md"), "utf-8");
|
||||
const nachweisRaw = readFileSync(join(seedDir, "Nachweisregister_zentral.md"), "utf-8");
|
||||
docs.push({ code: "BASELINE", type: "REGISTER", title: titleOf(baselineRaw), policyCode: null, fulfills: [], raw: baselineRaw, orderIdx: 900 });
|
||||
docs.push({ code: "NACHWEIS", type: "REGISTER", title: titleOf(nachweisRaw), policyCode: null, fulfills: [], raw: nachweisRaw, orderIdx: 901 });
|
||||
|
||||
for (const d of docs) {
|
||||
await prisma.policyDocument.create({
|
||||
data: {
|
||||
tenantId, code: d.code, type: d.type, title: d.title, version: "1.0", status: "FREIGEGEBEN",
|
||||
policyCode: d.policyCode, fulfills: d.fulfills, rawMarkdown: d.raw, orderIdx: d.orderIdx,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// ── 3. Anforderungen (mapping.json) + vaCodes ────────────────────────────
|
||||
for (const a of mapping.anforderungen) {
|
||||
await prisma.policyRequirement.create({
|
||||
data: {
|
||||
tenantId, reqId: a.id, policyCode: a.policy, control: a.control, obligation: a.type,
|
||||
condition: a.condition, requirement: a.requirement, implementation: a.implementation,
|
||||
vaCodes: [...(reqToVas.get(a.id) ?? [])].sort(), nachweisLink: a.nachweis_link ?? null,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// ── 4. Variablen + Feature-Flags (variables.schema.json) ─────────────────
|
||||
const schema = JSON.parse(readFileSync(join(seedDir, "variables.schema.json"), "utf-8")) as {
|
||||
properties: Record<string, SchemaProp>; required?: string[];
|
||||
};
|
||||
const required = new Set(schema.required ?? []);
|
||||
let vi = 0;
|
||||
for (const [key, prop] of Object.entries(schema.properties)) {
|
||||
const kind = prop.type === "boolean" ? "boolean" : "string";
|
||||
const value = prop.default !== undefined ? String(prop.default) : prop.example !== undefined ? String(prop.example) : kind === "boolean" ? "false" : "";
|
||||
await prisma.policyVariable.create({
|
||||
data: { tenantId, key, title: prop.title ?? key, kind, groupName: varGroup(key), value, required: required.has(key), orderIdx: vi++ },
|
||||
});
|
||||
}
|
||||
|
||||
// ── 5. Baseline-Parameter (Technische-Sicherheits-Baseline.md) ───────────
|
||||
let section = "";
|
||||
let bi = 0;
|
||||
for (const line of baselineRaw.split("\n")) {
|
||||
const h = line.match(/^##\s+(.+?)\s*$/);
|
||||
if (h) { section = h[1].trim(); continue; }
|
||||
const row = line.match(/^\|\s*(BL-[A-Z]+-\d+)\s*\|\s*(.+?)\s*\|\s*(.+?)\s*\|\s*$/);
|
||||
if (row) {
|
||||
await prisma.policyBaselineParam.create({
|
||||
data: { tenantId, blId: row[1], section, name: row[2].trim(), vorgabe: row[3].trim(), orderIdx: bi++ },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ── 6. Nachweisregister (Nachweisregister_zentral.md) ────────────────────
|
||||
for (const line of nachweisRaw.split("\n")) {
|
||||
const row = line.match(/^\|\s*(\d+)\s*\|\s*(.+?)\s*\|\s*(.+?)\s*\|\s*(.+?)\s*\|\s*(.+?)\s*\|\s*(.+?)\s*\|\s*$/);
|
||||
if (!row) continue;
|
||||
const policyMatch = row[2].match(/\{\{LINK:([^}]+)\}\}/);
|
||||
await prisma.policyEvidence.create({
|
||||
data: {
|
||||
tenantId, nr: parseInt(row[1], 10), policyCode: policyMatch ? policyMatch[1] : row[2].trim(),
|
||||
nachweis: row[3].trim(), quelle: row[4].trim(), verantwortlich: row[5].trim(), turnus: row[6].trim(),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const counts = {
|
||||
documents: docs.length,
|
||||
requirements: mapping.anforderungen.length,
|
||||
variables: Object.keys(schema.properties).length,
|
||||
baseline: bi,
|
||||
};
|
||||
return counts;
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "PolicyDocType" AS ENUM ('LEITLINIE', 'RICHTLINIE', 'VERFAHREN', 'REGISTER', 'HANDBUCH', 'EIGENES');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "PolicyStatus" AS ENUM ('ENTWURF', 'IN_FREIGABE', 'FREIGEGEBEN', 'ARCHIVIERT');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "policy_documents" (
|
||||
"id" TEXT NOT NULL,
|
||||
"tenant_id" TEXT NOT NULL,
|
||||
"code" TEXT NOT NULL,
|
||||
"type" "PolicyDocType" NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"version" TEXT NOT NULL DEFAULT '1.0',
|
||||
"status" "PolicyStatus" NOT NULL DEFAULT 'FREIGEGEBEN',
|
||||
"owner" TEXT,
|
||||
"policy_code" TEXT,
|
||||
"fulfills" TEXT[] DEFAULT ARRAY[]::TEXT[],
|
||||
"raw_markdown" TEXT NOT NULL,
|
||||
"order_idx" INTEGER NOT NULL DEFAULT 0,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "policy_documents_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "policy_requirements" (
|
||||
"id" TEXT NOT NULL,
|
||||
"tenant_id" TEXT NOT NULL,
|
||||
"req_id" TEXT NOT NULL,
|
||||
"policy_code" TEXT NOT NULL,
|
||||
"control" TEXT NOT NULL,
|
||||
"obligation" TEXT NOT NULL,
|
||||
"condition" TEXT,
|
||||
"requirement" TEXT NOT NULL,
|
||||
"implementation" TEXT NOT NULL,
|
||||
"va_codes" TEXT[] DEFAULT ARRAY[]::TEXT[],
|
||||
"nachweis_link" TEXT,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "policy_requirements_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "policy_variables" (
|
||||
"id" TEXT NOT NULL,
|
||||
"tenant_id" TEXT NOT NULL,
|
||||
"key" TEXT NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"kind" TEXT NOT NULL,
|
||||
"group_name" TEXT,
|
||||
"value" TEXT NOT NULL,
|
||||
"required" BOOLEAN NOT NULL DEFAULT false,
|
||||
"order_idx" INTEGER NOT NULL DEFAULT 0,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "policy_variables_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "policy_baseline_params" (
|
||||
"id" TEXT NOT NULL,
|
||||
"tenant_id" TEXT NOT NULL,
|
||||
"bl_id" TEXT NOT NULL,
|
||||
"section" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"vorgabe" TEXT NOT NULL,
|
||||
"order_idx" INTEGER NOT NULL DEFAULT 0,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "policy_baseline_params_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "policy_evidence" (
|
||||
"id" TEXT NOT NULL,
|
||||
"tenant_id" TEXT NOT NULL,
|
||||
"nr" INTEGER NOT NULL,
|
||||
"policy_code" TEXT NOT NULL,
|
||||
"nachweis" TEXT NOT NULL,
|
||||
"quelle" TEXT NOT NULL,
|
||||
"verantwortlich" TEXT NOT NULL,
|
||||
"turnus" TEXT NOT NULL,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "policy_evidence_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "policy_documents_tenant_id_idx" ON "policy_documents"("tenant_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "policy_documents_tenant_id_code_key" ON "policy_documents"("tenant_id", "code");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "policy_requirements_tenant_id_idx" ON "policy_requirements"("tenant_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "policy_requirements_tenant_id_control_idx" ON "policy_requirements"("tenant_id", "control");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "policy_requirements_tenant_id_req_id_key" ON "policy_requirements"("tenant_id", "req_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "policy_variables_tenant_id_idx" ON "policy_variables"("tenant_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "policy_variables_tenant_id_key_key" ON "policy_variables"("tenant_id", "key");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "policy_baseline_params_tenant_id_idx" ON "policy_baseline_params"("tenant_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "policy_baseline_params_tenant_id_bl_id_key" ON "policy_baseline_params"("tenant_id", "bl_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "policy_evidence_tenant_id_idx" ON "policy_evidence"("tenant_id");
|
||||
|
||||
|
||||
-- RLS-Policies für die Richtlinien-Tabellen
|
||||
DO $$
|
||||
DECLARE t text;
|
||||
BEGIN
|
||||
FOREACH t IN ARRAY ARRAY[
|
||||
'policy_documents','policy_requirements','policy_variables',
|
||||
'policy_baseline_params','policy_evidence'
|
||||
] LOOP
|
||||
EXECUTE format('ALTER TABLE %I ENABLE ROW LEVEL SECURITY', t);
|
||||
EXECUTE format(
|
||||
'CREATE POLICY tenant_isolation ON %I USING (tenant_id = current_setting(''app.tenant_id'', true))',
|
||||
t
|
||||
);
|
||||
END LOOP;
|
||||
END $$;
|
||||
@@ -655,3 +655,113 @@ model AuditLog {
|
||||
@@index([tenantId, createdAt])
|
||||
@@map("audit_logs")
|
||||
}
|
||||
|
||||
// ── Richtlinien & Verfahren (VDA-ISA 2027 Vorlagenpaket) ──────────────────────
|
||||
// Dokumente werden aus ihrer echten Markdown-Vorlage gerendert; Variablen,
|
||||
// Feature-Flags und Baseline-Parameter sind die eine Pflegestelle (§7).
|
||||
|
||||
enum PolicyDocType {
|
||||
LEITLINIE // L00
|
||||
RICHTLINIE // R01–R14
|
||||
VERFAHREN // VA-01–VA-13
|
||||
REGISTER // verwaltete Tabellen (Baseline, Nachweisregister, …)
|
||||
HANDBUCH // Anwender-Handbuch
|
||||
EIGENES // Word-Upload
|
||||
}
|
||||
|
||||
enum PolicyStatus {
|
||||
ENTWURF
|
||||
IN_FREIGABE
|
||||
FREIGEGEBEN
|
||||
ARCHIVIERT
|
||||
}
|
||||
|
||||
model PolicyDocument {
|
||||
id String @id @default(cuid())
|
||||
tenantId String @map("tenant_id")
|
||||
code String // L00 | R01..R14 | VA-01..VA-13 | BASELINE | NACHWEIS | ISA_MAPPING
|
||||
type PolicyDocType
|
||||
title String
|
||||
version String @default("1.0")
|
||||
status PolicyStatus @default(FREIGEGEBEN)
|
||||
owner String?
|
||||
policyCode String? @map("policy_code") // bei VA: operationalisierte Richtlinie (R..)
|
||||
fulfills String[] @default([]) // bei VA: erfüllte Anforderungs-IDs
|
||||
rawMarkdown String @map("raw_markdown") // Vorlagen-Markdown mit Platzhaltern
|
||||
orderIdx Int @default(0) @map("order_idx")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@unique([tenantId, code])
|
||||
@@index([tenantId])
|
||||
@@map("policy_documents")
|
||||
}
|
||||
|
||||
model PolicyRequirement {
|
||||
id String @id @default(cuid())
|
||||
tenantId String @map("tenant_id")
|
||||
reqId String @map("req_id") // z. B. 4.1.2-M1
|
||||
policyCode String @map("policy_code") // R08
|
||||
control String // 4.1.2
|
||||
obligation String // MUSS | SOLL
|
||||
condition String? // FLAG_… oder null
|
||||
requirement String
|
||||
implementation String
|
||||
vaCodes String[] @default([]) @map("va_codes") // operationalisierende Verfahren
|
||||
nachweisLink String? @map("nachweis_link")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
@@unique([tenantId, reqId])
|
||||
@@index([tenantId])
|
||||
@@index([tenantId, control])
|
||||
@@map("policy_requirements")
|
||||
}
|
||||
|
||||
// Wizard-Variablen und Feature-Flags (variables.schema.json) — eine Pflegestelle
|
||||
model PolicyVariable {
|
||||
id String @id @default(cuid())
|
||||
tenantId String @map("tenant_id")
|
||||
key String // UPPER_SNAKE, z. B. PW_MIN_LENGTH / FLAG_CLOUD_USED
|
||||
title String
|
||||
kind String // string | boolean
|
||||
groupName String? @map("group_name")
|
||||
value String // aktueller Wert (Default aus Schema); Flags als "true"/"false"
|
||||
required Boolean @default(false)
|
||||
orderIdx Int @default(0) @map("order_idx")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@unique([tenantId, key])
|
||||
@@index([tenantId])
|
||||
@@map("policy_variables")
|
||||
}
|
||||
|
||||
model PolicyBaselineParam {
|
||||
id String @id @default(cuid())
|
||||
tenantId String @map("tenant_id")
|
||||
blId String @map("bl_id") // BL-IAM-01
|
||||
section String // "1. Identitäts- und Zugriffsmanagement"
|
||||
name String
|
||||
vorgabe String // Vorlagentext (kann {{VARIABLE}} enthalten)
|
||||
orderIdx Int @default(0) @map("order_idx")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
@@unique([tenantId, blId])
|
||||
@@index([tenantId])
|
||||
@@map("policy_baseline_params")
|
||||
}
|
||||
|
||||
model PolicyEvidence {
|
||||
id String @id @default(cuid())
|
||||
tenantId String @map("tenant_id")
|
||||
nr Int
|
||||
policyCode String @map("policy_code")
|
||||
nachweis String
|
||||
quelle String
|
||||
verantwortlich String
|
||||
turnus String
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
@@index([tenantId])
|
||||
@@map("policy_evidence")
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ import "dotenv/config";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { PrismaPg } from "@prisma/adapter-pg";
|
||||
import { hash } from "@node-rs/argon2";
|
||||
import { join } from "node:path";
|
||||
import { PERMISSIONS, ROLE_DEFS } from "../src/server/rbac";
|
||||
import { importPolicies } from "./import-policies";
|
||||
|
||||
/**
|
||||
* Seed: global permission catalog + demo tenant with roles and users.
|
||||
@@ -504,6 +506,22 @@ async function main() {
|
||||
}
|
||||
console.log("✔ 1 Demo-IT-Service mit RACI-Matrix angelegt");
|
||||
}
|
||||
|
||||
// 10. Richtlinien & Verfahren aus dem VDA-ISA-2027-Vorlagenpaket importieren
|
||||
const seedDir = join(__dirname, "..", "seed", "isms-vorlagenpaket-v2");
|
||||
const pc = await importPolicies(prisma, tenant.id, seedDir);
|
||||
// Demo-Werte für Variablen ohne Schema-Default (damit die Doku vollständig wirkt)
|
||||
const demoVars: Record<string, string> = {
|
||||
ORG_NAME: "GEFIM Demo GmbH",
|
||||
ORG_SHORT: "GEFIM",
|
||||
ISMS_SCOPE: "IT-Betrieb & Softwareentwicklung",
|
||||
ISMS_SCOPE_DESCRIPTION: "IT-Betrieb, Softwareentwicklung und zugehörige Unterstützungsprozesse am Standort Zentrale",
|
||||
DOC_DATE: "2026-07-07",
|
||||
};
|
||||
for (const [key, value] of Object.entries(demoVars)) {
|
||||
await prisma.policyVariable.updateMany({ where: { tenantId: tenant.id, key }, data: { value } });
|
||||
}
|
||||
console.log(`✔ Richtlinienpaket importiert: ${pc.documents} Dokumente, ${pc.requirements} Anforderungen, ${pc.variables} Variablen, ${pc.baseline} Baseline-Parameter`);
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user