### OSCAL Back-Matter Resources Example Source: https://github.com/bsi-bund/stand-der-technik-bibliothek/blob/main/Dokumentation/OSCAL.md Illustrates how to include references to additional resources in the back-matter section of an OSCAL file. ```yaml back-matter: resources: - title: "Zugriffsrichtlinien" href: "https://example.com/zugriffsrichtlinien.pdf" ``` -------------------------------- ### OSCAL Catalog Control Example Source: https://github.com/bsi-bund/stand-der-technik-bibliothek/blob/main/Dokumentation/OSCAL.md An example of a control entry within an OSCAL catalog, including its ID, title, and description. ```yaml controls: - id: "BER.1.1" title: "Verfahren und Regelungen" description: "Regelt die Verwaltung von Benutzerkonten." ``` -------------------------------- ### OSCAL Metadata Example Source: https://github.com/bsi-bund/stand-der-technik-bibliothek/blob/main/Dokumentation/OSCAL.md Defines general information about the OSCAL file, such as title, last modification date, and organization. ```yaml metadata: title: "Grundschutz++ Kompendium 2026" last-modified: 2025-09-10 organization: "Bundesamt für Sicherheit in der Informationstechnik" ``` -------------------------------- ### Namespace-Werte aus CSV laden Source: https://context7.com/bsi-bund/stand-der-technik-bibliothek/llms.txt Lädt definierte Werte aus einer Namespace-CSV-Datei, die für Metadaten wie Modalverben oder Sicherheitsstufen verwendet werden. Die CSV-Datei muss mit Semikolons getrennt sein. ```python import csv def load_namespace_values(csv_path: str) -> list: """Lädt definierte Werte aus einer Namespace-CSV-Datei.""" values = [] with open(csv_path, 'r', encoding='utf-8') as f: reader = csv.DictReader(f, delimiter=';') for row in reader: values.append(row) return values # Modalverben laden modal_verbs = load_namespace_values('Dokumentation/namespaces/modal_verbs.csv') print("Definierte Modalverben:") for verb in modal_verbs: print(f" - {verb.get('value')}: {verb.get('description', verb.get('remarks', ''))}") # Sicherheitsstufen laden security_levels = load_namespace_values('Dokumentation/namespaces/security_level.csv') print("\nDefinierte Sicherheitsstufen:") for level in security_levels: print(f" - {level.get('value')}") ``` -------------------------------- ### Load OSCAL Catalog in Python Source: https://context7.com/bsi-bund/stand-der-technik-bibliothek/llms.txt Loads an OSCAL catalog from a JSON file. Ensure the file path is correct and the file contains a 'catalog' key. ```python import json from pathlib import Path # OSCAL-Katalog laden def load_oscal_catalog(file_path: str) -> dict: """Lädt einen OSCAL-Katalog aus einer JSON-Datei.""" with open(file_path, 'r', encoding='utf-8') as f: data = json.load(f) return data.get('catalog', {}) # Beispiel: Grundschutz++ Anwenderkatalog laden catalog = load_oscal_catalog('Anwenderkataloge/Grundschutz++/Grundschutz++-catalog.json') # Metadaten extrahieren metadata = catalog.get('metadata', {}) print(f"Katalog: {metadata.get('title')}") print(f"Version: {metadata.get('version')}") print(f"OSCAL-Version: {metadata.get('oscal-version')}") print(f"Letzte Änderung: {metadata.get('last-modified')}") # Ausgabe: # Katalog: Anwenderkatalog Grundschutz++ # Version: 2026-04-20T11:58:28.849874+00:00 # OSCAL-Version: 1.1.3 # Letzte Änderung: 2026-04-20T11:58:38.048452946Z ``` -------------------------------- ### Komponenten auflisten Source: https://context7.com/bsi-bund/stand-der-technik-bibliothek/llms.txt Listet Komponenten aus einer gegebenen Definition auf und zeigt deren Typ, Zweck und Beschreibung an. Zeigt auch implementierte Anforderungen für jede Komponente an. ```python for component in comp_def.get('components', []): print(f"\nKomponente: {component.get('title')}") print(f"Typ: {component.get('type')}") print(f"Zweck: {component.get('purpose', 'N/A')}") print(f"Beschreibung: {component.get('description')[:200]}...") # Implementierte Anforderungen anzeigen for impl in component.get('control-implementations', []): for req in impl.get('implemented-requirements', []): print(f" - Implementiert Control: {req.get('control-id')}") ``` -------------------------------- ### SSP-Vorlage erstellen Source: https://context7.com/bsi-bund/stand-der-technik-bibliothek/llms.txt Erstellt eine Vorlage für einen System-Sicherheitsplan (SSP) basierend auf einem OSCAL-Profil. Die Funktion generiert eine eindeutige UUID und fügt Systeminformationen sowie Komponenten hinzu. ```python import uuid from datetime import datetime import json def create_ssp_template(title: str, profile_href: str, components: list) -> dict: """Erstellt eine SSP-Vorlage basierend auf einem Profile.""" ssp = { "system-security-plan": { "uuid": str(uuid.uuid4()), "metadata": { "title": title, "last-modified": datetime.now().isoformat(), "version": "1.0", "oscal-version": "1.1.3" }, "import-profile": { "href": profile_href }, "system-characteristics": { "system-ids": [{"id": str(uuid.uuid4())}], "system-name": title, "description": f"System-Sicherheitsplan für {title}", "security-sensitivity-level": "moderate", "system-information": { "information-types": [] }, "security-impact-level": { "security-objective-confidentiality": "moderate", "security-objective-integrity": "moderate", "security-objective-availability": "moderate" }, "status": {"state": "operational"} }, "system-implementation": { "users": [], "components": components }, "control-implementation": { "description": "Implementierung der ausgewählten Anforderungen", "implemented-requirements": [] } } } return ssp # SSP für ein Beispielsystem erstellen ssp = create_ssp_template( title="Unternehmens-Webanwendung", profile_href="Quellkataloge/Methodik-Grundschutz++/Grundschutz++-profile.json", components=[ { "uuid": str(uuid.uuid4()), "type": "software", "title": "Apache Webserver", "description": "Webserver für die Anwendung", "status": {"state": "operational"} } ] ) # SSP speichern with open('mein_ssp.json', 'w', encoding='utf-8') as f: json.dump(ssp, f, indent=2, ensure_ascii=False) print("SSP erstellt: mein_ssp.json") ``` -------------------------------- ### OSCAL-Katalog nach Markdown exportieren Source: https://context7.com/bsi-bund/stand-der-technik-bibliothek/llms.txt Exportiert einen OSCAL-Katalog in ein Markdown-Dokument. Stellt sicher, dass der 'catalog'-Parameter ein Dictionary mit Metadaten und Gruppen ist. ```python def export_catalog_to_markdown(catalog: dict, output_path: str): """Exportiert einen OSCAL-Katalog als Markdown-Dokument.""" metadata = catalog.get('metadata', {}) lines = [ f"# {metadata.get('title', 'OSCAL Katalog')}", f"\n**Version:** {metadata.get('version')}", f"**OSCAL-Version:** {metadata.get('oscal-version')}", f"**Letzte Änderung:** {metadata.get('last-modified')}", f"\n{metadata.get('remarks', '')}\n", "---\n" ] for practice in catalog.get('groups', []): lines.append(f"\n## {practice.get('id')} - {practice.get('title')}\n") for theme in practice.get('groups', []): lines.append(f"\n### {theme.get('id')} - {theme.get('title')}\n") for control in theme.get('controls', []): lines.append(f"\n#### {control.get('id')}: {control.get('title')}\n") for part in control.get('parts', []): if part.get('name') == 'statement': lines.append(f"\n> {part.get('prose', '')}\n") with open(output_path, 'w', encoding='utf-8') as f: f.write('\n'.join(lines)) print(f"Katalog exportiert nach: {output_path}") # Export durchführen export_catalog_to_markdown(catalog, 'Grundschutz_Katalog.md') ``` -------------------------------- ### OSCAL-Profile laden Source: https://context7.com/bsi-bund/stand-der-technik-bibliothek/llms.txt Lädt ein OSCAL-Profil aus einer gegebenen Datei und gibt das Profil-Objekt zurück. Zeigt importierte Kataloge und modifizierte Controls an. ```python import json def load_profile(file_path: str) -> dict: """Lädt ein OSCAL-Profile.""" with open(file_path, 'r', encoding='utf-8') as f: data = json.load(f) return data.get('profile', {}) # Grundschutz++ Profile laden profile = load_profile('Quellkataloge/Methodik-Grundschutz++/Grundschutz++-profile.json') # Importierte Kataloge anzeigen for imp in profile.get('imports', []): print(f"Importiert von: {imp.get('href')}") # Ausgewählte Controls include = imp.get('include-controls', []) for inc in include: matching = inc.get('with-ids', []) print(f" Ausgewählte Control-IDs: {len(matching)}") # Modifikationen anzeigen modify = profile.get('modify', {}) for alteration in modify.get('alters', []): control_id = alteration.get('control-id') print(f"Modifiziert Control: {control_id}") ``` -------------------------------- ### Extract Controls from OSCAL Catalog in Python Source: https://context7.com/bsi-bund/stand-der-technik-bibliothek/llms.txt Extracts all controls from a loaded OSCAL catalog, organizing them by practice and theme. It also extracts the statement and modal verb from each control's parts. ```python def extract_controls(catalog: dict) -> list: """Extrahiert alle Controls aus einem OSCAL-Katalog.""" controls = [] for practice_group in catalog.get('groups', []): practice_id = practice_group.get('id') practice_title = practice_group.get('title') for theme_group in practice_group.get('groups', []): theme_id = theme_group.get('id') theme_title = theme_group.get('title') for control in theme_group.get('controls', []): controls.append({ 'id': control.get('id'), 'title': control.get('title'), 'practice': practice_title, 'theme': theme_title, 'class': control.get('class'), 'parts': control.get('parts', []) }) return controls # Alle Controls extrahieren all_controls = extract_controls(catalog) print(f"Anzahl Controls: {len(all_controls)}") # Erstes Control anzeigen control = all_controls[0] print(f"\nControl ID: {control['id']}") print(f"Titel: {control['title']}") print(f"Praktik: {control['practice']}") print(f"Thema: {control['theme']}") # Statement-Prose auslesen for part in control['parts']: if part.get('name') == 'statement': print(f"Statement: {part.get('prose')}") # Modalverb und Aktionswort extrahieren for prop in part.get('props', []): if prop.get('name') == 'modal_verb': print(f"Modalverb: {prop.get('value')}") # MUSS, SOLLTE, KANN if prop.get('name') == 'action_word': print(f"Aktionswort: {prop.get('value')}") # Ausgabe: # Control ID: GC.1.1 # Titel: Errichtung und Aufrechterhaltung eines ISMS # Praktik: Governance und Compliance # Thema: Grundlagen # Statement: Governance und Compliance MUSS Verfahren und Regelungen zur Errichtung... # Modalverb: MUSS # Aktionswort: verankern ``` -------------------------------- ### Controls nach Sicherheitsstufe filtern Source: https://context7.com/bsi-bund/stand-der-technik-bibliothek/llms.txt Filtert Controls aus einem Katalog basierend auf einer angegebenen Sicherheitsstufe. Gibt eine Liste von Controls mit ihrer ID, ihrem Titel und ihrer Sicherheitsstufe zurück. ```python def filter_controls_by_security_level(catalog: dict, level: str) -> list: """Filtert Controls nach Sicherheitsstufe.""" filtered = [] for practice in catalog.get('groups', []): for theme in practice.get('groups', []): for control in theme.get('controls', []): for prop in control.get('props', []): if prop.get('name') == 'sec_level' and prop.get('value') == level: filtered.append({ 'id': control.get('id'), 'title': control.get('title'), 'security_level': prop.get('value') }) return filtered # Nur Controls für normale Sicherheitsstufe normal_controls = filter_controls_by_security_level(catalog, 'normal-SdT') print(f"Controls für normale Sicherheitsstufe: {len(normal_controls)}") for ctrl in normal_controls[:3]: print(f" - {ctrl['id']}: {ctrl['title']}") ``` -------------------------------- ### OSCAL-Katalog validieren Source: https://context7.com/bsi-bund/stand-der-technik-bibliothek/llms.txt Validiert einen OSCAL-Katalog gegen ein gegebenes JSON-Schema. Gibt Erfolg oder Fehlermeldung aus. ```python import json from jsonschema import validate, ValidationError def validate_catalog(catalog_path: str, schema_path: str) -> bool: """Validiert einen OSCAL-Katalog gegen das Schema.""" with open(catalog_path, 'r', encoding='utf-8') as f: catalog = json.load(f) with open(schema_path, 'r', encoding='utf-8') as f: schema = json.load(f) try: validate(instance=catalog, schema=schema) print(f"✓ Katalog '{catalog_path}' ist gültig") return True except ValidationError as e: print(f"✗ Validierungsfehler: {e.message}") return False # Validierung durchführen validate_catalog( 'Anwenderkataloge/Grundschutz++/Grundschutz++-catalog.json', 'Dokumentation/datamodel/oscal_satzschablone_schema.json' ) ``` -------------------------------- ### Load OSCAL Component Definition in Python Source: https://context7.com/bsi-bund/stand-der-technik-bibliothek/llms.txt Loads an OSCAL component definition from a JSON file. This function is used to process reusable implementation templates for hardware, software, policies, or processes. ```python def load_component_definition(file_path: str) -> dict: """Lädt eine OSCAL-Komponentendefinition.""" with open(file_path, 'r', encoding='utf-8') as f: data = json.load(f) return data.get('component-definition', {}) # AWS IAM Komponenten laden comp_def = load_component_definition( 'Implementierungsbeschreibungen/Komponenten/AWS Beispiel-Components/aws_iam-component_definition.json' ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.