From 44d28397a152b68f7adb44748f166bc0dce8277d Mon Sep 17 00:00:00 2001 From: Dave Jong Date: Sun, 25 Jan 2026 13:59:58 +0100 Subject: [PATCH] Removed certain functionality that would slow down Drupal performance. --- src/Extensions/Drupal/Extension.php | 53 +++-------------------------- 1 file changed, 4 insertions(+), 49 deletions(-) diff --git a/src/Extensions/Drupal/Extension.php b/src/Extensions/Drupal/Extension.php index ce2dd7c..89cb0c9 100644 --- a/src/Extensions/Drupal/Extension.php +++ b/src/Extensions/Drupal/Extension.php @@ -69,6 +69,7 @@ public function logRequest($ruleId, $request, $blockType): void { /** * Determine if the current visitor can bypass the firewall. + * This is disabled in this extension. * * @param bool $isMuCall * Whether this is an early call before user session is available. @@ -77,28 +78,12 @@ public function logRequest($ruleId, $request, $blockType): void { * TRUE if the visitor can bypass, FALSE otherwise. */ public function canBypass($isMuCall): bool { - // If called too early, we can't check user permissions. - if ($isMuCall) { - return FALSE; - } - - try { - $currentUser = \Drupal::currentUser(); - - // Allow administrators to bypass. - if ($currentUser->hasPermission('administer site configuration')) { - return TRUE; - } - } - catch (\Throwable $e) { - // If we can't determine user, don't bypass. - } - return FALSE; } /** * Determine if the visitor is blocked due to too many blocked requests. + * This is disabled in this extension. * * @param int $minutes * The time window in minutes. @@ -111,36 +96,7 @@ public function canBypass($isMuCall): bool { * TRUE if the visitor should be blocked, FALSE otherwise. */ public function isBlocked($minutes, $blockTime, $attempts): bool { - // Currently disabled - return false to not auto-block based on attempts. - // This can be enabled later with proper configuration. - if (TRUE) { - return FALSE; - } - - if (empty($minutes) || empty($blockTime) || empty($attempts)) { - return FALSE; - } - - try { - // Calculate the time window. - $time = ($minutes + $blockTime) * 60; - $cutoffTime = \Drupal::time()->getRequestTime() - $time; - - // Count blocked requests from this IP in the time window. - $connection = \Drupal::database(); - $count = $connection->select('patchstack_logs', 'pl') - ->condition('block_type', 'BLOCK') - ->condition('ip', $this->getIpAddress()) - ->condition('log_date', $cutoffTime, '>=') - ->countQuery() - ->execute() - ->fetchField(); - - return (int) $count >= $attempts; - } - catch (\Throwable $e) { - return FALSE; - } + return FALSE; } /** @@ -205,6 +161,7 @@ public function getHostName(): string { /** * Determine if the request should bypass the firewall based on whitelist. + * This is disabled in this extension. * * @param array $whitelistRules * The whitelist rules. @@ -215,8 +172,6 @@ public function getHostName(): string { * TRUE if the request is whitelisted, FALSE otherwise. */ public function isWhitelisted($whitelistRules, $request): bool { - // Whitelist processing is handled by the firewall engine itself. - // This method can be used for additional Drupal-specific whitelisting. return FALSE; }