Allowed localhost when making requests - #878
Conversation
WalkthroughThe request URL validation now requires a string and accepts URLs supported by the default validator or localhost hosts. Tests cover overlong URLs, URLs with spaces or angle brackets, and successful requests to Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #878 +/- ##
==========================================
- Coverage 97.76% 96.59% -1.18%
==========================================
Files 105 14 -91
Lines 3452 676 -2776
Branches 616 118 -498
==========================================
- Hits 3375 653 -2722
+ Misses 25 9 -16
+ Partials 52 14 -38 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Just a heads up that I likely won't have time to review this today. Happy to take a look tomorrow/Thursday. I don't think it's urgent, but let me know if you disagree. |
|
Yeah, not urgent at all. No rush. |
ref TryGhost/Ghost#28978 (review) Post scheduling is broken in development because we use a `localhost` URL. `@tryghost/request` doesn't consider `localhost` URLs valid, so scheduling is broken. This fixes that by allowing `localhost` URLs. I was a little nervous about loosening the validation, but it's code could make requests to `localhost` before this change. (I considered an alternative where Ghost development used `127.0.0.1` instead, which also fixes the problem, but that's too disruptive to development IMO.)
8b2fca4 to
0e837c1
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
question: could you elaborate on "it's code could make requests to localhost before this change"? |
|
thought: I'm curious what changed that broke post scheduling locally. I'm a little hesitant to loosen this validation before we understand what caused it to break in the first place. |
|
Didn't realize that post scheduling ever worked locally. I'll investigate (probably not urgently). |
9larsons
left a comment
There was a problem hiding this comment.
From my perspective, looks fine. I think the risk for allowing localhost is SSRF, but we only use request for internal requests. We have request-external for external reqs.
+1 though it'd be nice to know the root cause.
|
I think newsletter scheduling broke in dev this way: e93c69f updated The root cause, though, is that we never detected this. (Those commits above are, IMO, flawless.) Now that I understand this, I'm going to merge, as it's blocking some other work. |
towards https://linear.app/ghost/issue/NY-1465
ref TryGhost/Ghost#28978 (review)
Post scheduling is broken in development because we use a
localhostURL.@tryghost/requestdoesn't considerlocalhostURLs valid, so scheduling is broken.This fixes that by allowing
localhostURLs.I was a little nervous about loosening the validation, but it's code could make requests to
localhostbefore this change.(I considered an alternative where Ghost development used
127.0.0.1instead, which also fixes the problem, but that's too disruptive to development IMO.)