Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow trailing dot in valid domains #2541

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open

Allow trailing dot in valid domains #2541

wants to merge 1 commit into from

Conversation

yubiuser
Copy link
Member

@yubiuser yubiuser commented Mar 4, 2023

What does this PR aim to accomplish?:

We use validDomain() in several places (e.g. adding a domain to black/whitelist, querying the adlists). So for, domains with a trailing dot (root zone) were marked as invalid, e.g. www.google.com.. However, they are valid.

How does this PR accomplish the above?:

Appends \.? to the validating RegEx


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code and I have tested my changes.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)
  6. I have checked that another pull request for this purpose does not exist.
  7. I have considered, and confirmed that this submission will be valuable to others.
  8. I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  9. I give this submission freely, and claim no ownership to its content.

  • I have read the above and my PR is ready for review. Check this box to confirm

Signed-off-by: Christian König <ckoenig@posteo.de>
@yubiuser yubiuser requested a review from a team March 4, 2023 14:04
@yubiuser yubiuser added the PR: Approval Required Open Pull Request, needs approval label Mar 4, 2023
@DL6ER
Copy link
Member

DL6ER commented Mar 5, 2023

Just as virtually any DNS software (except maybe for bind and its tools such as dig), the final dot is omitted. This makes such domains valid but meaningless in the world of Pi-hole. When you block example.com, you, well, block exactly this domain. When you, however, block example.com., then this will never actually block anything as all internal handling won't see the final dot.

The sole exception from this is the root zone itself . where we intentionally keep . (dnsmasq, however, still treats the root zone internally as zero-length domain).

My suggestion: Don't simply extend the regular expressions. It will just enable users to add domains that will never be blocked, possibly causing more frustration that the mere fact that this is not possible. A proper fix would likely allow them but also adding some internal logic to strip the trailing dot before doing any processing on them.

@dschaper
Copy link
Member

dschaper commented Mar 5, 2023

marked as invalid, e.g. www.google.com.. However, they are valid.

Are there some examples or an issue that this relates to where we can see how this condition happened in the wild?

Even Windows nslookup will strip off the anchoring . when you nslookup valid.domain.

@yubiuser
Copy link
Member Author

yubiuser commented Mar 6, 2023

I've not seen this in the wild. The real world stripping is the reason I opened this PR: "Search Adlists" uses validDomain() as well. If users query for flurry.com. it will show "invalid" domain, but usually this domain is blocked as well. This happens on cli as well (no results found), but we do not error because of an invalid domain.

pi@s740:~$ pihole -q flurry.com.
  [i] No results found for flurry.com. within the adlists

If you think we should not change the RegEx I can change the processing of the input on "Search Adlist" to stip a trailing dot before executing the search. This would still prevent users from adding test.com. as black/whitelisted domain.

@rdwebdesign
Copy link
Member

rdwebdesign commented Mar 6, 2023

I added this to abp_query branch:

Edit:
REMOVED

@dschaper
Copy link
Member

dschaper commented Mar 6, 2023

I added this to abp_query branch:

Please keep branches and PRs focused on one topic only. Don't bikeshed/goldplate please.

@rdwebdesign
Copy link
Member

rdwebdesign commented Mar 6, 2023

Please keep branches and PRs focused on one topic only. Don't bikeshed/goldplate please.

I only added this to that branch because yubiuser asked me to do it a few days ago:
pi-hole/pi-hole@273147a#r102882761

My comment was just to show him the code.

My branch is still a WIP and I didn't open a PR. I'll remove the code if this is set on another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Approval Required Open Pull Request, needs approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants