reference Flags

--json-output

Accepted by
opengrep scan, opengrep ci
Value
FILE
See also
--json, --output

Writes the JSON document that --json prints to FILE, in addition to the output on standard output.

The flag can be repeated to write several files, and combined with the other --<format>-output flags to write several formats from one scan. The file is written even when the scan finds nothing.

Examples

A report on screen and a JSON copy

rule.yaml
rules:  - id: find-eval    pattern: eval(...)    message: found eval    languages: [python]    severity: WARNING
app.py
eval(1)
Command and result
$ opengrep scan -q --config rule.yaml --json-output findings.json app.py
app.py

  warn  find-eval
  found eval

     1: eval(1)
$ jq . findings.json
{
  "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": []
}