Skip to content

sqlguardllm 1.0.0

Latest

Choose a tag to compare

@github-actions github-actions released this 01 Dec 23:31
ddef5b1

First stable release: the core API and the 15 core violation codes follow semver (docs/STABILITY.md). Also ships proxy mode, controlled writes, stored procedures and tainted sessions (experimental, outside that contract), the benchmark harness and sqlguardllm mcp --demo. Python, npm, NuGet and the MCP manifest advance together.

Added

  • Policy.from_database now maps the SQLAlchemy dialect postgresql to postgres (it raised "unknown dialect").
  • sqlguardllm protect (#216): finds dbhub, Postgres MCP Pro and MCP Toolbox in Claude Desktop, Cursor and VS Code configs, drafts a policy from the database (EN/ES PII column heuristics: hidden or masked, with the reason), lints it and rewrites the entry to run through sqlguardllm proxy. Dry run by default; --apply keeps a timestamped backup, --undo restores it; passwords are masked in all output. Docs in docs/PROTECT.md (EN/ES); examples/proxy/mcp-toolbox.yaml.
  • langchain-sqlguardllm 0.1.0a1 in clients/langchain (alpha, not on PyPI): a guarded sql_query_tool, sqlalchemy_executor and GuardedSQLDatabase for LangChain 1.x.
  • Controlled writes (#170, writes), off by default. Policy.writes (WritePolicy) and Guard.check_write() for single-table INSERT, UPDATE and DELETE, with row filters ANDed into the write and the violation codes write_not_allowed, write_column_not_allowed, missing_where and too_many_rows (EN/ES); check() still rejects every write. WriteRuntime (propose as a dry run, approved apply, undo with before-images, drift check) and a signed Ledger, tested on SQLite, PostgreSQL 16 and 18, MySQL 8 and SQL Server 2022. MCP tools propose_write, apply_write and undo, registered only when the policy has writes and a separate write database is given (create_server(write_database=, ledger_path=), sqlguardllm mcp --write-db --ledger); approval is asked through MCP elicitation and fails closed.
  • Tainted sessions in the MCP server (#171): untrusted_columns, sensitive_tables and on_tainted (deny) in the policy. Reading an untrusted column taints the session and queries on sensitive tables are refused with tainted_session (EN/ES); views over sensitive or untrusted data propagate; listed names must exist in the database or the server does not start. By default taint is kept per server-assigned mcp-session-id (bounded to 10,000 sessions); a call without one (stdio, in-process, the stateless protocol) has an unknown session and counts as tainted; stdio passes single_session=True (the mcp command does) and an explicit session_id callable still wins. explain_query reports tainted, taint_sources and reads_untrusted. A query refused by the taint check is audited once, as a refusal.
  • Allowlisted stored procedures (#173, procedures): procedures in the policy allows T-SQL EXEC and PostgreSQL CALL with named, type-checked parameters and context-bound values; dynamic SQL, sp_executesql, linked servers, positional arguments and extra clauses are refused (procedure_not_allowed, procedure_param_invalid).
  • sqlguardllm proxy: guards an existing database MCP server over stdio. Mapped SQL tools go through Guard.check() and receive the rewritten SQL; tools that are neither mapped nor in passthrough are hidden and refused. Checked against dbhub 2.1.0. Docs in docs/PROXY.md (EN/ES), maps in examples/proxy/ (#172).
  • sqlguardllm mcp --demo: a fictional read-only sample database and a built-in policy, with one-click install links for Cursor and VS Code (#180).
  • Guard benchmark (#174, #182, benchmark): python -m sqlguardllm.bench runs a versioned corpus (69 attacks, 34 legitimate queries) against sqlguardllm, two baselines or any validator through a JSON-lines adapter; published corpus at docs/assets/corpus-v1.json.
  • Playground challenge, "break the firewall" (playground/challenge/, #181): two beatable baseline levels and two sqlguardllm levels, all in the browser. Bypasses of sqlguardllm are reported privately and credited in docs/HALL_OF_FAME.md after the fix.
  • Compatibility check with the latest release of crewai-tools, agno, mcp-alchemy, langchain-community and pandasai, a weekly workflow and docs/COMPATIBILITY.md with the sqlglot support policy (#166); a guide to embed the core package in a library (docs/embedding.md).