matomo-org / matomo-org/plugin-TrackingSpamPrevention

Additionally block ISP/ASN

Open
#171 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
18
Forks
10
Avg merge
20h 11m
Merged PRs (30d)
1

Description

Hello,
I don't really understand, how works your filter for block tracking with ISP or ASN name.

You write:

> Additionally, some Cloud providers like Alibaba Cloud may be detected using the geolocation database (requires eg DB-IP City DB).

It is possible in matomo to activate a Geolocation database instead using the browser language setting for visitor location.
Settings → System → Geolocation
but in the default settings by select "DBIP / GeoIP 2 (Php)" only the "DB-IP City Lite DB" (DP-IP IP to City Lite database) is activated in the section "Location Database" and no IP to ISP or IP to ASN in the section "ISP Database",
https://matomo.org/faq/how-to/setting-up-accurate-visitors-geolocation/
```
public static function getDbIpLiteUrl($type = 'city')
{
$today = Date::today();
return "https://download.db-ip.com/free/dbip-{$type}-lite-{$today->toString('Y-m')}.mmdb.gz";
}
```
https://github.com/matomo-org/matomo/blob/686abd235607cb21db15aa6969a0c4a9b37ddcfb/plugins/GeoIp2/LocationProvider/GeoIp2.php#L51

The DP-IP "IP to City Lite database" haven't included ISP or ASN names - in reference to your "(requires eg DB-IP City DB)".
https://db-ip.com/db/download/ip-to-city-lite

It is possible to use the "DB-IP ASN Lite DB" (DP-IP IP to ASN Lite database) in the section "ISP Database",
https://db-ip.com/db/download/ip-to-asn-lite
Tutorial: https://forum.matomo.org/t/trackingspamprevention-block-isp/65362
see also here: https://github.com/matomo-org/matomo/issues/23142

The blacklist of the ISP/ASN names is founded in the `global.ini.php` in the section:
```
[TrackingSpamPrevention]
block_geoip_organisations [] = "..."
```
Further questions about the manually expansion of the default blocked/filtered ISP/ASN names here:
https://github.com/matomo-org/plugin-TrackingSpamPrevention/issues/170

Your rule for additionally block ISP/ASN:
```
if (empty($this->blockedProviders) || !(\Piwik\Plugin\Manager::getInstance()->isPluginActivated('UserCountry'))) {
return false;
}
```
https://github.com/matomo-org/plugin-TrackingSpamPrevention/blob/5.x-dev/BlockedGeoIp.php#L63C1-L65C10
The rule `isPluginActivated('UserCountry')` is not enough. It must be setted a ISP/ASN Database in the Settings → System → Geolocation → Setup automatic updates of geolocation databases → ISP Database.

PS: The using of browser language for visitor location is a bug:
Matomo must be learn, that language is not location (see tourists, migrants, etc. ...).
https://github.com/matomo-org/matomo/issues/23139

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in BlockedGeoIp.php at the isPluginActivated('UserCountry') check, then review how the ISP/ASN database is configured through the Geolocation settings and how block_geoip_organisations is used. Confirm the behavior when UserCountry is active without an ISP/ASN database, and add or update coverage so ISP/ASN blocking only relies on available provider data.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
66/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.