reference Flags

--junit-xml-output

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

Writes the JUnit XML report that --junit-xml prints to FILE, in addition to the output on standard output.

The flag can be repeated to write several files. The file is written even when the scan finds nothing.

Examples

A test report

rule.yaml
rules:  - id: find-eval    pattern: eval(...)    message: found eval    languages: [python]    severity: WARNING
app.py
eval(1)
Command and result
$ opengrep scan --config rule.yaml --junit-xml-output results.xml app.py > /dev/null 2>&1
$ python3 -c "import xml.etree.ElementTree as ET; print([(t.get('name'), t.get('file'), t.get('line')) for t in ET.parse('results.xml').iter('testcase')])"
[('find-eval', 'app.py', '1')]

The command prints the rule, file and line of each test case in the file.