Fix hostname() to reject case variants and wildcard forms of localhost#659
Fix hostname() to reject case variants and wildcard forms of localhost#659
hostname() to reject case variants and wildcard forms of localhost#659Conversation
hostname({ allowLocalhost: false }) only blocked the exact lowercase
string "localhost". Case variants (LOCALHOST, LocalHost) and wildcard
forms (*.localhost) were accepted because:
- The check used strict equality (===) instead of case-insensitive
comparison
- Wildcard hostnames bypassed the localhost check entirely
Now uses toLowerCase() for the localhost comparison and adds a
separate check for wildcard-localhost forms (*.localhost).
Close #321
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #659 +/- ##
==========================================
- Coverage 94.90% 94.89% -0.01%
==========================================
Files 38 38
Lines 17875 17882 +7
Branches 4773 4778 +5
==========================================
+ Hits 16964 16970 +6
- Misses 899 900 +1
Partials 12 12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis PR fixes the Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
hostname({ allowLocalhost: false })only blocked the exact lowercase string"localhost". Because DNS hostnames are case-insensitive per RFC 1123, case variants like"LOCALHOST"and"LocalHost"should also be rejected. Additionally, wildcard forms rooted at localhost (e.g.,"*.localhost","*.LOCALHOST") bypassed the localhost check entirely since the wildcard validation runs in a separate code path.This change makes the localhost comparison case-insensitive using
toLowerCase()in packages/core/src/valueparser.ts and adds a dedicated check inside the wildcard validation block to reject*.localhostand its case variants whenallowLocalhostis set tofalse. The fix also applies tosocketAddress()since it delegates host validation tohostname().Closes #321