Skip to content

Commit 51d084b

Browse files
authored
Merge pull request #3 from aws/harden-actions-event-context
Harden reusable workflows: pass event context via env vars
2 parents 6605d91 + 5560056 commit 51d084b

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎.github/workflows/reusable-pr-security-review.yml‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,15 @@ jobs:
8686
- name: Resolve subject
8787
id: subject
8888
if: github.event_name == 'pull_request_target'
89+
env:
90+
EVENT_ACTION: ${{ github.event.action }}
91+
SENDER_LOGIN: ${{ github.event.sender.login }}
92+
PR_AUTHOR_LOGIN: ${{ github.event.pull_request.user.login }}
8993
run: |
90-
if [ "${{ github.event.action }}" = "labeled" ]; then
91-
echo "login=${{ github.event.sender.login }}" >> "$GITHUB_OUTPUT"
94+
if [ "$EVENT_ACTION" = "labeled" ]; then
95+
echo "login=$SENDER_LOGIN" >> "$GITHUB_OUTPUT"
9296
else
93-
echo "login=${{ github.event.pull_request.user.login }}" >> "$GITHUB_OUTPUT"
97+
echo "login=$PR_AUTHOR_LOGIN" >> "$GITHUB_OUTPUT"
9498
fi
9599
# Authorized = member of the org team OR a write/admin collaborator (team tier first).
96100
- name: Check authorization

‎.github/workflows/reusable-strands-command.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ jobs:
8888
required-permission: write
8989
- name: Enforce authorization
9090
if: github.event_name != 'workflow_dispatch' && steps.authz.outputs.is-authorized != 'true'
91+
env:
92+
COMMENT_USER: ${{ github.event.comment.user.login }}
9193
run: |
92-
echo "❌ User ${{ github.event.comment.user.login }} does not have write access"
94+
echo "❌ User $COMMENT_USER does not have write access"
9395
exit 1
9496
9597
- name: Checkout

0 commit comments

Comments
 (0)