--timeout
- Accepted by
opengrep scan,opengrep ci,opengrep test- Value
SECONDS, a number- Default
5.0- Environment
OPENGREP_TIMEOUT
Limits the time that a rule may spend on a file. The limit applies to each pair of a rule and a file separately. 0 removes the limit.
When a rule exceeds the limit on a file, Opengrep stops that rule on the file, drops its findings there, records a timeout error and continues with the other rules. The error is listed in the errors of the --json output, and a warning names the file and the rules. After --timeout-threshold rules have timed out on a file, Opengrep runs no further rules on it.
Other limits:
--interfile-timeoutlimits the cross-file taint analysis of a rule.- With
--dynamic-timeout, the limit grows with the size of the file. - With
--allow-rule-timeout-control, a rule can set its own limit with its optionstimeoutanddynamic_timeout. These options have no effect when--timeoutis0.
OPENGREP_TIMEOUT sets the value for opengrep scan and opengrep ci when the flag is not given.
Examples
A rule that runs out of time
slow.yaml
rules: - id: slow patterns: - pattern: $F(..., $X, ...) + $G(..., $Y, ...) - pattern-not: $F($X, $X, ...) + $G(...) message: slow languages: [python] severity: INFOCommand and result
$ seq 20000 | sed 's/.*/x& = f(a, b, c) + g(d, e) + h(&)/' > big.py
$ opengrep scan --config slow.yaml --timeout 0.001 big.py 2>&1 | grep timeout
warning 1 timeout error(s) in big.py when running the following rules: [slow]