Semgrep metavariable comparisons support case-insensitive string matching
Introduced 2026-02-18 · score 0.97
HOW TO USE IT
When a Semgrep rule needs to compare a metavariable’s string value without case sensitivity, add a `metavariable-comparison` using `upper(str($VALUE)) == "SEMGREP"` (or use `lower()` for lowercase comparison).
- metavariable-comparison:
metavariable: $VALUE
comparison: upper(str($VALUE)) == "SEMGREP"WHY THIS HELPS
Write a Semgrep rule that compares a metavariable's string value without case sensitivity.
REQUIREMENTS AND LIMITATIONS
- Version: v1.152.0
- metavariable (required): The metavariable to compare; it must be bound by a positive pattern.
- comparison (required): A Python-like comparison expression. Docs list `str()` and comparison operators; v1.152.0 release note demonstrates `upper(str(...))` for case-insensitive matching.
FIRST-PARTY EVIDENCE
- https://github.com/semgrep/semgrep/releases/tag/v1.152.0
- https://docs.semgrep.dev/writing-rules/rule-syntax
Check the installed version and the source before using it. Entry JSON