Repository navigation
Fix created/updated dates and address in RDAP whois nets - #960
Open
Allen Joseph G (unknownhackerworld) wants to merge 1 commit into
Open
Allen Joseph G (unknownhackerworld) wants to merge 1 commit into
Allen Joseph G (unknownhackerworld) wants to merge 1 commit into
Conversation
_create_net reset both created and updated on every RDAP event, and mapped "last changed" to created and "registration" to updated. With ARIN's usual event order (last changed, then registration) the net ended up with created=None and updated set to the registration date. Map "registration" to created and "last changed" to updated, matching the ipwhois field meaning, and stop resetting the value on other events. The address was also overwritten by every entity, so a trailing entity without an address cleared the registrant's address. Keep the first address found. Treat events and entities as optional, since RDAP does not require them. Signed-off-by: Allen Joseph G <63872540+unknownhackerworld@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_create_netinmsticpy/context/ip_utils.pybuilds thenetsentries thatip_whoisreturns from RDAP data. Two loops in it lose data.Event dates. Each RDAP event reset both
createdandupdated, and the mapping was reversed ("last changed"went tocreated,"registration"toupdated):Only the last event survives. ARIN lists
"last changed"before"registration", so for the existingRDAP_RESPONSEfixture (13.64.0.0, MSFT) the result iscreated=Noneandupdated="2015-03-26T13:58:18-04:00", which is the registration date. Expected iscreated="2015-03-26T13:58:18-04:00"andupdated="2021-12-14T20:28:53-05:00", matching what thecreated/updatedfields meant in the oldipwhoisnets output.Address. The entities loop assigned
address = _find_address(entity)for every entity, so any later entity without an address set it back toNone. With the same fixture the registrant's "One Microsoft Way..." address is dropped andaddresscomes backNone.Fix
"registration"tocreatedand"last changed"toupdated, and only assign on a matching event, so the order of events does not matter.data.get("events", [])/data.get("entities", []). Both are optional members in RDAP (RFC 9083), and a response without them raisedKeyError.Testing
test_create_net_event_dates_and_addressintests/context/test_ip_utils.py. It checks the fixture'screated,updatedandaddress, the same with the events reversed, an extra trailing entity without an address, and a response with noeventsorentities. It fails onmain(createdisNone,updatedis the registration date,addressisNone) and passes with this change.python -m pytest tests/context/test_ip_utils.py: 6 passed.ruff checkpasses on both changed files.AI disclosure: this change was prepared with the help of an AI assistant (finding the bug, writing the patch, test and this description).