fix(sql): avoid false positives in disallowed function checks#40963
fix(sql): avoid false positives in disallowed function checks#40963LaurinBrechter wants to merge 2 commits into
Conversation
Use SQLScript.check_functions_present() instead of substring matching so identifiers containing disallowed function names (e.g. "kill" in "skilllevel") are not incorrectly blocked. Co-authored-by: Cursor <cursoragent@cursor.com>
Code Review Agent Run #beec35Actionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
/review |
There was a problem hiding this comment.
Code Review Agent Run #1be33c
Actionable Suggestions - 1
-
superset/sql/parse.py - 1
- Missing unit tests for new method · Line 838-871
Review Details
-
Files reviewed - 3 · Commit Range:
d28783b..bc26b66- superset/sql/execution/executor.py
- superset/sql/parse.py
- tests/unit_tests/sql/execution/test_executor.py
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.
Documentation & Help
| @@ -864,7 +868,7 @@ def check_functions_present(self, functions: set[str]) -> bool: | |||
| else: | |||
| present.add(function.name.upper()) | |||
|
|
|||
| return any(function.upper() in present for function in functions) | |||
| return present | |||
There was a problem hiding this comment.
The new public method get_present_functions() has no direct unit tests. Only indirect coverage exists via check_functions_present tests. Per BITO.md rule [11730], new tools should have dedicated unit tests covering success paths, error scenarios, and edge cases.
Code Review Run #1be33c
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
Code Review Agent Run #32fd30Actionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
SUMMARY
The SQL executor's disallowed-function check used substring matching on the raw SQL string, causing false positives when column or table names contained a disallowed function name as a substring (e.g.
skillleveltriggering thekillblocklist for MySQL).This change uses
SQLScript.check_functions_present()— the same AST-based approach already used insql_lab.pyandmodels/helpers.py— so only actual function invocations are blocked.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend-only change.
TESTING INSTRUCTIONS
DISALLOWED_SQL_FUNCTIONSwith{"mysql": {"kill"}}insuperset_config.pyskilllevel— it should succeedSELECT KILL(123)— it should be rejected with an error mentioningkillADDITIONAL INFORMATION