antonioribeiro/firewall

IP blacklisting broken (commit 0c901ed)

Closed this issue · 3 comments

Hello,

in our environment the IP blacklisting is not working.
We think we spotted the error, it's in the Firewall::isBlacklisted() method:

    /**
     * Check if IP is blacklisted.
     *
     * @param null $ip
     * @return bool
     */
    public function isBlacklisted($ip = null) {
        $list = $this->whichList($ip);
        return !$list == 'whitelist' &&
        $list == 'blacklist';
    }

The boolean expression at the end returns FALSE for IP's which are blacklisted
but not whitelisted.

The problem is caused by missing parentheses around the first comparison.
Correct would be:

return !($list == 'whitelist') &&
       $list == 'blacklist';

Best regards,
Anke

Version 0.5.3 is still working in our environment. The error seems to be in version 0.5.4 and 1.0.0.

I met the same problem and solved it by adding parentheses. You saved my day.