Skip to content

Add JSON MD5 hash to AWSIPPrefixes

Compare
Choose a tag to compare
@cmlccie cmlccie released this 02 Oct 02:37
· 3 commits to main since this release
6e3fa1a

JSON MD5 hash

This release adds a new .md5 attribute to the AWSIPPrefixes class that provides access to the computed MD5 hex digest of the downloaded JSON file. You can compare the computed MD5 hash with the MD5 hash provided by the AmazonIpSpaceChanged notifications to verify the integrity of the downloaded JSON file.

Notification JSON:

{
  "create-time":"2021-10-01T16:33:13+00:00",
  "synctoken":"1633105993",
  "md5":"59e4cd7f4757a9f380c626d772a5eef2",
  "url":"https://ip-ranges.amazonaws.com/ip-ranges.json"
}

AWSIPPrefixes collection:

{
 'create_date': datetime.datetime(2021, 10, 1, 16, 33, 13, tzinfo=datetime.timezone.utc),
 'ipv4_prefixes': (...),
 'ipv6_prefixes': (...),
 'md5': '59e4cd7f4757a9f380c626d772a5eef2',
 'sync_token': '1633105993',
}

New library exceptions

Added HTTP response error checking and a custom library exception hierarchy. awsipranges.get_ranges() will now raise an awsipranges.HTTPError exception for 4xx and 5xx HTTP response codes when downloading the JSON file. All awsipranges custom exceptions are subclasses of the AWSIPRangesException base exception class.