dnspython icon indicating copy to clipboard operation
dnspython copied to clipboard

Basic public suffix list support.

Open rthalley opened this issue 1 year ago • 7 comments

rthalley avatar May 05 '24 19:05 rthalley

Codecov Report

Attention: Patch coverage is 84.78261% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 93.88%. Comparing base (bfd0919) to head (87765ce). Report is 5 commits behind head on main.

Files Patch % Lines
dns/psl.py 84.78% 9 Missing and 5 partials :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1082      +/-   ##
==========================================
- Coverage   93.92%   93.88%   -0.05%     
==========================================
  Files         143      144       +1     
  Lines       13435    13527      +92     
  Branches     2606     2627      +21     
==========================================
+ Hits        12619    12700      +81     
- Misses        480      488       +8     
- Partials      336      339       +3     
Flag Coverage Δ
unittests 93.84% <84.78%> (-0.05%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

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

codecov-commenter avatar May 05 '24 19:05 codecov-commenter

Hello! Out of curiosity, why this needs to be in dnspython?

I mean, there are at least two existing libraries for Python:

  • https://pypi.org/project/publicsuffix2/
  • https://pypi.org/project/publicsuffixlist/

I wonder if there is a way improve dnspython interoperability with these? Or what is even the problem?

pspacek avatar May 06 '24 07:05 pspacek

I don't know that it "needs" to be in dnspython, but it goes along well with other things dnspython provides. Of the examples you cite, one hasn't been updated since 2019, and both of them use split(".") to convert a name into labels. This branch is based on code I've used for several years, and operates on dns.name.Name objects.

rthalley avatar May 06 '24 12:05 rthalley

I agree that split(".") is not how things should be done, definitely not. I'm just trying to find out if there is a good way to improve things for everyone and not just dnspython users, that's all.

pspacek avatar May 08 '24 07:05 pspacek

I did a DNS-based implementation of the PSL as a Python module (https://github.com/sse-secure-systems/psl-dns). Docs and demo are at https://publicsuffix.zone/.

This is publicly queryable, i.e. doesn't require applications to bring the PSL along. Not sure if it aligns with what you have in mind for dnspython's PSL support, but using it might avoid duplicate work and in particular update problems.

peterthomassen avatar May 10 '24 23:05 peterthomassen

I think your solution is probably better if you don't have to make too many queries and don't mind the information leak, as it would not have up-to-date problems. I had automatic updating in an earlier draft, but I got rid of it. For my typical PSL use cases, I would probably be making a rude number of queries and/or not want the information leak, so I think there's still value in this code too.

rthalley avatar May 11 '24 02:05 rthalley

Wondering out loud: Maybe best course of action - for the overall ecosystem - would be to add label-aware API to an existing library? I agree that split('.') is horrendous thing to do, but if that's the only problem maybe it can be fixed in the library instead of reinventing it here?

pspacek avatar May 15 '24 06:05 pspacek

I'll just set this one aside for now.

rthalley avatar May 22 '24 14:05 rthalley