Skip to content

metavariable-comparison returns 0 findings when comparison contains 3+ OR terms #585

@6enzu

Description

@6enzu

Describe the bug
metavariable-comparison returns 0 findings when comparison contains 3+ OR terms

To Reproduce
metavariable-comparison stops matching when the comparison expression uses or with three or more disjuncts. With 1 or 2 OR-terms it works, but with 3+ it returns 0 findings.
A similar story was discussed here semgrep/semgrep#11209

Expected behavior
The comparison should be evaluated (and match in the given example) regardless of the number of terms in the expression.

rules:
  - id: bug
    languages: [python]
    severity: WARNING
    message: test
    patterns:
      - pattern: |
          foo($A, $B, $C)
      # works
      - metavariable-comparison:
          metavariable: $A
          comparison: $A < 16

      # works
      # - metavariable-comparison:
      #     metavariable: $A
      #     comparison: $A < 16 or $B < 0

      # fails: 0 findings
      # - metavariable-comparison:
      #     metavariable: $A
      #     comparison: $A < 16 or $B < 0 or $C > 0
def foo(a, b, c):
    pass

foo(1, -1, 1)

What is the priority of the bug to you?

  • P0: blocking your adoption of Opengrep or workflow
  • P1: important to fix or quite annoying
  • P2: regular bug that should get fixed

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions