ci(ai): robust scanners (continue-on-error + no-pipe capture); gate decides hard
Some checks failed
Security / scan (push) Failing after 1m17s
Some checks failed
Security / scan (push) Failing after 1m17s
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
# Feature B (+C) — Security-Scan (HART blockierend) + KI-Klartext-Erklärung.
|
# Feature B (+C) — Security-Scan (HART blockierend) + KI-Klartext-Erklärung.
|
||||||
# Pilot: läuft auf Push zum Branch ci-ai/pilot (Validierung) und auf PRs.
|
# Pilot: läuft auf Push zum Branch ci-ai/pilot (Validierung) und auf PRs.
|
||||||
# python:3.12-slim (Debian: hat bash) + Memory-Cap (Pi-Runner). ⚠ ARM64-Binaries!
|
# python:3.12-slim (Debian: bash) + Memory-Cap (Pi-Runner). ⚠ ARM64-Binaries!
|
||||||
# Scanner-Schritte fangen ihren Exit-Code ab (kein Abbruch); der Gate-Schritt
|
# Scanner-Schritte: continue-on-error + Exit-Code ohne Pipe abgefangen -> der
|
||||||
# entscheidet hart. Clones brauchen ein Token (Instanz verweigert anon).
|
# Gate-Schritt entscheidet ALLEIN hart. Clones brauchen ein Token (anon verboten).
|
||||||
name: Security
|
name: Security
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@@ -31,23 +31,27 @@ jobs:
|
|||||||
|
|
||||||
- name: Gitleaks (Secret-Scan, ARM64)
|
- name: Gitleaks (Secret-Scan, ARM64)
|
||||||
id: gl
|
id: gl
|
||||||
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
set +e +o pipefail
|
set +e
|
||||||
curl -sSL "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_arm64.tar.gz" \
|
curl -sSL "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_arm64.tar.gz" \
|
||||||
| tar -xz -C /usr/local/bin gitleaks
|
| tar -xz -C /usr/local/bin gitleaks
|
||||||
cd src && gitleaks detect --no-git --source . --redact | tee /tmp/scan.log
|
cd src
|
||||||
echo "code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT"
|
gitleaks detect --no-git --source . --redact > /tmp/gl.log 2>&1
|
||||||
exit 0
|
echo "code=$?" >> "$GITHUB_OUTPUT"
|
||||||
|
tail -n 3 /tmp/gl.log; cat /tmp/gl.log >> /tmp/scan.log
|
||||||
|
|
||||||
- name: Trivy (IaC/config, leicht)
|
- name: Trivy (IaC/config, leicht)
|
||||||
id: tv
|
id: tv
|
||||||
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
set +e +o pipefail
|
set +e
|
||||||
curl -sSL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh \
|
curl -sSL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh \
|
||||||
| sh -s -- -b /usr/local/bin
|
| sh -s -- -b /usr/local/bin
|
||||||
cd src && trivy config --severity HIGH,CRITICAL --exit-code 1 . | tee -a /tmp/scan.log
|
cd src
|
||||||
echo "code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT"
|
trivy config --severity HIGH,CRITICAL --exit-code 1 . > /tmp/tv.log 2>&1
|
||||||
exit 0
|
echo "code=$?" >> "$GITHUB_OUTPUT"
|
||||||
|
tail -n 8 /tmp/tv.log; cat /tmp/tv.log >> /tmp/scan.log
|
||||||
|
|
||||||
- name: Gate — hart blockieren bei Funden
|
- name: Gate — hart blockieren bei Funden
|
||||||
run: |
|
run: |
|
||||||
@@ -57,8 +61,9 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
echo "Keine HIGH/CRITICAL-Funde."
|
echo "Keine HIGH/CRITICAL-Funde."
|
||||||
|
|
||||||
- name: KI erklärt die Funde (nur bei Fehler, überspringt ohne Key)
|
- name: KI erklärt die Funde (nur bei Fehler; braucht ci-ai-Zugriff + Key)
|
||||||
if: failure()
|
if: failure()
|
||||||
|
continue-on-error: true
|
||||||
env:
|
env:
|
||||||
AI_PROVIDER: anthropic
|
AI_PROVIDER: anthropic
|
||||||
AI_MODEL: claude-3-5-haiku-latest
|
AI_MODEL: claude-3-5-haiku-latest
|
||||||
@@ -66,5 +71,6 @@ jobs:
|
|||||||
GITEA_TOKEN: ${{ github.token }}
|
GITEA_TOKEN: ${{ github.token }}
|
||||||
GITEA_API: https://git.eulernest.eu/api/v1
|
GITEA_API: https://git.eulernest.eu/api/v1
|
||||||
run: |
|
run: |
|
||||||
git clone --depth 1 "https://x-access-token:${GITEA_TOKEN}@git.eulernest.eu/user2595/ci-ai.git" /opt/ci-ai
|
git clone --depth 1 "https://x-access-token:${GITEA_TOKEN}@git.eulernest.eu/user2595/ci-ai.git" /opt/ci-ai \
|
||||||
python3 /opt/ci-ai/scripts/ai_explain.py security /tmp/scan.log
|
&& python3 /opt/ci-ai/scripts/ai_explain.py security /tmp/scan.log \
|
||||||
|
|| echo "AI-Erklärung übersprungen (ci-ai-Zugriff/Key noch offen)."
|
||||||
|
|||||||
Reference in New Issue
Block a user