reference Rule syntax

options

See also
symbolic_propagation, constant_propagation, taint_intrafile

A mapping of rule options to their values. The options change how the rule matches, for that rule only: other rules of the same scan keep the defaults.

options:
  symbolic_propagation: true
  taint_intrafile: true

An unknown option makes the rule invalid, unlike an unknown key elsewhere in the rule, which only produces a warning.

Some options have a command-line flag that turns on the same behavior for every rule of a scan, such as --taint-intrafile for taint_intrafile. The flag cannot turn the option off for a rule that sets it.

Examples

An option for one rule

Two copies of a rule, the second with symbolic_propagation set, find different lines.

unsafe-query.yaml
rules:  - id: unsafe-query-default    pattern: $DB.cursor().execute(...)    message: raw SQL executed on a cursor    languages: [python]    severity: WARNING  - id: unsafe-query    pattern: $DB.cursor().execute(...)    message: raw SQL executed on a cursor    languages: [python]    severity: WARNING    options:      symbolic_propagation: true
unsafe-query.py
def query(db, sql):    # ruleid: unsafe-query-default, unsafe-query    db.cursor().execute(sql)    cur = db.cursor()    # ruleid: unsafe-query    cur.execute(sql)
Command and result
$ opengrep test .
2/2: ✓ All tests passed
No tests for fixes found.