You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by PGNet Dev <pg...@gmail.com> on 2022/09/09 12:15:04 UTC

alternatives for deprecated Perl API support in SA's RelayCountry plugin + MaxMind GeoIP2 *.mmdb data?

i run

	spamassassin -V
	SpamAssassin version 3.4.6
	  running on Perl version 5.34.1

i maintain GeoIP2 data updates from MaxMind,

	systemctl status geoipdb
		○ geoipdb.service - update geoipdb service
		     Loaded: loaded (/etc/systemd/system/geoipdb.service; static)
		     Active: inactive (dead) since Tue 2022-08-30 14:55:17 EDT; 22s ago
		TriggeredBy: ● geoipdb.timer
		    Process: 34949 ExecStart=/usr/bin/geoipupdate (code=exited, status=0/SUCCESS)
		   Main PID: 34949 (code=exited, status=0/SUCCESS)
		        CPU: 265ms

which execs

	/usr/bin/geoipupdate

to maintain / populate

	tree /usr/share/GeoIP/
		/usr/share/GeoIP/
		├── GeoLite2-ASN.mmdb
		├── GeoLite2-City.mmdb
		└── GeoLite2-Country.mmdb

RelayCountry plugin is enabled / in use

	grep RelayCountry init.pre
		# RelayCountry - add metadata for Bayes learning, marking the countries
		loadplugin Mail::SpamAssassin::Plugin::RelayCountry

for use with the GeoIP2 data,

	https://github.com/apache/spamassassin/blob/39ea11b27b55f99a945d2542779175d393d35334/build/announcements/3.4.2.txt#L96
		"GeoIP2 support has been added to RelayCountry and URILocalBL plugins due
		 to GeoIP legacy API deprecations."

config points to the data above

	cat local.cf
		...
		ifplugin Mail::SpamAssassin::Plugin::RelayCountry
		  country_db_type GeoIP2
		  country_db_path /usr/share/GeoIP/GeoLite2-Country.mmdb
		  add_header all Relay-Country _RELAYCOUNTRY_
		endif
		...

source for RelayCountry.pm

	https://metacpan.org/dist/Mail-SpamAssassin/source/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm

