Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
*
* ## Two halves, and why both
*
* 1. **The enumeration** reads `sql-driver.ts` and lists every function that
* builds an `INVALID_FILTER` error. Only three may call
* 1. **The enumeration** reads `sql-driver.ts` and its cross-field seam module
* `sql-driver-cross-field-comparison.ts` (#25521 cut 13) and lists every
* function that builds an `INVALID_FILTER` error. Only three may call
* `unsupportedFilterError` directly (the seam itself, the `'author'`
* re-issue, and the column refusal raised from a dialect error AFTER the
* statement ran), and every caller of `withheldFilterError` must have a row
Expand Down Expand Up @@ -64,7 +65,7 @@ const SECRET_NUM = 7770123;
const UNDECLARED_KEY = '$psecret_combinator';

type Door = {
/** The builder in `sql-driver.ts` this row drives — asserted by the error's stack. */
/** The builder in `sql-driver.ts` or its cross-field seam module this row drives — asserted by the error's stack. */
readonly builder: string;
readonly where: () => Record<string, unknown> | unknown[];
readonly secrets: readonly string[];
Expand Down Expand Up @@ -271,8 +272,8 @@ const DOORS: readonly Door[] = [
// ── Half 1: the enumeration ───────────────────────────────────────────────────

/**
* Every function in `sql-driver.ts` that builds an `INVALID_FILTER` error, by
* the route it takes. Read with the TypeScript parser, not a regex, so a call
* Every function in `sql-driver.ts` and `sql-driver-cross-field-comparison.ts`
* that builds an `INVALID_FILTER` error, by the route it takes. Read with the TypeScript parser, not a regex, so a call
* split across lines, an inline `throw`, or a builder written as a method or an
* arrow cannot slip past the count.
*/
Expand All @@ -281,8 +282,12 @@ function enumerateRefusalBuilders(): {
seamCallers: Set<string>;
codeWriters: Set<string>;
} {
const source = readFileSync(new URL('./sql-driver.ts', import.meta.url), 'utf8');
const sf = ts.createSourceFile('sql-driver.ts', source, ts.ScriptTarget.Latest, true);
// [#25521 cut 13] The cross-field and now-anchored comparison compile moved to
// its own seam module with two of the builders below; the scan reads both.
const sources = [
['sql-driver.ts', readFileSync(new URL('./sql-driver.ts', import.meta.url), 'utf8')],
['sql-driver-cross-field-comparison.ts', readFileSync(new URL('./sql-driver-cross-field-comparison.ts', import.meta.url), 'utf8')],
] as const;
const directCallers = new Set<string>();
const seamCallers = new Set<string>();
const codeWriters = new Set<string>();
Expand Down Expand Up @@ -339,7 +344,7 @@ function enumerateRefusalBuilders(): {
}
ts.forEachChild(node, visit);
};
visit(sf);
for (const [name, source] of sources) visit(ts.createSourceFile(name, source, ts.ScriptTarget.Latest, true));
return { directCallers, seamCallers, codeWriters };
}

Expand Down
Loading
Loading