|
| 1 | +# sonar-findings-export |
| 2 | +(Also available as `sonar-issues-export` for backward compatibility, but **deprecated**) |
| 3 | + |
| 4 | +Exports a list of issues as CSV, JSON or SARIF format. The export is sent to standard output or into a file |
| 5 | +Plenty of issue filters can be specified from the command line, type `sonar-findings-export -h` for details. |
| 6 | +:warning: On large SonarQube Server or Cloud instances with a lot of issues, it can be stressful for the instance (many API calls) and very long to export all issues. It's recommended to define filters that will only export a subset of all issues (see examples below). |
| 7 | + |
| 8 | +Basic Usage: `sonar-findings-export [--format csv|json|sarif] [--sarifNoCustomProperties] [-k <keyList>] ...` |
| 9 | + |
| 10 | +- `--format csv|json|sarif`: Choose export format. Default is based on output file extension, and csv in last - `--sarifNoCustomProperties`: For SARIF export. By default all Sonar custom properties are exported which makes the SARIF export quite verbose. Use this option to not export the Sonar custom properties (only the SARIF standard ones) |
| 11 | +- `--statuses <statusList>`: Only export findings with given statuses, comma separated among OPEN,CONFIRMED,REOPENED,RESOLVED,CLOSED,TO_REVIEW,REVIEWED |
| 12 | +- `--resolutions <resolutionList>`: Only export findings with given resolution, comma separated among FALSE-POSITIVE,WONTFIX,FIXED,REMOVED,ACCEPTED,SAFE,ACKNOWLEDGED,FIXED |
| 13 | +- `--severities <severityList>`: Only export findings with given resolution, comma separated among BLOCKER,CRITICAL,MAJOR,MINOR,INFO |
| 14 | +- `--types <typeList>`: Only export findings with given type, comma separated among BUG,VULNERABILITY,CODE_SMELL,SECURITY_HOTSPOT |
| 15 | +- `--createdAfter <YYYY-MM-DD>`: Only export findings created after a given date |
| 16 | +- `--createdBefore <YYYY-MM-DD>`: Only export findings created before a given date |
| 17 | +- `--tags <tagList>`: Comma separated list of tags corresponding to issues |
| 18 | +- `--languages <languageList>`: Comma separated list of languages from whom findings should be exported |
| 19 | +- `--useFindings`: Use SonarQube Server `api/projects/export_findings` whenever possible, No effect with SonarQube Cloud |
| 20 | +- `-k <keyList>`: Comma separated list of keys of objects to export (all objects if not specified) |
| 21 | +- `-b <branchList>`: For projects and apps, comma separated list of branches to export (Use * for all branches) |
| 22 | +- `--datesWithoutTime`: Reports timestamps only with date, not time |
| 23 | +- `-h`, `-u`, `-t`, `-o`, `-v`, `-l`, `--httpTimeout`, `--threads`, `--clientCert`: See **sonar-tools** [common parameters](https://github.com/okorach/sonar-tools/blob/master/README.md) |
| 24 | + |
| 25 | + |
| 26 | +## Required Permissions |
| 27 | + |
| 28 | +`sonar-findings-export` needs `Browse` permission on all projects, applications or portfolios for which findings are exported |
| 29 | + |
| 30 | +## Requirements and Installation |
| 31 | + |
| 32 | +`sonar-findings-export` is installed through the **sonar-tools** [general installation](https://github.com/okorach/sonar-tools/blob/master/README.md#install) |
| 33 | + |
| 34 | +## Common command line parameters |
| 35 | + |
| 36 | +`sonar-config` accepts all the **sonar-tools** [common parameters](https://github.com/okorach/sonar-tools/blob/master/README.md) |
| 37 | + |
| 38 | +## Examples |
| 39 | +``` |
| 40 | +export SONAR_HOST_URL=https://sonar.acme-corp.com |
| 41 | +export SONAR_TOKEN=squ_83356c9b2db891d45da2a119a29cdc4d03fe654e |
| 42 | +
|
| 43 | +# Exports all issues (main branch). This can be very long and stressful for SonarQube APIs |
| 44 | +sonar-findings-export >all_issues.csv |
| 45 | +
|
| 46 | +# Exports all issues of project myProjectKey |
| 47 | +sonar-findings-export -k myProjectKey -f project_issues.csv |
| 48 | +
|
| 49 | +# Exports all false positive and won't fix issues across all projects |
| 50 | +sonar-findings-export -r FALSE-POSITIVE,WONTFIX -f fp_wf.json |
| 51 | +
|
| 52 | +# Exports all issues created in 2020 |
| 53 | +sonar-findings-export -a 2020-01-01 -b 2020-12-31 -f issues_created_in_2020.csv |
| 54 | +
|
| 55 | +# Exports all vulnerabilities and bugs |
| 56 | +sonar-findings-export -types VULNERABILITY,BUG --format json >bugs_and_vulnerabilities.json |
| 57 | +
|
| 58 | +# Exports all vulnerabilities and bugs in SARIF format |
| 59 | +sonar-findings-export -types VULNERABILITY,BUG --format sarif >bugs_and_vulnerabilities.sarif.json |
| 60 | +
|
| 61 | +# Export all findings of project myProjectKey in SARIF format without the custom Sonar properties |
| 62 | +sonar-findings-export -k myProjectKey ----sarifNoCustomProperties -f myProjectKey.sarif |
| 63 | +``` |
0 commit comments