for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Someshwer\Firewall\Lib;
/**
* This class filters ips forwarded from FirewallMiddleware.
*
* IPFilter class
*/
class IPFilter
{
* Determines whether to block current request or not.
* @var bool
private $block;
* Sets the constant to 'BLACKLIST'.
* @var string
private $black_list;
* Sets the constant to 'WHITELIST'.
private $white_list;
* Sets the constant to 'NONE'.
private $none;
* Constructor function.
public function __construct()
$this->block = true;
$this->black_list = 'BLACKLIST';
$this->white_list = 'WHITELIST';
$this->none = 'NONE';
}
* Returns one of the filter type i.e; 'BLACKLIST', 'WHITELIST', or 'NONE'.
* @return string $list
public function getFilterType()
$filter_type = $this->none;
if (config('firewall.enable_whitelist') && config('firewall.enable_blacklist')) {
config
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
if (/** @scrutinizer ignore-call */ config('firewall.enable_whitelist') && config('firewall.enable_blacklist')) {
$filter_type = $this->black_list;
if (config('firewall.enable_whitelist') && (!config('firewall.enable_blacklist'))) {
$filter_type = $this->white_list;
if (config('firewall.enable_blacklist') && (!config('firewall.enable_whitelist'))) {
return $filter_type;
* Filters whitelist and returns 'true' if current request ip is not in whitelist.
* @param object $request
* @return bool
public function filterWhiteList($request)
if (in_array($request->ip(), config('firewall.whitelist'))) {
if (in_array($request->ip(), /** @scrutinizer ignore-call */ config('firewall.whitelist'))) {
return $this->block;
return false;
* Filters blacklist and returns 'true' if current request ip is available in blacklist.
* @param [type] $request
[type]
0
public function filterBlackList($request)
if (in_array($request->ip(), config('firewall.blacklist'))) {
if (in_array($request->ip(), /** @scrutinizer ignore-call */ config('firewall.blacklist'))) {