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
+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())