SQLite
database.sqlite
Protects against destructive SQLite operations like DROP TABLE, DELETE without WHERE, and accidental data loss
- 7blocking rules
- 4safe patterns
- 2Critical
- 4High
- 1Medium
[packs]
enabled = ["database.sqlite"]Evaluated when a command contains sqlite, sqlite3, DROP, TRUNCATE, DELETE, UPDATE.
Recorded verdicts
sqlite3 app.db "DELETE FROM orders"Blockeddatabase.sqlite:delete-without-where
Blocking rules
Each rule ID is database.sqlite:<name>. Use it in allowlists and [policy.rules].
Criticaldelete-without-whereDELETE without WHERE deletes ALL rows. Add a WHERE clause.
Explanation
DELETE FROM without a WHERE clause removes every row from the table. This is almost always unintentional - if you truly want to remove all rows, TRUNCATE or DROP TABLE + CREATE is more explicit about the intent. SQLite doesn't support TRUNCATE, making this pattern especially dangerous. Safer alternatives: - SELECT COUNT(*) FROM table: Check row count first - DELETE FROM table WHERE condition: Add explicit conditions - .backup before DELETE: Create backup first - Use transactions: BEGIN; DELETE ...; verify; COMMIT or ROLLBACK
Criticaldrop-tableDROP TABLE permanently deletes the table (even with IF EXISTS). Verify it is intended.
Explanation
DROP TABLE permanently removes a table and all its data from the SQLite database. Unlike some other databases, SQLite has no recycle bin or undo mechanism. The IF EXISTS clause only prevents errors, it doesn't make the operation less destructive. Safer alternatives: - .schema tablename: View table structure first - .dump tablename: Export table data as SQL backup - .backup: Create full database backup before dropping - ALTER TABLE ... RENAME: Rename instead of drop if reorganizing
Highdrop-columnALTER TABLE ... DROP COLUMN permanently deletes that column's data in every row.
Explanation
SQLite rewrites the table without the column; its values are gone unless you have a backup. Safer alternatives: - .backup first - CREATE TABLE t_col_backup AS SELECT rowid, col FROM t
Highsqlite3-stdinRunning SQL from file could contain destructive commands. Review the file first.
Explanation
Piping SQL from a file into sqlite3 executes all commands without review. The file may contain DROP TABLE, DELETE, or other destructive statements. If the file comes from an untrusted source or was auto-generated, it could cause unintended data loss. Safer alternatives: - Review the SQL file contents first - .backup before running: Create database backup - .read filename inside sqlite3: Allows Ctrl+C interruption - Run in a transaction: Wrap file contents in BEGIN/COMMIT
Highstdin-unverifiedsqlite3 receives indirect input that dcg cannot statically verify.
Explanation
Materialize and review the exact SQL before piping or redirecting it into sqlite3.
Highupdate-without-whereUPDATE without WHERE overwrites the column in ALL rows. Add a WHERE clause.
Explanation
UPDATE without a WHERE clause changes every row in the table; outside a transaction the previous values are gone. Safer alternatives: - UPDATE table SET col = value WHERE condition - .backup first, or BEGIN; UPDATE ...; verify; COMMIT or ROLLBACK
Mediumvacuum-intoVACUUM INTO overwrites the target file if it exists.
Explanation
VACUUM INTO creates a new compacted copy of the database at the specified path. If a file already exists at that path, it will be overwritten without warning. This can accidentally destroy other databases or important files. Safer alternatives: - Check if target file exists before running - Use a unique filename with timestamp - .backup filename: Alternative backup method - Move existing file before VACUUM INTO
Safe patterns
Checked first. A command that matches one is never blocked by this pack.
select-querysqlite3-dot-commanddot-command-standaloneexplain