python-whois icon indicating copy to clipboard operation
python-whois copied to clipboard

Linux whois "getaddrinfo" causes exception even when results occur.

Open DeepMac opened this issue 3 years ago • 3 comments

Describe the bug

When a registrar has populated their "Registrar WHOIS Server" field with an incorrectly formatted server name, a linux whois client may return an error regarding name resolution failure such as this: getaddrinfo(https://www.arsys.es/dominios/whois): Name or service not known However the information for the requested domain is still returned. The _do_whois_query() function however detects the error code returned by the whois query and presumes the query failed and raises an exception.

To Reproduce

Steps to reproduce the behavior:

  1. Use the module to perform a query on the domain "custler.com"
  2. Observe a traceback error occurs followed by legitimate whois results

Expected behavior

The legitimate output would be parsed accordingly.

Screenshots

Python 3.8.10 (default, Nov 26 2021, 20:14:08)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import whois
>>> dom = whois.query("custler.com")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/dnschecks/whois/__init__.py", line 106, in query
    pd = do_parse(do_query(d, force, cache_file, slow_down, ignore_returncode), tld)
  File "/home/user/dnschecks/whois/_1_query.py", line 46, in do_query
    _do_whois_query(dl, ignore_returncode),
  File "/home/user/dnschecks/whois/_1_query.py", line 81, in _do_whois_query
    raise WhoisCommandFailed(r)
whois.exceptions.WhoisCommandFailed: getaddrinfo(https://www.arsys.es/dominios/whois): Name or service not known
   Domain Name: CUSTLER.COM
   Registry Domain ID: 2434195838_DOMAIN_COM-VRSN
   Registrar WHOIS Server: https://www.arsys.es/dominios/whois
   Registrar URL: http://www.arsys.es
   Updated Date: 2021-09-18T07:20:25Z
   Creation Date: 2019-09-17T15:36:26Z
   Registry Expiry Date: 2022-09-17T15:36:26Z
   Registrar: Arsys Internet, S.L. dba NICLINE.COM
   Registrar IANA ID: 379
   Registrar Abuse Contact Email: [email protected]
   Registrar Abuse Contact Phone: +34 941 620 100
   Domain Status: ok https://icann.org/epp#ok
   Name Server: NS1.DIGITALOCEAN.COM
   Name Server: NS2.DIGITALOCEAN.COM
   Name Server: NS3.DIGITALOCEAN.COM
   DNSSEC: unsigned
   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/
>>> Last update of whois database: 2022-02-09T07:24:30Z <<<

For more information on Whois status codes, please visit https://icann.org/epp

NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar.  Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.

TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability.  VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.

The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.

DeepMac avatar Feb 09 '22 19:02 DeepMac

confirmed also on Mac with io.io

DannyCork avatar May 18 '22 15:05 DannyCork

added it to the test.py

maarten-boot avatar Jun 09 '22 13:06 maarten-boot

actually the flag: ignore_returncode=True will fix this

maarten-boot avatar Jun 10 '22 11:06 maarten-boot

using the new test program test2.py we can see that this has been solved no data is returned as the domain no longer exists

[mboot@PC-MBOOT python-whois]$  ./test2.py -v -d custler.com
## ===== TEST DOMAINS
--------------------------------------------------------------------------------
custler.com
['custler', 'com']
['custler', 'com']
None
[mboot@PC-MBOOT python-whois]$  ./test2.py -v -I -d custler.com
## ===== TEST DOMAINS
--------------------------------------------------------------------------------
custler.com
['custler', 'com']
['custler', 'com']
None

maarten-boot avatar Sep 27 '22 11:09 maarten-boot

io.io will give

[mboot@PC-MBOOT python-whois]$  ./test2.py -d io.io
## ===== TEST DOMAINS
--------------------------------------------------------------------------------
io.io
                name	"io.io"
                 tld	"io"
           registrar	"Donuts Internal (9998)"
  registrant_country	"GB"
       creation_date	"1998-03-19 00:00:00"
     expiration_date	"2027-05-01 00:00:02"
        last_updated	"2021-12-16 20:20:18"
              status	"serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited"
            statuses	"['serverRenewProhibited https://icann.org/epp#serverRenewProhibited', 'serverTransferProhibited https://icann.org/epp#serverTransferProhibited', 'serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited', 'serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited']"
              dnssec	"False"
        name_servers	"['hosting1.cdns.net', 'hosting2.cdns.net', 'hosting3.cdns.net', 'hosting4.cdns.net']"
          registrant	"INTERNET ONE"
[mboot@PC-MBOOT python-whois]$ 

maarten-boot avatar Sep 27 '22 11:09 maarten-boot

This is actually a error in whois cli command itself not in python-whois, the only way to ignore this is by using the ignore_returncode=True when calling whois.query().

The "Registrar WHOIS Server" will be queried for a result and if the server is wrongly configured this error is the result of a wrongly configured whois entry.

Also the 2 examples given now have a correct whois response so the problem has gone away.

I suggest to close the ticket.

maarten-boot avatar Nov 07 '22 21:11 maarten-boot

Er, no that's not correct at all. Custler.com definitely still exists.

> whois custler.com
   Domain Name: CUSTLER.COM
   Registry Domain ID: 2434195838_DOMAIN_COM-VRSN
   Registrar WHOIS Server: https://www.arsys.es/dominios/whois
   Registrar URL: http://www.arsys.es
   Updated Date: 2022-09-18T07:29:05Z
   Creation Date: 2019-09-17T15:36:26Z
   Registry Expiry Date: 2023-09-17T15:36:26Z
   Registrar: Arsys Internet, S.L. dba NICLINE.COM
   Registrar IANA ID: 379
   Registrar Abuse Contact Email: [email protected]
   Registrar Abuse Contact Phone: +34 941 620 100
   Domain Status: ok https://icann.org/epp#ok
   Name Server: NS1.DIGITALOCEAN.COM
   Name Server: NS2.DIGITALOCEAN.COM
   Name Server: NS3.DIGITALOCEAN.COM
   DNSSEC: unsigned
   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/
>>> Last update of whois database: 2022-11-08T23:19:05Z <<<

I'm using Ubuntu 20.04.5 LTS with whois version 5.5.6 (https://ubuntu.pkgs.org/20.04/ubuntu-main-amd64/whois_5.5.6_amd64.deb.html)

I can't speak for any other whois binary clients. In the case of "custler.com" the registrar does have the info wrong, but the whois client itself still returns correct information.

So. Fingerprinting of the client version and capability may need to go on the roadmap. :/

DeepMac avatar Nov 08 '22 23:11 DeepMac

my apologies for any misunderstanding, i was not trying to suggest that the domain does not exist anymore but that the error has gone away, using the flag ignore_returncode=True should meanwhile be able to handle this issue without any side effects.

by the way from my Fedora36 there still is no data at all from whois (see below) but there is no longer a error in whois or in python-whois.

i expect that the whois server for this domain uses the new RDAP (https://www.icann.org/rdap) which is actually communicating over HTTP but that is another standard. The implementation of the current python-whois simply uses the native whois of the host and there are no plans currently to implement it in a different way. Possibly a future proof way to handle this is to look at current python libraries that speak RDAP.

whois custler.com [Querying whois.verisign-grs.com] [Redirected to https://www.arsys.es/dominios/whois] [Querying https://www.arsys.es/dominios/whois] [https://www.arsys.es/dominios/whois: Name or service not known] [Unable to connect to remote host]

host www.arsys.es www.arsys.es is an alias for arsys.es. arsys.es has address 217.76.128.28 arsys.es mail is handled by 10 llsk489-a90.servidoresdns.net. arsys.es mail is handled by 10 llsk488-a90.servidoresdns.net.

$ python Python 3.10.7 (main, Sep 7 2022, 00:00:00) [GCC 12.2.1 20220819 (Red Hat 12.2.1-1)] on linux Type "help", "copyright", "credits" or "license" for more information.

import whois d = whois.query("custler.com") print(d) None

maarten-boot avatar Nov 09 '22 09:11 maarten-boot

No worries, thanks for the clarification. And you are likely right about the RDAP. The challenge for any python module is of course, do you implement the protocol in pure python and take-on all that extra maintenance or just rely on another module/binary?

DeepMac avatar Nov 09 '22 16:11 DeepMac