Skip to content

Upd. Cleantalk.php. Rotate moderate. Now use CURLOPT_RESOLVE for IP instead of converting IP as string if IP is used as fallback. - #894

Merged
svedge merged 3 commits into
devfrom
curlopt_resolve.ag
Oct 15, 2026
Merged

svedge merged 3 commits into
devfrom
curlopt_resolve.ag

Conversation

@alexandergull

Copy link
Copy Markdown
Member

@alexandergull alexandergull changed the title Upd. Cleantalk.php. Rotate moderate. Now use CURLOPT_RESOLVE for IP instead of converting IP as string if IP is used as fallback. https://app.doboard.com/1/task/55885 Upd. Cleantalk.php. Rotate moderate. Now use CURLOPT_RESOLVE for IP instead of converting IP as string if IP is used as fallback. Sep 21, 2026
@codecov

codecov Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.46479% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 33.39%. Comparing base (968b546) to head (f9fef08).
⚠️ Report is 124 commits behind head on dev.

Files with missing lines Patch % Lines
lib/Cleantalk/Antispam/Cleantalk.php 85.00% 9 Missing ⚠️
inc/cleantalk-common.php 33.33% 6 Missing ⚠️
lib/Cleantalk/ApbctWP/Antispam/ForceProtection.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                dev     #894      +/-   ##
============================================
+ Coverage     30.59%   33.39%   +2.80%     
- Complexity     6639     6983     +344     
============================================
  Files           292      297       +5     
  Lines         26493    27314     +821     
============================================
+ Hits           8105     9121    +1016     
+ Misses        18388    18193     -195     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved critical and moderate issues affect fallback correctness and runtime safety.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

Updates moderate-server fallback requests to use CURLOPT_RESOLVE while preserving hostname-based TLS verification.

Changes:

  • Adds hostname-to-IP resolution with default and explicit ports.
  • Updates fallback retry behavior.
  • Adds regression tests for resolution, TLS, and invalid inputs.

Review findings:

  • CURLOPT_RESOLVE needs a defined-constant guard.
  • DNS failure classification does not reach the new fallback in common cases.
  • The fallback must preserve $url_host rather than using the PTR hostname.
File Summary
tests/​Antispam/​TestCleantalkResolveIP.php Adds regression tests for mappings, ports, TLS, and invalid inputs.
lib/​Cleantalk/​Antispam/​Cleantalk.php Implements IP-pinned fallback requests and retry behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/Cleantalk/Antispam/Cleantalk.php Outdated
Comment thread lib/Cleantalk/Antispam/Cleantalk.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved production TLS/SNI and fallback-handling issues remain, along with a regression test that asserts unsafe behavior.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (2)

Comment thread lib/Cleantalk/Antispam/Cleantalk.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Address the unavailable CURLOPT_RESOLVE guard and legacy URL handling when no valid IP is present.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Comment thread lib/Cleantalk/Antispam/Cleantalk.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

  • Copilot's review of this pull request may be incomplete because some of the changed files are excluded by your Copilot content exclusion settings. See Excluding content from Copilot for details.

🔵 Needs a closer look

Rotation excludes cached IPs without attempting them, which can break feedback delivery and DNS recovery.

0 open findings

1 resolved since last review
Files excluded by content exclusion policy (1)
  • tests/Antispam/TestCleantalkResolveIP.php
Previously missed (1)

In code that hasn't changed since last review

Medium severity Avoid blacklisting cached IP when the request is skipped

lib/​Cleantalk/​Antispam/​Cleantalk.php:285

This marks the cached IP as failed even when the initial request was skipped because work_url is empty or expired. Both feedback callers reject stored HTTPS URLs with their HTTP-only check but now load work_ip, so they reach this case. If that IP is the only candidate, rotation skips it and feedback is sent to a relative URL; with an expired URL, retries lose IP pinning and cannot recover from DNS failures. Only blacklist the cached IP after an actual failed request. Here, $result === false identifies a skipped request because sendRequest() returns a response object even on failure.

🧠 Review effort: Balanced

@svedge
svedge merged commit 0f98955 into dev Oct 15, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants