Repository navigation
Conversation
A CTE name no longer hides a real table with the same name: schema-qualified tables, tables outside the CTE's scope and the non-recursive self-reference inside a CTE body are now checked against the allowed tables. When extraction fails, no partial result is returned, so the query is rejected. Fixes dataease#1543
This branch has not been deployed
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.
extract_tables_from_sql()dropped every table whose name matched any CTE in the statement, no matter the scope or schema. SoWITH secret AS (SELECT 1) SELECT * FROM public.secret ...or a CTE in a subquery could hide a real table from the allowlist check.Now tables are resolved per scope with
traverse_scope. Only unqualified tables that match a CTE visible in their scope are skipped. On any error during extraction the function returns an empty set, so the query is rejected.Tests in
test_table_check.py: the bypass cases from the issue plus a non-recursive self-reference are rejected, normal and recursive CTEs still pass, and an error doesn't leak partial results.pytest -q tests/test_table_check.py26 passed, full suite no new failuresFixes #1543