dynamic_timeout
- Value
trueorfalse- Default
unset, the scan's --dynamic-timeout applies
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)| Term | Rule option | Otherwise |
|---|---|---|
| base | timeout | --timeout, default 5 s |
| unit | dynamic_timeout_unit_kb | --dynamic-timeout-unit-kb, default 30 |
| max multiplier | dynamic_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
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: 6With 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.
$ opengrep scan -q --config rule.yaml --allow-rule-timeout-control .