diff --git a/AGENTS.md b/AGENTS.md index 942302a..73aa20f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -133,7 +133,7 @@ Noch nicht umgesetzt — bitte nicht als vorhanden dokumentieren, bevor es wirkl - [ ] Automatischer Server-Neustart (`systemd` oder `pm2`). - [ ] SSL/HTTPS für Produktionsbetrieb. - [ ] Docker-Containerisierung. -- [ ] Path-Traversal-Schutz und Auth für den PUT-Endpoint. +- [ ] Auth für den PUT-Endpoint. --- diff --git a/README.md b/README.md index 28e0f09..5aa35f9 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ python scripts/validate.py pfad/zum/template.json python scripts/validate.py --all # Nur JSON-Templates -python scripts/validate.py --type-json +python scripts/validate.py --all --type-json ``` --- diff --git a/docs/INDEX.md b/docs/INDEX.md index 3b399ce..5ae1c02 100644 --- a/docs/INDEX.md +++ b/docs/INDEX.md @@ -25,4 +25,4 @@ Dieser Ordner enthält alle technischen und prozessbezogenen Dokumentationen fü --- -*Letzte Aktualisierung: `$(date +%Y-%m-%d)`* +*Letzte Aktualisierung: 2026-05-03* diff --git a/web/file_ops.py b/web/file_ops.py index 594661a..e50f8aa 100644 --- a/web/file_ops.py +++ b/web/file_ops.py @@ -10,25 +10,6 @@ from pathlib import Path from typing import Optional -def read_file(filepath: str) -> Optional[str]: - """ - Liest eine Datei und gibt den Inhalt als String zurück. - - Args: - filepath: Absoluter Pfad zur Datei - - Returns: - Dateiinhalt als UTF-8 String, oder None bei Fehler - """ - try: - with open(filepath, "r", encoding="utf-8") as f: - return f.read() - except FileNotFoundError: - return None - except Exception: - return None - - def read_file_binary(filepath: str) -> Optional[bytes]: """ Liest eine Datei im Binärmodus. @@ -71,11 +52,6 @@ def write_file(filepath: str, content: bytes) -> bool: return False -def file_exists(filepath: str) -> bool: - """Prüft, ob eine Datei existiert.""" - return os.path.isfile(filepath) - - def directory_exists(dirpath: str) -> bool: """Prüft, ob ein Verzeichnis existiert.""" return os.path.isdir(dirpath) diff --git a/web/handler.py b/web/handler.py index 547426b..3f98d84 100644 --- a/web/handler.py +++ b/web/handler.py @@ -35,6 +35,26 @@ class Handler(http.server.SimpleHTTPRequestHandler): def __init__(self, *args, directory=None, **kwargs): super().__init__(*args, directory=directory or self.directory, **kwargs) + def send_response(self, code, message=None): + if self.request_version != 'HTTP/0.9': + if message is None: + if code in self.responses: + message = self.responses[code][0] + else: + message = '' + if not hasattr(self, '_headers_buffer'): + self._headers_buffer = [] + self._headers_buffer.append(("%s %d %s\r\n" % + (self.protocol_version, code, message)).encode('latin-1', 'strict')) + # Write Server and Date headers (mimicking base class behavior) + self.send_header('Server', self.version_string()) + self.send_header('Date', self.date_time_string()) + # Security headers + self.send_header('X-Content-Type-Options', 'nosniff') + self.send_header('X-Frame-Options', 'DENY') + self.send_header('Content-Security-Policy', + "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self'; frame-ancestors 'none'") + def do_PUT(self): """Speichert eine Template-Datei.""" file_path = self.validator.resolve_template_path(urlparse(self.path).path) @@ -77,7 +97,7 @@ class Handler(http.server.SimpleHTTPRequestHandler): self.wfile.write(b"File saved successfully") except Exception as e: logger.error("Failed to save file: %s", e) - self.send_error(500, f"Failed to save file: {e}") + self.send_error(500, "Failed to save file") def do_GET(self): """Liefert Dateien aus.""" diff --git a/web/index.html b/web/index.html index 848e20e..073415d 100644 --- a/web/index.html +++ b/web/index.html @@ -47,7 +47,7 @@ -
+