Skip to main content

SonarQube integration

Integration type: scanning tool. SonarQube and SonarCloud analyze code themselves and own the issues they raise, so verdicts go through SonarQube's own issue workflow. Compare the DefectDojo findings-management integration and the integration types.

Decide whether an issue or hotspot needs action, then record the evidence where your team works. Threatlint triages SonarQube/SonarCloud findings. Reviewing changes no server status; posting requires separate confirmation.

What you need​

RequirementAction
HTTPS base URLSonarQube origin/context path (https://example.test/sonarqube) or https://sonarcloud.io
User tokenMy Account → Security
Read permissionsBrowse on the project
Posting permissionsAdminister Issues / Administer Security Hotspots, as applicable
Source and modelSCM link or DevOps binding; GitHub/Azure DevOps access; configured model
Direct CLI triageSemgrep CLI on PATH (semgrep --version); run fp-review checks that it is installed. This does not establish which engine produced the Sonar finding

CLI​

Replace the sample URL/key with an authorized issue:

  1. Validate/save credentials:

    threatlint sonar login --url https://sonarqube.example.test
  2. Fetch one issue and check out its source:

    threatlint sonar fetch AYxExampleKey01 -o sonar.md
    threatlint sonar checkout SONAR-AYxExampleKey01 --dir ./sonar-review
  3. Run triage from the checkout (LM Studio by default; change --provider as needed):

    (cd sonar-review && threatlint run fp-review --findings ../sonar.md --provider lmstudio)
  4. Inspect the report before posting.

Result: an artifact and advisory report, no server updates. Without source mapping, supply --repo-url URL / --branch NAME, or disclose an evidence-only review.

References are SONAR-<issue-key> and SONAR-HOTSPOT-<hotspot-key>. A bare key is tried as an issue, then a hotspot. Preserve that full reference in the report's Original finding field. Explicit lists have no limit.

threatlint sonar fetch --project web --branch develop --severity CRITICAL -o sonar.md

Search filters: required --project; --branch or --pull-request; --organization for SonarCloud; repeatable --type, --severity, --status; --limit (default: every matching finding, within a 10,000-result window for each issue or hotspot search). Types default to VULNERABILITY and SECURITY_HOTSPOT. Issues default to OPEN,CONFIRMED,REOPENED; hotspots to TO_REVIEW.

File/line: components[].path (else suffix after project:), line / textRange. Repository: SCM link → DevOps binding; THREATLINT_SONAR_REPO_URL overrides. Verify reviewed branch/revision matches the scan.

Credentials​

CLI: THREATLINT_SONAR_URL / THREATLINT_SONAR_TOKEN → saved ~/.threatlint/sonarqube.json → Parameter Store token → unsaved interactive prompt. THREATLINT_HOME relocates the saved file. Login calls GET /api/authentication/validate before saving with POSIX mode 0600; protect Windows ACLs too.

Parameter Store: THREATLINT_SONAR_TOKEN_PARAMETER or sonarTokenParameter in ~/.threatlint/org.json, using your AWS session (--aws-profile). Workbench shares the file; direct connections prefer saved values over environment. Tokens use HTTP Basic with an empty password; redirects are refused.

Resolve​

SonarQube stores no attachments. Publish the report for authorized reviewers and supply its URL:

threatlint sonar resolve SONAR-AYxExampleKey01 --report fp_review.md \
--report-url https://reports.example.test/reviews/123

The CLI asks first; --yes authorizes writes without prompting. Without --report-url, comments name a local file, not a shared report. --docx names a file but does not upload it.

VerdictIssueSecurity hotspot
FALSE POSITIVEAdd summary comment, then falsepositive transitionMark REVIEWED / SAFE with comment
Evidence-backed TRUE POSITIVEAdd comment, attempt confirmComment only
Conservative TRUE POSITIVEComment only; do not claim independent confirmationComment only

Current reviews use TRUE POSITIVE or FALSE POSITIVE. Legacy AMBIGUOUS reports become conservative, unverified true positives while retaining their confidence and evidence gaps.

Comments include ID, confidence, title, outcome, and report location. Unavailable Confirm (HTTP 400) leaves the comment; other failures are reported. Writes are nontransactional: inspect server state before retrying.

For a status-neutral note, use threatlint sonar note SONAR-AYxExampleKey01 --message "Awaiting matching scan revision." (confirmation required).

Workbench​

  1. Save URL/token in Settings → Scanning & triage → SonarQube.
  2. Open Finding triage, select SonarQube as the finding source, and enter keys or project/branch filters. Run and inspect each report in Findings.
  3. Select Post to SonarQube…, supply an optional HTTPS report location, and confirm.

Triage a scan report also accepts /api/issues/search and /api/hotspots/search JSON exports; posting maps each imported result back to its issue/hotspot. Direct Workbench reviews use one model run per finding, with up to 64 model runs per batch. Narrow a filter or split a longer list before reviewing. Reviews run concurrently, normally 3 at a time. In Advanced experience, Parallel review and budget lets you choose 1–8 parallel reviewers and a lower model-run budget. Reports remain in Findings after temporary checkouts are removed. Company administrators configure the connection; administrators and analysts can review and post. The desktop app uses its local profile without a Threatlint login. See Workbench import limits.

API calls​

Reads: /api/issues/search, /api/hotspots/search, /api/hotspots/show, /api/project_links/search, /api/alm_settings/get_binding, /api/authentication/validate. Writes: /api/issues/add_comment, /api/issues/do_transition, /api/hotspots/change_status, /api/hotspots/add_comment.

Limits​

Available transitions depend on the server version and current issue state; newer servers may omit Confirm. Check the reported transition result after posting. A successful comment does not establish that the issue status changed.

Troubleshooting​

SymptomNext action
401 / 403Check token, Browse access, and permission for the specific write
Empty project searchCheck branch/PR, organization, type, and default status filters
No repositoryAdd an SCM link/binding, use THREATLINT_SONAR_REPO_URL, or pass --repo-url
Comment posted, no ConfirmCheck the reported transition result and server version; do not infer closure
Full report inaccessiblePublish it securely and use --report-url; local filenames are not uploads

Next: check evidence, proposed fixes, and acceptance criteria before changing status.