Page MenuHomePhabricator

Ensure the number 0 is a valid value for formattedData
Closed, ResolvedPublic

Assigned To
Authored By
wikitrent
Oct 18 2021, 2:44 PM
Referenced Files
F34724672: false_contribs.png
Nov 2 2021, 2:38 PM
F34724651: zero_popup.png
Nov 2 2021, 2:38 PM
F34724679: null_2_popup.png
Nov 2 2021, 2:38 PM
F34724670: false_popup.png
Nov 2 2021, 2:38 PM
F34724666: null_contribs.png
Nov 2 2021, 2:38 PM
F34724655: zero_contribs.png
Nov 2 2021, 2:38 PM
F34724682: false_2_popup.png
Nov 2 2021, 2:38 PM
F34724663: null_popup.png
Nov 2 2021, 2:38 PM

Description

We could be passing along a 0 in these data points which would be considered falsy even though that's a valid value that's coming back. (formattedData) in ipInfo/widget.js needs to consider 0 as valid.

Event Timeline

Being bold and assigning Trent since @phuedx said y'all were going to take care of it as part of your current patch

@STran I've verified that inputting 0 as a value seems to trigger the appropriate messages/data. Was there anything else I need to do on this ticket specifically?

moving to QA because I'm not able to find any 0 registering as falsey.

I am not sure what we are wanting to test here. I am guessing we want to see how IPInfo handles various types of data.

I set up an intercepting proxy (OWASP ZAP) so I could modify the response the browser is getting from the IPInfo API.

Here are some examples (all tested on beta):

Zeros:

{
  "info": [
    {
      "subject": "<removed>",
      "data": [
        {
          "source": "ipinfo-source-geoip2",
          "coordinates": {
            "latitude": 39.4439,
            "longitude": -104.8515
          },
          "asn": 0,
          "organization": 0,
          "location": [
            {
              "id": 0,
              "label": 0
            },
            {
              "id": 0,
              "label": 0
            }
          ],
          "isp": 0,
          "connectionType": 0,
          "proxyType": {
            "isAnonymous": 0,
            "isAnonymousVpn": 0,
            "isPublicProxy": 0,
            "isResidentialProxy": 0,
            "isLegitimateProxy": 0,
            "isTorExitNode": 0
          }
        },
        {
          "source": "ipinfo-source-block",
          "numActiveBlocks": 0
        },
        {
          "source": "ipinfo-source-contributions",
          "numLocalEdits": 0,
          "numRecentEdits": 0
        }
      ]
    }
  ]
}

zero_popup.png (205×326 px, 15 KB)

zero_contribs.png (299×257 px, 11 KB)

{
  "info": [
    {
      "subject": "<removed>",
      "data": [
        {
          "source": "ipinfo-source-geoip2",
          "coordinates": 0,
          "asn": 0,
          "organization": 0,
          "location": 0,
          "isp": 0,
          "connectionType": 0,
          "proxyType": 0
        },
        {
          "source": "ipinfo-source-block",
          "numActiveBlocks": 0
        },
        {
          "source": "ipinfo-source-contributions",
          "numLocalEdits": 0,
          "numRecentEdits": 0
        }
      ]
    }
  ]
}

zero_2_popup.png (40×335 px, 829 B)

Nulls:

{
  "info": [
    {
      "subject": "<removed>",
      "data": [
        {
          "source": "ipinfo-source-geoip2",
          "coordinates": {
            "latitude": null,
            "longitude": null
          },
          "asn": null,
          "organization": null,
          "location": [
            {
              "id": null,
              "label": null
            },
            {
              "id": null,
              "label": null
            }
          ],
          "isp": null,
          "connectionType": null,
          "proxyType": {
            "isAnonymous": null,
            "isAnonymousVpn": null,
            "isPublicProxy": null,
            "isResidentialProxy": null,
            "isLegitimateProxy": null,
            "isTorExitNode": null
          }
        },
        {
          "source": "ipinfo-source-block",
          "numActiveBlocks": null
        },
        {
          "source": "ipinfo-source-contributions",
          "numLocalEdits": null,
          "numRecentEdits": null
        }
      ]
    }
  ]
}

null_popup.png (204×326 px, 15 KB)

null_contribs.png (298×238 px, 11 KB)

{
  "info": [
    {
      "subject": "<removed>",
      "data": [
        {
          "source": "ipinfo-source-geoip2",
          "coordinates": null,
          "asn": null,
          "organization": null,
          "location": null,
          "isp": null,
          "connectionType": null,
          "proxyType": null
        },
        {
          "source": "ipinfo-source-block",
          "numActiveBlocks": null
        },
        {
          "source": "ipinfo-source-contributions",
          "numLocalEdits": null,
          "numRecentEdits": null
        }
      ]
    }
  ]
}

null_2_popup.png (41×333 px, 805 B)

Falses:

{
  "info": [
    {
      "subject": "127.0.0.1",
      "data": [
        {
          "source": "ipinfo-source-geoip2",
          "coordinates": false,
          "asn": false,
          "organization": false,
          "location": [],
          "isp": false,
          "connectionType": false,
          "proxyType": false
        },
        {
          "source": "ipinfo-source-block",
          "numActiveBlocks": false
        },
        {
          "source": "ipinfo-source-contributions",
          "numLocalEdits": false,
          "numRecentEdits": false
        }
      ]
    }
  ]
}

false_popup.png (208×332 px, 16 KB)

false_contribs.png (298×220 px, 12 KB)

{
  "info": [
    {
      "subject": "<removed>",
      "data": [
        {
          "source": "ipinfo-source-geoip2",
          "coordinates": {
            "latitude": false,
            "longitude": false
          },
          "asn": false,
          "organization": false,
          "location": [
            {
              "id": false,
              "label": false
            },
            {
              "id": false,
              "label": false
            }
          ],
          "isp": false,
          "connectionType": false,
          "proxyType": {
            "isAnonymous": false,
            "isAnonymousVpn": false,
            "isPublicProxy": false,
            "isResidentialProxy": false,
            "isLegitimateProxy": false,
            "isTorExitNode": false
          }
        },
        {
          "source": "ipinfo-source-block",
          "numActiveBlocks": false
        },
        {
          "source": "ipinfo-source-contributions",
          "numLocalEdits": false,
          "numRecentEdits": false
        }
      ]
    }
  ]
}

false_2_popup.png (213×331 px, 18 KB)

This is obviously only testing the client-side of IPInfo.

To test the server-side, I am currently searching through the Max Mind databases for example IPs which return different datatypes, but this will take a while as there is a lot of data.

@wikitrent What do you think?

@dom_walden That's more thorough than anything I thought of, so as long as it's still working that's great on the client side. I'm not sure of another way to test the server side other than what you've suggested.

For the server-side part of this, I used a script to try to find IPs in MaxMind which return different combinations of datatypes for the different data points (ISP, ASN, etc.)

I then checked what response we were getting from the IPInfo API for each of those IPs (using this script).

The way the API handled different types of data seemed reasonable to me and matched the results I was getting from MaxMind using my own script.

I also checked the IPInfo popup for each of those IP addresses. Again, null data appeared to be handled the way I expect.

I don't think I can publish the raw data publicly because it contains personal or licensed data, but I will make it available to the AHT team privately.

Test Environment: local docker IP Info 0.0.0 (6509358) 08:33, 1 November 2021.