includes,

	elsif ($country_db_type eq "GeoIP2") {
	    if (!$country_db_path) {
	      # Try some default locations
	      foreach (@{$opts->{conf}->{geoip2_default_db_path}}) {
	        if (-f $_) {
	          $country_db_path = $_;
	          last;
	        }
	      }
	    }
	    if (-f $country_db_path) {
	      eval {
	        require GeoIP2::Database::Reader;
	        $db = GeoIP2::Database::Reader->new(
	          file => $country_db_path,
	          locales => [ 'en' ]
	        );
	        die "unknown error" unless $db;
	        $db_info = sub {
	          my $m = $db->metadata();
	          return "GeoIP2 ".$m->description()->{en}." / ".localtime($m->build_epoch());
	        };
	        1;
	      } or do {
	        # Fallback to IP::Country::Fast
	        $@ =~ s/\s+Trace begun.*//s;
	        dbg("metadata: RelayCountry: GeoIP2: ${country_db_path} load failed: $@, trying IP::Country::Fast as fallback");
	        $country_db_type = "Fast";
	      }


which specifies 'require'

	require GeoIP2::Database::Reader;

which, checking @ https://metacpan.org/dist/GeoIP2/source/lib/GeoIP2/Database/Reader.pm, further requires,

	use Data::Validate::IP 0.25 qw( is_private_ip );
	use GeoIP2::Error::Generic;
	use GeoIP2::Error::IPAddressNotFound;
	use GeoIP2::Model::ASN;
	use GeoIP2::Model::AnonymousIP;
	use GeoIP2::Model::City;
	use GeoIP2::Model::ConnectionType;
	use GeoIP2::Model::Country;
	use GeoIP2::Model::Domain;
	use GeoIP2::Model::Enterprise;
	use GeoIP2::Model::Insights;
	use GeoIP2::Model::ISP;
	use GeoIP2::Types qw( Str );
	use MaxMind::DB::Reader 1.000000;

where

	https://metacpan.org/pod/MaxMind::DB::Reader

		Deprecated.
		The maintainer of this distribution has indicated that it is deprecated and no longer suitable for use.

and all (sub)modules under

	https://metacpan.org/dist/GeoIP2

		Deprecated.
		The maintainer of this distribution has indicated that it is deprecated and no longer suitable for use.

verifying, @ https://dev.maxmind.com/geoip/docs/web-services?lang=en, Perl support is in fact deprecated


	Language or Framework
	...
	Node.js
!!	Perl (deprecated) <--------------------------
	PHP
	Python
	Ruby
	...

What alternative, non-deprecated support, if any, exists, or is planned, for SA RelayCountry plugin usage with MaxMind GeoIP2 *.mmdb data?


Re: alternatives for deprecated Perl API support in SA's RelayCountry plugin + MaxMind GeoIP2 *.mmdb data?

Posted by PGNet Dev <pg...@gmail.com>.
fwiw,

> It'd be useful to hear from @maxmind what they're recommending ...

I received the following response from MaxMind support:

"
Thank you for contacting MaxMind support. Though I wouldn't be able to advise regarding the RelayCountry plugin, it's correct that our GeoIP2 Perl API has been deprecated. It will still receive fixes in the event of major bugs and security vulnerabilities, but it will not receive other updates. We don't have a particular date set for when we would completely end support.
  
You may possibly wish to try using MaxMind::DB::Reader directly (https://metacpan.org/pod/MaxMind::DB::Reader) as an alternative. It is similarly deprecated, but unlike GeoIP2::Database::Reader, it doesn't require updates to get access to new fields.
  
Otherwise, in case it may potentially be of interest,  there is a third party module available here:
https://metacpan.org/pod/IP::Geolocation::MMDB
"

Re: alternatives for deprecated Perl API support in SA's RelayCountry plugin + MaxMind GeoIP2 *.mmdb data?

Posted by PGNet Dev <pg...@gmail.com>.
-------- Original Message --------
From: Henrik K [mailto:hege@hege.li]
Sent: Friday, September 9, 2022 at 9:59 AM EDT
To: users@spamassassin.apache.org
Subject: alternatives for deprecated Perl API support in SA's RelayCountry plugin + MaxMind GeoIP2 *.mmdb data?

> On Fri, Sep 09, 2022 at 08:15:04AM -0400, PGNet Dev wrote:
>>
>> What alternative, non-deprecated support, if any, exists, or is planned,
>> for SA RelayCountry plugin usage with MaxMind GeoIP2 *.mmdb data?
> 
> As the database format should not ever change, there is no reason to assume
> the current code would break in the future.
> 
> Also, upcoming SpamAssassin 4.0 uses a much smaller subset of modules, only
> MaxMind::DB::Reader / MaxMind::DB::Reader::XS directly.

The maintainer, MaxMind, for even just both of those

  https://metacpan.org/pod/MaxMind::DB::Reader
  https://metacpan.org/pod/MaxMind::DB::Reader::XS

explicitly states the perl mods are "no longer suitable for use."

The database format is still in (planned) use and supported for other langs' APIs, just not supported for Perl.

If SA project choice is to continue to use the mods despite that statement, with no planned alternative, that's helpful to know.

It'd be useful to hear from @maxmind what they're recommending ...







Re: alternatives for deprecated Perl API support in SA's RelayCountry plugin + MaxMind GeoIP2 *.mmdb data?

Posted by Henrik K <he...@hege.li>.
On Fri, Sep 09, 2022 at 08:15:04AM -0400, PGNet Dev wrote:
>
> What alternative, non-deprecated support, if any, exists, or is planned,
> for SA RelayCountry plugin usage with MaxMind GeoIP2 *.mmdb data?

As the database format should not ever change, there is no reason to assume
the current code would break in the future.

Also, upcoming SpamAssassin 4.0 uses a much smaller subset of modules, only
MaxMind::DB::Reader / MaxMind::DB::Reader::XS directly.

https://metacpan.org/pod/MaxMind::DB::Reader::XS

"This module is deprecated and will only receive fixes for major bugs and
security vulnerabilities.  New features and functionality will not be
added."

So it still received updates if necessary.