feat(agent): managed git source — auto targets and CRA issues (#439)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 7m23s

A tenant's managed Gitea organisation becomes a git source: every
repository in it is a target, scanned on push, with findings as
labelled issues.

- Git source per tenant (`git_sources`, one doc): https base URL whose
  host must match GIT_SOURCE_HOST_PATTERN, org, bot token and webhook
  secret sealed like other credentials. Platform API
  PUT/GET/DELETE /api/v1/platform/tenants/{id}/git-source; the secret
  is returned only when issued (first PUT or rotate_webhook_secret).
  Read-only GET /api/v1/git-source for IT admins and support.
- POST /webhook/{tenant_id}/gitea-source on the webhook server,
  X-Gitea-Signature checked before anything is created. repository
  created -> target (clone URL built from the source origin, bot token,
  Gitea tracker, type from detection) and first scan unless empty;
  deleted -> target archived; push to the default branch -> scan,
  creating the target if missing. Other orgs are ignored. Entitlement
  and ladder are checked as for scheduled work; usage events as usual.
- Targets get source_repo (unique per instance + repo id, so racing
  deliveries make one target) and archived_at; the scheduler skips
  archived targets.
- Sync job every GIT_SOURCE_SYNC_MINUTES (default 30): lists the org's
  repos (paginated), creates missing, refreshes renamed, archives gone.
- Managed repos get the labels pruefwerk, cra:annex-i and
  severity:* ensured once per run and attached by id; issue bodies name
  the CRA requirement(s) and link into Prüfwerk. User-configured
  trackers behave as before.
- Docs (DE/EN): connecting Managed Git and the bot's minimal rights.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
This commit is contained in:
Sharang ParnerkarandClaude Opus 5.5 committed 2026-10-05 12:17:12 +02:00
1 parent 9b85d5148e
commit 1a9af09bc4
30 files changed
+2991 -32

No files matched your search

+2
View File
@@ -58,6 +58,8 @@ export default withMermaid(defineConfig({
{ text: 'MCP-Schnittstelle', link: '/features/mcp-server' },
{ text: 'Tickets', link: '/guide/issues' },
{ text: 'Webhooks und PR-Reviews', link: '/guide/webhooks' },
{ text: 'Managed Git anbinden', link: '/guide/managed-git' },
{ text: 'Connecting Managed Git (English)', link: '/guide/managed-git-en' },
{ text: 'Getting Started (English)', link: '/guide/getting-started-en' },
],
},
+73
View File
@@ -0,0 +1,73 @@
---
title: Connecting Managed Git
---
# Connecting Managed Git
With Managed Git, BreakPilot runs a Gitea instance for your company
(`https://<company>.code.breakpilot.com`). Prüfwerk can check every repository
of an organisation in that instance automatically:
- **New repository → new target.** When a repository is created, Prüfwerk
creates a target for it and scans it after the first push.
- **Push to the default branch → scan.** Pushes to other branches and tags do
not start a scan.
- **Repository deleted → target archived.** Findings and evidence are kept;
the target is no longer scanned.
- **Findings as issues.** Findings of severity medium and above become issues
in the repository, with location, CWE, the CRA requirement concerned, the
remediation and a link into Prüfwerk. Prüfwerk creates the labels
`pruefwerk`, `cra:annex-i` and `severity:critical|high|medium|low` in the
repository for them.
- **Sync.** Every 30 minutes Prüfwerk compares the organisation's repositories
with its targets, in case a webhook delivery was lost.
BreakPilot sets the connection up during provisioning; there is nothing for you
to configure. IT administrators can see it in the workspace (read-only).
::: tip Deleted a target?
A target that belongs to a repository of the connected organisation is created
again by the next sync. To exclude a repository, move it to another
organisation.
:::
## The bot user's rights
Prüfwerk acts in Gitea as the bot user **`pruefwerk`** — never as an
administrator:
- The bot is a member of a dedicated team of the organisation (e.g.
"Prüfwerk") that has only the units **Code: Read** and **Issues: Write**. No
administration, no write access to code, no wiki, release or package rights.
- Its access token has only the scopes `read:organization` (repository list),
`read:repository` (clone) and `write:issue` (issues, comments and labels).
- Prüfwerk stores the token encrypted and never returns it.
Removing the bot from the team ends its access immediately.
## For operations (BreakPilot)
The platform configures the source through the platform API (service token,
like the other `/api/v1/platform/*` calls):
```http
PUT /api/v1/platform/tenants/{tenant_id}/git-source
{ "base_url": "https://kunde.code.breakpilot.com", "org": "kunde",
"bot_token": "<the bot's token>" }
```
The response carries `webhook_url` and — only the first time, or with
`"rotate_webhook_secret": true` — `webhook_secret`. With these, register an
organisation or system webhook in Gitea (type Gitea, `application/json`) for
the **Repository** and **Push** events. A repeated `PUT` without `bot_token`
keeps the stored token, and without `rotate_webhook_secret` the secret. `GET`
returns the source without secrets; `DELETE` removes it and archives its
targets.
Agent environment: `GIT_SOURCE_HOST_PATTERN` (allowed hosts, default
`^[a-z0-9-]+\.code(-stage)?\.breakpilot\.com$`), `GIT_SOURCE_SYNC_MINUTES`
(default 30), `WEBHOOK_PUBLIC_URL` (public origin of the webhook server, for
`webhook_url`). The Gitea instance's `[webhook] ALLOWED_HOST_LIST` must allow
the Prüfwerk host.
[Deutsche Fassung](./managed-git)
+78
View File
@@ -0,0 +1,78 @@
---
title: Managed Git anbinden
---
# Managed Git anbinden
Mit Managed Git betreibt BreakPilot für Ihr Unternehmen eine eigene
Gitea-Instanz (`https://<firma>.code.breakpilot.com`). Prüfwerk kann jede
Repository-Organisation dieser Instanz automatisch prüfen:
- **Neues Repository → neues Prüfobjekt.** Sobald ein Repository angelegt
wird, legt Prüfwerk ein Prüfobjekt dafür an und prüft es nach dem ersten
Push.
- **Push auf den Standard-Branch → Prüfung.** Pushes auf andere Branches und
Tags lösen keine Prüfung aus.
- **Repository gelöscht → Prüfobjekt archiviert.** Befunde und Nachweise
bleiben erhalten; das Prüfobjekt wird nicht mehr geprüft.
- **Befunde als Issues.** Befunde ab Schweregrad „mittel“ erscheinen als Issue
im Repository, mit Fundstelle, CWE, der betroffenen CRA-Anforderung, der
Maßnahme und einem Link ins Prüfwerk. Prüfwerk legt dazu die Labels
`pruefwerk`, `cra:annex-i` und `severity:critical|high|medium|low` im
Repository an.
- **Abgleich.** Alle 30 Minuten gleicht Prüfwerk die Repository-Liste der
Organisation mit den Prüfobjekten ab, falls ein Webhook verloren ging.
Die Anbindung richtet BreakPilot bei der Bereitstellung ein; Sie müssen nichts
konfigurieren. IT-Administratoren sehen die Anbindung im Arbeitsbereich
(nur lesend).
::: tip Prüfobjekt gelöscht?
Ein Prüfobjekt, das zu einem Repository der angebundenen Organisation gehört,
legt der nächste Abgleich wieder an. Soll ein Repository nicht geprüft werden,
verschieben Sie es in eine andere Organisation.
:::
## Rechte des Bot-Benutzers
Prüfwerk arbeitet in Gitea als Bot-Benutzer **`pruefwerk`** – nie mit
Administratorrechten:
- Der Bot ist Mitglied eines eigenen Teams der Organisation (z. B.
„Prüfwerk“), das nur die Einheiten **Code: Lesen** und **Issues: Schreiben**
hat. Keine Administration, kein Schreibzugriff auf Code, keine Wiki-,
Release- oder Paketrechte.
- Sein Zugriffstoken hat nur die Bereiche `read:organization`
(Repository-Liste), `read:repository` (Klonen) und `write:issue` (Issues,
Kommentare und Labels).
- Das Token wird in Prüfwerk verschlüsselt gespeichert und nie wieder
ausgegeben.
Entziehen Sie dem Bot die Teammitgliedschaft, endet der Zugriff sofort.
## Für den Betrieb (BreakPilot)
Die Plattform richtet die Quelle über die Plattform-API ein (Service-Token wie
die übrigen `/api/v1/platform/*`-Aufrufe):
```http
PUT /api/v1/platform/tenants/{tenant_id}/git-source
{ "base_url": "https://kunde.code.breakpilot.com", "org": "kunde",
"bot_token": "<token des Bots>" }
```
Die Antwort enthält `webhook_url` und – nur beim ersten Mal oder mit
`"rotate_webhook_secret": true` – `webhook_secret`. Damit wird in Gitea ein
Organisations- oder System-Webhook (Typ Gitea, `application/json`) mit den
Ereignissen **Repository** und **Push** angelegt. Ein erneuter `PUT` ohne
`bot_token` behält das gespeicherte Token, ohne `rotate_webhook_secret` das
Secret. `GET` liefert die Quelle ohne Geheimnisse, `DELETE` entfernt sie und
archiviert ihre Prüfobjekte.
Umgebungsvariablen des Agents: `GIT_SOURCE_HOST_PATTERN` (erlaubte Hosts,
Standard `^[a-z0-9-]+\.code(-stage)?\.breakpilot\.com$`),
`GIT_SOURCE_SYNC_MINUTES` (Standard 30), `WEBHOOK_PUBLIC_URL` (öffentlicher
Ursprung des Webhook-Servers für die `webhook_url`). In der Gitea-Instanz muss
`[webhook] ALLOWED_HOST_LIST` den Prüfwerk-Host zulassen.
[English version](./managed-git-en)