Security:
- CORS restricted to explicit methods/headers, configurable via CORS_ORIGINS env
- Auth added to /reports/{rid}/html and /compliance-report endpoints
- Ownership check on report downloads
- Rate limiting on login (10 attempts/5min per IP with threading.Lock)
- Non-root container user (agent via gosu entrypoint)
- Nginx security headers (X-Frame-Options, X-Content-Type-Options, X-XSS-Protection, Referrer-Policy, Permissions-Policy)
- .gitignore and .dockerignore for secret leak prevention
- .env.example with documentation
Performance:
- 16 SQLite indexes on foreign keys and frequently queried columns
- Pagination on chat messages (100), reports (50), audit log (100)
- subprocess.run wrapped in run_in_executor (3 async handlers)
- asyncio.wait_for timeouts on GenAI calls (300s) and Chromium PDF (120s)
- Thread pool reduced to 10 workers
- Code splitting with React.lazy (bundle: 1.3MB -> ~550KB initial)
- React.memo on TreeItem (recursive compartment tree)
Error handling:
- 13 bare except clauses replaced with logged Exception handlers
- Graceful shutdown handler (terminates subprocesses + executor)
- File upload validation (50MB max, extension whitelist per endpoint)
- Health check expanded (version, uptime, db_ok)
- Cache-Control on /api/genai/models (1h)
- Auto-cleanup audit_log > 30 days
Dead code removed:
- DownloadsPage.tsx, StubPage.tsx, MfaPage.tsx (moved to UsersPage)
- Legacy frontend/ directory
- 19 unused i18n keys, dist/ removed from git tracking
UX & i18n:
- 8 alert() calls replaced with styled error states (TerraformPage)
- 50+ hardcoded Portuguese strings localized to i18n (pt/en) across 11 files
- aria-label on all icon-only buttons (Chat, Explorer, Sidebar)
- focus-visible CSS for keyboard navigation
- Responsive grid fix (360px -> 280px for mobile)
- aria-hidden on decorative SVGs
Deployment:
- Docker resource limits (backend 4G, frontend 512M)
- Log rotation (json-file, 10MB x 3)
- Terraform version parameterized via ARG
44 lines
1.5 KiB
Docker
44 lines
1.5 KiB
Docker
FROM python:3.12-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Install system deps + Chromium + Terraform CLI
|
|
ARG TERRAFORM_VERSION=1.7.5
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
curl gcc libffi-dev unzip \
|
|
chromium && \
|
|
ARCH=$(dpkg --print-architecture) && \
|
|
curl -fsSL "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_${ARCH}.zip" -o /tmp/tf.zip && \
|
|
unzip /tmp/tf.zip -d /usr/local/bin/ && rm /tmp/tf.zip && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install Python deps + OCI CLI
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt && \
|
|
pip install --no-cache-dir oci-cli
|
|
|
|
# Copy app
|
|
COPY app.py .
|
|
COPY cis_reports.py .
|
|
COPY mcp_cis_server.py .
|
|
COPY gen_tf_reference.py .
|
|
|
|
# Non-root user setup
|
|
RUN groupadd -r agent && useradd -r -g agent -d /app -s /bin/bash agent && \
|
|
mkdir -p /data && chown -R agent:agent /app /data
|
|
|
|
# Generate OCI Terraform resource reference at build time
|
|
RUN python gen_tf_reference.py || echo "WARN: tf reference generation skipped (terraform init may need network)"
|
|
|
|
# Entrypoint: fix /data ownership then exec as agent user
|
|
RUN printf '#!/bin/bash\nchown -R agent:agent /data 2>/dev/null || true\nexec gosu agent "$@"\n' > /entrypoint.sh && \
|
|
chmod +x /entrypoint.sh && \
|
|
apt-get update && apt-get install -y --no-install-recommends gosu && rm -rf /var/lib/apt/lists/*
|
|
|
|
VOLUME /data
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
|
|
|
EXPOSE 8000
|
|
|
|
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "8"]
|