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

t/800_regression/01_capture_request.t fails in presence of wildcard DNS records #128

Closed
eserte opened this issue Mar 7, 2022 · 1 comment

Comments

@eserte
Copy link
Contributor

eserte commented Mar 7, 2022

Furl's test suite fails on many of my smokers like this:

#   Failed test at t/800_regression/01_capture_request.t line 10.
#          got: 'POST / HTTP/1.1
# Connection: keep-alive
# User-Agent: Furl::HTTP/3.14
# Host: example.com.local
# 
# '
#     expected: undef

#   Failed test at t/800_regression/01_capture_request.t line 11.
#          got: ''
#     expected: undef
# Looks like you failed 2 tests of 2.
t/800_regression/01_capture_request.t ........... 
Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/2 subtests 

The problem is that the test hostname example.com.local, which obviously should not exist, actually resolves to something which has a web server running. This seems to happen if
a) the local DNS configuration does a fallback search for one or more domains (usually the default is to search for the local domain)
b) one of these domains has a wildcard DNS record
c) a webserver is running on the resolved address

It can be reproduced using the following Dockerfile (by experiments I found out that bing.com has a wildcard DNS record):

# docker build -t perl-test . && docker run -rm perl-test
FROM debian:11
RUN apt-get -y update
RUN apt-get -y --no-install-recommends install perl make cpanminus
RUN apt-get -y --no-install-recommends install libclass-accessor-lite-perl libencode-perl libhttp-parser-xs-perl
RUN apt-get -y --no-install-recommends install libtest-tcp-perl
ENV LOCALDOMAIN bing.com
CMD cpanm --test-only --verbose Furl

How can this be resolved? The LOCALDOMAIN environment variable is possibly Linux-specific, but setting it's value to something really non-existent might help on these systems. Additionally maybe do a gethostbyname call and check if it really returns nothing, otherwise skip the test.

eserte added a commit to eserte/srezic-cpan-distroprefs that referenced this issue Mar 7, 2022
@eserte
Copy link
Contributor Author

eserte commented Mar 7, 2022

Another possible solution: use a trailing dot in the invalid hostname. It seems that in this case the fallback to the search domains does not happen (at least this is the case on a debian:11 system). So

my $r=$f->post("http://example.com.local.");

should work.

eserte added a commit to eserte/Furl that referenced this issue Mar 7, 2022
syohex added a commit that referenced this issue Mar 9, 2022
@syohex syohex closed this as completed Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants