reference Rule options

attr_expr

Value
true or false
Default
true
See also
decorators_order_matters

A call pattern such as route(...) also matches an attribute written like a call: a Python decorator @route("/admin"), or a Java annotation @RequestMapping("/admin") for the pattern RequestMapping(...). The arguments of the attribute are then inside a call, so pattern-inside: route(...) covers them.

With attr_expr: false, attributes are not matched as calls.

Examples

A decorator and a call

The rule route-call turns the option off.

routes.yaml
rules:  - id: route-call-default    pattern: route(...)    message: registers a route    languages: [python]    severity: WARNING  - id: route-call    pattern: route(...)    message: registers a route    languages: [python]    severity: WARNING    options:      attr_expr: false
routes.py
# ruleid: route-call-default@route("/admin")def admin():    passdef health():    pass# ruleid: route-call-default, route-callroute("/health")(health)
Command and result
$ opengrep test .
2/2: ✓ All tests passed
No tests for fixes found.