reference Rule options

dynamic_timeout

Value
true or false
Default
unset, the scan's --dynamic-timeout applies
See also
--allow-rule-timeout-control, --dynamic-timeout, --timeout, timeout, dynamic_timeout_unit_kb, dynamic_timeout_max_multiplier

Opengrep ignores this option unless the scan runs with --allow-rule-timeout-control. The same holds for the other timeout options of a rule: timeout, dynamic_timeout_unit_kb and dynamic_timeout_max_multiplier. When the flag is given, dynamic_timeout: true makes the rule's time limit on a file grow with the size of the file:

limit = base × clamp(size in KB / unit, 1, max multiplier)
TermRule optionOtherwise
basetimeout--timeout, default 5 s
unitdynamic_timeout_unit_kb--dynamic-timeout-unit-kb, default 30
max multiplierdynamic_timeout_max_multiplier--dynamic-timeout-max-multiplier, default 20

For example, with the defaults, a 150 KB file gets 5 × 5 = 25 seconds, and a 10 KB file gets 5 seconds.

dynamic_timeout: false turns scaling off for the rule even when the scan uses --dynamic-timeout. Without the option, --dynamic-timeout decides. When --timeout is 0, no time limit applies, and these options have no effect.

Examples

A rule allowed more time on large files

rule.yaml
rules:  - id: expensive-rule    pattern: $X == $X    message: comparison with itself    languages: [python]    severity: WARNING    options:      timeout: 10      dynamic_timeout: true      dynamic_timeout_max_multiplier: 6

With these options, the rule gets 10 seconds on files up to 30 KB, and up to 60 seconds on files of 180 KB or more. Without --allow-rule-timeout-control, it gets the 5 seconds of the scan.

Command
$ opengrep scan -q --config rule.yaml --allow-rule-timeout-control .