Skip to content

Commit 4dab70b

Browse files
author
Morgan Haskel
committed
Merge pull request #404 from roderickm/PUP-3856_isnt_domain_name
(MODULES-1670) Do not match dotted-quad IP address as domain name
2 parents 40b6207 + ee13438 commit 4dab70b

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

lib/puppet/parser/functions/is_domain_name.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ module Puppet::Parser::Functions
3333
return false if domain.empty?
3434
return false if domain.length > domain_max_length
3535

36+
# The top level domain must be alphabetic if there are multiple labels.
37+
# See rfc1123, 2.1
38+
return false if domain.include? '.' and not /\.[A-Za-z]+$/.match(domain)
39+
3640
# Check each label in the domain
3741
labels = domain.split('.')
3842
vlabels = labels.each do |label|

spec/functions/is_domain_name_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,14 @@
6868
result = scope.function_is_domain_name(["my.domain.name".freeze])
6969
expect(result).to(be_truthy)
7070
end
71+
72+
it "should return false if top-level domain is not entirely alphabetic" do
73+
result = scope.function_is_domain_name(["kiwi.2bar"])
74+
expect(result).to(be_falsey)
75+
end
76+
77+
it "should return false if domain name has the dotted-decimal form, e.g. an IPv4 address" do
78+
result = scope.function_is_domain_name(["192.168.1.1"])
79+
expect(result).to(be_falsey)
80+
end
7181
end

0 commit comments

Comments
 (0)