-
-
Notifications
You must be signed in to change notification settings - Fork 313
Fix files-changed label workflow for all PRs with proper validation and security #4701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
Co-authored-by: DonnieBLT <[email protected]>
Co-authored-by: DonnieBLT <[email protected]>
|
@copilot can we make it so that the permissions are sufficient to allow the tag creation for bots too? |
Co-authored-by: DonnieBLT <[email protected]>
Yes! I've updated the workflow to use proper permissions that work for bot PRs. Changes in commit 5da6c08:
The key issue was that |
Co-authored-by: DonnieBLT <[email protected]>
|
@copilot please make this work for any user submitting a PR - Starting Files Changed Label workflow for PR #4701 in OWASP-BLT/BLT |
|
@copilot continue |
Co-authored-by: DonnieBLT <[email protected]>
Fixed in commit 0908926. The error detection now properly validates if the API response is a valid JSON array instead of doing string matching. This prevents valid responses (that may contain the word "message" in patch data) from being incorrectly treated as errors. The workflow now works for any user submitting a PR. |
Co-authored-by: DonnieBLT <[email protected]>
Co-authored-by: DonnieBLT <[email protected]>
The files-changed label workflow fails with "Bad credentials" on Copilot bot PRs due to token authentication issues, and incorrectly treats valid API responses as errors when response data contains the word "message".
Changes
Token Authentication: Changed from
secrets.CUSTOM_GITHUB_TOKEN || secrets.GITHUB_TOKENtogithub.tokengithub.tokenis the automatic token provided by GitHub Actions with permissions defined in the workflowFixed Error Detection: Changed from string matching to proper JSON validation
jq -e 'type == "array"'has("name")to verify successSecurity Improvements: Sanitize error messages to prevent sensitive data leakage
jq -r '.message // empty'Updated Error Messages: Removed references to CUSTOM_GITHUB_TOKEN and updated guidance to reflect the new token approach
Why This Works
The workflow now works correctly for all PR types by addressing multiple issues:
Authentication: The "Bad credentials" error occurred because
secrets.GITHUB_TOKENmay not be accessible in certain contexts for bot-created PRs. By usinggithub.tokenwith the explicit permissions already defined in the workflow (pull-requests: write,issues: write,contents: read,repository-projects: write), proper authentication is ensured for all PR types.Error Detection: The previous string matching approach (
*"message"*"Not Found"*) incorrectly flagged valid API responses as errors when the response data contained the word "message" (e.g., in commit messages or patch data). The new JSON validation approach correctly distinguishes between successful responses and actual errors.Security: By extracting only error messages instead of logging full API responses, the workflow prevents potential exposure of sensitive data like authentication tokens in workflow logs.
The workflow now supports:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.