Repository navigation
test: add meaningful Vitest coverage for the query allowlist - #334
Closed
MackWiser1 wants to merge 1 commit into
Closed
MackWiser1 wants to merge 1 commit into
MackWiser1 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test: add meaningful Vitest coverage for the query allowlist
Summary
Adds the first test suite for
src/allowlist/index.ts, the security-critical module that decides whether an incoming SQL statement is permitted to run. The module previously had zero tests despite gating every query whenfeatures.allowlistis enabled.The suite is test-only: no production code or configuration was changed.
Cases covered
Bypass behaviour
isEnabled: false) allows any SQL without touching the database.role: 'admin'allows any SQL without touching the database.role: 'client'does not bypass and actually loads the allowlist.Valid input
-1literal.IS NULLcomparison.tmp_allowlist_rejectionswith the correctsql_statementandsourceparams.Invalid / fake input
SELECT ...; DROP TABLE ...) is rejected.Omitted input
Error('No SQL provided for allowlist check')(the function returns, rather than throws, this Error).undefinedSQL returns the same Error.Error handling
Query not allowed.Coverage
src/allowlistcoverage from this suite:How to run
Or the full suite:
Verification notes
npx vitest run src/allowlist/index.test.ts? 19/19 tests pass.src/rls/index.test.tsand reproduce on a clean checkout (they are unrelated to this change).npx prettier --check src/allowlist/index.test.ts? clean.npx tsc --noEmitreports no errors in the new test file (the repo has other pre-existing type errors, e.g. insrc/cache/index.test.ts,src/do.test.ts, andplugins/cdc).Relates to #71