-
Notifications
You must be signed in to change notification settings - Fork 11
chore: duplicate changes from http to swoole #36
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
chore: duplicate changes from http to swoole #36
Conversation
WalkthroughUpdated composer.json to change the required version constraint for "utopia-php/framework" from "0.33.*" to "0.33.35". Added a protected property in src/Swoole/Request.php to store trusted proxy header names, added setTrustedIpHeaders(array $headers) to normalize/configure them, and modified getIP() to prefer the leftmost valid IP from those trusted headers before falling back to REMOTE_ADDR; docblocks and notes updated. Removed the top-level Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
composer.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
composer.json(1 hunks)src/Swoole/Request.php(2 hunks)
🧰 Additional context used
🪛 GitHub Actions: CodeQL
src/Swoole/Request.php
[error] 22-22: PHPStan: Property Utopia\Swoole\Request::$trustedIpHeaders type has no value specified for iterable type 'array'.
[error] 83-83: PHPStan: Method Utopia\Swoole\Request::setTrustedIpHeaders() has parameter $headers with no value type specified in iterable type 'array'.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Unit & E2E
🔇 Additional comments (2)
composer.json (1)
18-18: LGTM! Version constraint syntax modernized.The change from "0.33.*" to "0.33.x" is a syntax update that maintains the same version range. Both constraints match versions 0.33.0, 0.33.1, etc., but the "x" notation is the preferred modern syntax.
src/Swoole/Request.php (1)
101-123: Consider rejecting private IP ranges in trusted headers.The
filter_var($ip, FILTER_VALIDATE_IP)validation accepts private IP ranges (10.x.x.x, 172.16-31.x.x, 192.168.x.x) and reserved ranges (127.x.x.x, 0.0.0.0) by default. If this IP is used for security decisions (rate limiting, access control, logging), an attacker could spoof trusted headers with private IPs to bypass restrictions.Consider using additional flags to reject private and reserved ranges:
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { return $ip; }However, this depends on your use case—if legitimate clients connect from private networks behind proxies, rejecting private IPs would break functionality. Please verify whether your application requires this additional validation.
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/e2e/server.php (1)
74-75: For consistency, explicitly setoverride: falseon both Set-Cookie headers.Line 75 correctly uses
override: falseto allow multiple Set-Cookie headers to coexist. Consider applying the same explicit parameter to line 74 for clarity:$response->addHeader('Set-Cookie', 'key1=value1', override: false); $response->addHeader('Set-Cookie', 'key2=value2', override: false);The framework version 0.33.x (confirmed in composer.json) supports the
overrideparameter inResponse::addHeader().
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/e2e/server.php(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/e2e/server.php (1)
src/Swoole/Request.php (1)
addHeader(338-343)
Summary by CodeRabbit
New Features
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.