pogzyb / asyncwhois

Python WHOIS and RDAP utility for querying and parsing information about Domains, IPv4s, IPv6s, and AS numbers
MIT License
63 stars 18 forks source link

Fix mismatched rdap keys #65

Closed pogzyb closed 1 year ago

pogzyb commented 1 year ago

Fixes:

codecov[bot] commented 1 year ago

Codecov Report

Attention: 38 lines in your changes are missing coverage. Please review.

Comparison is base (9dc7ad0) 88.62% compared to head (7b3260d) 85.84%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #65 +/- ## ========================================== - Coverage 88.62% 85.84% -2.78% ========================================== Files 8 8 Lines 2821 2960 +139 ========================================== + Hits 2500 2541 +41 - Misses 321 419 +98 ``` | [Files](https://app.codecov.io/gh/pogzyb/asyncwhois/pull/65?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Joe) | Coverage Δ | | |---|---|---| | [asyncwhois/parse\_rir.py](https://app.codecov.io/gh/pogzyb/asyncwhois/pull/65?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Joe#diff-YXN5bmN3aG9pcy9wYXJzZV9yaXIucHk=) | `31.73% <ø> (ø)` | | | [asyncwhois/query.py](https://app.codecov.io/gh/pogzyb/asyncwhois/pull/65?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Joe#diff-YXN5bmN3aG9pcy9xdWVyeS5weQ==) | `78.43% <100.00%> (ø)` | | | [asyncwhois/parse.py](https://app.codecov.io/gh/pogzyb/asyncwhois/pull/65?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Joe#diff-YXN5bmN3aG9pcy9wYXJzZS5weQ==) | `94.41% <92.85%> (-0.17%)` | :arrow_down: | | [asyncwhois/pywhois.py](https://app.codecov.io/gh/pogzyb/asyncwhois/pull/65?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Joe#diff-YXN5bmN3aG9pcy9weXdob2lzLnB5) | `44.66% <50.00%> (+1.93%)` | :arrow_up: | | [asyncwhois/parse\_tld.py](https://app.codecov.io/gh/pogzyb/asyncwhois/pull/65?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Joe#diff-YXN5bmN3aG9pcy9wYXJzZV90bGQucHk=) | `76.58% <74.07%> (-13.12%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

y-polyakov-ddl commented 5 months ago

This actually broke the functionality, advertised in the main README: both rdap methods now return None for bitcoin.org registrar. Reason:

def convert_whodap_keys(parser_output: dict) -> dict:
    conversions = [  # snip
        (TLDBaseKeys.REGISTRAR, "registrar_name", False),  # 'registrar'
    ]
    for asyncwhois_key, whodap_key, keep in conversions:
        if keep:
            parser_output[asyncwhois_key] = parser_output.get(whodap_key)
        else:
            parser_output[asyncwhois_key] = parser_output.pop(whodap_key)

    # at this point, parser_output['registrar'] is the registrar name

    non_whodap_keys = [
       TLDBaseKeys.REGISTRAR,  # also 'registrar'
    ]
    for key in non_whodap_keys:
        parser_output[key] = None  # overwrites any value present in parser_output

   # at this point, parser_output['registrar'] is None

The easiest fix would probably be to remove this key, present in conversions, from non_whodap_keys.

pogzyb commented 5 months ago

This actually broke the functionality, advertised in the main README: both rdap methods now return None for bitcoin.org registrar. Reason:

def convert_whodap_keys(parser_output: dict) -> dict:
    conversions = [  # snip
        (TLDBaseKeys.REGISTRAR, "registrar_name", False),  # 'registrar'
    ]
    for asyncwhois_key, whodap_key, keep in conversions:
        if keep:
            parser_output[asyncwhois_key] = parser_output.get(whodap_key)
        else:
            parser_output[asyncwhois_key] = parser_output.pop(whodap_key)

    # at this point, parser_output['registrar'] is the registrar name

    non_whodap_keys = [
       TLDBaseKeys.REGISTRAR,  # also 'registrar'
    ]
    for key in non_whodap_keys:
        parser_output[key] = None  # overwrites any value present in parser_output

   # at this point, parser_output['registrar'] is None

The easiest fix would probably be to remove this key, present in conversions, from non_whodap_keys.

Thanks for pointing this out! I added your suggestion and rolled it into v1.1.4.