Coder Social home page Coder Social logo

stklcode / statify-blacklist Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 699 KB

Filter extension for the Statify WordPress plugin

Home Page: https://wordpress.org/plugins/statify-blacklist/

License: GNU General Public License v2.0

PHP 100.00%
blacklist-extension filter referrer-spam statify wordpress-plugin

statify-blacklist's People

Contributors

stklcode avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

alexclassroom

statify-blacklist's Issues

Referer blacklist incomplete for countries using ccSLD

The current filter strips sld.tld from referer URLs. The idea was to simplify wildcard filters for spammers using multiple subdomains as server1.example.com, server2.example.com , etc.

This filter rule obviously does not work for country-code secold-level-domains as example.co.uk.

Filter has to be expanded to at least 3 parts or dropped completely.

Filter not hooked, if refer filter is disabled

With the changes in v1.4.1 it is now possible to filter target pages and IPs. Unfortunately the appender still checks for the availability of referer live filtering.

This check has to be corrected to add the filter if any (live) blacklist is activated.

Regular expression filters

Add the ability to filter by regular expressions instead of (or in addition to?) domain in_array check.

Performance is far worse than the simple filter, so not recommended for live filtering, but using cron or manual clean-up is should be fine.

Opt-In Feature: Collect IP addresses of spammers for auto-blacklist

Feature suggested in the WP support forums (https://wordpress.org/support/topic/blacklisten-bitte-zur-auswahl-stellen/#post-10381313 - German).

IP addresses of blocked visitors (by any metric except IP-blacklist itself) should be collected in a local blacklist (similar to the approach of AntispamBee for comments) and automatically excluded from tracking.

This feature has to be an opt-in and store addresses anonymized (at least a salted hash) to not break GDPR compliance.

Add geolocation-based filtering

Feature request from WP support forums: https://wordpress.org/support/topic/great-feature-request/

Introduce a feature to white- or blacklist requests from certain countries from tracking.

To achieve this, a geolocation service has to be integrated and processed during live filter - cron cleanup is not possible here because the IP is not saved.

Such service might be MaxMind GeoIP2 which provides a nice PHP API1. Keep in mind the latest changes for database usage2.

[1] https://maxmind.github.io/GeoIP2-php/
[2] https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-geolite2-databases/

Evaluate and improve hook performance

In 1.1.x the filter hook splits referer domain by dot and runs the last 2 parts (sld.tld) against a blacklist using in_array(). It's fast, but it can be faster, as the hook is exeuted on every visit.

Some evaluation hast to be made to compare different methods in a real-world scenario (about a dozen blacklisted domains with a small percentage of hits).

First improvement in develop branch is the switch from in_array() to isset() by flipping the array.

CleanUp Database broken in v1.7

Received a bug report with reproducible misbehavior in v1.7.0.

Seems the "CleanUp Database" feature is broken after rewriting the settings page.

There's a problem with the plugin, as of 1.7 the 'CleanUp Database' is not working any more.
After roll back to 1.6.3 it's working again.
Verified on WP 5.0.x and WP 6.4.x, both with Statify 1.8.4.

The setting file is completely rewritten and it's difficult to compare with the former one. But it looks like you forgot the call of the cleanup function.

Bump required WordPress version to 4.4

As part of v1.4.1 parse_url() has been changed to wp_parse_url() which requires at least WP 4.4 (second parameter as of 4.7 is not used here).

This change has already been published without community complains (and Statify itself is requires 4.7 as of 1.5.2), so just change the README file here and don't revert any code if not necessary.

IP filtering

In addition to the existing referer blacklist, an optional IP address filter should be implemented.

Requirements

  • efficient matching on single addresses and subnets
  • compatibility with both IPv4 and IPv6 addresses
  • comfortable input (e.g. CIDR notation and/or ranges)

Limitations
Since addresses are not stored, this filter can only be applied during live filtering.
For a consistent UI experience, the input form has to be adapted to that.

Live filter configuration inverted

Due to an added check in a previous commit that should disable the live filter completely if not activated, the condition is inverted.

if ( self::$_options['active_referer'] != 1 ) {
    add_filter( 'statify_skip_tracking', array( 'StatifyBlacklist', 'apply_blacklist_filter' ) );
}

Obviously it should be != 0, seems to be copy&paste mistake from the filter method itself.

Multisite installation fails

On multisite installations the activation hook for new sites references a non-existing method StatifyBlacklist_Install::init_site().

Second issue is triggered on network wide activation. For compatibility with WP < 4.6 a fallback to wp_get_sites() is called, which generates an array of associative arrays, while get_sites() returns an array of WP_Site objects, hence $site['blog_id'] and $site->blog_id both fail in one case.

Validate regular expressions before saving

When using regular expressions, the filter strings are simply saved to database. This raises a warning from preg_match() when an expression is invalid or clashes with delimiters /.

These expresions should be validated before saving or - if possible - sanitized (analog to URL sanitization for non-regex referrer filter) to avoid such warnings.

Target filter

Analogous to the referer filter, a target filter might be a handy feature to exclude certain pages or posts from tracking.

Skimming over the table there are always a couple of requests to suspicious pages in the admin area that usually end up in a 404 state and thus not recognized as admin pages (that are filtered out by Statify itself) and also a handful of requests to /.git/ or /.well-known/ locations.

The filter mechanisms can be the same as for referer (live, cron, regexp, manual cleanup).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.