| 1 |
<?php |
| 2 |
|
| 3 |
namespace Patchstack\Extensions\Test; |
| 4 |
|
| 5 |
use Patchstack\Extensions\ExtensionInterface; |
| 6 |
|
| 7 |
class Extension implements ExtensionInterface |
| 8 |
{ |
| 9 |
/** |
| 10 |
* Log the request, this can be of type BLOCK, LOG or REDIRECT. |
| 11 |
* |
| 12 |
* @param int $ruleId |
| 13 |
* @param string $bodyData |
| 14 |
* @param string $blockType |
| 15 |
* @return void |
| 16 |
*/ |
| 17 |
public function logRequest($ruleId, $bodyData, $blockType) |
| 18 |
{ |
| 19 |
return true; |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Determine if the current visitor can bypass the firewall. |
| 24 |
* If $isMuCall is true, we MUST avoid any function calls that checks the current authorization of the user, |
| 25 |
* this includes current_user_can. Otherwise, a fatal error is thrown. |
| 26 |
* |
| 27 |
* @param bool $isMuCall |
| 28 |
* @return bool |
| 29 |
*/ |
| 30 |
public function canBypass($isMuCall) |
| 31 |
{ |
| 32 |
return false; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Determine if the visitor is blocked from the website. |
| 37 |
* |
| 38 |
* @param int $minutes |
| 39 |
* @param int $blockTime |
| 40 |
* @param int $attempts |
| 41 |
* @return bool |
| 42 |
*/ |
| 43 |
public function isBlocked($minutes, $blockTime, $attempts) |
| 44 |
{ |
| 45 |
return false; |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Force exit the page when a request has been blocked. |
| 50 |
* |
| 51 |
* @param int $ruleId |
| 52 |
* @return void |
| 53 |
*/ |
| 54 |
public function forceExit($ruleId) |
| 55 |
{ |
| 56 |
exit; |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* Get the IP address of the request. |
| 61 |
* |
| 62 |
* @return string |
| 63 |
*/ |
| 64 |
public function getIpAddress() |
| 65 |
{ |
| 66 |
return '127.0.0.1'; |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Determine if the request should not go through the firewall. |
| 71 |
* |
| 72 |
* @param array $whitelistRules |
| 73 |
* @param array $request |
| 74 |
*/ |
| 75 |
public function isWhitelisted($whitelistRules, $request) |
| 76 |
{ |
| 77 |
return false; |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* Get the hostname of the environment. |
| 82 |
* This is only used for open redirect vulnerabilities. |
| 83 |
* |
| 84 |
* @return string |
| 85 |
*/ |
| 86 |
public function getHostName() |
| 87 |
{ |
| 88 |
return 'wordpress.test'; |
| 89 |
} |
| 90 |
|
| 91 |
/** |
| 92 |
* Determine if the current request is a file upload request. |
| 93 |
* |
| 94 |
* @return boolean |
| 95 |
*/ |
| 96 |
public function isFileUploadRequest() |
| 97 |
{ |
| 98 |
return false; |
| 99 |
} |
| 100 |
} |
| 101 |
|