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

(MODULES-1670) Do not match dotted-quad IP address as domain name #404

Merged
merged 1 commit into from
Mar 6, 2015
Merged

(MODULES-1670) Do not match dotted-quad IP address as domain name #404

merged 1 commit into from
Mar 6, 2015

Conversation

roderickm
Copy link

A valid host name can never have the dotted-decimal form #.#.#.#,
since at least the highest-level component label will be alphabetic.
See RFC 1123, Section 2.1
http://tools.ietf.org/html/rfc1123#section-2
Fixes PUP-3856

@hlindberg
Copy link
Contributor

As I read the RFCs for domains, the highest order segment must be alphabetical which makes a domain such as 'a.b.c.42' not legal.

Tests are needed.

@@ -32,6 +32,7 @@ module Puppet::Parser::Functions
# Check the whole domain
return false if domain.empty?
return false if domain.length > domain_max_length
return false if /^\d+\.\d+\.\d+\.\d+$/.match(domain)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be appropriate to use Resolv::IPv4::Regex and Resolv::IPv6::Regex here to match both 4 and 6 ip addresses without having to write our own regexes?

Thanks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the match should only consider the highest-order label (aka top-level domain) because digits are not permitted there, which would also excluded dotted-quads. Using IPv4 or IPv6 tests would be too strict, I think, because there are dotted quads that would be invalid according to Resolv::IPv4::Regex (such as '192.168.1.500') but should still fail is_domain_name().

@roderickm roderickm changed the title Do not match dotted-quad IP address as domain name (MODULES-1670) Do not match dotted-quad IP address as domain name Jan 19, 2015
@underscorgan
Copy link
Contributor

@roderickm Thanks for the contribution! Could you rebase this and squash to a single commit?

@roderickm
Copy link
Author

@mhaskel Done!

@underscorgan
Copy link
Contributor

@roderickm Did you fetch current master and rebase against that? This is still showing as unmergeable. Thanks!

underscorgan pushed a commit that referenced this pull request Mar 6, 2015
(MODULES-1670) Do not match dotted-quad IP address as domain name
@underscorgan underscorgan merged commit 4dab70b into puppetlabs:master Mar 6, 2015
@underscorgan
Copy link
Contributor

Great, thanks @roderickm !

@roderickm roderickm deleted the PUP-3856_isnt_domain_name branch March 11, 2015 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants