Pipeline-Fix: Commit-Message als ENV-Variable durchreichen statt String-Interpolation [deploy]
All checks were successful
Deploy mahnung / deploy (push) Successful in 14s

Bug: ${{ github.event.head_commit.message }} wurde direkt in den
Bash-Script-Text eingefuegt. Sobald die Commit-Message Klammern,
Backticks oder andere Shell-Sonderzeichen enthielt, kam Syntaxfehler
"line 9: syntax error near unexpected token" und der ganze Deploy
fiel um. Phase 2, 3 und 5 waren betroffen, Phase 4 ging durch
weil zufaellig keine Klammern in der Message waren.

Zusaetzlich Sicherheits-Aspekt: Shell-Injection war moeglich, wenn
jemand eine Commit-Message mit Befehlssubstitution committet.

Fix:
- COMMIT_MSG via env: an den Step uebergeben statt im Run-Block
  per Expression einzusetzen.
- RUN_NUMBER, NTFY_AUTH und GIT_TOKEN gleichzeitig via env: harten
  fuer Konsistenz und Sicherheit.
- printf %s statt echo fuer mehrzeilige Messages.
- Klammern-frei verifiziert in dieser Commit-Message.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Eduard Wisch 2026-05-11 12:28:30 +02:00
parent 660e91e65d
commit 3a016ce999

View file

@ -16,20 +16,26 @@ jobs:
steps: steps:
- name: Notify Start - name: Notify Start
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
RUN_NUMBER: ${{ github.run_number }}
NTFY_AUTH: ${{ secrets.NTFY_AUTH }}
run: | run: |
MSG=$(echo "${{ github.event.head_commit.message }}" | head -1) MSG=$(printf '%s\n' "$COMMIT_MSG" | head -1)
wget -q -O- \ wget -q -O- \
--header="Authorization: ${{ secrets.NTFY_AUTH }}" \ --header="Authorization: $NTFY_AUTH" \
--header="Title: Mahnung Deploy gestartet" \ --header="Title: Mahnung Deploy gestartet" \
--header="Priority: default" \ --header="Priority: default" \
--header="Tags: hammer_and_wrench,envelope_with_arrow" \ --header="Tags: hammer_and_wrench,envelope_with_arrow" \
--post-data="Deploy #${{ github.run_number }}: ${MSG}" \ --post-data="Deploy #$RUN_NUMBER: $MSG" \
"$NTFY_URL" || true "$NTFY_URL" || true
- name: Checkout - name: Checkout
env:
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
run: | run: |
git clone --depth 1 --branch "${GITHUB_REF_NAME}" \ git clone --depth 1 --branch "$GITHUB_REF_NAME" \
"https://token:${{ secrets.GIT_TOKEN }}@git.data-it-solution.de/${GITHUB_REPOSITORY}.git" . "https://token:$GIT_TOKEN@git.data-it-solution.de/$GITHUB_REPOSITORY.git" .
- name: Deploy nach Dolibarr - name: Deploy nach Dolibarr
run: | run: |
@ -59,23 +65,29 @@ jobs:
- name: Notify Success - name: Notify Success
if: success() if: success()
env:
RUN_NUMBER: ${{ github.run_number }}
NTFY_AUTH: ${{ secrets.NTFY_AUTH }}
run: | run: |
wget -q -O- \ wget -q -O- \
--header="Authorization: ${{ secrets.NTFY_AUTH }}" \ --header="Authorization: $NTFY_AUTH" \
--header="Title: Mahnung Deploy erfolgreich" \ --header="Title: Mahnung Deploy erfolgreich" \
--header="Priority: high" \ --header="Priority: high" \
--header="Tags: white_check_mark,envelope_with_arrow" \ --header="Tags: white_check_mark,envelope_with_arrow" \
--post-data="Deploy #${{ github.run_number }} abgeschlossen." \ --post-data="Deploy #$RUN_NUMBER abgeschlossen." \
"$NTFY_URL" || true "$NTFY_URL" || true
- name: Notify Failure - name: Notify Failure
if: failure() if: failure()
env:
RUN_NUMBER: ${{ github.run_number }}
NTFY_AUTH: ${{ secrets.NTFY_AUTH }}
run: | run: |
wget -q -O- \ wget -q -O- \
--header="Authorization: ${{ secrets.NTFY_AUTH }}" \ --header="Authorization: $NTFY_AUTH" \
--header="Title: Mahnung Deploy FEHLGESCHLAGEN" \ --header="Title: Mahnung Deploy FEHLGESCHLAGEN" \
--header="Priority: urgent" \ --header="Priority: urgent" \
--header="Tags: x,rotating_light,envelope_with_arrow" \ --header="Tags: x,rotating_light,envelope_with_arrow" \
--header="Click: https://git.data-it-solution.de/${GITHUB_REPOSITORY}/actions" \ --header="Click: https://git.data-it-solution.de/$GITHUB_REPOSITORY/actions" \
--post-data="Deploy #${{ github.run_number }} hat einen Fehler." \ --post-data="Deploy #$RUN_NUMBER hat einen Fehler." \
"$NTFY_URL" || true "$NTFY_URL" || true