--exclude-minified-files
- Accepted by
opengrep scan- Also spelled
--no-exclude-minified-files- Default
false- See also
--max-target-bytes,--exclude
Skips the files that look minified.
A file is considered minified when its first 4096 bytes contain less than 7% whitespace (spaces, tabs, carriage returns and newlines), or have more than 1000 bytes per line on average. The rest of the file is not examined. Files of 1000 bytes or less are never skipped.
Minified files are scanned by default. --no-exclude-minified-files restores the default. --max-target-bytes skips files by size instead.
Examples
Skipping a minified file
rule.yaml
rules: - id: find-eval pattern: eval(...) message: found eval languages: [python] severity: WARNINGnormal.py
eval(1)Command and result
$ python3 -c "open('min.py','w').write('eval(1);' * 400 + '\n')"
$ opengrep scan -q --config rule.yaml --files-with-matches .
min.py
normal.py
$ opengrep scan -q --config rule.yaml --files-with-matches --exclude-minified-files .
normal.pySmall files, and only the start of a file
The first two files have no whitespace in their first bytes. The first is 1000 bytes long and is kept; the second is one byte longer and is skipped. The third starts with 4800 bytes of ordinary lines, so the long line after them does not count.
rule.yaml
rules: - id: find-eval pattern: eval(...) message: found eval languages: [python] severity: WARNINGCommand and result
$ python3 -c "open('a.py','w').write('eval(1);' * 125)"
$ python3 -c "open('b.py','w').write('eval(1);' * 125 + '\n')"
$ python3 -c "open('c.py','w').write('eval(1)\n' * 600 + 'eval(1);' * 2000 + '\n')"
$ opengrep scan -q --config rule.yaml --files-with-matches --exclude-minified-files .
a.py
c.py