Skip to content

Commit

Permalink
Merge pull request #5773 from mrclschstr/staging
Browse files Browse the repository at this point in the history
[Fix] Watchdog: escape subject and body for webhooks
  • Loading branch information
DerLinkman authored Aug 7, 2024
2 parents 76194be + 82fde23 commit 8017394
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 6 additions & 2 deletions data/Dockerfiles/watchdog/watchdog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,13 @@ function notify_error() {
return 1
fi

# Escape subject and body (https://stackoverflow.com/a/2705678)
ESCAPED_SUBJECT=$(echo ${SUBJECT} | sed -e 's/[\/&]/\\&/g')
ESCAPED_BODY=$(echo ${BODY} | sed -e 's/[\/&]/\\&/g')

# Replace subject and body placeholders
WEBHOOK_BODY=$(echo ${WATCHDOG_NOTIFY_WEBHOOK_BODY} | sed "s/\$SUBJECT\|\${SUBJECT}/$SUBJECT/g" | sed "s/\$BODY\|\${BODY}/$BODY/g")
WEBHOOK_BODY=$(echo ${WATCHDOG_NOTIFY_WEBHOOK_BODY} | sed -e "s/\$SUBJECT\|\${SUBJECT}/$ESCAPED_SUBJECT/g" -e "s/\$BODY\|\${BODY}/$ESCAPED_BODY/g")

# POST to webhook
curl -X POST -H "Content-Type: application/json" ${CURL_VERBOSE} -d "${WEBHOOK_BODY}" ${WATCHDOG_NOTIFY_WEBHOOK}

Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,6 @@ services:
- mysql-mailcow
- acme-mailcow
- redis-mailcow

environment:
- IPV6_NETWORK=${IPV6_NETWORK:-fd4d:6169:6c63:6f77::/64}
- LOG_LINES=${LOG_LINES:-9999}
Expand Down

0 comments on commit 8017394

Please sign in to comment.