diff --git a/Test Suite-DE.md b/Test Suite-DE.md index 386bb52..071189c 100644 --- a/Test Suite-DE.md +++ b/Test Suite-DE.md @@ -15,7 +15,7 @@ Dieses Dokument bietet einen umfassenden Überblick über alle Tests im vgui-cic ## abschnitte App Tests -Die abschnitte App enthält 32 Tests, die Modelle, Utility-Funktionen, Diagram-Caching und Management-Befehle abdecken. +Die abschnitte App enthält 33 Tests, die Modelle, Utility-Funktionen, Diagram-Caching, Management-Befehle und Sicherheit abdecken. ### Modell-Tests @@ -58,6 +58,7 @@ Die abschnitte App enthält 32 Tests, die Modelle, Utility-Funktionen, Diagram-C - **test_render_text_with_footnotes**: Verarbeitet Text, der Fußnoten enthält - **test_render_abschnitt_without_type**: Behandelt Textabschnitte ohne AbschnittTyp - **test_render_abschnitt_with_empty_content**: Behandelt Textabschnitte mit leerem Inhalt +- **test_render_textabschnitte_xss_prevention**: Überprüft, dass bösartiger HTML-Code und Skript-Tags aus gerenderten Inhalten bereinigt werden, um XSS-Angriffe zu verhindern ### Diagram-Caching-Tests @@ -332,8 +333,8 @@ Die stichworte App enthält 18 Tests, die Schlüsselwortmodelle und ihre Sortier ## Test-Statistiken -- **Gesamt-Tests**: 206 -- **abschnitte**: 32 Tests +- **Gesamt-Tests**: 207 +- **abschnitte**: 33 Tests (einschließlich XSS-Prävention) - **dokumente**: 116 Tests (98 in tests.py + 9 in test_json.py + 9 JSON-Tests in Haupt-tests.py) - **pages**: 4 Tests - **referenzen**: 18 Tests @@ -348,6 +349,7 @@ Die stichworte App enthält 18 Tests, die Schlüsselwortmodelle und ihre Sortier 4. **Utility-Funktionen**: Textverarbeitung, Caching, Formatierung 5. **Management-Befehle**: CLI-Schnittstelle und Ausgabeverarbeitung 6. **Integration**: App-übergreifende Funktionalität und Datenfluss +7. **Sicherheit**: XSS-Prävention durch HTML-Bereinigung beim Rendern von Inhalten ## Ausführen der Tests diff --git a/Test suite.md b/Test suite.md index f3f33ee..dda99a5 100644 --- a/Test suite.md +++ b/Test suite.md @@ -15,7 +15,7 @@ This document provides a comprehensive overview of all tests in the vgui-cicd Dj ## abschnitte App Tests -The abschnitte app contains 32 tests covering models, utility functions, diagram caching, and management commands. +The abschnitte app contains 33 tests covering models, utility functions, diagram caching, management commands, and security. ### Model Tests @@ -58,6 +58,7 @@ The abschnitte app contains 32 tests covering models, utility functions, diagram - **test_render_text_with_footnotes**: Processes text containing footnotes - **test_render_abschnitt_without_type**: Handles Textabschnitte without AbschnittTyp - **test_render_abschnitt_with_empty_content**: Handles Textabschnitte with empty content +- **test_render_textabschnitte_xss_prevention**: Verifies that malicious HTML and script tags are sanitized from rendered content to prevent XSS attacks ### Diagram Caching Tests @@ -332,8 +333,8 @@ The stichworte app contains 18 tests covering keyword models and their ordering. ## Test Statistics -- **Total Tests**: 206 -- **abschnitte**: 32 tests +- **Total Tests**: 207 +- **abschnitte**: 33 tests (including XSS prevention) - **dokumente**: 116 tests (98 in tests.py + 9 in test_json.py + 9 JSON tests in main tests.py) - **pages**: 4 tests - **referenzen**: 18 tests @@ -348,6 +349,7 @@ The stichworte app contains 18 tests covering keyword models and their ordering. 4. **Utility Functions**: Text processing, caching, formatting 5. **Management Commands**: CLI interface and output handling 6. **Integration**: Cross-app functionality and data flow +7. **Security**: XSS prevention through HTML sanitization in content rendering ## Running the Tests diff --git a/VorgabenUI/settings.py b/VorgabenUI/settings.py index f32e2f8..b77e2cd 100644 --- a/VorgabenUI/settings.py +++ b/VorgabenUI/settings.py @@ -28,12 +28,6 @@ DEBUG = True ALLOWED_HOSTS = ["10.128.128.144","localhost","127.0.0.1","*"] -TEMPLATES = [ - {"BACKEND": "django.template.backends.django.DjangoTemplates", - "APP_DIRS": True, - } -] - # Application definition INSTALLED_APPS = [ diff --git a/abschnitte/tests.py b/abschnitte/tests.py index 8d8d8b9..a8c7ba1 100644 --- a/abschnitte/tests.py +++ b/abschnitte/tests.py @@ -467,6 +467,32 @@ A -> B typ, html = result[0] self.assertEqual(typ, "text") + def test_render_textabschnitte_xss_prevention(self): + """Test that malicious HTML is sanitized in rendered content""" + from dokumente.models import VorgabeLangtext + + # Create content with malicious HTML + malicious_abschnitt = VorgabeLangtext.objects.create( + abschnitt=self.vorgabe, + abschnitttyp=self.typ_text, + inhalt='Normal text', + order=1 + ) + + result = render_textabschnitte(VorgabeLangtext.objects.filter(pk=malicious_abschnitt.pk)) + + self.assertEqual(len(result), 1) + typ, html = result[0] + self.assertEqual(typ, "text") + + # Dangerous tags and attributes should be removed or sanitized + self.assertNotIn('