Skip to content

test(allowlist): add tests for isQueryAllowed + fix truthy-Error allowlist bypass - #352

Open
AgoniJJ wants to merge 2 commits into
outerbase:mainfrom
AgoniJJ:allowlist-tests
Open

AgoniJJ wants to merge 2 commits into
outerbase:mainfrom
AgoniJJ:allowlist-tests

Conversation

@AgoniJJ

@AgoniJJ AgoniJJ commented Nov 15, 2026

Copy link
Copy Markdown

Related to #71 (Improve test coverage with Vitest).

What

  • Adds src/allowlist/index.test.ts with 8 tests for isQueryAllowed (previously untested): disabled feature, admin bypass, exact match, semicolon/whitespace normalization, rejection + audit-log write, empty SQL, allowlist load failure, cross-source isolation.
  • One-line fix in src/allowlist/index.ts: empty SQL previously returned an Error object instead of throwing. Error objects are truthy, so callers doing if (await isQueryAllowed(...)) would treat that failure as allowed — an allowlist bypass path. It now throws consistently.

Verification

npx vitest run src/allowlist/index.test.ts → 8/8 pass.
Full suite: 159 passed; the 4 failures in src/rls/index.test.ts are pre-existing on main and untouched by this PR.

… return

- Add src/allowlist/index.test.ts covering: disabled allowlist, admin role bypass, exact match, semicolon/whitespace normalization, rejection + audit log write, empty SQL, allowlist load failure, and cross-source isolation.
- Fix: empty SQL returned an Error *object* instead of throwing. Since Error objects are truthy, callers doing if (await isQueryAllowed(...)) would treat the failure as allowed - an allowlist bypass. It now throws consistently.
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