fix: treat an unverifiable mirror as a finding, and repair auth headers
game-operating was made private on Gitea, and the check quietly skipped the mirror comparison. A repo that IS mirrored but whose far side cannot be read is unverified, and unverified must not look like fine. It is now a finding that names the missing GITEA_TOKEN. While testing that, a second bug surfaced: the header helper built 'Authorization: token: <value>' from a name that already contained the schema, producing a silently invalid header. The Authentik check had the same defect and would have failed the moment a token was added - it never ran, so nobody would have connected the two. Refs axion1337.chat/management#28, #31
This commit is contained in:
@@ -15,6 +15,7 @@ und die ist bei uns die Alarmanlage (siehe gitops/CLAUDE.md zur TURN-Rotation).
|
||||
Braucht:
|
||||
GITLAB_TOKEN Lesezugriff auf die Gruppe axion1337.chat (read_api)
|
||||
LAB_CA optional, Pfad zur Lab-CA-Kette
|
||||
GITEA_TOKEN optional, noetig fuer private Spiegel (Lesezugriff genuegt)
|
||||
AUTHENTIK_URL optional, sonst wird die Blueprint-Pruefung uebersprungen
|
||||
AUTHENTIK_TOKEN
|
||||
"""
|
||||
@@ -39,10 +40,14 @@ uebersprungen = []
|
||||
MIT_MIRROR = []
|
||||
|
||||
|
||||
def http(url, token=None, header="PRIVATE-TOKEN"):
|
||||
def http(url, token=None, header="PRIVATE-TOKEN", schema=""):
|
||||
"""schema ist das Praefix VOR dem Token im Header-Wert (Gitea: "token ",
|
||||
Authentik: "Bearer "). Ohne diese Trennung entsteht ein doppelter Doppelpunkt
|
||||
wie "Authorization: token: abc" — der Header ist dann still ungueltig, und die
|
||||
Pruefung meldet "nicht lesbar" statt eines Zugriffsfehlers."""
|
||||
cmd = ["curl", "-s", "--max-time", "25"]
|
||||
if token:
|
||||
cmd += ["-H", f"{header}: {token}"]
|
||||
cmd += ["-H", f"{header}: {schema}{token}"]
|
||||
ca = os.environ.get("LAB_CA")
|
||||
if ca and "git.lab" in url:
|
||||
cmd += ["--cacert", ca]
|
||||
@@ -103,9 +108,17 @@ def pruefe_mirror(token, gespiegelt):
|
||||
if not isinstance(lab, list) or not lab:
|
||||
uebersprungen.append(f"Mirror {p}: git.lab nicht lesbar")
|
||||
continue
|
||||
git = http(f"{GITEA}/repos/sorb/{p}/commits?limit=1")
|
||||
git = http(f"{GITEA}/repos/sorb/{p}/commits?limit=1",
|
||||
os.environ.get("GITEA_TOKEN"), header="Authorization", schema="token ")
|
||||
if not isinstance(git, list) or not git:
|
||||
uebersprungen.append(f"Mirror {p}: auf Gitea nicht lesbar")
|
||||
# KEIN "uebersprungen": Dieses Repo HAT einen Mirror. Koennen wir die
|
||||
# Gegenseite nicht lesen, wissen wir nicht, ob er auseinanderlaeuft —
|
||||
# und "nicht geprueft" darf nicht wie "in Ordnung" aussehen. Real
|
||||
# aufgefallen am 2026-08-09, als game-operating auf Gitea privat
|
||||
# gestellt wurde und die Pruefung es klaglos uebersprang.
|
||||
befunde.append(
|
||||
f"Mirror {p}: Gegenseite auf Gitea nicht lesbar — Abgleich nicht "
|
||||
f"moeglich. Bei privaten Spiegeln GITEA_TOKEN hinterlegen.")
|
||||
continue
|
||||
if lab[0]["id"] != git[0]["sha"]:
|
||||
befunde.append(
|
||||
@@ -188,7 +201,7 @@ def pruefe_authentik_blueprints():
|
||||
"genau der Fall, der uns am laengsten unbemerkt lief")
|
||||
return
|
||||
d = http(f"{url.rstrip('/')}/api/v3/managed/blueprints/?page_size=100",
|
||||
tok, header="Authorization: Bearer")
|
||||
tok, header="Authorization", schema="Bearer ")
|
||||
if not isinstance(d, dict):
|
||||
uebersprungen.append("Authentik-Blueprints: API nicht lesbar")
|
||||
return
|
||||
|
||||
@@ -42,12 +42,19 @@ Lokal:
|
||||
|
||||
```bash
|
||||
export GITLAB_TOKEN=$(cat ~/.config/gitlab-lab/token)
|
||||
export GITEA_TOKEN=$(cat ~/.config/gitea-rohana/push-token) # fuer private Spiegel
|
||||
export LAB_CA=.../ci/lab-ca-chain.crt
|
||||
python3 scripts/stillstandspruefung.py
|
||||
```
|
||||
|
||||
## Zwei Regeln für diese Prüfung
|
||||
|
||||
**Ein „kann nicht geprüft werden" ist ein Befund, kein Übersprungen.** Real
|
||||
aufgefallen am 2026-08-09: `game-operating` wurde auf Gitea privat gestellt, und
|
||||
die Prüfung übersprang den Mirror-Abgleich klaglos. Ein Repo, das gespiegelt wird,
|
||||
dessen Gegenseite aber unlesbar ist, ist **ungeprüft** — und das darf nicht wie
|
||||
„in Ordnung" aussehen.
|
||||
|
||||
**Ein Befund wird zum Issue, nicht weggeklickt.** Sonst wird die Prüfung zu dem,
|
||||
was sie sucht: etwas, das läuft, ohne dass jemand hinsieht.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user