Page MenuHomePhabricator

Normalise IP address when checking if IP address in response matches
Closed, ResolvedPublic2 Estimated Story Points

Description

IPInfo's API endpoints return a response mapping an IP address to some data about the IP address.

Before displaying the data, we check that the IP address returned matches the IP address on the page; however the address is not normalised before this check. That can result in incorrectly showing an error: "The IP address provided did not match the log or revision."

Event Timeline

ARamirez_WMF set the point value for this task to 2.Nov 4 2020, 5:15 PM
Niharika triaged this task as Medium priority.Nov 4 2020, 5:16 PM

@STran I had been hoping we could normalise the IP addresses in the client using a utility method; however, I think I was wrong about such a method being available. (There are some other methods for detecting IP addresses - see util.js or try mw.util in the console.)

Instead we can use IPUtils::prettifyIP in the InfoManager - that should ensure that the IP address in the response is in the same "prettified" format as in the DOM.

Change 642591 had a related patch set uploaded (by STran; owner: STran):
[mediawiki/extensions/IPInfo@master] Normalize IP addresses returned from GeoIP2

https://gerrit.wikimedia.org/r/642591

Change 642591 merged by jenkins-bot:
[mediawiki/extensions/IPInfo@master] Normalize IP addresses returned from GeoIP2

https://gerrit.wikimedia.org/r/642591

@STran @Tchanders Do we know if all IPs are "prettified" in the same way everywhere we might use IPInfo?

For example, they don't appear to be for all the columns in the Special:Investigate Compare and Timeline tabs. Is the plan to add this to Special:Investigate? Or perhaps we should cross that bridge when we come to it.

special_investigate.png (143×1 px, 32 KB)

@dom_walden Thanks for pointing this out. I think the problem is with Special:Investigate not displaying the prettified IPs - filed as T268745.

Is the plan to add this to Special:Investigate?

@Niharika would know best, but I don't believe this is in our immediate plans.

It is now possible to see information about IPv6 IPs in the popup. I have not seen the The IP address provided did not match the log or revision error since this change.

Test environment: Vagrant MediaWiki 1.36.0-alpha (7410f4d), IP Info 0.0.0 (748907b).
Test browser: Firefox 78