Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: empty f-string is not matched by "..." pattern #10047

Open
2 tasks
GrosQuildu opened this issue Apr 3, 2024 · 0 comments
Open
2 tasks

Python: empty f-string is not matched by "..." pattern #10047

GrosQuildu opened this issue Apr 3, 2024 · 0 comments
Labels
good first issue Good for newcomers

Comments

@GrosQuildu
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Development

No branches or pull requests

2 participants