Skip to main content

SonarQube

SonarQube scans your code projects for potential vulnerabilities, code smells, bugs, and other issues, and provides recommendations for fixing those issues. You can bring code project and static code findings from SonarQube into Brinqa to better understand the security risks associated with your codebase and prioritize remediation efforts to strengthen your cybersecurity posture.

This document details the information you must provide for the connector to authenticate with SonarQube and how to obtain that information from SonarQube. See create a data integration for step-by-step instructions on setting up the integration.

info

The SonarQube connector supports the Community, Developer, Enterprise, and Data Center editions of SonarQube. For additional information, see SonarQube plans and pricing.

Required connection settings

When setting up a data integration, select SonarQube from the Connector drop-down. If you cannot find the connector in the drop-down, make sure that you have installed it first. You must provide the following information to authenticate SonarQube with Brinqa:

  • Server URL: The SonarQube Server URL.

  • User token: The access token associated with the SonarQube user, which must have permissions to log in to the API server and return data.

Generate a SonarQube user token

For the SonarQube connector to use the SonarQube API, you must provide a user token. The user token inherits the permissions of the user who creates the token and can be used to perform any SonarQube Web API action.

To create a user token, follow these steps:

  1. Log in to your organization's SonarQube server.

  2. Click the account profile icon on the upper-right corner of the page and then click My Account.

  3. Click the Security tab.

  4. Enter a name for the token and click Generate.

    Your new user token displays. You cannot view the token again after this. Copy and save it to a secure location.

note

If you do not have permissions to create a user token, contact your SonarQube administrator. For additional information on managing user tokens and permissions, see SonarQube documentation.

Additional settings

The SonarQube connector contains additional options for specific configuration:

  • Page size: The maximum number of records to get per API request. The default setting is 500. It is not recommended to go over 500.

  • Parallel requests: The maximum number of parallel API requests. The default setting is 4.

  • Skip certificate verification: Select this option to allow for untrusted certificates.

Types of data to retrieve

The SonarQube connector can retrieve the following types of data from the SonarQube API:

Table 1: Data retrieved from SonarQube

Connector ObjectRequiredMaps to Data Model
Code ProjectYesCode Project
Static Code FindingYesStatic Code Finding
Static Code Finding DefinitionYesStatic Code Finding Definition
info

For detailed steps on how to view the data retrieved from SonarQube in the Brinqa Platform, see How to view your data.

Attribute mappings

Expand the sections below to view the mappings between the source and the Brinqa data model attributes.

Code Project

Table 2: Code Project attribute mappings

Source Field NameMaps to Attribute
analysis.projectVersionLocal variable (projectVersion)
component.descriptiondescription
component.measure("alert_status")Local variable (qualityGate)
component.measure("cognitive_complexity")Local variable (cognitiveComplexity)
component.measure("complexity")Local variable (cyclomaticComplexity)
component.measure("coverage")Local variable (coverage)
component.measure("duplicated_lines_density")Local variable (duplication)
component.measure("ncloc")Local variable (linesOfCode)
component.measure("reliability_rating")Local variable (reliabilityRating)
component.measure("security_rating")Local variable (securityRating)
component.measure("sqale_rating")Local variable (maintainabilityRating)
project.keyuid
project.lastAnalysisDatelastAssessed
project.namename
project.organizationLocal variable (org)
project.qualifierLocal variable (qualifier)
project.revisionLocal variable (revision)
project.visibilityLocal variable (visibility)
Static Code Finding

Table 3: Static Code Finding attribute mappings

Source Field NameMaps to Attribute
issue.authorLocal variable (author)
issue.component, issue.linepath
issue.creationDatefirstFound
issue.debtLocal variable (debt)
issue.effortLocal variable (effort)
issue.hashLocal variable (hash)
issue.keyuid, Local variable (key)
issue.messageresults
issue.projecttargets
issue.ruletype
issue.statusstatus (normalize), statusCategory
issue.tagstags
issue.updateDatelastFound
sourcescodeSnippet
Static Code Finding Definition

