mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-07-16 05:24:56 +00:00
Stop system GeoIP files from shadowing the bundled IPinfo database (#813)
* Stop system GeoIP files from shadowing the bundled IPinfo database _get_ip_database_path() searched well-known system paths (including /usr/share/GeoIP/GeoLite2-Country.mmdb and CWD-relative names) before the database parsedmarc manages, so on any host with a distro GeoIP package installed every lookup silently used a country-only — and often years-old — database instead of the bundled IPinfo Lite one. That disabled ASN enrichment entirely (asn/as_name/as_domain were None for every IP) and with it the ASN-fallback path into the reverse-DNS map, with no signal beyond a generic "IP database is more than a month old" warning. Verified live on a Fedora host whose distro GeoLite2-Country.mmdb dated to December 2019. New precedence: explicit ip_db_path -> _IP_DB_PATH selected by load_ip_db() (downloaded/cached/bundled) -> the bundled copy -> system paths as a true last resort (only consulted when the bundled data file is missing). The selected file is logged at debug level so a --debug run shows which database answered. The automatic system-path pickup was documented behavior, so installation.md now tells MaxMind GeoLite2 users to set ip_db_path explicitly, with a migration note. Both new regression tests reproduce the shadowing portably via a decoy CWD GeoLite2-Country.mmdb (the fallback list includes relative names), and fail on the unfixed code (verified by stashing the source change). Fixes https://github.com/domainaware/parsedmarc/issues/810. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Address review: accurate fallback comment, dedup selection log, cover fallback tiers - Correct the nothing-found-anywhere comment: the os.stat() age check raises FileNotFoundError before the caller's open_database() would. - Log "Using IP database at ..." only when the selected path changes instead of on every uncached IP lookup, so --debug runs over large batches aren't flooded; tracked via _LAST_LOGGED_IP_DB_PATH, reset in the test fixture for order-independence. - Cover the previously untested branches of _get_ip_database_path: system-path fallback when the bundled database is missing, the FileNotFoundError when nothing exists anywhere, the stale-database warning, and the log-once-per-path behavior. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: MISAPOR LAB <misapor@lab.misapor.pl> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: Sean Whalen <44679+seanthegeek@users.noreply.github.com>
This commit is contained in:
co-authored by
MISAPOR LAB
Claude Fable 5
Sean Whalen
parent
cdda5dae62
commit
7fed72798a
@@ -119,12 +119,28 @@ This installs the `msgconvert` script to `/usr/local/bin/msgconvert`.
|
||||
|
||||
## Using MaxMind GeoLite2 (optional)
|
||||
|
||||
`parsedmarc` will pick up the [MaxMind GeoLite2 Country database] if
|
||||
it is installed at one of the standard system paths (e.g.
|
||||
`/usr/share/GeoIP/GeoLite2-Country.mmdb`,
|
||||
`/var/lib/GeoIP/GeoLite2-Country.mmdb`, or the equivalent location on
|
||||
Windows). **Use this only if you specifically prefer MaxMind data over
|
||||
the bundled IPinfo Lite database — most users do not need it.**
|
||||
To use the [MaxMind GeoLite2 Country database] instead of the bundled
|
||||
IPinfo Lite database, point the `ip_db_path` option at it explicitly:
|
||||
|
||||
```ini
|
||||
[general]
|
||||
ip_db_path = /usr/share/GeoIP/GeoLite2-Country.mmdb
|
||||
```
|
||||
|
||||
**Use this only if you specifically prefer MaxMind data over the
|
||||
bundled IPinfo Lite database — most users do not need it.** Country
|
||||
databases like GeoLite2 carry no ASN data, so source attribution for
|
||||
IP addresses without reverse DNS is reduced when one is used.
|
||||
|
||||
:::{note}
|
||||
parsedmarc no longer picks up a GeoLite2/DBIP database from standard
|
||||
system paths (e.g. `/usr/share/GeoIP/GeoLite2-Country.mmdb`)
|
||||
automatically — a GeoIP file installed by an unrelated distro package
|
||||
would silently override the bundled database and disable ASN
|
||||
enrichment. System paths are now only consulted as a last resort when
|
||||
the bundled database is missing. If you previously relied on the
|
||||
automatic pickup, set `ip_db_path` as shown above.
|
||||
:::
|
||||
|
||||
Install [geoipupdate] for your platform:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user