Prerequisites
Before you begin, ensure you have the following:- A running SonarQube 10.x installation
- A valid SCANOSS API key (required only for premium features)
- The SCANOSS SonarQube plugin: download the latest pre-built JAR from the releases page
- Maven installed (required only if building the plugin from source)
How It Works
The SCANOSS SonarQube plugin is a custom plugin built on the SCANOSS Java SDK. Once installed, it runs automatically as part of your SonarQube analysis. It is capable of:- Scanning your source code for open-source components using High Precision Snippet Matching (HPSM)
- Ingesting SCANOSS settings from your
scanoss.jsonfile to control scan behaviour - Reporting copyleft licence counts, copyright declarations, and vulnerability counts as SonarQube metrics
- Raising SonarQube issues for undeclared components not listed in your
scanoss.jsonfile
Installation
Step 1: Obtain the Plugin JAR
Option A: Download the pre-built JAR (recommended) Download the latest release directly from the GitHub releases page. Option B: Build from source If you prefer to build the plugin locally, run the following command from the repository root:target/scanoss-sonar-plugin-VERSION.jar.
Step 2: Install the Plugin into SonarQube
Copy the JAR to your SonarQubeextensions/plugins/ directory:
/path/to/sonarqube/ with the actual path to your SonarQube installation directory.
Step 3: Restart SonarQube
Restart SonarQube to load the new plugin. Once the service has restarted, the SCANOSS plugin will be available for configuration.Configuration
Plugin Parameters
In your SonarQube instance, navigate to the SCANOSS plugin settings and configure the following parameters:| Parameter | Description | Required | Default |
|---|---|---|---|
Scan API URL | SCANOSS API endpoint. Format: http(s)://host:port | Optional | https://api.osskb.org |
Scan API Token | SCANOSS API authentication token | Optional | — |
Custom Certificate Chain | PEM-encoded custom certificate chain | Optional | — |
SCANOSS HPSM | Enable High Precision Snippet Matching (requires a Premium subscription) | Optional | false |
SCANOSS Settings | Enable use of a SCANOSS settings file during scanning. See the SCANOSS settings documentation | Optional | true |
SCANOSS Settings File Path | Path to the scanoss.json settings file used during scanning | Optional | scanoss.json |
Note: TheScan API URLformat description previously referencedhost:ip. This has been corrected tohost:port, as the second component of a URL authority is a port number, not an IP address.
Running a Scan
Using Docker
To run a SonarQube scan using the official SonarScanner CLI Docker image:Note: Replace[PROJECT_KEY]with your SonarQube project key and[AUTH_TOKEN]with a valid user-type authentication token.
Policy Checks
The SCANOSS SonarQube plugin surfaces open-source compliance information through SonarQube metrics and issues.Reported Metrics
The following metrics are reported on every scan and are visible in the SonarQube project dashboard:- Copyleft Licence Count — Number of components or snippets associated with copyleft licences
- Copyright Declarations Count — Number of copyright declarations detected in the codebase
- Vulnerability Count — Number of vulnerabilities detected in scanned components
Reported Issues
- Undeclared Components — Components detected in the repository that are not declared in your
scanoss.jsonfile are raised as SonarQube issues
Issue Detection Setup
To enable issue detection for undeclared components, you must configure a Quality Profile in SonarQube. Ensure yourscanoss.json settings file is in place before proceeding.
Step 1: Create a Quality Profile
- Navigate to the Quality Profiles tab in SonarQube
- In the desired language section, create a new profile named SCANOSS Way
- Within the SCANOSS Way profile, add a new rule activation
- Search for the Undeclared Component rule in the SCANOSS Analyser repository
- Activate the Undeclared Component rule to add it to the profile
Step 2: Assign the Quality Profile to Your Project
- Navigate to your project in SonarQube
- Go to Project Settings → Quality Profiles
- Click Add language
- Select the
textlanguage and assign the SCANOSS Way profile
Extracting SCANOSS Data via the SonarQube Web API
SCANOSS metrics and issues can be queried programmatically using the SonarQube Web API. Authentication requires a user-type token — refer to the SonarQube API documentation for details on token generation.Authentication
Include the following header in all API requests:Available Endpoints
List all metrics — Returns all available metrics. Use theps parameter to increase page size when searching for SCANOSS-specific metrics: