M5: statische CI ohne Serverzugang (Gitea Actions) + 2 gebrochene Doku-Links fixen

- .gitea/workflows/ci-static.yml: Jobs secret-scan, yamllint, ansible-syntax,
  markdown-links; Job-Image python:3.13-bookworm per Digest gepinnt
- ci/requirements-ci.txt (ansible-core==2.21.4 wie Control-Node, yamllint==1.37.0),
  .yamllint, scripts/ci/{secret_scan.py,check_links.py,check_ansible_syntax.sh}
- lokal gegen das Repo geprueft: alle 4 Checks gruen
- Linkfixes: GNENC-001 (../ -> ../../), GNAI-018 (ein ../ zu viel)

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
2026-11-11 05:41:40 +01:00
parent 2fe80bc015
commit f48f831e82
9 changed files with 210 additions and 2 deletions
+50
View File
@@ -0,0 +1,50 @@
name: ci-static
# Statische CI ohne Serverzugang (GNAI-001 Meilenstein 5, erster Schritt):
# Secret-Scan, YAML-Lint, Ansible-Syntax-Check aller Projekte, Markdown-Links.
# Images sind per Digest gepinnt; Runner siehe proxmox/lxc/ct-116-runner.
on:
push:
pull_request:
branches: [main]
jobs:
secret-scan:
runs-on: [self-hosted]
container:
image: python:3.13-bookworm@sha256:cc55e4ded9c95f6ce2133b3d096db43f214d280c2a8af65d83e246c8fa7d168c
steps:
- uses: actions/checkout@v4
- name: Secret-Scan (Private Keys, AWS-Keys, WG-PSK-Muster)
run: python3 scripts/ci/secret_scan.py
yamllint:
runs-on: [self-hosted]
container:
image: python:3.13-bookworm@sha256:cc55e4ded9c95f6ce2133b3d096db43f214d280c2a8af65d83e246c8fa7d168c
steps:
- uses: actions/checkout@v4
- name: yamllint installieren (gepinnt)
run: pip install --no-cache-dir -r ci/requirements-ci.txt
- name: YAML-Lint
run: yamllint -c .yamllint $(git ls-files '*.yml' '*.yaml' | grep -v -E '^\.venv/|\.ansible/')
ansible-syntax:
runs-on: [self-hosted]
container:
image: python:3.13-bookworm@sha256:cc55e4ded9c95f6ce2133b3d096db43f214d280c2a8af65d83e246c8fa7d168c
steps:
- uses: actions/checkout@v4
- name: ansible-core installieren (gepinnt wie Control-Node)
run: pip install --no-cache-dir -r shared/ansible/requirements-control.txt
- name: Syntax-Check aller Ansible-Projekte
run: bash scripts/ci/check_ansible_syntax.sh
markdown-links:
runs-on: [self-hosted]
container:
image: python:3.13-bookworm@sha256:cc55e4ded9c95f6ce2133b3d096db43f214d280c2a8af65d83e246c8fa7d168c
steps:
- uses: actions/checkout@v4
- name: Relative Markdown-Links pruefen
run: python3 scripts/ci/check_links.py
+11
View File
@@ -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
+17
View File
@@ -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.
+4
View File
@@ -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
@@ -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
@@ -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
+21
View File
@@ -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"
+45
View File
@@ -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())
+60
View File
@@ -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())