From fb9cc5ff11bb4784087b34195a24406066a7de57 Mon Sep 17 00:00:00 2001 From: Arnaud Dartois Date: Wed, 28 Oct 2026 13:44:52 +0100 Subject: [PATCH] docs: add project-specific development skills --- .../skills/docker-test-environment/SKILL.md | 26 +++++++++++++++ .claude/skills/gitea-actions-ci/SKILL.md | 29 +++++++++++++++++ .claude/skills/gitea-api-client/SKILL.md | 28 ++++++++++++++++ .claude/skills/java-best-practices/SKILL.md | 27 ++++++++++++++++ .claude/skills/java-testing/SKILL.md | 27 ++++++++++++++++ .claude/skills/maven-build-packaging/SKILL.md | 32 +++++++++++++++++++ .claude/skills/project-workflow/SKILL.md | 27 ++++++++++++++++ .../release-versioning-changelog/SKILL.md | 27 ++++++++++++++++ .claude/skills/secure-coding-plugin/SKILL.md | 29 +++++++++++++++++ .../sonarqube-frontend-extension/SKILL.md | 29 +++++++++++++++++ .../sonarqube-plugin-development/SKILL.md | 31 ++++++++++++++++++ 11 files changed, 312 insertions(+) create mode 100644 .claude/skills/docker-test-environment/SKILL.md create mode 100644 .claude/skills/gitea-actions-ci/SKILL.md create mode 100644 .claude/skills/gitea-api-client/SKILL.md create mode 100644 .claude/skills/java-best-practices/SKILL.md create mode 100644 .claude/skills/java-testing/SKILL.md create mode 100644 .claude/skills/maven-build-packaging/SKILL.md create mode 100644 .claude/skills/project-workflow/SKILL.md create mode 100644 .claude/skills/release-versioning-changelog/SKILL.md create mode 100644 .claude/skills/secure-coding-plugin/SKILL.md create mode 100644 .claude/skills/sonarqube-frontend-extension/SKILL.md create mode 100644 .claude/skills/sonarqube-plugin-development/SKILL.md diff --git a/.claude/skills/docker-test-environment/SKILL.md b/.claude/skills/docker-test-environment/SKILL.md new file mode 100644 index 0000000..279469d --- /dev/null +++ b/.claude/skills/docker-test-environment/SKILL.md @@ -0,0 +1,26 @@ +--- +name: docker-test-environment +description: Use when changing the local Docker build, test Compose stack, SonarQube/Gitea/PostgreSQL images, or plugin mounting. +--- +# Docker test environment + +- Pin SonarQube Community Build to `25.9.0.112764-community` and pin PostgreSQL and Gitea image tags. +- Provide health checks and start dependencies before SonarQube; persist database data in named volumes. +- Mount the plugin JAR read-only into `/opt/sonarqube/extensions/plugins/` and restart SonarQube after packaging. +- Use test-only credentials from environment variables; never commit live tokens. +- Document Linux kernel prerequisites for Docker hosts (including `vm.max_map_count` where needed by the bundled search engine). +- Keep the Compose test stack isolated from production volumes and endpoints. + +## Checklist +- [ ] All service image tags pinned. +- [ ] Health checks and durable named DB volumes present. +- [ ] Test plugin mount path correct. +- [ ] Setup and credentials documented safely. + +## Sources +- SonarQube Docker setup: https://docs.sonarsource.com/sonarqube-community-build/server-update-and-maintenance/update/update (consulted 2026-10-28) +- SonarQube Docker image tags: https://hub.docker.com/_/sonarqube (consulted 2026-10-28) +- Docker Compose specification: https://docs.docker.com/compose/compose-file/ (consulted 2026-10-28) + +## Not verified +- Host OS and Docker engine version are unspecified; kernel tuning is host dependent. diff --git a/.claude/skills/gitea-actions-ci/SKILL.md b/.claude/skills/gitea-actions-ci/SKILL.md new file mode 100644 index 0000000..f6fe4a6 --- /dev/null +++ b/.claude/skills/gitea-actions-ci/SKILL.md @@ -0,0 +1,29 @@ +--- +name: gitea-actions-ci +description: Use when creating or changing CI workflows, artifact upload, release commits, tags, or Gitea release publishing. +--- +# Gitea Actions CI + +- Use `.gitea/workflows/*.yml`; trigger push, pull request, and manual dispatch as required. +- Fetch complete history and tags before version calculation (`fetch-depth: 0` where supported). +- Pin actions to immutable commits or exact versions and document when a mirror is required; act_runner compatibility must be checked. +- Cache Maven dependencies without caching secrets. Never put tokens in command output. +- Gate release on push to the configured main branch, version script release-needed output, and a workflow-generated-commit guard. Do not rely only on `[skip ci]`. +- Update changelog, commit, tag that commit, push commit and tag, then create Gitea release from the exact changelog section. +- Use repository secrets for API credentials; describe branch protection permissions required for the release identity. +- Avoid release loops by checking actor/commit marker and tag state. + +## Checklist +- [ ] Full history/tags available. +- [ ] PR validates changelog without mutation. +- [ ] Release job guarded against loops and branch scope. +- [ ] Secret only used for authenticated push/release. +- [ ] Actions are act_runner compatible or mirror requirements documented. + +## Sources +- Gitea Actions documentation: https://docs.gitea.com/usage/actions/overview (consulted 2026-10-28) +- Gitea Actions migration guide: https://docs.gitea.com/usage/actions/comparison (consulted 2026-10-28) +- Gitea API documentation: https://docs.gitea.com/api/ (consulted 2026-10-28) + +## Not verified +- Runner version, main branch name, and protected-branch policy are unspecified. diff --git a/.claude/skills/gitea-api-client/SKILL.md b/.claude/skills/gitea-api-client/SKILL.md new file mode 100644 index 0000000..1b52d36 --- /dev/null +++ b/.claude/skills/gitea-api-client/SKILL.md @@ -0,0 +1,28 @@ +--- +name: gitea-api-client +description: Use when implementing or modifying Gitea API requests, pagination, authentication, DTOs, errors, or HTTP retry behavior. +--- +# Gitea API client + +- Assume Gitea REST API v1 (OpenAPI documented by Gitea); use documented paths: `/user/orgs`, `/orgs/{org}/repos`, and `/user/repos` when personal repositories are enabled. +- Send the token only in the server-side `Authorization: token …` header; never echo it or include it in exceptions. +- Paginate with bounded `page` and `limit` parameters and stop only when a page is shorter than the requested limit. +- Use `java.net.http.HttpClient` with explicit connect and request timeouts. +- Do not automatically retry non-idempotent operations. If retries are added for GET, cap attempts and honor `Retry-After` when valid. +- Map 401 to invalid token, 403 to insufficient Gitea access, 404 to missing organization/resource, 429 to rate limit, and 5xx/network failures to temporary service errors. +- Parse only fields needed by the UI; handle absent optional branch fields safely. +- Validate configured base URL and disable redirects to prevent token forwarding to another host. + +## Checklist +- [ ] Token remains server side and is redacted. +- [ ] Pagination bounded and tested. +- [ ] Timeouts and status mappings are explicit. +- [ ] Redirects disabled; base URL validated. + +## Sources +- Gitea API documentation: https://docs.gitea.com/api/ (API 28.2.0 consulted 2026-10-28) +- Gitea user/org operations: https://docs.gitea.com/api/1.26/operations/tags/organization/ (consulted 2026-10-28) +- Java HttpClient: https://docs.oracle.com/en/java/javase/17/docs/api/java.net.http/java/net/http/HttpClient.html (consulted 2026-10-28) + +## Not verified +- Deployment-specific Gitea version is unspecified; current endpoint compatibility across older Gitea versions must be checked against the test instance. diff --git a/.claude/skills/java-best-practices/SKILL.md b/.claude/skills/java-best-practices/SKILL.md new file mode 100644 index 0000000..2d675f3 --- /dev/null +++ b/.claude/skills/java-best-practices/SKILL.md @@ -0,0 +1,27 @@ +--- +name: java-best-practices +description: Use when writing or reviewing Java production code in this plugin, especially HTTP, validation, lifecycle, concurrency, or error handling. +--- +# Java best practices + +- Compile with Java 17 (`maven.compiler.release=17`), the baseline supported by the target plugin API. +- Prefer immutable records for internal DTOs where compatible with JSON parsing; keep collections defensively copied. +- Validate null, length, and format at service boundaries. Use named constants for bounds and timeouts. +- Use try-with-resources for closeable resources; `java.net.http.HttpClient` is reusable and immutable. +- Do not create static mutable state, swallow exceptions, catch `Throwable`, or catch broad `Exception` without translating a known boundary failure. +- Keep errors actionable but never include authorization headers, tokens, or full secret-bearing URLs. +- Use SLF4J host-provided logging; log operation context without credentials. +- Keep packages under `cc.tordais.sonar.bifrost`; name types and methods in ASCII English. + +## Checklist +- [ ] Java 17 compilation; immutable data and bounded inputs. +- [ ] Exceptions translated at boundaries, not hidden. +- [ ] No static mutable state or secret-bearing logs. +- [ ] Resources and HTTP timeouts handled. + +## Sources +- SonarQube API JDK baseline: https://github.com/SonarSource/sonar-plugin-api (consulted 2026-10-28) +- Java 17 API documentation: https://docs.oracle.com/en/java/javase/17/docs/api/ (consulted 2026-10-28) + +## Not verified +- No project-specific Sonar quality profile has been run yet. diff --git a/.claude/skills/java-testing/SKILL.md b/.claude/skills/java-testing/SKILL.md new file mode 100644 index 0000000..799392f --- /dev/null +++ b/.claude/skills/java-testing/SKILL.md @@ -0,0 +1,27 @@ +--- +name: java-testing +description: Use when adding or changing unit or integration tests for Java services, validation, project keys, or HTTP interactions. +--- +# Java testing + +- Use pinned JUnit Jupiter and AssertJ; use Mockito only for narrow collaborator seams. +- Mock HTTP at the transport boundary with a local in-process `HttpServer`; tests must not need a real Gitea instance or network. +- Test pagination, authentication failures, 404, 5xx, malformed payloads, timeout behavior, and secret redaction. +- Test project-key sanitization, invalid/empty inputs, and collisions across distinct source names. +- Test organization allowlist behavior in both fixed and all-accessible modes. +- Use deterministic fixtures, no sleeps, no dependence on wall-clock except injected clock behavior. +- Run `./mvnw test` (Windows: `mvnw.cmd test`) and report only results actually run. + +## Checklist +- [ ] Gitea HTTP paths and failure mapping covered. +- [ ] Key and organization boundary cases covered. +- [ ] Tests are offline and deterministic. +- [ ] Test suite passes with Maven Wrapper. + +## Sources +- JUnit 5 User Guide: https://junit.org/junit5/docs/current/user-guide/ (consulted 2026-10-28) +- AssertJ documentation: https://assertj.github.io/doc/ (consulted 2026-10-28) +- Java HttpServer API: https://docs.oracle.com/en/java/javase/17/docs/api/jdk.httpserver/com/sun/net/httpserver/HttpServer.html (consulted 2026-10-28) + +## Not verified +- Plugin lifecycle integration tests against a running server are outside unit test scope. diff --git a/.claude/skills/maven-build-packaging/SKILL.md b/.claude/skills/maven-build-packaging/SKILL.md new file mode 100644 index 0000000..a0a412d --- /dev/null +++ b/.claude/skills/maven-build-packaging/SKILL.md @@ -0,0 +1,32 @@ +--- +name: maven-build-packaging +description: Use when changing Maven coordinates, compiler or plugin versions, wrapper, packaging, JavaScript resources, or Docker build integration. +--- +# Maven build and packaging + +- Use Maven and commit the Maven Wrapper; pin Maven distribution, compiler, Surefire, packaging, and flatten plugin versions. +- Inject `${revision}` through `-Drevision=...`; use `flatten-maven-plugin` so published metadata resolves the version. +- Set compiler release 17. Declare `org.sonarsource.api.plugin:sonar-plugin-api:13.0.0.3026` as `provided` for Community Build 25.9. +- Configure `sonar-packaging-maven-plugin` with plugin key `bifrost`, ASCII display fallback `Bifrost (Gitea Import)` until manifest UTF-8 is verified, and plugin API minimum `13.0.0.3026`. +- Do not confuse manifest `Sonar-Version` with a SonarQube product version: it records the minimum plugin API version. Track the minimum tested SonarQube release separately. +- Keep JavaScript dependency-free and package it as a static resource; no Node build step is needed. +- Produce `sonar-bifrost-plugin-${revision}.jar`; inspect manifest and contents after packaging. +- Build reproducibly where plugin versions permit; avoid timestamps and unpinned image tags. +- Docker build stages must use pinned JDK/Maven images and provide a clear host extraction command. + +## Checklist +- [ ] Wrapper and all plugin versions pinned. +- [ ] Public API dependency provided, not packaged. +- [ ] JAR filename and manifest correct. +- [ ] Static page resource included. +- [ ] Container build can export the JAR. + +## Sources +- SonarQube plugin packaging: https://docs.sonarsource.com/sonarqube-community-build/extension-guide/developing-a-plugin/plugin-basics (consulted 2026-10-28) +- Maven Wrapper: https://maven.apache.org/wrapper/ (consulted 2026-10-28) +- Maven CI-friendly versions: https://maven.apache.org/maven-ci-friendly.html (consulted 2026-10-28) +- SonarSource packaging plugin: https://github.com/SonarSource/sonar-packaging-maven-plugin (consulted 2026-10-28) +- Manifest metadata reference: https://docs.sonarsource.com/sonarqube-community-build/extension-guide/developing-a-plugin/plugin-basics (consulted 2026-10-28) + +## Not verified +- Exact minimum-version manifest syntax must be checked against the pinned packaging plugin release during build implementation. diff --git a/.claude/skills/project-workflow/SKILL.md b/.claude/skills/project-workflow/SKILL.md new file mode 100644 index 0000000..8d42bf5 --- /dev/null +++ b/.claude/skills/project-workflow/SKILL.md @@ -0,0 +1,27 @@ +--- +name: project-workflow +description: Use for every task in this repository to enforce its implementation order, evidence rules, skills, language, and definition of done. +--- +# Project workflow + +- Keep all source, docs, UI, logs, comments, workflows, and commit messages in English. Use ASCII identifiers; display text may use `Bifröst` only if UTF-8 manifest encoding is verified. +- Before implementation, read relevant project skills and verify any version-sensitive claims against their listed primary sources. +- Work in this order: compatibility research, skills, design, implementation, tests/build, packaging inspection, compliance review. +- If reality conflicts with a skill, confirm with primary documentation, fix the skill in the same change, and explain the correction. +- Keep security boundaries server-side; never trust UI visibility or client-provided organization names. +- Do not claim build, runtime, browser, or integration verification unless actually performed. +- Definition of done: requested artifacts exist, unit tests/build pass, packaged metadata inspected, limitations documented, and each skill checklist reviewed. +- Use Conventional Commit messages; do not claim commits were created unless the repository is a Git checkout and the commit actually exists. + +## Checklist +- [ ] Relevant skills loaded and followed. +- [ ] English-only content and ASCII identifiers. +- [ ] Verification evidence accurately reported. +- [ ] Skill checklists and limitations reviewed. + +## Sources +- User project requirements in the initial task (consulted 2026-10-28) +- SonarQube Community Build plugin basics: https://docs.sonarsource.com/sonarqube-community-build/extension-guide/developing-a-plugin/plugin-basics (consulted 2026-10-28) + +## Not verified +- Repository hosting policy, default branch, and commit identity are unspecified. diff --git a/.claude/skills/release-versioning-changelog/SKILL.md b/.claude/skills/release-versioning-changelog/SKILL.md new file mode 100644 index 0000000..39ac82c --- /dev/null +++ b/.claude/skills/release-versioning-changelog/SKILL.md @@ -0,0 +1,27 @@ +--- +name: release-versioning-changelog +description: Use when changing semantic version calculation, release automation, Conventional Commit parsing, or CHANGELOG.md generation and validation. +--- +# Release versioning and changelog + +- Treat `vMAJOR.MINOR.PATCH` Git tags as the sole release version source. +- Parse commits since the latest reachable version tag: breaking change or `!` bumps major; `feat` bumps minor; `fix`, `perf`, and `refactor` bump patch; other types do not request release. +- Use a valid plugin manifest version format; keep snapshot metadata out of release tags. +- Keep `CHANGELOG.md` in Keep a Changelog 1.1.0 structure, newest first, with only Added, Changed, Deprecated, Removed, Fixed, and Security categories. +- Never invent a user-facing changelog detail from an unclear commit. Allow maintainers to edit generated entries before release. +- Validate headings, dates, allowed categories, order, and comparison links with a script. +- Extract release body directly from the version section in `CHANGELOG.md`. + +## Checklist +- [ ] Tag parsing is deterministic and handles no-tag repositories. +- [ ] Bump mapping matches repository policy. +- [ ] Changelog validator catches malformed sections and links. +- [ ] Release tag points to the changelog update commit. + +## Sources +- Keep a Changelog 1.1.0: https://keepachangelog.com/en/1.1.0/ (consulted 2026-10-28) +- Semantic Versioning 2.0.0: https://semver.org/spec/v2.0.0.html (consulted 2026-10-28) +- Conventional Commits 1.0.0: https://www.conventionalcommits.org/en/v1.0.0/ (consulted 2026-10-28) + +## Not verified +- SonarQube's exact accepted plugin manifest version grammar needs build-time confirmation against target 25.9. diff --git a/.claude/skills/secure-coding-plugin/SKILL.md b/.claude/skills/secure-coding-plugin/SKILL.md new file mode 100644 index 0000000..3094995 --- /dev/null +++ b/.claude/skills/secure-coding-plugin/SKILL.md @@ -0,0 +1,29 @@ +--- +name: secure-coding-plugin +description: Use when adding or reviewing configuration, web-service inputs, authorization, outbound HTTP, secrets, or dependencies in the plugin. +--- +# Secure coding for this plugin + +- Require authenticated SonarQube users and check `Create Projects` on every action that enumerates or imports repositories. +- Treat all browser input as untrusted. Bound batch size and string lengths; validate organization and repository identifiers before API calls. +- Validate configured Gitea URL as absolute HTTP(S) with host and no userinfo, query, or fragment. The URL is trusted administrator configuration and may target a private Gitea host; never accept a request-specific outbound URL. +- Disable redirects to avoid forwarding the Gitea token; do not expose outbound arbitrary URL input. +- Store the token in a `.secured` PASSWORD property. Never return it from web services, JS, logs, errors, or generated files. +- Use same-origin authenticated SonarQube requests for mutations; do not build custom cookie bypasses. Preserve SonarQube's normal CSRF/session protections. +- Reject duplicate or colliding project keys before making any project mutations. +- Pin dependencies, inspect transitive dependency changes, and keep the Sonar API provided. + +## Checklist +- [ ] Every endpoint checks Create Projects. +- [ ] URL, identifiers, and batch sizes validated. +- [ ] Secret handling and redirects safe. +- [ ] Project-key collisions fail closed. +- [ ] Dependency versions pinned. + +## Sources +- OWASP SSRF Prevention Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html (consulted 2026-10-28) +- SonarQube Community Build Web API security: https://docs.sonarsource.com/sonarqube-community-build/extension-guide/web-api (consulted 2026-10-28) +- SonarQube plugin configuration: https://docs.sonarsource.com/sonarqube-community-build/extension-guide/developing-a-plugin/plugin-basics (consulted 2026-10-28) + +## Not verified +- Exact WebService framework CSRF behavior for custom POST actions must be validated on 25.9 during integration testing. diff --git a/.claude/skills/sonarqube-frontend-extension/SKILL.md b/.claude/skills/sonarqube-frontend-extension/SKILL.md new file mode 100644 index 0000000..116f6cc --- /dev/null +++ b/.claude/skills/sonarqube-frontend-extension/SKILL.md @@ -0,0 +1,29 @@ +--- +name: sonarqube-frontend-extension +description: Use when implementing or changing a SonarQube 25.9 page extension, its JavaScript bundle, navigation placement, API calls, or browser permissions. +--- +# SonarQube frontend extension + +- Register a global page with `PageDefinition`; its key is `bifrost/import`. +- Put the matching unbundled JavaScript at `src/main/resources/static/import.js`; call `window.registerExtension("bifrost/import", start)`. +- Use only `options.el` as the page mount point; return a cleanup callback. +- Do not assume global libraries except React. Plain browser JavaScript avoids an unnecessary build step. +- Use same-origin `fetch` for `api/bifrost/*`; rely on the active SonarQube session and never send the Gitea token to the browser. +- Render API errors as accessible text; use labels for controls, semantic table headers, keyboard-accessible controls, and text status in addition to color. +- Validate repository links as HTTP or HTTPS before assigning them to an anchor. +- Grey out imported rows and disable their checkboxes. Keep selection in page state across organization changes. +- Page visibility is not authorization. The server must enforce Create Projects permission on every endpoint. +- Do not embed inline scripts or use `eval`. + +## Checklist +- [ ] `PageDefinition` key matches JS registration key and resource filename. +- [ ] Bundle packaged under `/static/bifrost/import.js`. +- [ ] Accessible labels, feedback and keyboard controls. +- [ ] No token in browser or authorization based only on menu visibility. + +## Sources +- Adding pages to the webapp: https://docs.sonarsource.com/sonarqube-community-build/extension-guide/developing-a-plugin/adding-pages-to-the-webapp (consulted 2026-10-28) +- SonarQube Web API: https://docs.sonarsource.com/sonarqube-community-build/extension-guide/web-api (consulted 2026-10-28) + +## Not verified +- No live 25.9 instance was available to inspect final menu rendering. diff --git a/.claude/skills/sonarqube-plugin-development/SKILL.md b/.claude/skills/sonarqube-plugin-development/SKILL.md new file mode 100644 index 0000000..c361b55 --- /dev/null +++ b/.claude/skills/sonarqube-plugin-development/SKILL.md @@ -0,0 +1,31 @@ +--- +name: sonarqube-plugin-development +description: Use when adding or changing Java plugin entry points, extension registration, properties, web services, manifest metadata, or packaging compatibility for SonarQube Community Build 25.9.0.112764. +--- +# SonarQube plugin development + +- Target SonarQube Community Build `25.9.0.112764`; use Java 17 bytecode and the matching public plugin API (`13.0.0.3026`, confirmed from the target server dependency metadata). +- Declare all server extensions through `Plugin.Context.addExtensions`; keep constructors free of service work. +- Use only `org.sonar.api.*` public API. Never import `org.sonar.server.*`, DAO classes, or implementation packages. +- Define settings through `PropertyDefinition`; secured values must use a `.secured` key and PASSWORD type. +- Add web services using `WebService` and `@ServerSide`; authorize each action explicitly. +- Set key, display name, version and minimum plugin API version in packaging metadata. The manifest `Sonar-Version` is an API version, not a SonarQube product release. Keep the minimum tested server release separately. +- Use SLF4J supplied by the host; never package logging implementations or log credentials. +- Verify extension APIs against the exact API artifact/Javadoc when changing the target release. +- For project creation, prefer the browser's same-origin public SonarQube REST call when the logged-in user's session must be preserved; do not invoke internal project creation services from a plugin endpoint. + +## Checklist +- [ ] Entry point and only public API types. +- [ ] Extensions registered and server side scoped correctly. +- [ ] Secure configuration and explicit authorization. +- [ ] Manifest key/name/version/minimum version inspected in final JAR. +- [ ] `mvnw verify` succeeds. + +## Sources +- SonarQube Community Build Plugin basics: https://docs.sonarsource.com/sonarqube-community-build/extension-guide/developing-a-plugin/plugin-basics (consulted 2026-10-28) +- SonarSource API compatibility matrix: https://github.com/SonarSource/sonar-plugin-api (consulted 2026-10-28) +- SonarQube target dependency metadata: https://central.sonatype.com/artifact/org.sonarsource.sonarqube/sonar-core/25.9.0.112764 (consulted 2026-10-28) +- SonarQube project creation REST API: https://docs.sonarsource.com/sonarqube-community-build/project-administration/creating-project/automating-creation (consulted 2026-10-28) + +## Not verified +- Full target-tag SonarQube source checkout was not available; API pin follows target dependency metadata and the published 25.8/25.10 compatibility table.