Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checksum validation for dbip #22

Merged
merged 4 commits into from
Jan 4, 2022
Merged

Add checksum validation for dbip #22

merged 4 commits into from
Jan 4, 2022

Conversation

chr0mag
Copy link
Owner

@chr0mag chr0mag commented Jan 4, 2022

The valid checksum is pulled directly from the dbip webpage via screen scrape as its not available as a direct download. For this reason a new command line flag (--checksum/--no-checksum) has been added. In the event a change in the webpage breaks checksum validation, the --no-checksum flag will allow geoipsets to continue working.

For consistency the flags apply to MaxMind as well.

This is a command line flag only and is not honoured when present in the configuration file.

Fixes #12

Julian Phillips added 4 commits January 1, 2022 18:18
Uses the BeautifulSoup4 library to scrape the sha1sum from the dbip
webpage. Unfortunately no checksums are downloadable as files.
Option exists because the dbip checksum is retrieved via screen
scrape. If the page changes, checksum validation will fail. In that
case, the --no-checksum option can be used to workaround the issue
until a fix is available.

The flag applies to the MaxMind provider as well for consistency.

Minor refactoring of maxmind.py:
 - use requests instead of urllib for downloads
 - pass file to be checksum'd all at once instead of 4K chunks
Moved hash calculations to read in files in 8K chunks. This doesn't
change much for MaxMind since the hash is calculated over the compressed
file (~4MB). For Dbip the hash is calculated over the uncompressed
file (~25MB) and reading all that into memory at once is unecessary.
For Python 3.8 compatibility. BooleanOptionalAction was added in
Python 3.9.
@chr0mag chr0mag merged commit 3ca7b3e into main Jan 4, 2022
@chr0mag chr0mag deleted the dbip-checksum branch January 4, 2022 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DBIP] validate download checksum
1 participant