Skip to content

Commit 2581e75

Browse files
Issue 33050 claude workflow security (#421)
### Proposed Changes * change 1 * change 2 ### Checklist - [ ] Tests - [ ] Translations - [ ] Security Implications Contemplated (add notes if applicable) ### Additional Info ** any additional useful context or info ** ### Screenshots Original | Updated :-------------------------:|:-------------------------: ** original screenshot ** | ** updated screenshot ** --------- Co-authored-by: Claude <[email protected]>
1 parent b321687 commit 2581e75

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

.github/actions/security/org-membership-check/README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,7 @@ This composite action checks if a GitHub user is a member of the dotCMS organiza
3939
4040
## Implementation Details
4141
42-
The action uses the GitHub CLI (`gh`) with a fine-grained GitHub token to check organization membership via the GitHub API endpoint `GET /orgs/dotCMS/members/{username}`.
43-
44-
**Token Requirements:**
45-
- Fine-grained token with organization membership read permissions
46-
- Should be from a machine/service account for security
47-
- Stored as repository secret: `MACHINE_USER_CORE_ORG_MEMBERSHIP_CHECK`
42+
The action uses the GitHub CLI (`gh`) with the repository's `GITHUB_TOKEN` to check organization membership via the GitHub API endpoint `GET /orgs/dotCMS/members/{username}`.
4843

4944
**Key Design Decision: Status Code vs Response Body**
5045

.github/actions/security/org-membership-check/action.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,27 @@ runs:
3131
3232
set +e # Don't exit on error, we want to handle it gracefully
3333
34-
# Check organization membership using GitHub API with fine-grained token
34+
# Check organization membership using GitHub API
3535
#
36-
# Uses a fine-grained token with organization membership read permissions
37-
# to check both public and private organization membership reliably.
36+
# IMPORTANT: We check the HTTP status code (via exit code) rather than parsing
37+
# the response body because GitHub's membership API has specific behavior:
3838
#
39-
# API Behavior:
40-
# - HTTP 200 + user object = Public member
41-
# - HTTP 200 + empty response = Private member
42-
# - HTTP 404 = Not a member
43-
# - Other errors = API/token issues
44-
45-
echo "Checking organization membership for ${{ inputs.username }} in dotCMS..."
39+
# HTTP 200 (exit code 0) = User IS a member (regardless of response content)
40+
# - Public member: Returns user object with populated fields
41+
# - Private member: Returns empty response body (but still 200 OK)
42+
#
43+
# HTTP 404 (exit code 1) = User is NOT a member
44+
# - Returns {"message":"Not Found",...} error response
45+
#
46+
# This approach correctly handles both public and private organization members
47+
# without needing to distinguish between their visibility settings.
4648
47-
# Use the provided fine-grained token instead of default GITHUB_TOKEN
48-
response=$(gh api orgs/dotCMS/members/${{ inputs.username }} \
49-
--header "Authorization: token ${{ inputs.github_token }}" 2>/dev/null)
49+
response=$(gh api orgs/dotCMS/members/${{ inputs.username }} 2>/dev/null)
5050
api_exit_code=$?
5151
5252
if [ $api_exit_code -eq 0 ]; then
5353
# HTTP 200: User is a member (public or private)
54+
# We check response content only for logging clarity, not authorization logic
5455
if [ -n "$response" ]; then
5556
echo "✅ User ${{ inputs.username }} is a member of dotCMS (public membership)"
5657
else
@@ -59,7 +60,8 @@ runs:
5960
echo "is_member=true" >> $GITHUB_OUTPUT
6061
echo "membership_status=member" >> $GITHUB_OUTPUT
6162
else
62-
# HTTP 404 or other error: User is not a member or API issue
63+
# HTTP 404 or other error: User is not a member
64+
6365
echo "❌ User ${{ inputs.username }} is not a member of dotCMS (API exit code: $api_exit_code)"
6466
echo "is_member=false" >> $GITHUB_OUTPUT
6567
echo "membership_status=non-member" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)