| 1 |
<?php |
| 2 |
|
| 3 |
namespace Patchstack\Extensions; |
| 4 |
|
| 5 |
/** |
| 6 |
* Any extension must implement the methods of the interface. |
| 7 |
* Some CMS systems might implement some of the logic completely different than others. |
| 8 |
*/ |
| 9 |
interface ExtensionInterface |
| 10 |
{ |
| 11 |
/** |
| 12 |
* Log the request, this can be of type BLOCK, LOG or REDIRECT. |
| 13 |
* |
| 14 |
* @param int $ruleId |
| 15 |
* @param string $bodyData |
| 16 |
* @param string $blockType |
| 17 |
* @return void |
| 18 |
*/ |
| 19 |
public function logRequest($ruleId, $bodyData, $blockType); |
| 20 |
|
| 21 |
/** |
| 22 |
* Determine if the current visitor can bypass the firewall. |
| 23 |
* If $isMuCall is true, we MUST avoid any function calls that checks the current authorization of the user, |
| 24 |
* this includes current_user_can. Otherwise, a fatal error is thrown. |
| 25 |
* |
| 26 |
* @param bool $isMuCall |
| 27 |
* @return bool |
| 28 |
*/ |
| 29 |
public function canBypass($isMuCall); |
| 30 |
|
| 31 |
/** |
| 32 |
* Determine if the visitor is blocked from the website. |
| 33 |
* |
| 34 |
* @param int $minutes |
| 35 |
* @param int $blockTime |
| 36 |
* @param int $attempts |
| 37 |
* @return bool |
| 38 |
*/ |
| 39 |
public function isBlocked($minutes, $blockTime, $attempts); |
| 40 |
|
| 41 |
/** |
| 42 |
* Force exit the page when a request has been blocked. |
| 43 |
* |
| 44 |
* @param int $ruleId |
| 45 |
* @return void |
| 46 |
*/ |
| 47 |
public function forceExit($ruleId); |
| 48 |
|
| 49 |
/** |
| 50 |
* Get the IP address of the request. |
| 51 |
* Do NOT blindly rely on IP address headers which can be spoofed, such as X-Forwarded-For. |
| 52 |
* |
| 53 |
* @return string |
| 54 |
*/ |
| 55 |
public function getIpAddress(); |
| 56 |
|
| 57 |
/** |
| 58 |
* Get the hostname of the environment. |
| 59 |
* This is only used for open redirect vulnerabilities. |
| 60 |
* |
| 61 |
* @return string |
| 62 |
*/ |
| 63 |
public function getHostName(); |
| 64 |
|
| 65 |
/** |
| 66 |
* Determine if the request should be passed without going through the firewall. |
| 67 |
* |
| 68 |
* @param array $whitelistRules |
| 69 |
* @param array $request |
| 70 |
*/ |
| 71 |
public function isWhitelisted($whitelistRules, $request); |
| 72 |
|
| 73 |
/** |
| 74 |
* Determine if the current request is a file upload request. |
| 75 |
* |
| 76 |
* @return boolean |
| 77 |
*/ |
| 78 |
public function isFileUploadRequest(); |
| 79 |
} |
| 80 |
|