Skip to content

Commit 44d2839

Browse files
Removed certain functionality that would slow down Drupal performance.
1 parent 8f58885 commit 44d2839

1 file changed

Lines changed: 4 additions & 49 deletions

File tree

src/Extensions/Drupal/Extension.php

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public function logRequest($ruleId, $request, $blockType): void {
6969

7070
/**
7171
* Determine if the current visitor can bypass the firewall.
72+
* This is disabled in this extension.
7273
*
7374
* @param bool $isMuCall
7475
* Whether this is an early call before user session is available.
@@ -77,28 +78,12 @@ public function logRequest($ruleId, $request, $blockType): void {
7778
* TRUE if the visitor can bypass, FALSE otherwise.
7879
*/
7980
public function canBypass($isMuCall): bool {
80-
// If called too early, we can't check user permissions.
81-
if ($isMuCall) {
82-
return FALSE;
83-
}
84-
85-
try {
86-
$currentUser = \Drupal::currentUser();
87-
88-
// Allow administrators to bypass.
89-
if ($currentUser->hasPermission('administer site configuration')) {
90-
return TRUE;
91-
}
92-
}
93-
catch (\Throwable $e) {
94-
// If we can't determine user, don't bypass.
95-
}
96-
9781
return FALSE;
9882
}
9983

10084
/**
10185
* Determine if the visitor is blocked due to too many blocked requests.
86+
* This is disabled in this extension.
10287
*
10388
* @param int $minutes
10489
* The time window in minutes.
@@ -111,36 +96,7 @@ public function canBypass($isMuCall): bool {
11196
* TRUE if the visitor should be blocked, FALSE otherwise.
11297
*/
11398
public function isBlocked($minutes, $blockTime, $attempts): bool {
114-
// Currently disabled - return false to not auto-block based on attempts.
115-
// This can be enabled later with proper configuration.
116-
if (TRUE) {
117-
return FALSE;
118-
}
119-
120-
if (empty($minutes) || empty($blockTime) || empty($attempts)) {
121-
return FALSE;
122-
}
123-
124-
try {
125-
// Calculate the time window.
126-
$time = ($minutes + $blockTime) * 60;
127-
$cutoffTime = \Drupal::time()->getRequestTime() - $time;
128-
129-
// Count blocked requests from this IP in the time window.
130-
$connection = \Drupal::database();
131-
$count = $connection->select('patchstack_logs', 'pl')
132-
->condition('block_type', 'BLOCK')
133-
->condition('ip', $this->getIpAddress())
134-
->condition('log_date', $cutoffTime, '>=')
135-
->countQuery()
136-
->execute()
137-
->fetchField();
138-
139-
return (int) $count >= $attempts;
140-
}
141-
catch (\Throwable $e) {
142-
return FALSE;
143-
}
99+
return FALSE;
144100
}
145101

146102
/**
@@ -205,6 +161,7 @@ public function getHostName(): string {
205161

206162
/**
207163
* Determine if the request should bypass the firewall based on whitelist.
164+
* This is disabled in this extension.
208165
*
209166
* @param array $whitelistRules
210167
* The whitelist rules.
@@ -215,8 +172,6 @@ public function getHostName(): string {
215172
* TRUE if the request is whitelisted, FALSE otherwise.
216173
*/
217174
public function isWhitelisted($whitelistRules, $request): bool {
218-
// Whitelist processing is handled by the firewall engine itself.
219-
// This method can be used for additional Drupal-specific whitelisting.
220175
return FALSE;
221176
}
222177

0 commit comments

Comments
 (0)