v0.4.1-beta
π codebadger β v0.4.1-beta
π― Highlights
v0.4.1-beta turns the v0.4.0 scalability redesign into a production-ready, hardened deployment. The whole stack β including the MCP server itself β now comes up from a single docker compose; Postgres + Redis are required defaults (SQLite is gone); there's a real /health endpoint for orchestrators; idle codebases are evicted to survive long-running batches; you can analyze pasted code snippets, not just repos and paths; and every LLM-supplied input now passes a thorough validation + security layer backed by a documented threat model.
β οΈ Breaking Changes
- Postgres + Redis are now required (and the default). SQLite and the in-process coordinator have been removed. This reverses the v0.4.0 "optional" note β the server now fails fast on a missing/unreachable Postgres or Redis. Stand the stack up with
./scripts/deploy.sh(ordocker compose up -d). pgdatarelocated out ofplayground/β now./pgdata(override withPOSTGRES_DATA_PATH) so Joern workers can't reach the database files. Migration: while stopped,mv playground/pgdata ./pgdatato preserve an existing catalog, or start fresh.- redis-py bumped to 8.x (from 5.x). All in-code usage is stable API; review any custom Redis integrations.
π¦ What's New
One-Command Full-Stack Deployment (fixes #21)
- New
Dockerfile.mcpcontainerizes the MCP server;docker compose up -dnow brings up MCP + Joern + Postgres + Redis together. - The MCP drives the host Docker daemon (Docker-out-of-Docker via the mounted socket) and uses host networking, so it builds CPGs and spawns per-CPG pool workers as sibling containers β no app code changes required.
- New
scripts/deploy.sh(up/down/restart/logs/status) builds, launches, exports an absolute playground path for pool mounts, and polls/health.
Production /health Endpoint (fixes #20)
- Reports
status(up/partial/down), anmcp: "codebadger"field, and adependenciesmap (joern, postgres, redis, docker, cpg_queue) β returns 200 for up/partial and 503 for down, so it works directly as a liveness/readiness probe.
Idle CPG Eviction (memory safety on long runs)
- Servers idle beyond
JOERN_IDLE_TTL_SECONDS(default 600s) are offloaded by a background reaper and auto-wake on the next query β fixing the long-run idle-worker leak that could exhaust RAM/swap. - Explicit
JOERN_MEMORY_BUDGET_MBbudgeting plus per-run file logging (logs/codebadger-<ts>-<pid>.log+ acodebadger-latest.logsymlink).
Code Snippet Analysis (fixes #19)
generate_cpg(source_type="snippet", code=..., language=...)analyzes code pasted straight into the chat β no repo or path needed. Staged like any other source, with content-hash dedup so re-pasting the same code reuses the cached CPG.
Security: Threat Model + Hardening (see docs/security.md)
- New
docs/security.md: threat model, trust boundaries (Mermaid), the controls we provide, and a production hardening checklist. - Every LLM-supplied input is now validated:
codebase_hash,language,branch&github_token(anti arg-/URL-injection, e.g. blocks--upload-pack), snippetcode/filename/label, and regex filters (length + ReDoS-shape guard). run_cpgql_querynow enforces the CPGQL blocklist by default (process exec, file read/write, network, dynamic dependency load, reflection) β previously the blocklist was never wired in. Patterns expanded after an audit. (Defense-in-depth; the real boundary is the Joern worker sandbox.)- Resource caps at the executor: query timeout β€ 300s, β€ 10 000 rows, β€ 5 MB output, β€ 5 000-line snippet spans, and clamped
take(n)/depthβ with visibletruncatedflags (never silent). - Filesystem hardening: symlink-safe local copy (no dereferencing escapes),
realpath/commonpathconfinement, a deletion guard onremove_cpg, and host-path redaction in client-facing errors.
π Documentation
- New
docs/security.md(threat model + diagrams), linked from both READMEs. docs/installation.mdanddocs/deployment.mdrewritten as clear, step-by-step guides (full-stack and host-dev paths, day-2 ops).- New
docs/available-tools.mdcataloguing every MCP tool; snippet flow documented across usage/deployment.
π³ Deployment & Infrastructure
Dockerfile.mcp(new) βpython:3.13-slim+ git + Docker CLI 29.5.3 (client only).- Dependency bumps:
fastmcp>=3.4.2,mcp>=1.27.2,aiohttp>=3.14.1,uvicorn>=0.49.0,psycopg[binary]>=3.3.4,redis>=8.0.0. - Backing-service URLs now resolve from env β
DATABASE_URL/REDIS_URL, or the componentPOSTGRES_*/REDIS_*vars compose uses β instead of hardcoded defaults, so a host-run MCP honorsPOSTGRES_PORT/REDIS_PORToverrides. - Postgres on 55432 / Redis on 56379 (overridable); updated
.env.example,docker-compose.yml,.dockerignore, andcleanup.sh.
π οΈ Tooling
get_cpg_statusdescription now explicitly documents it as the way to wait forgenerate_cpgβ poll with the returnedcodebase_hashuntilready/failed(fixes #22).
π§ͺ Testing
- New/expanded suites for snippets, the security validators (CPGQL blocklist + bypasses, ReDoS guard, error redaction), executor resource caps & truncation, malformed-hash rejection, and
QueryLoadernumeric clamps. 426 passing / 24 skipped.
β οΈ Notes
- This remains a beta release.
- Dedicate the host to Codebadger β the MCP container mounts the Docker socket (root-equivalent on the host) and uses host networking. The MCP HTTP endpoint has no built-in auth; front it with a reverse proxy / network policy.
- Pool-mode invariant still applies:
build container mem_limit + memory_budget_mb β€ total Joern budget. Runpython scripts/recommend_config.pybefore launching on a new host.
Full Changelog: v0.4.0-beta...v0.4.1-beta