ci(ai): token-clone ci-ai (anon refused) + scanner steps capture exit, gate decides
Some checks failed
Security / scan (push) Has been cancelled
Some checks failed
Security / scan (push) Has been cancelled
This commit is contained in:
@@ -1,9 +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 -> PIPESTATUS ok) + Memory-Cap (Pi-Runner).
|
# python:3.12-slim (Debian: hat bash) + Memory-Cap (Pi-Runner). ⚠ ARM64-Binaries!
|
||||||
# ⚠ ARM64-Binaries! Gitleaks (Secrets) + Trivy config (IaC/Misconfig) — ohne
|
# Scanner-Schritte fangen ihren Exit-Code ab (kein Abbruch); der Gate-Schritt
|
||||||
# schweren Vuln-DB-Scan. Funde -> Check schlägt hart fehl; danach erklärt die KI
|
# entscheidet hart. Clones brauchen ein Token (Instanz verweigert anon).
|
||||||
# sie im PR (überspringt sauber ohne Key).
|
|
||||||
name: Security
|
name: Security
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@@ -25,7 +24,7 @@ jobs:
|
|||||||
- name: Tooling
|
- name: Tooling
|
||||||
run: apt-get update -qq && apt-get install -y -qq --no-install-recommends git curl ca-certificates tar
|
run: apt-get update -qq && apt-get install -y -qq --no-install-recommends git curl ca-certificates tar
|
||||||
|
|
||||||
- name: Repo auschecken (Auto-Token — Org-Repo braucht Auth; LAN via add-host)
|
- name: Repo auschecken (Auto-Token; LAN via Runner-add-host)
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ github.token }}
|
GITEA_TOKEN: ${{ github.token }}
|
||||||
run: git clone --depth 1 "https://x-access-token:${GITEA_TOKEN}@git.eulernest.eu/${GITHUB_REPOSITORY}.git" src
|
run: git clone --depth 1 "https://x-access-token:${GITEA_TOKEN}@git.eulernest.eu/${GITHUB_REPOSITORY}.git" src
|
||||||
@@ -33,21 +32,26 @@ jobs:
|
|||||||
- name: Gitleaks (Secret-Scan, ARM64)
|
- name: Gitleaks (Secret-Scan, ARM64)
|
||||||
id: gl
|
id: gl
|
||||||
run: |
|
run: |
|
||||||
|
set +e +o pipefail
|
||||||
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 -v 2>&1 | tee /tmp/scan.log
|
cd src && gitleaks detect --no-git --source . --redact | tee /tmp/scan.log
|
||||||
echo "code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT"
|
echo "code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT"
|
||||||
|
exit 0
|
||||||
|
|
||||||
- name: Trivy (IaC/config, leicht)
|
- name: Trivy (IaC/config, leicht)
|
||||||
id: tv
|
id: tv
|
||||||
run: |
|
run: |
|
||||||
|
set +e +o pipefail
|
||||||
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 . 2>&1 | tee -a /tmp/scan.log
|
cd src && trivy config --severity HIGH,CRITICAL --exit-code 1 . | tee -a /tmp/scan.log
|
||||||
echo "code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT"
|
echo "code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT"
|
||||||
|
exit 0
|
||||||
|
|
||||||
- name: Gate — hart blockieren bei Funden
|
- name: Gate — hart blockieren bei Funden
|
||||||
run: |
|
run: |
|
||||||
|
echo "gitleaks=${{ steps.gl.outputs.code }} trivy=${{ steps.tv.outputs.code }}"
|
||||||
if [ "${{ steps.gl.outputs.code }}" != "0" ] || [ "${{ steps.tv.outputs.code }}" != "0" ]; then
|
if [ "${{ steps.gl.outputs.code }}" != "0" ] || [ "${{ steps.tv.outputs.code }}" != "0" ]; then
|
||||||
echo "Security-Funde -> Check schlägt fehl (hart blockierend)."; exit 1
|
echo "Security-Funde -> Check schlägt fehl (hart blockierend)."; exit 1
|
||||||
fi
|
fi
|
||||||
@@ -62,5 +66,5 @@ 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://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
|
||||||
|
|||||||
Reference in New Issue
Block a user