Skip to content

Commit 909e79c

Browse files
abhizipstackclaude
andauthored
fix: release notification secrets context and script injection (#50)
* fix: release notification — secrets context and script injection - Move secrets check from job-level if to step-level env (secrets context is not available in jobs.<id>.if — only github, inputs, needs, and vars are allowed) - Pass release event data via env variables instead of direct ${{ }} interpolation in run block to prevent script injection - Skip Slack post if no message was built Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: build full JSON payload in shell to prevent JSON injection Use jq to build the Slack payload JSON in the shell step instead of interpolating untrusted values into the payload block. This ensures release names with quotes or backslashes produce valid JSON. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ee40136 commit 909e79c

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

.github/workflows/release-notification.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,24 @@ on:
77
jobs:
88
notify:
99
runs-on: ubuntu-latest
10-
if: ${{ secrets.SLACK_WEBHOOK_URL != '' }}
1110
steps:
12-
- name: Build Slack message
11+
- name: Build Slack payload
1312
id: message
13+
if: ${{ env.SLACK_WEBHOOK_URL != '' }}
1414
env:
15+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
1516
TAG: ${{ github.event.release.tag_name }}
1617
RELEASE_NAME: ${{ github.event.release.name }}
1718
URL: ${{ github.event.release.html_url }}
1819
run: |
19-
echo "text=🚀 *Visitran ${TAG}* released! ${RELEASE_NAME} <${URL}|View Release Notes>" >> "$GITHUB_OUTPUT"
20+
TEXT=$(printf '🚀 *Visitran %s* released! %s <%s|View Release Notes>' "$TAG" "$RELEASE_NAME" "$URL")
21+
PAYLOAD=$(jq -nc --arg text "$TEXT" '{"text": $text}')
22+
echo "payload=$PAYLOAD" >> "$GITHUB_OUTPUT"
2023
2124
- name: Post to Slack
25+
if: ${{ steps.message.outputs.payload != '' }}
2226
uses: slackapi/slack-github-action@v2.1.0
2327
with:
2428
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
2529
webhook-type: incoming-webhook
26-
payload: |
27-
{
28-
"text": "${{ steps.message.outputs.text }}"
29-
}
30+
payload: ${{ steps.message.outputs.payload }}

0 commit comments

Comments
 (0)