sql-sink
An SQL statement given to node:sqlite (db.exec(sql), db.prepare(sql)) that isn't a constant the source shows.
Why: text from data in a statement changes what the statement does. A name of x' OR '1'='1 in db.exec(`DELETE FROM users WHERE name = '${name}'`) deletes every row. A statement written once with placeholders, and the data bound to them, can't be changed by the data.
✕ Rejectedsql-sink
ts
import { DatabaseSync } from "node:sqlite";
import { unsafe } from "@evobug_com/safe-ts-std/result";
export function forget(db: DatabaseSync, name: string): unknown {
return unsafe(() => db.exec(`DELETE FROM users WHERE name = '${name}'`));
}✅ Accepted: a constant statement, the data bound
✓ Accepted0 diagnostics
ts
import { DatabaseSync } from "node:sqlite";
import { unsafe } from "@evobug_com/safe-ts-std/result";
export function forget(db: DatabaseSync, name: string): unknown {
return unsafe(() => db.prepare("DELETE FROM users WHERE name = ?").run(name));
}Accepted: a constant the source shows (a literal, a template of constants, a const of one, an imported const), numbers, values of a literal type (ORDER BY ${column} with column: "name" | "created"). A statement built from parts the project vouches for is a brand of the project's own: declare an Sql with brandConstructor and its sinks with brandSinks, and the members you list take only it (Proof types: brands of your own).
What the rule can't see: a database client from a package without a pack that declares its sinks (a pack can: "sinks": { "members": { "pg Pool#query": { "brand": "Sql", "takes": "argument 0" } } }, or the project, with brandSinks).