reference Rule options

unify_ids_strictly

Value
true or false
Default
true

When a metavariable bound to an identifier occurs again, the two occurrences must name the same variable. A parameter of an inner function that has the name of an outer variable is a different variable, so it does not unify with it.

With unify_ids_strictly: false, having the same name is enough.

Examples

A parameter with the name of an outer variable

The rule source-to-sink turns the option off.

flow.yaml
rules:  - id: source-to-sink-default    patterns:      - pattern-inside: |          $X = source()          ...      - pattern: sink($X)    message: value from source() reaches sink()    languages: [python]    severity: WARNING  - id: source-to-sink    patterns:      - pattern-inside: |          $X = source()          ...      - pattern: sink($X)    message: value from source() reaches sink()    languages: [python]    severity: WARNING    options:      unify_ids_strictly: false
flow.py
def handler():    data = source()    # ruleid: source-to-sink-default, source-to-sink    sink(data)    def log(data):        # ruleid: source-to-sink        sink(data)
Command and result
$ opengrep test .
2/2: ✓ All tests passed
No tests for fixes found.