/security-tooling-skills:sonarqube-code-quality-and-securityfrom security-tooling-skills
Guides deep configuration of SonarQube/SonarCloud for code quality and security analysis — quality gates, PR decoration, technical debt ratio, security hotspot triage, and CI wiring.
Ships in security-tooling-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
SonarQube (self-hosted) and SonarCloud (its SaaS counterpart) analyze source code for both security vulnerabilities and code-quality issues (bugs, code smells, duplication, cyclomatic complexity) in a single platform, and — unlike a pure SAST tool — attach a maintainability rating and a "technical debt" time estimate to what it finds. Its central operational mechanism is the quality gate: a named set of pass/fail conditions, evaluated primarily against new code introduced since a baseline, that a CI pipeline can query and fail on. Used well, this turns "code review plus static analysis" into a single enforced bar every PR must clear; used naively (gating on the whole codebase's historical debt, or ignoring the new-code vs. overall-code distinction), it becomes an unpassable or ignored gate within weeks. This skill goes deep on SonarQube's specific quality-gate mechanics, PR decoration, and debt-ratio/rating metrics. For the general SAST concept — tool selection, triage workflow, suppression policy — see sast-integration.
sonar-project.properties.>= 10.x / SonarCloud (continuously updated) for current
quality-gate "new code" condition syntax; older 9.x LTS servers use
slightly different default gate condition names.sonar-scanner CLI
(language-agnostic), sonar-maven-plugin/sonar-gradle-plugin
(Java), or dotnet-sonarscanner (.NET) — the Maven/Gradle/.NET
scanners integrate with the build's own dependency resolution and
generally produce more accurate results than the generic CLI scanner
for those ecosystems.Execute Analysis permission, stored in the CI secrets
store — never inline in sonar-project.properties. See
secrets-management.Configure sonar-project.properties at the repo root (or pass
equivalents as scanner CLI args/CI env vars):
sonar.projectKey=example-org_checkout-service
sonar.organization=example-org
sonar.sources=src
sonar.tests=test
sonar.exclusions=**/vendor/**,**/node_modules/**,**/*.generated.ts
sonar.test.exclusions=**/*.spec.ts,**/*.test.ts
sonar.coverage.exclusions=**/migrations/**,**/*.d.ts
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.python.coverage.reportPaths=coverage.xml
Run the scanner in CI, feeding in the auth token as a secret, not a literal value:
# GitHub Actions
name: sonarqube
on:
pull_request:
push:
branches: [main]
jobs:
sonar:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # required for accurate blame/new-code detection
- name: Run tests with coverage
run: npm test -- --coverage
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v4
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- name: Quality Gate check
uses: SonarSource/sonarqube-quality-gate-action@v1
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
fetch-depth: 0 matters: SonarQube's new-code detection relies on
git blame history, and a shallow clone produces incomplete or
incorrect new-code attribution.
Define "new code" deliberately — Administration → Project → New Code — as one of:
main —
the standard choice for trunk-based/PR-heavy workflows).
Gating on "new code" rather than the whole codebase's historical
baseline is what makes a quality gate adoptable on an existing
codebase with pre-existing debt — see the first Common pitfall.Design the quality gate's conditions around new code first; SonarQube's built-in "Sonar way" default gate is a reasonable starting point:
Quality Gate: "checkout-service-gate"
Conditions on New Code:
- Coverage is less than 80%
- Duplicated Lines (%) is greater than 3%
- Maintainability Rating is worse than A
- Reliability Rating is worse than A
- Security Rating is worse than A
- Security Hotspots Reviewed is less than 100%
Add Overall Code conditions sparingly (e.g. "Security Rating on Overall Code is worse than C") only once the team has capacity to work down historical debt — an overall-code gate applied to an existing large codebase on day one typically fails immediately and permanently.
Triage security hotspots as a distinct workflow from vulnerabilities. SonarQube auto-confirms clear-cut vulnerabilities but marks security-sensitive code patterns (e.g. use of a cryptographic API, a regex that could be ReDoS-prone, a dynamic SQL builder) as "hotspots" requiring a human "Safe" / "Fixed" / "Acknowledged (won't fix, with reason)" review — they do not block the quality gate by count alone, only via the "Security Hotspots Reviewed %" condition, so an unreviewed backlog silently erodes that metric rather than failing loudly.
Enable PR decoration so findings appear as inline PR comments, not only on the SonarQube dashboard (Administration → DevOps Platform Integrations, then per-project binding to the repo):
# sonar-project.properties (PR context, usually scanner-injected in CI)
sonar.pullrequest.key=${PR_NUMBER}
sonar.pullrequest.branch=${PR_BRANCH}
sonar.pullrequest.base=main
Most CI scanner actions/plugins auto-populate these from CI
environment variables (GITHUB_*, CI_MERGE_REQUEST_*) — check the
scanner action's docs before hand-setting them.
Track the technical debt ratio and ratings as trend metrics, not just gate pass/fail — the debt ratio (remediation cost of all issues ÷ cost to rewrite the codebase from scratch) is what drives the A-E Maintainability Rating, and watching it trend is a better long-term signal than a binary gate result on any single PR.
Suppress with // NOSONAR or issue-level "Won't Fix"/"False
Positive" resolution, with a mandatory comment, mirroring the same
discipline used for any SAST suppression:
String query = "SELECT * FROM users WHERE id = " + id; // NOSONAR — id is validated as int upstream in UserIdValidator, see JIRA-771
fetch-depth: 0 (full git history) in CI — shallow
clones break new-code blame attribution and can cause a gate to
silently evaluate against the wrong baseline.sonar.exclusions, sonar.coverage.exclusions)
narrow and justified in a comment — broad exclusions (e.g. excluding
an entire src/ subtree) silently blind the gate to real code.Symptom: A quality gate is enabled on an existing codebase and fails immediately for every single PR, regardless of what the PR changes. Fix: The gate is evaluating Overall Code conditions against years of pre-existing debt. Switch primary blocking conditions to "New Code" (step 3-4), and address overall-code debt as a separate, scheduled paydown effort with its own backlog, not a blocking gate.
Symptom: New-code coverage/duplication numbers look wrong or
inconsistent between local analysis and CI.
Fix: Check fetch-depth in CI — a shallow git clone (the default
in many CI templates) breaks SonarQube's blame-based new-code
detection; set fetch-depth: 0 (or git fetch --unshallow).
Symptom: The security hotspot count keeps growing every sprint and nobody reviews them, even though the quality gate keeps passing. Fix: Hotspots don't block by count — only the "Security Hotspots Reviewed %" condition does, and only if it's in the gate. Add that condition explicitly to the quality gate, and assign a rotating owner to review the hotspot queue on a fixed cadence rather than leaving it ownerless.
Symptom: A Java/Kotlin (or other JVM-ecosystem) project analyzed
with the generic sonar-scanner CLI reports far fewer/different
issues than expected, and coverage shows as 0%.
Fix: Use the build-integrated scanner
(sonar-maven-plugin/sonar-gradle-plugin) instead of the generic
CLI for JVM ecosystems — it reuses the actual build's classpath and
compiled bytecode, which the generic scanner cannot reconstruct on
its own, and wire the coverage report path
(sonar.coverage.jacoco.xmlReportPaths) explicitly.
Symptom: PR decoration comments never appear on GitHub/GitLab
pull requests even though the dashboard shows the analysis completed.
Fix: DevOps Platform Integration isn't configured/bound for the
project, or the token used lacks permission to post PR comments on
the source-control side. Verify the server-wide integration
(Administration → DevOps Platform Integrations) and the per-project
binding, and confirm sonar.pullrequest.* properties are actually
being populated in the CI run (check scanner logs for the PR context
block).
A Python service (payments-api) adopts SonarCloud with a new-code
quality gate and PR decoration.
sonar-project.properties:
sonar.projectKey=example-org_payments-api
sonar.organization=example-org
sonar.sources=app
sonar.tests=tests
sonar.python.coverage.reportPaths=coverage.xml
sonar.exclusions=**/migrations/**,**/__pycache__/**
Quality gate ("payments-api-gate"), new-code conditions:
Coverage < 85% -> FAIL
Duplicated Lines (%) > 3% -> FAIL
Maintainability Rating worse than A -> FAIL
Security Rating worse than A -> FAIL
Security Hotspots Reviewed < 100% -> FAIL
.github/workflows/sonar.yml:
name: sonarqube
on:
pull_request:
push:
branches: [main]
jobs:
sonar:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run tests with coverage
run: |
pip install -r requirements-dev.txt
pytest --cov=app --cov-report=xml
- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@v4
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Quality Gate check
uses: SonarSource/sonarqube-quality-gate-action@v1
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Sample failing PR decoration comment:
Quality Gate: FAILED
New Code:
Security Rating: E (worse than required A)
app/billing/charge.py:88 — Hardcoded secret used in a cryptographic
key derivation (BLOCKER, CWE-798)
Coverage: 71.2% (required >= 85%)
Remediation: replace the hardcoded key with one sourced from the secrets
manager (see
secrets-management),
add tests to cover charge.py's new branch, push, and confirm the gate
re-evaluates to passed on the updated commit.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
15 skills in this plugin
/certificate-lifecycle-management-at-scaleGuides managing TLS/mTLS certificate lifecycle across many services and environments beyond a single Kubernetes cluster — enterprise CA integration (ACME private CA, Microsoft AD CS, cloud-managed private CAs), cross-service rotation automation, expiry monitoring/alerting, and CA hierarchy/trust-chain management for a mixed fleet of VMs, on-prem servers, and multiple clusters. Use when the user asks to "automate cert rotation across our whole fleet," "integrate with our enterprise CA," "why do we keep having certificate expiry outages," "design a CA hierarchy for the org," "track every certificate's expiry date across environments," or "cert-manager only covers our Kubernetes clusters, what about everything else." Distinct from cert-manager's Kubernetes-native scope — see `../../../kubernetes-platform/skills/cert-manager-tls-automation/SKILL.md`.
/enterprise-sso-and-idp-federation-configurationGuides configuring enterprise workforce single sign-on — SAML 2.0 and OIDC federation between an identity provider (Okta, Azure AD/Entra ID, Keycloak) and downstream applications, including metadata exchange, attribute/claim mapping, group-to-role provisioning (SCIM), and multi-IdP federation trust. Use when the user asks to "set up SAML SSO with Okta," "configure Azure AD/Entra ID as our OIDC provider," "stand up Keycloak as an internal IdP," "map IdP groups to application roles," "debug a SAML assertion that won't validate," or "federate a second IdP for an acquired company's users." Distinct from cloud-iam-hardening (workload/service IAM in a cloud provider) — this skill is about federating *human workforce* identity into applications for SSO.
/falco-configuration-validationValidates Falco runtime detection rules for false-positive rate and actual firing correctness before trusting them in a channel that pages a human — running new/changed rules in log-only mode against real traffic, measuring alert volume and content, and confirming a rule fires on a deliberate positive-control trigger before promoting it to a higher-severity, paging-routed configuration. Use when the user asks to "validate this Falco rule before enabling it," "why is Falco so noisy," "test our Falco rules don't false-positive on real traffic," "review this rule set before it pages on-call," or "make sure Falco rules aren't about to be enabled in enforce/blocking mode without an audit period." Pairs with falco-runtime-threat-detection-configuration.
/falco-runtime-threat-detection-configurationGuides authoring and deploying Falco runtime threat detection rules — the eBPF/kernel-module-based syscall event stream, Falco's rule syntax (condition/output/priority), writing custom rules for a specific workload's known-good behavior, tuning noisy default rules, and wiring alerts to Falcosidekick outputs. Use when the user asks to "write a Falco rule to detect X," "why is Falco alerting on normal behavior," "detect a shell spawned inside a container at runtime," "set up Falco with eBPF instead of the kernel module," "send Falco alerts to Slack/PagerDuty," or "what's the difference between Falco and admission-control policy engines like OPA/Kyverno." Pairs with falco-configuration-validation for pre-enforcement false-positive testing.
/fortify-static-analysisGuides deep, tool-specific use of OpenText (formerly Micro Focus) Fortify Static Code Analyzer (SCA) and Fortify Audit Workbench for enterprise, on-premises static analysis — the translate/scan build workflow, Fortify Security Rulepacks, audit workbench triage (Not an Issue / Reliability / Suspicious), and how Fortify's on-prem, build-integrated model differs operationally from cloud-native SAST. Use when the user asks to "run a Fortify scan", "configure sourceanalyzer for a build", "triage findings in Fortify Audit Workbench", "integrate Fortify with Jenkins/Azure DevOps", "reduce Fortify SCA false positives", or "compare Fortify against SonarQube/Semgrep for enterprise compliance". Fortify-specific depth on the translate/scan model and enterprise workflow; for the general SAST concept see sast-integration in the devsecops domain.
/kubewarden-admission-policy-configurationGuides configuring Kubewarden as a WASM-based Kubernetes admission policy engine — installing the policy-server and controller, writing or reusing WebAssembly policies from the Kubewarden Policy Hub, ClusterAdmissionPolicy/AdmissionPolicy resources, monitor-mode rollout before enforce, and multi-language policy authoring (Rego, Rust, Go via the SDKs) as an alternative to OPA/Gatekeeper or Kyverno. Use when the user asks to "set up Kubewarden," "write a WASM admission policy," "why use Kubewarden instead of OPA/Kyverno," "reuse a policy from the Kubewarden Policy Hub," "run an admission policy in monitor mode before enforcing it," or "author a Kubernetes admission policy without writing Rego."
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin security-tooling-skillsOther plugins' skills for the same job