Project

General

Profile

Actions

Feature #13385

open

[PATCH] Make Resolv::DNS::Name validation similar to host and dig commands

Added by pavel.mikhailyuk@gmail.com (Pavel Mikhailyuk) over 7 years ago. Updated 8 months ago.

Status:
Assigned
Target version:
-
[ruby-core:80464]

Description

Abstract

Add validations similar to host and dig commands to Resolv::DNS::Name.create

Background

Resolv::DNS::Name.create(str) does not make any domain name validation.
So it returns false positive results for queries like

[1] pry(main)> Resolv::DNS.new.getresources('.gmail....com', Resolv::DNS::Resource::IN::MX)
=> [#<Resolv::DNS::Resource::IN::MX:0x007fc3107ecf68 @exchange=#<Resolv::DNS::Name: alt1.gmail-smtp-in.l.google.com.>, @preference=10, @ttl=3600>,
 #<Resolv::DNS::Resource::IN::MX:0x007fc313013730 @exchange=#<Resolv::DNS::Name: alt2.gmail-smtp-in.l.google.com.>, @preference=20, @ttl=3600>,
 #<Resolv::DNS::Resource::IN::MX:0x007fc313011f20 @exchange=#<Resolv::DNS::Name: gmail-smtp-in.l.google.com.>, @preference=5, @ttl=3600>,
 #<Resolv::DNS::Resource::IN::MX:0x007fc313010a30 @exchange=#<Resolv::DNS::Name: alt4.gmail-smtp-in.l.google.com.>, @preference=40, @ttl=3600>,
 #<Resolv::DNS::Resource::IN::MX:0x007fc313012858 @exchange=#<Resolv::DNS::Name: alt3.gmail-smtp-in.l.google.com.>, @preference=30, @ttl=3600>]

while

~ dig .gmail....com MX
dig: '.gmail....com' is not a legal name (empty label)

I added basic RFC validations in Resolv::DNS::Label.split to get ArgumentError with messages similar to host and dig commands.

Pull request

https://github.com/ruby/ruby/pull/1551

Actions

Also available in: Atom PDF

Like0
Like0Like0