Skip to content

Commit

Permalink
Update PHPDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
riverside committed Jul 8, 2023
1 parent fe990a6 commit 2f09bd7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/BaseFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
abstract class BaseFilter
{
/**
* Payloads
*
* @var array
*/
protected $payloads = array();

/**
* Payload filename
*
* @var string
*/
protected $payloads_file = "";
Expand Down
2 changes: 2 additions & 0 deletions src/Filter/CRLF.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
class CRLF extends BaseFilter
{
/**
* Payload filename
*
* @var string
*/
protected $payloads_file = "crlf.txt";
Expand Down
2 changes: 2 additions & 0 deletions src/Filter/SQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
class SQL extends BaseFilter
{
/**
* Payload filename
*
* @var string
*/
protected $payloads_file = "sql.txt";
Expand Down
2 changes: 2 additions & 0 deletions src/Filter/XML.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
class XML extends BaseFilter
{
/**
* Payload filename
*
* @var string
*/
protected $payloads_file = "xml.txt";
Expand Down
2 changes: 2 additions & 0 deletions src/Filter/XSS.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
class XSS extends BaseFilter
{
/**
* Payload filename
*
* @var string
*/
protected $payloads_file = "xss.txt";
Expand Down
22 changes: 18 additions & 4 deletions src/Firewall.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ public function disable(string $filter): Firewall
* @param string $value
* @param string $filter
* @return Firewall
* @throws \Exception
*/
public function handle(string $value, string $filter): Firewall
{
Expand All @@ -212,21 +213,34 @@ public function handle(string $value, string $filter): Firewall
}

/**
* Runs a given filter
* Get filter's instance
*
* @param string $filter
* @return Firewall
* @return BaseFilter
* @throws \Exception
*/
public function runFilter(string $filter): Firewall
public function getFilterInstance(string $filter): BaseFilter
{
if (!array_key_exists($filter, $this->getFilters()))
{
throw new \Exception("Unknown filter {$filter}.");
}

$class = "PhpWaf\\Filter\\$filter";
$instance = new $class;

return new $class;
}

/**
* Runs a given filter
*
* @param string $filter
* @return Firewall
* @throws \Exception
*/
public function runFilter(string $filter): Firewall
{
$instance = $this->getFilterInstance($filter);

foreach ($_GET as $key => $val)
{
Expand Down

0 comments on commit 2f09bd7

Please sign in to comment.