From 962b387b42d4dc21dd97110c0c145e771f86bede Mon Sep 17 00:00:00 2001 From: vibe-agent Date: Wed, 11 Nov 2026 06:07:36 +0100 Subject: [PATCH] M5: statische CI (Gitea Actions) + CT-116 Runner + Branch-Protection main (#2) Co-authored-by: vibe-agent --- .gitea/workflows/ci-static.yml | 58 ++++++++++++++++++ .yamllint | 11 ++++ ci/README.md | 17 ++++++ ci/requirements-ci.txt | 4 ++ .../ai/GNAI-008-PLAN_Ansible-Deployment.md | 24 ++++++++ .../encoding/GNENC-001-PLAN_Architecture.md | 2 +- ...I-018-REQ_Encoding-Pipeline-Integration.md | 2 +- scripts/ci/check_ansible_syntax.sh | 21 +++++++ scripts/ci/check_links.py | 45 ++++++++++++++ scripts/ci/secret_scan.py | 60 +++++++++++++++++++ 10 files changed, 242 insertions(+), 2 deletions(-) create mode 100644 .gitea/workflows/ci-static.yml create mode 100644 .yamllint create mode 100644 ci/README.md create mode 100644 ci/requirements-ci.txt create mode 100644 scripts/ci/check_ansible_syntax.sh create mode 100644 scripts/ci/check_links.py create mode 100644 scripts/ci/secret_scan.py diff --git a/.gitea/workflows/ci-static.yml b/.gitea/workflows/ci-static.yml new file mode 100644 index 0000000..6ee46ea --- /dev/null +++ b/.gitea/workflows/ci-static.yml @@ -0,0 +1,58 @@ +name: ci-static + +# Statische CI ohne Serverzugang (GNAI-001 Meilenstein 5, erster Schritt): +# Secret-Scan, YAML-Lint, Ansible-Syntax-Check aller Projekte, Markdown-Links. +# Job-Image node:22-trixie (Debian 13, python3.13) (actions/checkout ist ein Node-Action) per Digest +# gepinnt; python3 wird pro Job nachinstalliert. Runner: CT 116 (ci-static-01). +on: + push: + pull_request: + branches: [main] + +env: + DEBIAN_FRONTEND: noninteractive + +jobs: + secret-scan: + runs-on: [ubuntu-latest] + container: + image: node:22-trixie@sha256:c46850e69b4fab3c4f225aa36b777c8cc001d1cd5b2136e1ea024796f6d3bbbb + steps: + - uses: actions/checkout@v4 + - name: python3 installieren + run: apt-get update -qq && apt-get install -y -qq python3 >/dev/null + - name: Secret-Scan (Private Keys, AWS-Keys, WG-PSK-Muster) + run: python3 scripts/ci/secret_scan.py + + yamllint: + runs-on: [ubuntu-latest] + container: + image: node:22-trixie@sha256:c46850e69b4fab3c4f225aa36b777c8cc001d1cd5b2136e1ea024796f6d3bbbb + steps: + - uses: actions/checkout@v4 + - name: python3 + pip installieren, CI-Tools gepinnt + run: apt-get update -qq && apt-get install -y -qq python3 python3-pip >/dev/null && pip install --no-cache-dir --break-system-packages -r ci/requirements-ci.txt + - name: YAML-Lint + run: yamllint -c .yamllint $(git ls-files -z '*.yml' '*.yaml' | tr '\0' '\n' | grep -v -E '^\.venv/|\.ansible/') + + ansible-syntax: + runs-on: [ubuntu-latest] + container: + image: node:22-trixie@sha256:c46850e69b4fab3c4f225aa36b777c8cc001d1cd5b2136e1ea024796f6d3bbbb + steps: + - uses: actions/checkout@v4 + - name: python3 + pip installieren, ansible-core gepinnt (wie Control-Node) + run: apt-get update -qq && apt-get install -y -qq python3 python3-pip >/dev/null && pip install --no-cache-dir --break-system-packages -r shared/ansible/requirements-control.txt + - name: Syntax-Check aller Ansible-Projekte + run: bash scripts/ci/check_ansible_syntax.sh + + markdown-links: + runs-on: [ubuntu-latest] + container: + image: node:22-trixie@sha256:c46850e69b4fab3c4f225aa36b777c8cc001d1cd5b2136e1ea024796f6d3bbbb + steps: + - uses: actions/checkout@v4 + - name: python3 installieren + run: apt-get update -qq && apt-get install -y -qq python3 >/dev/null + - name: Relative Markdown-Links pruefen + run: python3 scripts/ci/check_links.py diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..b759529 --- /dev/null +++ b/.yamllint @@ -0,0 +1,11 @@ +extends: default +rules: + line-length: disable + document-start: disable + truthy: disable + comments: disable + braces: + max-spaces-inside: 1 + # Ansible-Templates enthalten haeufig {{ }} am Zeilenende + indentation: + indent-sequences: consistent diff --git a/ci/README.md b/ci/README.md new file mode 100644 index 0000000..6355e79 --- /dev/null +++ b/ci/README.md @@ -0,0 +1,17 @@ +# Statische CI (Gitea Actions, ohne Serverzugang) + +GNAI-001 Meilenstein 5, erster Schritt: repository-spezifische statische +Prüfungen laufen auf einem dedizierten Runner-LXC (CT 116, `10.0.0.60`), +der keine Server-Zugangsdaten besitzt. + +Hinweis: Der Runner-Pfad (CT 116) wird in GNAI-008 Abschnitt M5 dokumentiert. + +- Workflow: `.gitea/workflows/ci-static.yml` (läuft auf Push und PR gegen `main`) +- Jobs: `secret-scan`, `yamllint`, `ansible-syntax`, `markdown-links` +- Gepinnt: Job-Image `python:3.13-bookworm` per Digest, Werkzeuge in + `ci/requirements-ci.txt` (`ansible-core==2.21.4` wie der Control-Node, + `yamllint==1.37.0`), `actions/checkout@v4` +- Skripte: `scripts/ci/secret_scan.py`, `scripts/ci/check_links.py`, + `scripts/ci/check_ansible_syntax.sh` + +Runner-Registrierung und Branch-Protection siehe GNAI-008 Abschnitt M5. diff --git a/ci/requirements-ci.txt b/ci/requirements-ci.txt new file mode 100644 index 0000000..e2c36d4 --- /dev/null +++ b/ci/requirements-ci.txt @@ -0,0 +1,4 @@ +# Gepinnte CI-Werkzeuge (GNAI-001 M5: Werkzeugversionen pinnen). +# ansible-core identisch zum Control-Node (shared/ansible/requirements-control.txt). +ansible-core==2.21.4 +yamllint==1.37.0 diff --git a/docs/platform/llm-server/ai/GNAI-008-PLAN_Ansible-Deployment.md b/docs/platform/llm-server/ai/GNAI-008-PLAN_Ansible-Deployment.md index 86185a5..f6902a5 100644 --- a/docs/platform/llm-server/ai/GNAI-008-PLAN_Ansible-Deployment.md +++ b/docs/platform/llm-server/ai/GNAI-008-PLAN_Ansible-Deployment.md @@ -761,6 +761,30 @@ Zustandsdatei und Recovery-Timer (Abschnitt 14.6, T1–T7 bestanden; nach Host-Neustart am 09.11.2026 automatisches Recovery auf Production verifiziert). Frage 5 bleibt bis zur Delivery-Kette (Gitea Actions, Meilenstein 5) offen. +**M5-Fortschritt 10.11.2026 (Fragen 1 und 2 teilweise beantwortet):** +- **Gitea live (CT 110, `git.ghostnet.selfhost.eu`):** Version 1.27.2 (go1.26.5), + `ROOT_URL http://10.0.0.17:3000/` hinter NPM, `DISABLE_REGISTRATION=true`, + Actions-API aktiv (`has_actions=true` für `ghostnet.ai/infrastructure`), + bisher 0 Runner, 0 Branch-/Tag-Protection, 7 Repos. Registrierungs-Endpunkt + in 1.27.2: `POST /api/v1/repos/{owner}/{repo}/actions/runners/registration-token`. +- **Statische CI ohne Serverzugang eingeführt:** `.gitea/workflows/ci-static.yml` + (Jobs `secret-scan`, `yamllint`, `ansible-syntax`, `markdown-links`; Job-Image + `node:22-trixie` per Digest gepinnt, `actions/checkout@v4`, ansible-core und + yamllint per `ci/requirements-ci.txt` gepinnt; Skripte unter `scripts/ci/`). + Erster Lauf auf Branch `ci/static-ci` am 10.11.2026 grün (alle 4 Jobs + `success`); zwei gebrochene Doku-Links dabei gefunden und gefixt. +- **Runner:** dedizierter LXC **CT 116** (`runner`, `10.0.0.60/24`, unprivileged, + nesting=1), `act_runner v0.2.13` (SHA-256 + `3acac8b506ac8cadc88a55155b5d6378f0fab0b8f62d1e0c0450f4ccd69733e2`), Podman 5.4.2 + rootful mit Socket als Docker-API (`docker_host=unix:///run/podman/podman.sock`), + systemd-Unit `act-runner.service`, repo-scoped Runner `ci-static-01` online + (Labels `ubuntu-latest`/`ubuntu-22.04`/`ubuntu-20.04`; Jobs laufen in + gepinnten Job-Containern). Der Runner-LXC besitzt keine Server-Zugangsdaten. +- Branch-Protection `main` (PR-Pflicht + required status check `ci-static`, + 1 Approver, kein Direkt-Push) wird mit dem Merge des CI-Branches gesetzt. +- Offen: Fragen 3–5 (Review-/Freigabe-Rechte, Secret-Store, Promotion-Tag), + privilegierter Deployment-Runner, Secret-Scan über die Git-Historie. + --- ## 13. Referenzstand der Planung diff --git a/docs/platform/llm-server/encoding/GNENC-001-PLAN_Architecture.md b/docs/platform/llm-server/encoding/GNENC-001-PLAN_Architecture.md index 05940c2..b7b0f41 100644 --- a/docs/platform/llm-server/encoding/GNENC-001-PLAN_Architecture.md +++ b/docs/platform/llm-server/encoding/GNENC-001-PLAN_Architecture.md @@ -23,7 +23,7 @@ Validierung, Statusmodell — ist in host-weite Monitoring (Systemmetriken, Dashboard) wird im Monitoring-Bereich unter `docs/platform/llm-server/monitoring/` geführt (GNMON). Die Samba-Anbindung der Pipeline auf CT-101 ist in -[GNAI-017](../proxmox-server/lxc/ct-101-samba/GNAI-017-PLAN_Samba-NFS-Export.md) +[GNAI-017](../../proxmox-server/lxc/ct-101-samba/GNAI-017-PLAN_Samba-NFS-Export.md) beschrieben. ## 2. Bestätigte Entscheidungen diff --git a/docs/platform/proxmox-server/lxc/ct-101-samba/GNAI-018-REQ_Encoding-Pipeline-Integration.md b/docs/platform/proxmox-server/lxc/ct-101-samba/GNAI-018-REQ_Encoding-Pipeline-Integration.md index 6ae935f..43cbd53 100644 --- a/docs/platform/proxmox-server/lxc/ct-101-samba/GNAI-018-REQ_Encoding-Pipeline-Integration.md +++ b/docs/platform/proxmox-server/lxc/ct-101-samba/GNAI-018-REQ_Encoding-Pipeline-Integration.md @@ -175,7 +175,7 @@ Der Rebuild gilt als abgenommen, wenn alles Folgende nachgewiesen ist - [GNENC-002](../../../llm-server/encoding/GNENC-002-PLAN_Pipeline.md) — Pipeline, Verzeichnislayout, Rechte - [GNMON-001](../../../llm-server/monitoring/GNMON-001-PLAN_Architecture.md) — Monitoring-Anbindung - [GNAI-011](../../GNAI-011-SEC_LXC-SSH-Architecture.md) — SSH-Zugang der LXCs -- [`proxmox/lxc/ct-102-keycloak/ansible/README.md`](../../../../../../proxmox/lxc/ct-102-keycloak/ansible/README.md) — Konventionen des Ansible-Projekts +- [`proxmox/lxc/ct-102-keycloak/ansible/README.md`](../../../../../proxmox/lxc/ct-102-keycloak/ansible/README.md) — Konventionen des Ansible-Projekts ## 7. Offene Punkte für den Rebuild diff --git a/scripts/ci/check_ansible_syntax.sh b/scripts/ci/check_ansible_syntax.sh new file mode 100644 index 0000000..62ee42b --- /dev/null +++ b/scripts/ci/check_ansible_syntax.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Syntax-Check aller Ansible-Projekte im Repo (CI, GNAI-001 M5). +# ansible-core kommt gepinnt aus shared/ansible/requirements-control.txt. +set -euo pipefail +cd "$(git rev-parse --show-toplevel)" + +fail=0 +while IFS= read -r cfg; do + dir=$(dirname "$cfg") + echo "== Projekt $dir ==" + while IFS= read -r pb; do + (cd "$dir" && ansible-playbook -i /dev/null "$pb" --syntax-check >/dev/null 2>&1) \ + || { (cd "$dir" && ansible-playbook -i /dev/null "$pb" --syntax-check) || true; fail=1; } + done < <(cd "$dir" && ls playbooks/*.yml 2>/dev/null || true) +done < <(git ls-files -z 'ansible.cfg' | tr '\0' '\n' | grep -v '^\.venv/') + +if [ "$fail" -ne 0 ]; then + echo "ANSIBLE-SYNTAX: FEHLER (siehe oben)" + exit 1 +fi +echo "ANSIBLE-SYNTAX: OK" diff --git a/scripts/ci/check_links.py b/scripts/ci/check_links.py new file mode 100644 index 0000000..640d9a4 --- /dev/null +++ b/scripts/ci/check_links.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +"""Prueft relative Markdown-Links aller versionierten .md-Dateien. + +Analog zum lokalen Linkvalidator (GNAI-013 Abschnitt 4: broken_local_links=0). +Absolute externe URLs (http/https/mailto) und reine Anker werden nicht geprüft. +""" +import os +import re +import subprocess +import sys + +LINK_RE = re.compile(r"\[[^\]]*\]\(([^)#\s]+)(#[^)]*)?\)") + + +def md_files() -> list[str]: + out = subprocess.run(["git", "ls-files", "-z", "*.md"], capture_output=True, check=True) + return [f for f in out.stdout.decode("utf-8", "surrogateescape").split("\0") if f and not f.startswith(".venv/")] + + +def main() -> int: + broken = [] + checked = 0 + for path in md_files(): + base = os.path.dirname(path) + with open(path, encoding="utf-8", errors="replace") as fh: + for lineno, line in enumerate(fh, 1): + for m in LINK_RE.finditer(line): + target = m.group(1) + if re.match(r"^[a-zA-Z][a-zA-Z0-9+.-]*:", target): # http:, mailto:, ... + continue + checked += 1 + resolved = os.path.normpath(os.path.join(base, target)) + if not os.path.exists(resolved): + broken.append(f"{path}:{lineno}: {target}") + if broken: + print(f"LINK-CHECK: {len(broken)} gebrochene Links (geprueft: {checked}):") + for b in broken: + print(" ", b) + return 1 + print(f"LINK-CHECK: OK ({checked} relative Links in {len(md_files())} Dateien)") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/scripts/ci/secret_scan.py b/scripts/ci/secret_scan.py new file mode 100644 index 0000000..5c4b67c --- /dev/null +++ b/scripts/ci/secret_scan.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 +"""Secret-Scan fuer die statische CI (GNAI-001 M5). + +Prueft alle versionierten Dateien auf starke Secret-Muster: +Private-Key-Bloecke, AWS-Access-Key-IDs, WireGuard-PSK-artige Base64-Werte +(44 Zeichen, analog GNAI-013). Befunde werden mit Datei:Zeile gemeldet, +ausser erklaerende Beispieltexte (siehe GNAI-013 Abschnitt 4). +""" +import re +import subprocess +import sys + +PATTERNS = [ + ("private-key-block", re.compile(r"-----BEGIN [A-Z ]*PRIVATE KEY-----")), + ("aws-access-key", re.compile(r"\bAKIA[0-9A-Z]{16}\b")), + ("wg-psk-like", re.compile(r"(?i)(preshared_?key|psk)\s*[:=]\s*[\"']?[A-Za-z0-9+/]{43}=[\"']?")), + ("generic-secret-yaml", re.compile(r"(?i)^\s*(password|secret|client_secret|api_key)\s*:\s*[\"']?[^\s{\"'][^\"']{7,}[\"']?\s*$", re.M)), +] + +# Erlaubte Beispiel-/Platzhalterwerte (dokumentierte Ausnahmen aus GNAI-013). +ALLOWLIST = ("<", "…", "…") + + +def tracked_files() -> list[str]: + out = subprocess.run(["git", "ls-files", "-z"], capture_output=True, check=True) + return [ + f + for f in out.stdout.decode("utf-8", "surrogateescape").split("\0") + if f and not f.startswith((".venv/", ".ansible/")) + ] + + +def main() -> int: + findings = [] + for path in tracked_files(): + try: + with open(path, "rb") as fh: + data = fh.read() + except OSError: + continue + if b"\x00" in data[:4096]: + continue # Binärdatei + text = data.decode("utf-8", "replace") + for lineno, line in enumerate(text.splitlines(), 1): + if any(a in line for a in ALLOWLIST) and "PRIVATE KEY" not in line: + continue + for name, rx in PATTERNS: + if rx.search(line): + findings.append(f"{path}:{lineno}: {name}: {line.strip()[:80]}") + if findings: + print("SECRET-SCAN: Befunde gefunden:") + for f in findings: + print(" ", f) + return 1 + print(f"SECRET-SCAN: OK ({len(tracked_files())} Dateien geprüft)") + return 0 + + +if __name__ == "__main__": + sys.exit(main())