Table 4: Static Code Finding Definition attribute mappings

Source Field NameMaps to Attribute
rule.createdAtpublishedDate
rule.htmlDesc , rule.descriptionSectionsdescription
rule.isTemplateLocal variable (template)
rule.keyuid
rule.langlanguages
rule.namename
rule.paramsLocal variable (params)
rule.reporepository
rule.severityseverity (normalize), sourceSeverity, severityScore
rule.tagstags
rule.typecategories
rule.updatedAtsourceLastModified
rules.isExternalLocal variable (external)
note

Local variable indicates that the field is processed within a specific context, such as a particular workflow or calculation. Unlike other attributes, local variables aren't mapped to the unified data models. They only exist on the source data model.

Operation options

The SonarQube connector supports the following operation options. See connector operation options for information about how to apply them.

Expand the sections below to view the supported operation options for each connector object:

Code Project

Table 5: Code Project operation options

Connector ObjectOptionAll Possible valuesDescriptionExample
Code ProjectresolutionsFALSE-POSITIVE, FIXED, REMOVED, WONTFIXA comma-separated list of resolutions. Retrieve code projects with the specified resolution.Key: resolutions Value: FIXED. This key and value combination only retrieves fixed code projects.
resolvedfalse, no, true, yesRetrieve code projects with the specified status.Key: resolved Value: true. This key and value combination only retrieves resolved code projects.
severitiesBLOCKER, CRITICAL, INFO, MAJOR, MINORA comma-separated list of severity levels. Retrieve code projects with the specified severity level.Key: severities Value: CRITICAL. This key and value combination only retrieves critical code projects.
sonarsourceSecurityauth, buffer-overflow, command-injection, csrf, dos, file-manipulation, http-response-splitting, insecure-conf, ldap-injection, log-injection, object-injection, open-redirect, others, path-traversal-injection, rce, sql-injection, ssrf, weak-cryptography, xpath-injection, xss, xxeA comma-separated list of SonarSource security categories. Retrieve code projects with the specified category.Key: sonarsourceSecurity Value: file-manipulation. This key and value combination only retrieves code projects that fall under the file-manipulation SonarSource security category.
statusesCLOSED, CONFIRMED, IN_REVIEW, OPEN, REOPENED, RESOLVED, REVIEWED, TO_REVIEWA comma-separated list of issue statuses. Retrieve code projects by the specified statuses.Key: statuses Value: OPEN,REOPENED. This key and value combination only retrieves open and reopened code projects.
tagsAny code project tags.A comma-separated list of tags. Retrieve code projects with the specified tags.Key: tags Value: convention. This key and value combination only retrieves code projects with the convention tag.
typesBUG, CODE_SMELL, VULNERABILITYA comma-separated list of issue types. Retrieve code projects by the specified type.Key: types Value: CODE_SMELL,BUG. This key and value combination only retrieves code projects of the code smell and bug types.
Static Code Finding

Table 6: Static Code Finding operation options

