Improved DNS validation in external request handling#26754
Improved DNS validation in external request handling#26754kevinansfield merged 1 commit intomainfrom
Conversation
no issue Ensured that the IP address validated during the DNS check is the same one used for the actual TCP connection by installing a custom dnsLookup on request options. Added tests for the new validation layer.
WalkthroughThis change introduces DNS rebinding attack protection by adding a new 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ghost/core/test/unit/server/lib/request-external.test.js (1)
527-535: Unnecessaryawaiton synchronous function.
installSafeDnsLookupis a synchronous function that doesn't return a promise. Theawaitis harmless but unnecessary.🔧 Suggested fix
- await installSafeDnsLookup(options); + installSafeDnsLookup(options);This applies to all test cases in this suite (lines 532, 544, 556, 568, 589, 619, 649, 681, 714, 743).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ghost/core/test/unit/server/lib/request-external.test.js` around lines 527 - 535, The tests call the synchronous function installSafeDnsLookup with an unnecessary await; remove the await operator from all test invocations of installSafeDnsLookup (e.g., in the "installs a lookup function on request options" test and the other cases in the same suite) so the function is invoked directly (installSafeDnsLookup(options)) and assertions remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@ghost/core/test/unit/server/lib/request-external.test.js`:
- Around line 527-535: The tests call the synchronous function
installSafeDnsLookup with an unnecessary await; remove the await operator from
all test invocations of installSafeDnsLookup (e.g., in the "installs a lookup
function on request options" test and the other cases in the same suite) so the
function is invoked directly (installSafeDnsLookup(options)) and assertions
remain unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f28fbf46-5ecc-4036-beca-4e1d85128855
📒 Files selected for processing (2)
ghost/core/core/server/lib/request-external.jsghost/core/test/unit/server/lib/request-external.test.js
ref https://linear.app/ghost/issue/ONC-1533/ Ensured that the IP address validated during the DNS check is the same one used for the actual TCP connection by installing a custom dnsLookup on request options. Added tests for the new validation layer.
ref https://linear.app/ghost/issue/ONC-1533/
Ensured that the IP address validated during the DNS check is the same
one used for the actual TCP connection by installing a custom dnsLookup
on request options. Added tests for the new validation layer.