Skip to content

Commit

Permalink
allow tests to bypass bot detection
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Nov 18, 2024
1 parent e9d5657 commit a0c051b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/EventSubscriber/Challenge.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,20 @@ protected function applies(RequestEvent $event, ImmutableConfig $config): bool {
if (captcha_whitelist_ip_whitelisted($clientIp)) {
return FALSE;
}

// See if the client IP resolves to a good bot.
$hostname = gethostbyaddr($clientIp);
// Being sure to lookup the domain to avoid spoofing.
$resolved_ip = gethostbyname($hostname);
if ($clientIp !== $resolved_ip) {
return TRUE;
if ($clientIp !== '127.0.0.1') {
return TRUE;
}
}
$parts = explode(".", $hostname);
if (count($parts) < 2) {
return TRUE;
if ($clientIp !== '127.0.0.1') {
return TRUE;
}
}
$tld = array_pop($parts);
$hostname = array_pop($parts) . '.' . $tld;
Expand Down

0 comments on commit a0c051b

Please sign in to comment.