Connector ObjectOptionAll Possible valuesDescriptionExample
Static Code FindingresolutionsFALSE-POSITIVE, FIXED, REMOVED, WONTFIXA comma-separated list of resolutions. Retrieve static code findings with the specified resolution.Key: resolutions Value: FIXED. This key and value combination only retrieves fixed issues.
resolvedfalse, no, true, yesRetrieve static code findings with the specified status.Key: resolved Value: true. This key and value combination only retrieves resolved issues.
severitiesBLOCKER, CRITICAL, INFO, MAJOR, MINORA comma-separated list of severity levels. Retrieve static code findings with the specified severity level.Key: severities Value: CRITICAL. This key and value combination only retrieves critical issues.
sonarsourceSecurityauth, buffer-overflow, command-injection, csrf, dos, file-manipulation, http-response-splitting, insecure-conf, ldap-injection, log-injection, object-injection, open-redirect, others, path-traversal-injection, rce, sql-injection, ssrf, weak-cryptography, xpath-injection, xss, xxeA comma-separated list of SonarSource security categories. Retrieve static code findings with the specified category.Key: sonarsourceSecurity Value: file-manipulation. This key and value combination only retrieves issues that fall under the file-manipulation SonarSource security category.
statusesCLOSED, CONFIRMED, IN_REVIEW, OPEN, REOPENED, RESOLVED, REVIEWED, TO_REVIEWA comma-separated list of issue statuses. Retrieve static code findings by the specified statuses.Key: statuses Value: OPEN,REOPENED. This key and value combination only retrieves open and reopened issues.
tagsAny static code finding tags.A comma-separated list of tags. Retrieve static code findings with the specified tags.Key: tags Value: convention. This key and value combination only retrieves issues with the convention tag.
typesBUG, CODE_SMELL, VULNERABILITYA comma-separated list of issue types. Retrieve static code findings by the specified type.Key: types Value: CODE_SMELL,BUG. This key and value combination only retrieves code smell and bug type issues.
Static Code Finding Definition

Table 7: Static Code Finding operation options

Connector ObjectOptionAll Possible valuesDescriptionExample
Static Code Finding DefinitionresolutionsFALSE-POSITIVE, FIXED, REMOVED, WONTFIXA comma-separated list of resolutions. Retrieve static code finding definitions with the specified resolution.Key: resolutions Value: FIXED. This key and value combination only retrieves fixed issues.
resolvedfalse, no, true, yesRetrieve static code finding definitions with the specified status.Key: resolved Value: true. This key and value combination only retrieves resolved issues.
severitiesBLOCKER, CRITICAL, INFO, MAJOR, MINORA comma-separated list of severity levels. Retrieve static code finding definitions with the specified severity level.Key: severities Value: CRITICAL. This key and value combination only retrieves critical issues.
sonarsourceSecurityauth, buffer-overflow, command-injection, csrf, dos, file-manipulation, http-response-splitting, insecure-conf, ldap-injection, log-injection, object-injection, open-redirect, others, path-traversal-injection, rce, sql-injection, ssrf, weak-cryptography, xpath-injection, xss, xxeA comma-separated list of SonarSource security categories. Retrieve static code finding definitions with the specified category.Key: sonarsourceSecurity Value: file-manipulation. This key and value combination only retrieves issues that fall under the file-manipulation SonarSource security category.
statusesCLOSED, CONFIRMED, IN_REVIEW, OPEN, REOPENED, RESOLVED, REVIEWED, TO_REVIEWA comma-separated list of issue statuses. Retrieve static code finding definitions by the specified statuses.Key: statuses Value: OPEN,REOPENED. This key and value combination only retrieves open and reopened issues.
tagsAny static code finding definition tags.A comma-separated list of tags. Retrieve static code finding definitions with the specified tags.Key: tags Value: convention. This key and value combination only retrieves issues with the convention tag.
typesBUG, CODE_SMELL, VULNERABILITYA comma-separated list of issue types. Retrieve static code finding definitions by the specified type.Key: types Value: CODE_SMELL,BUG. This key and value combination only retrieves code smell and bug type issues.
note

The option keys and values are case-sensitive as they are shown in this documentation.

APIs

The SonarQube connector uses the SonarQube Web API. Specifically, it uses the following endpoints:

Table 8: SonarQube Web API Endpoints

Connector ObjectAPI Endpoint
Code ProjectGET /api/measures/component
GET /api/project_analyses/search
GET /api/projects/search
Static Code FindingGET /api/issues/search
Static Code Finding DefinitionGET /api/rules/search

Changelog

The SonarQube connector has undergone the following changes:

Table 9: SonarQube connector changelog

VersionDescription
3.0.3Fixed an issue where syncs were failing with a "NoSuchElementException" error.
3.0.2Improved its handling of the vendor API's limitation, which restricts the maximum return of 10,000 records.
3.0.1Replaced ImmutableSet with HashSet.
3.0.0Initial Integration+ release.