# Code Review: vgui-cicd Django Project **Date:** January 20, 2026 **Reviewer:** AI Code Review **Project Path:** /home/adebaumann/development/vgui-cicd --- ## 1. PROJECT STRUCTURE ### Overview The project follows Django conventions with a clear app structure: - **VorgabenUI** - Main project settings, URLs, WSGI/ASGI - **dokumente** - Core document and Vorgabe models (315 lines) - **abschnitte** - Text section models and utilities - **stichworte** - Keyword/stichwort models - **referenzen** - Reference models (MPTT-based) - **rollen** - Role models - **pages** - General pages and views - **diagramm_proxy** - Diagram caching functionality ### Issues Found **Minor - settings-docker.py**: The `settings-docker.py` file has duplicate `AUTH_PASSWORD_VALIDATORS` definitions (lines 92-105 and 183-199), which is redundant. - **File**: `/home/adebaumann/development/vgui-cicd/VorgabenUI/settings-docker.py` (lines 92-105 and 183-199) --- ## 2. SETTINGS REVIEW ### Critical Issues **1. Fallback SECRET_KEY in production** (`/home/adebaumann/development/vgui-cicd/VorgabenUI/settings.py`, lines 27-47) ```python SECRET_KEY = os.environ.get('VORGABENUI_SECRET') if not SECRET_KEY: is_build_env = any([...]) debug_mode = ... if debug_mode or is_build_env: SECRET_KEY = 'dev-fallback-key-for-local-debugging-only-not-for-production-use-12345' ``` - **Issue**: Even though there's a check for build environments, the hardcoded fallback key creates a significant security risk if the environment variable is not properly set in production - **Recommendation**: The fallback should NEVER be enabled, even in development - require the environment variable to be set **2. DEBUG mode default** (`/home/adebaumann/development/vgui-cicd/VorgabenUI/settings.py`, line 24) ```python DEBUG = os.environ.get('DEBUG', 'True').lower() in ('true', '1', 'yes', 'on') ``` - **Issue**: DEBUG defaults to True, which could expose sensitive information if environment variables are misconfigured - **Recommendation**: Require explicit setting of DEBUG to False in production ### Major Issues **3. ALLOWED_HOSTS with wildcard** (`/home/adebaumann/development/vgui-cicd/VorgabenUI/settings.py`, line 50) ```python ALLOWED_HOSTS = os.environ.get('DJANGO_ALLOWED_HOSTS', "10.128.128.144,localhost,127.0.0.1,*").split(",") ``` - **Issue**: Default includes `*` which allows any host - dangerous in production - **Recommendation**: Default should not include wildcard; require explicit configuration **4. No rate limiting on authentication** (`/home/adebaumann/development/vgui-cicd/VorgabenUI/settings.py`) - **Issue**: No login throttling or rate limiting configured for authentication endpoints - **Recommendation**: Add `django-axes` or similar for brute-force protection **5. SQLite in production** (`/home/adebaumann/development/vgui-cicd/VorgabenUI/settings.py`, lines 109-114) ```python DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'data/db.sqlite3', } } ``` - **Issue**: SQLite is used as default database - not suitable for production with concurrent access - **Recommendation**: Configure PostgreSQL or other production-ready database ### Minor Issues **6. TIME_ZONE mismatch** (`/home/adebaumann/development/vgui-cicd/VorgabenUI/settings.py`, lines 139-145) - **Issue**: `LANGUAGE_CODE = 'de-ch'` but `TIME_ZONE = 'UTC'` - timezone should probably be 'Europe/Zurich' for Swiss deployment - **File**: `/home/adebaumann/development/vgui-cicd/VorgabenUI/settings.py` (lines 141) --- ## 3. MODELS REVIEW ### Major Issues **1. Missing `verbose_name` on models** - Several models are missing proper `verbose_name` in their Meta class: - `Stichwort` (`/home/adebaumann/development/vgui-cicd/stichworte/models.py`, lines 4-11) - missing verbose_name - `Referenz` (`/home/adebaumann/development/vgui-cicd/referenzen/models.py`, lines 6-27) - missing verbose_name - `Rolle` (`/home/adebaumann/development/vgui-cicd/rollen/models.py`, lines 5-11) - missing verbose_name - `Person` (`/home/adebaumann/development/vgui-cicd/dokumente/models.py`, lines 22-30) - missing verbose_name - `Thema` (`/home/adebaumann/development/vgui-cicd/dokumente/models.py`, lines 32-39) - missing verbose_name **2. BooleanField with `blank=True` but no default** (`/home/adebaumann/development/vgui-cicd/dokumente/models.py`, line 52) ```python aktiv = models.BooleanField(blank=True) ``` - **Issue**: BooleanField should have explicit `default=False` for clarity - **Recommendation**: Add `default=False` **3. No database constraints for date validation** (`/home/adebaumann/development/vgui-cicd/dokumente/models.py`, lines 96-97) ```python gueltigkeit_von = models.DateField() gueltigkeit_bis = models.DateField(blank=True,null=True) ``` - **Issue**: No database-level constraint ensuring `gueltigkeit_bis >= gueltigkeit_von` - **Recommendation**: Add constraint validation or override `save()` method ### Minor Issues **4. Inconsistent naming in foreign key fields** - Some models use plural related names inconsistently: - `autoren` and `pruefende` on `Dokument` use plural (correct) - Could consider singular `related_name` for consistency where applicable **5. Missing `related_name` on some ManyToMany fields** (`/home/adebaumann/development/vgui-cicd/dokumente/models.py`, line 289) ```python autoren = models.ManyToManyField(Person) # Missing related_name ``` - **Recommendation**: Add `related_name='changelog_entries'` for clarity --- ## 4. VIEWS REVIEW ### Critical Issues **1. No CSRF protection on comment endpoints** (`/home/adebaumann/development/vgui-cicd/dokumente/views.py`, lines 321-377) ```python @require_POST @login_required def add_vorgabe_comment(request, vorgabe_id): # No @csrf_exempt but also no CSRF token verification in the view ``` - **Issue**: The view uses `@require_POST` but doesn't verify CSRF tokens for the JSON endpoint - **Recommendation**: Add `@csrf_exempt` ONLY if intentionally bypassing, or ensure CSRF is handled via the X-CSRFToken header (which is done in the template) **Note**: Looking at line 368, the template sends `'X-CSRFToken': getCookie('csrftoken')`, so this is actually properly handled. **Not a bug.** **2. XSS in comment display** (`/home/adebaumann/development/vgui-cicd/dokumente/views.py`, lines 305-306) ```python escaped_text = escape(comment.text).replace('\n', '
') ``` - **Issue**: Using `escape()` is good, but line breaks are converted to `
` which could still be exploited - **Note**: The `dangerous_patterns` check at lines 339-343 provides some protection - **Recommendation**: Consider using a more robust HTML sanitization library **3. No input validation on comment length** (`/home/adebaumann/development/vgui-cicd/dokumente/views.py`, line 335) ```python if len(text) > 2000: # Reasonable length limit ``` - **Issue**: This is actually properly implemented with a 2000 character limit - **Status**: OK ### Major Issues **4. Referenz view lacks error handling** (`/home/adebaumann/development/vgui-cicd/referenzen/views.py`, lines 11-19) ```python def detail(request, refid): referenz_item = Referenz.objects.get(id=refid) ``` - **Issue**: `DoesNotExist` exception not caught - will return 500 error instead of 404 - **Recommendation**: Use `get_object_or_404` for consistency ### Minor Issues **5. Search view allows complex regex patterns** (`/home/adebaumann/development/vgui-cicd/pages/views.py`, lines 36-70) - **Issue**: The validation is good but the `groupby` usage at line 54 could fail if data is not properly sorted - **Recommendation**: Add explicit ordering before groupby **6. No rate limiting on search** (`/home/adebaumann/development/vgui-cicd/pages/views.py`) - **Issue**: Search endpoint could be abused for DoS - **Recommendation**: Add rate limiting --- ## 5. URL CONFIGURATION ### Minor Issues **1. No URL namespace for include** (`/home/adebaumann/development/vgui-cicd/VorgabenUI/urls.py`, lines 31-35) ```python path('dokumente/', include("dokumente.urls")), path('stichworte/', include("stichworte.urls")), ``` - **Issue**: No `app_name` namespace defined in included apps - **Recommendation**: Add `app_name = 'dokumente'` to `dokumente/urls.py` for cleaner reversals **2. Inconsistent trailing slashes** - Most URLs have trailing slashes but not all - ensure consistency --- ## 6. TEMPLATES REVIEW ### Critical Issues **1. XSS vulnerability in `standard_detail.html`** (`/home/adebaumann/development/vgui-cicd/dokumente/templates/standards/standard_detail.html`, lines 163-164) ```html {% for ref in vorgabe.referenzpfade %} {{ ref|safe }}{% if not forloop.last %}, {% endif %} ``` - **Issue**: Using `|safe` on reference paths could allow XSS if malicious content is stored - **Recommendation**: Use `escape` filter and handle line breaks separately **2. JavaScript in template without CSP** (`/home/adebaumann/development/vgui-cicd/dokumente/templates/standards/standard_detail.html`, lines 249-424) - **Issue**: Inline JavaScript in template - **Note**: CSP headers are set in the view (line 316-317), but inline scripts violate strict CSP - **Recommendation**: Move JavaScript to external file ### Major Issues **3. Missing ARIA labels and roles** - Several accessibility issues: - Base template (`/home/adebaumann/development/vgui-cicd/pages/templates/base.html`) has navigation but missing `aria-label` on some elements - The mobile navigation could use better ARIA attributes **4. Missing alt attributes on images** (`/home/adebaumann/development/vgui-cicd/pages/templates/base.html`, lines 39-41) ```html Zur Startseite ``` - **Issue**: alt is present but could be more descriptive - **Status**: Acceptable ### Minor Issues **5. Hardcoded URLs in templates** (`/home/adebaumann/development/vgui-cicd/dokumente/templates/standards/incomplete_vorgaben.html`, line 21) ```html