java/src/main/resources/targets/claude/skills/conditional/security/x-security-sonar/SKILL.md
Integrates with SonarQube/SonarCloud for security hotspot tracking, quality gate enforcement, and SARIF output from findings.
npx skillsauth add edercnj/ia-dev-environment x-security-sonarInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Integrate with SonarQube or SonarCloud to generate sonar-project.properties, execute SonarScanner, poll quality gate status, and produce SARIF output with a Markdown report. Support default and strict quality gate modes for security hotspot tracking and vulnerability enforcement.
Include this skill when security.qualityGate.provider is not "none" in the project configuration.
/x-security-sonar --server https://sonar.example.com --token squ_abc123... -- default quality gate/x-security-sonar --server https://sonar.example.com --token squ_abc123... --quality-gate strict -- strict mode for release pipeline/x-security-sonar --server https://sonar.example.com --token squ_abc123... --project-key my-service --branch release/1.0 -- custom project key and branch| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| --server | String | Yes | -- | SonarQube/SonarCloud server URL |
| --token | String | Yes | -- | Authentication token (min 40 chars) |
| --quality-gate | String | No | default | Quality gate mode: default, strict |
| --project-key | String | No | auto-detect | Project key in SonarQube |
| --branch | String | No | current branch | Branch for analysis |
| --timeout | Integer | No | 300 | Polling timeout in seconds (30-3600) |
| Pack | Files | Purpose |
|------|-------|---------|
| security | skills/security/references/security-principles.md | Data classification, input validation, fail-secure patterns |
| security | skills/security/references/application-security.md | OWASP Top 10, security headers, secrets management |
Execute Analysis permission--server is a reachable HTTP/HTTPS URL--token is non-empty and at least 40 charactersSonarQube server unreachable: <url>SonarQube authentication failedDetect language, source directories, test directories, and project key from build files.
Generate the properties file with auto-detected values including language-specific properties.
sonar-scanner \
-Dsonar.host.url=<server-url> \
-Dsonar.token=<token> \
-Dsonar.branch.name=<branch> \
-Dsonar.projectKey=<project-key>
Capture the task ID from scanner output for polling.
GET /api/qualitygates/project_status?analysisId=<id>--timeout (default: 300s)OK, ERRORDefault Mode: Use the quality gate configured on the SonarQube server.
Strict Mode: Enforce stricter thresholds:
| Metric | Threshold | Operator |
|--------|-----------|----------|
| new_vulnerabilities | 0 | GT |
| security_hotspots_reviewed | 100% | LT |
| security_rating | A (1) | GT |
| duplicated_lines_density | 3% | GT |
| coverage | 95% | LT |
| Scenario | Action |
|----------|--------|
| Server unreachable | Abort with SonarQube server unreachable: <url>, verify URL and network |
| Authentication failed | Abort with SonarQube authentication failed: 401, verify token |
| Polling timeout | Report last known status with analysis ID, suggest increasing timeout |
| Scanner not found | Abort with SonarScanner not found on PATH, provide install instructions |
| Invalid project key | Abort with Invalid project key format, suggest pattern [a-zA-Z0-9_:.-]+ |
- name: SonarQube Quality Gate
run: |
sonar-scanner \
-Dsonar.host.url=${{ '{{' }} secrets.SONAR_HOST_URL {{ '}}' }} \
-Dsonar.token=${{ '{{' }} secrets.SONAR_TOKEN {{ '}}' }} \
-Dsonar.branch.name=${{ '{{' }} github.ref_name {{ '}}' }} \
-Dsonar.qualitygate.wait=true
sonarqube-check:
stage: quality
image: sonarsource/sonar-scanner-cli:latest
script:
- sonar-scanner
-Dsonar.host.url=${SONAR_HOST_URL}
-Dsonar.token=${SONAR_TOKEN}
-Dsonar.qualitygate.wait=true
sonar-project.properties generated with correct source/test directoriestesting
Scaffolds a Helidon SE/MP service with routing, health, config, Dockerfile, and tests.
tools
Generates a Picocli @Command with subcommands, options, converters, and unit tests.
testing
Scaffolds a Micronaut service with @Controller, DI, health, Dockerfile, and tests.
testing
Scaffolds a Helidon SE/MP service with routing, health, config, Dockerfile, and tests.