Files
pruefwerk/docs/guide/managed-git-en.md
sharangandClaude Opus 5.5 692840df59
CI / Check (push) Skipped
CI / Agent integration (push) Skipped
CI / Detect Changes (push) Successful in 4s
CI / Deploy Dashboard (push) Skipped
CI / Deploy MCP (push) Skipped
CI / Deploy Docs (push) Successful in 1m14s
CI / Deploy Agent (push) Successful in 6m58s
feat(issues): poll Gitea for issues a person closed or reopened (#953) (#972)
The back-sync of #960 only listened to the managed git source's
organisation webhook, which most targets do not have: repositories with a
Gitea issue tracker get no webhook at all. Every GIT_SOURCE_SYNC_MINUTES
(30 by default) the agent now lists the issues of each target that has
Prüfwerk issues, one listing per repository, and compares their state with
its records. For an issue whose state differs it reads the timeline to see
who closed or reopened it; a person's change is carried back exactly as a
webhook delivery is (same rules: an undecided finding is resolved as
"closed in the ticket", a decision already made stays, a CVE issue only
records the close). Changes by the bot user that opened the issue are left
alone. Targets are polled one after the other, so a small Gitea sees one
listing at a time; tenants go through the same entitlement check as the
webhook. Where the webhook delivered a change already, the records match
and the poll does nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 21:31:02 +00:00

101 lines
5.0 KiB
Markdown

---
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`, `severity:critical|high|medium|low`, `cve` and
`risk:accepted` in the repository for them.
- **Known vulnerabilities as issues.** A critical or high CVE in a dependency
becomes one issue per package and CVE (`[CVE] okhttp@3.12.0: CVE-2021-0341`),
labelled like the findings plus `cve`, with the fixed version where the
advisory names one. When a complete scan no longer finds it (the dependency
was updated or removed), the issue is closed with a comment; if it comes
back, it is reopened.
- **The issue follows the finding.** When the finding is closed in Prüfwerk —
the scan no longer finds it, or someone marks it resolved, a false alarm or
ignored — Prüfwerk comments on the issue why and closes it. An accepted risk
also gets the label `risk:accepted`, with the reason in the comment. When
the finding comes back (the scan finds it again, or it is reopened), the
issue is reopened.
- **The finding follows the issue.** When someone closes a Prüfwerk issue in
Gitea, a finding still open counts as resolved; its history reads "Closed
in the ticket by *Gitea user*". The next scan confirms that, or it finds the
finding again and reopens it and the issue with a comment. When the issue
is reopened in Gitea, the finding is open again. A decision already made in
Prüfwerk (an accepted risk, say) stays when the issue is closed. A CVE
issue someone closes stays closed while the scan finds the vulnerability
unchanged; it does not set a VEX status. Prüfwerk checks its issues itself
every 30 minutes; with the **Issues** event in the webhook a change arrives
at once.
- **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 read it through the API
(`GET /api/v1/git-source`); a view in the interface will follow.
::: 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**, **Push** and **Issues** events; the response names them in
`webhook_events`. Prüfwerk cannot create or change the webhook itself (the bot
has no administration rights). An older webhook without the **Issues** event
still gets closed and reopened issues across, at the next check (every 30
minutes); with the event added they arrive at once. 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)