go_deeper_stmt
- Value
trueorfalse- Default
true- See also
go_deeper_expr
In a statement pattern, ... between two statements also reaches statements nested in the blocks that follow. lock.acquire(), ..., lock.release() matches when lock.release() is in an if or a finally after the call to acquire.
With go_deeper_stmt: false, the statement after ... must be in the same block as the one before it.
Examples
A release in a nested block
The rule lock-released turns the option off.
locks.yaml
rules: - id: lock-released-default pattern: | lock.acquire() ... lock.release() message: lock acquired and released languages: [python] severity: WARNING - id: lock-released pattern: | lock.acquire() ... lock.release() message: lock acquired and released languages: [python] severity: WARNING options: go_deeper_stmt: falselocks.py
def conditional(lock, ok): # ruleid: lock-released-default lock.acquire() if ok: lock.release()def guarded(lock): # ruleid: lock-released-default lock.acquire() try: work() finally: lock.release()def flat(lock): # ruleid: lock-released-default, lock-released lock.acquire() lock.release()Command and result
$ opengrep test .
2/2: ✓ All tests passed
No tests for fixes found.