Python: empty f-string is not matched by "..." pattern
GrosQuildu opened this issue · comments
Paweł Płatek commented
Describe the bug
For Python, the "..."
pattern does not match empty f-strings (f""
). This seems to be an inconsistency.
To Reproduce
https://semgrep.dev/playground/s/yyRjO
rules:
- id: python-fstring
languages:
- python
severity: ERROR
patterns:
- pattern: $X = "..."
a = "asd"
b = ""
c = f"asd"
d = f""
e = f"{2+2}"
The a, b, and c lines are matched, d and e lines are not matched.
Expected behavior
I would expect the "..."
pattern to match empty f-strings, because the pattern matches not-empty, constant f-strings already.
What is the priority of the bug to you?
- P0: blocking your adoption of Semgrep or workflow
- P1: important to fix or quite annoying
- [X P2: regular bug that should get fixed
Use case
The bug makes us to write additional pattern-not cases, so it is a minor inconvenience. See trailofbits/semgrep-rules#39 (comment)