Documentation
¶
Overview ¶
Package safety classifies SQL statements, enforces the read-only/write/ddl gate, validates identifiers, detects multi-statement input, and flags destructive operations. It is dependency-free and fully unit-testable.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrReadonlyViolation = errors.New("statement requires --write") ErrDDLRequiresWrite = errors.New("ddl requires --write and --ddl") ErrDestructiveRequiresYes = errors.New("destructive operation requires --yes") ErrIdentifierInvalid = errors.New("invalid identifier") ErrMultiStatement = errors.New("multiple statements are not allowed; use the txn subcommand") )
Sentinel errors. Each maps to a CLI exit code in the cli layer.
Functions ¶
func HasMultiStatement ¶
HasMultiStatement reports whether sql contains more than one statement, matching the original MCP's trailing-semicolon-tolerant check.
func IsDestructive ¶
IsDestructive reports whether a statement is DROP/TRUNCATE or an UPDATE/DELETE without a WHERE clause.
func ValidateIdentifier ¶
ValidateIdentifier ensures a bare identifier matches the allowlist.
Types ¶
type CheckOptions ¶
CheckOptions carries the user's explicit permission flags.
Click to show internal directories.
Click to hide internal directories.