reference

Rule options

The options key of a rule sets options that change how the rule matches; the other rules of the scan keep the defaults.

rules:
  - id: example
    pattern: ...
    options:
      symbolic_propagation: true

An unknown option makes the rule invalid: the run stops with exit status 2 and reports Found unknown JSON field <name>. An unknown key elsewhere in a rule produces only a warning.

Some options have a command-line flag that enables the same behavior for every rule of a scan. Such a flag cannot turn the option off for a rule that enables it.

Index

NameSummary
ac_matchingMatch chains of an associative operator as a flat list of operands.
arrow_is_functionMatch arrow functions and function expressions like other functions.
attr_exprLet a call pattern match a decorator or an annotation written like a call.
commutative_boolopMatch the operands of && and || in any order.
constant_propagationLet a literal in a pattern match a variable known to hold that value.
cpp_parsing_prefRead an ambiguous C++ pattern such as foo $X(...); as a function declaration or a constructed variable.
decorators_order_mattersRequire decorators and annotations to appear in the order the pattern gives.
dynamic_timeoutScale the time limit of this rule with the size of the file; requires --allow-rule-timeout-control.
dynamic_timeout_max_multiplierThe largest factor of the dynamic timeout of this rule; requires --allow-rule-timeout-control.
dynamic_timeout_unit_kbThe file size, in KB, of one step of the dynamic timeout of this rule; requires --allow-rule-timeout-control.
flddef_assignLet a pattern assigning a function match methods and fields that hold functions.
generic_bracesWith aliengrep, replace the pairs of braces that an ellipsis keeps balanced.
generic_caselessWith aliengrep, match text regardless of letter case.
generic_comment_styleWith spacegrep, remove comments of one style from the target before matching.
generic_ellipsis_max_spanWith spacegrep, the maximum number of line breaks that an ellipsis may span.
generic_engineThe engine of rules for the generic language: spacegrep or aliengrep.
generic_extra_bracesWith aliengrep, add pairs of braces that an ellipsis keeps balanced.
generic_extra_word_charactersWith aliengrep, add characters that a metavariable may capture as part of a word.
generic_multilineWith aliengrep, whether an ellipsis may span several lines.
go_deeper_exprLet deep expression patterns and statements look inside expressions.
go_deeper_stmtLet ... between statements match statements nested in later blocks.
guarded_taint_signaturesDrop a cross-function taint finding when the branch leading to the sink cannot be taken.
implicit_deep_exprstmtLet an expression statement in a statement pattern match a statement containing it.
implicit_ellipsisLet a record or class pattern match targets with more fields than it lists.
implicit_returnLet a return pattern match the value a function returns without the return keyword.
let_is_varLet a var declaration pattern match let and const declarations.
max_match_per_fileKeep only the first findings of this rule in each file.
symbolic_propagationLet a variable assigned an expression match that expression.
symmetric_eqMatch the operands of == and != in either order.
taint_assume_safe_booleansAssume that a boolean value is clean, even when it was computed from tainted data.
taint_assume_safe_comparisonsAssume that the result of a comparison is clean, even when an operand is tainted.
taint_assume_safe_functionsAssume that a call returns clean data, even when its arguments are tainted.
taint_assume_safe_indexesAssume that a tainted index does not taint the element it selects.
taint_assume_safe_numbersAssume that a number is clean, even when it was computed from tainted data.
taint_focus_onReport a taint finding at the source instead of at the sink.
taint_interfileMark a taint rule for cross-file analysis under --enable-interfile.
taint_interfile_depthThe longest call chain that the cross-file taint analysis of this rule follows.
taint_intrafileFollow taint through calls to functions defined in the same file.
taint_only_propagate_through_assignmentsPropagate taint only through assignments, not through operators or calls.
taint_unify_mvarsRequire a metavariable used in both a source and a sink to bind the same code in both.
timeoutThe time limit of this rule on each file, in seconds; requires --allow-rule-timeout-control.
unify_ids_strictlyRequire a metavariable bound twice to name the same variable, not only the same name.
vardef_assignLet an assignment pattern match a variable declaration with an initial value.
xml_attrs_implicit_ellipsisLet an XML pattern match elements with more attributes than it lists.
xml_children_orderedRequire the children of an XML element to appear in the order the pattern gives.
xml_singleton_loose_matchingLet a self-closing element and an element with open and close tags match each other.

Examples

A misspelled option stops the run

rule.yaml
rules:  - id: unsafe-query    pattern: $DB.cursor().execute(...)    message: raw SQL executed on a cursor    languages: [python]    severity: WARNING    options:      symbolic_propagatio: true
app.py
def query(db, sql):    cur = db.cursor()    cur.execute(sql)
Command and result
$ opengrep scan --config rule.yaml app.py 2>&1 | sed 's/ while expecting.*//'
error    Error: Found unknown JSON field symbolic_propagatio
$ opengrep scan --config rule.yaml app.py > /dev/null 2>&1; echo "exit status: $?"
exit status: 2