--text
- Accepted by
opengrep scan,opengrep ci
Selects the text output. It is the default format of a scan, so the flag is needed only to override another format setting.
The layout of the output is set by --skin, and the amount of code shown for a match by --max-chars-per-line and --max-lines-per-finding.
--text-output writes the text output to a file. Unlike -o, it leaves standard output unchanged.
Examples
A readable report beside the JSON
rule.yaml
rules: - id: find-eval pattern: eval(...) message: found eval languages: [python] severity: WARNINGapp.py
eval(1)Command and result
$ opengrep scan --config rule.yaml --json --text-output report.txt app.py 2>/dev/null | jq .
{
"version": "X.Y.Z",
"results": [
{
"check_id": "find-eval",
"path": "app.py",
"start": {
"line": 1,
"col": 1,
"offset": 0
},
"end": {
"line": 1,
"col": 8,
"offset": 7
},
"extra": {
"metavars": {},
"message": "found eval",
"metadata": {},
"severity": "WARNING",
"fingerprint": "cc2ee9ac3b87e874db7ede72562f586db0607e44a6ebc8879fc1772bd2699a2f302d90e0cf6bde9dce450cb0891646fb0b3d70263351681e1d2e48ca0d26d960_0",
"lines": "eval(1)",
"is_ignored": false,
"validation_state": "NO_VALIDATOR",
"engine_kind": "Opengrep"
}
}
],
"errors": [],
"paths": {
"scanned": [
"app.py"
]
},
"interfile_languages_used": [],
"skipped_rules": []
}
$ cat report.txt
app.py
warn find-eval
found eval
1: eval(1)