go_deeper_expr
- Value
trueorfalse- Default
true- See also
implicit_deep_exprstmt,go_deeper_stmt
This option lets matching look inside expressions in two places:
- a deep expression pattern
<... e ...>matches any expression that containse; - in a statement pattern, a statement such as
finish()also matches a statement that contains it, such asresult = finish(); seeimplicit_deep_exprstmt.
With go_deeper_expr: false, both match only at the top level: <... e ...> matches e itself, and finish() matches the statement finish().
Examples
A condition that contains the check
The rule admin-branch turns the option off.
branch.yaml
rules: - id: admin-branch-default pattern: | if <... user.is_admin ...>: ... message: branch on admin rights languages: [python] severity: WARNING - id: admin-branch pattern: | if <... user.is_admin ...>: ... message: branch on admin rights languages: [python] severity: WARNING options: go_deeper_expr: falsebranch.py
def view(user, ok): # ruleid: admin-branch-default, admin-branch if user.is_admin: pass # ruleid: admin-branch-default if ok and user.is_admin: passCommand and result
$ opengrep test .
2/2: ✓ All tests passed
No tests for fixes found.