--scan-unknown-extensions
- Accepted by
opengrep scan,opengrep ci- Also spelled
--skip-unknown-extensions- Default
false- See also
--lang,--include,--force-exclude
Opengrep selects the language of each file by its extension. By default, a file named on the command line whose extension belongs to no language is skipped, and a scan with no other targets reports nothing to scan.
With --scan-unknown-extensions, such a file is scanned as the language given by --lang, or, without --lang, with the languages of the rules. The flag applies only to files named on the command line; for files found under directory targets, the extension still decides. --skip-unknown-extensions is the default.
Examples
A file whose extension names no language
rule.yaml
rules: - id: find-eval pattern: eval(...) message: found eval languages: [python] severity: WARNINGscript.unknown
eval(1)Command and result
$ opengrep scan --config rule.yaml script.unknown 2>&1
╭┮┭╮ Opengrep
┌┼┼┼┘ the open source static code analysis engine
╰┶┵╯ version X.Y.Z
nothing to scan
no findings
$ opengrep scan -q --config rule.yaml --scan-unknown-extensions script.unknown
script.unknown
warn find-eval
found eval
1: eval(1)Without the flag, the file is not scanned, and Opengrep reports that there is nothing to scan.