Skip to content

fix: add safety guards for destructive DDL and multi-statement queries#6

Merged
corvid-agent merged 1 commit intomainfrom
fix/sql-safety-guards
May 7, 2026
Merged

fix: add safety guards for destructive DDL and multi-statement queries#6
corvid-agent merged 1 commit intomainfrom
fix/sql-safety-guards

Conversation

@corvid-agent
Copy link
Copy Markdown
Collaborator

Summary

  • Block destructive DDL by default: DROP, ALTER, and TRUNCATE are rejected unless --allow-destructive flag is passed. Prevents accidental schema destruction.
  • Block multi-statement execution: Queries containing multiple semicolon-separated statements are rejected to prevent SQL injection via query chaining.
  • DML success indicator: INSERT/UPDATE/DELETE queries that return no rows now output {"ok":true,"changes":N} (using SQLite's changes() in the same session) instead of [] or (no results).

Test plan

  • All 26 tests pass (up from 13), covering:
    • DROP/ALTER/TRUNCATE blocked by default
    • Case-insensitive DDL detection (lowercase truncate)
    • --allow-destructive flag bypasses the guard
    • Multi-statement queries rejected
    • Trailing semicolons are not falsely flagged
    • INSERT/UPDATE/DELETE return {"ok":true,"changes":N} with correct count
    • All existing tests (params, injection, migration, schema) still pass

🤖 Generated with Claude Code

…and DML feedback

Block destructive DDL (DROP/ALTER/TRUNCATE) by default with a new
--allow-destructive flag to override. Reject multi-statement queries
(semicolon-separated) to prevent injection via query chaining. For
INSERT/UPDATE/DELETE that return no rows, output {"ok":true,"changes":N}
using SQLite's changes() function instead of an empty result.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@corvid-agent corvid-agent merged commit e0ec72e into main May 7, 2026
4 checks passed
@corvid-agent corvid-agent deleted the fix/sql-safety-guards branch May 7, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant