element-hq / element-hq/synapse
Use PEP 675 `LiteralString` to refine database function annotations
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
This issue has been migrated from [#13473](https://github.com/matrix-org/synapse/issues/13473).
---
[PEP 675](https://peps.python.org/pep-0675/) proposes a new `typing.LiteralString` type. The idea is that typecheckers should check that a `LiteralString` is composed only from string literals (i.e. cannot contain user-provided data), to help mitigate e.g. SQL injection attacks. This sounds like a nice-to-have for us, though it's probably not worth picking up until mypy has support for the type (python/mypy#12554).
Contributor guide
Research direction
No files or tests are named. First verify whether mypy supports PEP 675 LiteralString, then locate the database functions whose annotations would be affected. Done means the relevant annotations use LiteralString and type checking accepts the intended safe calls while rejecting non-literal SQL input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- databases, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100