-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add CDN integrity and absolute URL to stats API #42
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
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
api-worker | bb3c9d2 | Commit Preview URL Branch Preview URL |
Jan 14 2026, 12:18 PM |
|
@copilot the CORS changes are not suitable as the endpoints are intended as public APIs. Think carefully and update the PR. |
Reverted the CORS restrictions in commit bdf06d3. The endpoints now use |
- Add integrity and crossorigin attributes to Chart.js CDN script - Fix regex pattern escaping in parsePhpVersion function - Use absolute URL for stats data fetch request - Restrict CORS to specific allowed origins - Update integration tests for CORS changes Co-authored-by: admdly <[email protected]>
Co-authored-by: admdly <[email protected]>
The original double-escaped pattern /(\\d+\\.\\d+)/ is correct for template literals. In a template literal, \\d becomes \d in the output, which is the proper regex escape. The single-escaped version /(\d+\.\d+)/ would produce /(d+.d+)/ which is incorrect. Co-authored-by: admdly <[email protected]>
Remove CORS allowlist and restore origin: "*" to allow public access. The stats API endpoints are intended to be publicly accessible, so the CORS restrictions were inappropriate. Co-authored-by: admdly <[email protected]>
bdf06d3 to
9827e76
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds security improvements to the stats API by implementing CDN resource integrity verification and using absolute URLs for API requests.
Changes:
- Added integrity hash and crossorigin attributes to Chart.js CDN script for Subresource Integrity (SRI) verification
- Changed fetch API call to use absolute URL constructed from window.location.origin instead of relative path
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Applies security hardening to the stats API v1 endpoint based on identified vulnerabilities.
Changes
crossorigin="anonymous"to Chart.js script tag to prevent tampering/stats/v1/datatowindow.location.origin + '/stats/v1/data'to handle serving from different paths/subdomains/(\\d+\\.\\d+)/pattern is correct for template literal context (proposed fix would have broken version parsing)Public API Access
The stats API endpoints remain publicly accessible with
origin: "*"CORS policy, as these are intended to be public APIs that can be consumed from any origin.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.