PDF Report Generator for SonarQube Analysis
Project description
ReflectSonar
PDF Report Generator for SonarQube Analysis
ReflectSonar is a simple Python tool for generating a PDF report of a project scan conducted by a SonarQube instance. It reads the data via API and generates a PDF report for general metrics, issues and security hotspots.
SonarQube Community and Developer Editions do not have a built-in report generation feature. The purpose of this tool is to add that functionality to those editions.
This tool is not affiliated with Sonar. The report is generated based on SonarQube instance that its information is provided. All data is fetched from SonarQube API. ReflectSonar just provides a way to generate the report.
Quick Start
Installation
Option 1: Install from PyPI
# Install ReflectSonar
pip install reflectsonar
# Run directly
reflectsonar -p "your-project-key" -t "your-token" -u "http://your-sonarqube:9000"
Option 2: Download Pre-built Binary
Download the latest binary release for your platform from the Releases page:
Linux:
# Download and extract
wget https://github.com/ataseren/reflectsonar/releases/latest/download/reflectsonar-linux-x64.tar.gz
tar -xzf reflectsonar-linux-x64.tar.gz
# Make executable and run
chmod +x reflectsonar
./reflectsonar --help
Windows:
# Download reflectsonar-windows-x64.zip from releases page
# Extract and run reflectsonar.exe
.\reflectsonar.exe --help
macOS:
# Download and extract
wget https://github.com/ataseren/reflectsonar/releases/latest/download/reflectsonar-macos-x64.tar.gz
tar -xzf reflectsonar-macos-x64.tar.gz
# Make executable and run
chmod +x reflectsonar
./reflectsonar --help
Option 3: Install from Source
# Clone the repository
git clone https://github.com/ataseren/reflectsonar.git
cd reflectsonar
# Create a virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Optional: install development dependencies
pip install -r requirements-dev.txt
# Run local help
PYTHONPATH=src python -m reflectsonar --help
Basic Usage
Using an Installed Package or Binary
# Generate a report for your project
reflectsonar -p "your-project-key" -t "your-sonarqube-token" -u "http://your-sonarqube-server:9000"
# With custom output path
reflectsonar -p "my-app" -t "squ_abc123..." -o "reports/my-app-quality-report.pdf"
# With verbose logging
reflectsonar -p "my-app" -t "squ_abc123..." --verbose
# Using a configuration file
reflectsonar -c config.yaml
# Faster report without code snippets or rules reference
reflectsonar -p "my-app" -t "squ_abc123..." --no-snippets --no-rules
# Keep only BLOCKER or HIGH-severity issues and HIGH-probability hotspots
reflectsonar -p "my-app" -t "squ_abc123..." --high-severity-only
If you downloaded a release binary instead of installing from PyPI, replace reflectsonar with ./reflectsonar on Linux/macOS or .\reflectsonar.exe on Windows.
Using a Local Source Checkout
# From the repository root
source .venv/bin/activate
# Generate a report for your project
PYTHONPATH=src python -m reflectsonar \
-p "your-project-key" \
-t "your-sonarqube-token" \
-u "http://your-sonarqube-server:9000"
# With custom output path
PYTHONPATH=src python -m reflectsonar \
-p "my-app" \
-t "squ_abc123..." \
-o "reports/my-app-quality-report.pdf"
# With verbose logging
PYTHONPATH=src python -m reflectsonar -p "my-app" -t "squ_abc123..." --verbose
# Using a configuration file
PYTHONPATH=src python -m reflectsonar -c config.yaml
You do not need to build the project before running it locally.
Command Line Options
| Option | Short | Description | Required | Default |
|---|---|---|---|---|
--project |
-p |
SonarQube project key | ✅ Yes | - |
--token |
-t |
SonarQube authentication token | ✅ Yes | - |
--url |
-u |
SonarQube server URL | ❌ No | http://localhost:9000 |
--output |
-o |
Output PDF file path | ❌ No | Auto-generated |
--config |
-c |
Configuration file path | ❌ No | Not set |
--verbose |
-v |
Enable detailed logging | ❌ No | False |
--no-snippets |
- | Skip fetching and rendering code snippets | ❌ No | False |
--high-severity-only |
- | Keep only BLOCKER or HIGH-severity issues and HIGH-probability hotspots | ❌ No | False |
--no-rules |
- | Skip rule description fetching and omit the Rules Reference section | ❌ No | False |
Configuration
If --config is provided, values from the YAML file override command-line arguments when the same keys are present.
Example configuration:
project: your-project-key
token: squ_your_user_token_here
url: http://localhost:9000
output: reports/quality-report.pdf
verbose: false
no_snippets: false
high_severity_only: false
no_rules: false
SonarQube Token Setup
- Generate Token: Go to SonarQube → My Account → Security → Generate Tokens (It must be a User Token)
- Token Format:
squ_1a2b3c4d5e6f7g8h9i0j... - Permissions: Ensure token has enough permission on your project
Runtime Options
--no-snippetsskips code-context fetching from/api/sources/show, which can noticeably speed up large reports.--high-severity-onlykeeps only BLOCKER issues or issues that contain at least oneHIGHimpact. For hotspots, it keeps onlyHIGHvulnerability probability entries.--no-rulesskips/api/rules/showrequests and removes the Rules Reference section from the PDF.- When any of these options exclude content, the cover page adds a short sentence below the summary table describing what was omitted.
Data Collection Notes
- Issues are fetched separately for
SECURITY,RELIABILITY, andMAINTAINABILITYusingimpactSoftwareQualitiesand then deduplicated. This helps work around SonarQube's per-query 10,000-result cap. - Pagination stops automatically once SonarQube's 10,000-result API limit is reached for a single query.
- In verbose mode, long-running fetch loops update in place and the PDF build step shows a live page counter.
Report Structure
1. Cover Page
- Project overview and summary statistics
- Quality metrics and ratings
- Generation timestamp and SonarQube mode
- Optional note describing excluded content when runtime filters are used
2. Issues
- Security, reliability and maintainability issues
- Affected code snippets and triggered rules
3. Security Hotspots
- Detailed security hotspot analysis
- Risk categories and remediation guidance
- Code context and security implications
4. Rules
- Rules triggered by the issues in a project
- Mitigation and detailed description for the issue
- Extra resources
- This section is omitted when
--no-rulesis used
Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Open an issue to discuss your ideas! Submit a PR in any way you want.
I am trying to make life easier for peoples' that need the functionality of this tool. Therefore, I don't want to bother you with strict contribution rules. Just open an issue or PR and I will be happy to review it.
Also, feel free to reach out to me via email or LinkedIn.
License
This project is licensed under the GPL-3.0 License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file reflectsonar-1.1.1.tar.gz.
File metadata
- Download URL: reflectsonar-1.1.1.tar.gz
- Upload date:
- Size: 359.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c187808f3979fbf3a2173b54b25b4853f9cf5099ab0851a7ad01b6e4184033d
|
|
| MD5 |
19549a095ec66032f1c4661ce3f4b625
|
|
| BLAKE2b-256 |
c492fc1eec558fc95a228d3a636271b195c2bdb2b5b53ea54fd1893696b0712e
|
Provenance
The following attestation bundles were made for reflectsonar-1.1.1.tar.gz:
Publisher:
release.yml on ataseren/reflectsonar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
reflectsonar-1.1.1.tar.gz -
Subject digest:
8c187808f3979fbf3a2173b54b25b4853f9cf5099ab0851a7ad01b6e4184033d - Sigstore transparency entry: 1096871417
- Sigstore integration time:
-
Permalink:
ataseren/reflectsonar@8584d0ee2f2845ee379af18cf1781ae6d3e242ae -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/ataseren
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8584d0ee2f2845ee379af18cf1781ae6d3e242ae -
Trigger Event:
push
-
Statement type:
File details
Details for the file reflectsonar-1.1.1-py3-none-any.whl.
File metadata
- Download URL: reflectsonar-1.1.1-py3-none-any.whl
- Upload date:
- Size: 360.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b53a3bd11743f34d2b498d17cdb6f99ad02d000ba95e8efe38bbc9013905cae0
|
|
| MD5 |
7b21d9efa509ee79a405a4d117247a1d
|
|
| BLAKE2b-256 |
5bb354c671f1662cf432b88451d061731d0edfb269f1d4cc85380aaedaf9183b
|
Provenance
The following attestation bundles were made for reflectsonar-1.1.1-py3-none-any.whl:
Publisher:
release.yml on ataseren/reflectsonar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
reflectsonar-1.1.1-py3-none-any.whl -
Subject digest:
b53a3bd11743f34d2b498d17cdb6f99ad02d000ba95e8efe38bbc9013905cae0 - Sigstore transparency entry: 1096871419
- Sigstore integration time:
-
Permalink:
ataseren/reflectsonar@8584d0ee2f2845ee379af18cf1781ae6d3e242ae -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/ataseren
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8584d0ee2f2845ee379af18cf1781ae6d3e242ae -
Trigger Event:
push
-
Statement type: