rusackas opened a new pull request, #40642:
URL: https://github.com/apache/superset/pull/40642
### SUMMARY
Two small hardening fixes:
1. **`re.escape` schema name in `base.py`** — In
`BaseEngineSpec.get_table_names()` and `get_view_names()`, the schema name is
interpolated into a regex via f-string to strip the schema prefix from returned
table/view names. If a schema name contains regex metacharacters, that pattern
can match incorrectly or backtrack pathologically. The schema is now passed
through `re.escape()` before interpolation so it is matched as a literal string.
2. **`get_filters` docstring in `jinja_context.py`** — The docstring
previously showed a manual escaping example (`replace("'", "''")`) for a `LIKE`
clause. Hand-rolled SQL escaping is error-prone and inconsistent across
dialects. The docstring now recommends the `where_in` filter and proper
parameterization, and adds a short warning against manual escaping. This is a
docs-only change to the docstring; behavior is unchanged.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
### TESTING INSTRUCTIONS
Added unit tests in `tests/unit_tests/db_engine_specs/test_base.py` that
pass a schema name containing regex metacharacters (`a.b(c)`) to
`get_table_names` and `get_view_names` and assert the schema prefix is stripped
correctly without error, while a look-alike name (`axbyc.other`) is left intact.
```
python -m pytest tests/unit_tests/db_engine_specs/test_base.py -q -k
regex_metacharacters
```
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]