fix: code audit — security, correctness, and robustness fixes

Security:
- Path traversal: validate user_id, case_id, skill_name against safe regex
- Input sanitization in memory.py and skills.py file path construction

Correctness:
- ISR timezone: replace hardcoded UTC+3 with ZoneInfo("Asia/Jerusalem") for DST
- save_rule: use EspoCrmApiError.status_code instead of fragile string matching
- Background tasks: store references to prevent GC before completion
- Lock race: use dict.setdefault() for atomic lock creation
- Version: health.py now matches main.py (0.2.0)
- Skill names: normalized to lowercase for dedup consistency

Build:
- Dockerfile: install from pyproject.toml instead of hardcoded pip list
- Remove unused mcp>=1.0.0 dependency from pyproject.toml

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-13 20:18:01 +00:00
parent a990f527a2
commit e947bca655
9 changed files with 59 additions and 21 deletions
+3 -3
View File
@@ -4,14 +4,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf
WORKDIR /app
# Copy application
# Copy project files
COPY pyproject.toml .
COPY api/ api/
COPY mcp_server/ mcp_server/
COPY config/ config/
# Install dependencies
RUN pip install --no-cache-dir fastapi "uvicorn[standard]" httpx pydantic openai pyyaml
# Install dependencies from pyproject.toml
RUN pip install --no-cache-dir .
# Create persistent data directories
RUN mkdir -p /opt/data/skills /opt/data/profiles /opt/data/cases