Skip to content

Commit

Permalink
whois.dns.be crashes when the status is not allowd
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Oct 30, 2013
1 parent a77ee1d commit 7602d3b
Show file tree
Hide file tree
Showing 12 changed files with 296 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
# Changelog


# master

- SERVER: Added .XN--MGBX4CD0AB (.ایران, Iran) IDN TLD definition.
Expand All @@ -12,6 +13,8 @@

- NEW: Added whois.rrpproxy.net parser (GH-259). [Thanks @takama]

- FIXED: whois.dns.be crashes when the status is `not allowd`.

- CHANGED: Changed .NU TLD to the new response format and parser (GH-265).

- CHANGED: Changed .SE TLD to the new response format and parser.
Expand Down
26 changes: 20 additions & 6 deletions lib/whois/record/parser/whois.dns.be.rb
Expand Up @@ -33,10 +33,16 @@ class WhoisDnsBe < Base
property_supported :status do
if content_for_scanner =~ /Status:\s+(.+?)\n/
case $1.downcase
when "available" then :available
when "not available" then :registered
when "quarantine" then :redemption
when "out of service" then :redemption
when "available"
:available
when "not available"
:registered
when "quarantine"
:redemption
when "out of service"
:redemption
when "not allowed"
:invalid
else
Whois.bug!(ParserError, "Unknown status `#{$1}'.")
end
Expand All @@ -46,11 +52,11 @@ class WhoisDnsBe < Base
end

property_supported :available? do
(status == :available)
!invalid? && (status == :available)
end

property_supported :registered? do
!available?
!invalid? && !available?
end


Expand Down Expand Up @@ -101,6 +107,14 @@ def response_blocked?
!!(content_for_scanner =~ /^-3: IP address blocked/)
end


# NEWPROPERTY
def invalid?
cached_properties_fetch(:invalid?) do
status == :invalid
end
end

end

end
Expand Down
@@ -0,0 +1,8 @@
#status
%s == :invalid

#available?
%s == false

#registered?
%s == false
@@ -0,0 +1,40 @@
% .be Whois Server 6.1
%
% The WHOIS service offered by DNS.be and the access to the records in the DNS.be
% WHOIS database are provided for information purposes only. It allows
% persons to check whether a specific domain name is still available or not
% and to obtain information related to the registration records of
% existing domain names.
%
% DNS.be cannot, under any circumstances, be held liable where the stored
% information would prove to be incomplete or inaccurate in any sense.
%
% By submitting a query you agree not to use the information made available
% to:
% - allow, enable or otherwise support the transmission of unsolicited,
% commercial advertising or other solicitations whether via email or otherwise;
% - target advertising in any possible way;
% - to cause nuisance in any possible way to the domain name holders by sending
% messages to them (whether by automated, electronic processes capable of
% enabling high volumes or other possible means).
%
% Without prejudice to the above, it is explicitly forbidden to extract, copy
% and/or use or re-utilise in any form and by any means (electronically or
% not) the whole or a quantitatively or qualitatively substantial part
% of the contents of the WHOIS database without prior and explicit permission
% by DNS.be, nor in any attempt thereof, to apply automated, electronic
% processes to DNS.be (or its systems).
%
% You agree that any reproduction and/or transmission of data for commercial
% purposes will always be considered as the extraction of a substantial
% part of the content of the WHOIS database.
%
% By submitting the query you agree to abide by this policy and accept that
% DNS.be can take measures to limit the use of its whois services in order to
% protect the privacy of its registrants or the integrity of the database.
%

Domain: www.kimdemolenaer.be
Status: NOT ALLOWED
Message: Use only approved characters.

Expand Up @@ -33,3 +33,7 @@

#response_throttled?
%s == false


#invalid?
%s == false
39 changes: 39 additions & 0 deletions spec/fixtures/responses/whois.dns.be/status_invalid.expected
@@ -0,0 +1,39 @@
#domain
%s == "www.kimdemolenaer.be"


#status
%s == :invalid

#available?
%s == false

#registered?
%s == false


#created_on
%s == nil

#updated_on
%s %ERROR{AttributeNotSupported}

#expires_on
%s %ERROR{AttributeNotSupported}


#registrar
%s == nil


#nameservers
%s %CLASS{array}
%s == []


#response_throttled?
%s == false


#invalid?
%s == true
40 changes: 40 additions & 0 deletions spec/fixtures/responses/whois.dns.be/status_invalid.txt
@@ -0,0 +1,40 @@
% .be Whois Server 6.1
%
% The WHOIS service offered by DNS.be and the access to the records in the DNS.be
% WHOIS database are provided for information purposes only. It allows
% persons to check whether a specific domain name is still available or not
% and to obtain information related to the registration records of
% existing domain names.
%
% DNS.be cannot, under any circumstances, be held liable where the stored
% information would prove to be incomplete or inaccurate in any sense.
%
% By submitting a query you agree not to use the information made available
% to:
% - allow, enable or otherwise support the transmission of unsolicited,
% commercial advertising or other solicitations whether via email or otherwise;
% - target advertising in any possible way;
% - to cause nuisance in any possible way to the domain name holders by sending
% messages to them (whether by automated, electronic processes capable of
% enabling high volumes or other possible means).
%
% Without prejudice to the above, it is explicitly forbidden to extract, copy
% and/or use or re-utilise in any form and by any means (electronically or
% not) the whole or a quantitatively or qualitatively substantial part
% of the contents of the WHOIS database without prior and explicit permission
% by DNS.be, nor in any attempt thereof, to apply automated, electronic
% processes to DNS.be (or its systems).
%
% You agree that any reproduction and/or transmission of data for commercial
% purposes will always be considered as the extraction of a substantial
% part of the content of the WHOIS database.
%
% By submitting the query you agree to abide by this policy and accept that
% DNS.be can take measures to limit the use of its whois services in order to
% protect the privacy of its registrants or the integrity of the database.
%

Domain: www.kimdemolenaer.be
Status: NOT ALLOWED
Message: Use only approved characters.

Expand Up @@ -41,3 +41,11 @@
%s[2].name == "ns1.google.com"
%s[3] %CLASS{nameserver}
%s[3].name == "ns2.google.com"


#response_throttled?
%s == false


#invalid?
%s == false
@@ -0,0 +1,39 @@
# encoding: utf-8

# This file is autogenerated. Do not edit it manually.
# If you want change the content of this file, edit
#
# /spec/fixtures/responses/whois.dns.be/property_status_notallowed.expected
#
# and regenerate the tests with the following rake task
#
# $ rake spec:generate
#

require 'spec_helper'
require 'whois/record/parser/whois.dns.be.rb'

describe Whois::Record::Parser::WhoisDnsBe, "property_status_notallowed.expected" do

subject do
file = fixture("responses", "whois.dns.be/property_status_notallowed.txt")
part = Whois::Record::Part.new(body: File.read(file))
described_class.new(part)
end

describe "#status" do
it do
expect(subject.status).to eq(:invalid)
end
end
describe "#available?" do
it do
expect(subject.available?).to eq(false)
end
end
describe "#registered?" do
it do
expect(subject.registered?).to eq(false)
end
end
end
Expand Up @@ -72,4 +72,9 @@
expect(subject.response_throttled?).to eq(false)
end
end
describe "#invalid?" do
it do
expect(subject.invalid?).to eq(false)
end
end
end
@@ -0,0 +1,80 @@
# encoding: utf-8

# This file is autogenerated. Do not edit it manually.
# If you want change the content of this file, edit
#
# /spec/fixtures/responses/whois.dns.be/status_invalid.expected
#
# and regenerate the tests with the following rake task
#
# $ rake spec:generate
#

require 'spec_helper'
require 'whois/record/parser/whois.dns.be.rb'

describe Whois::Record::Parser::WhoisDnsBe, "status_invalid.expected" do

subject do
file = fixture("responses", "whois.dns.be/status_invalid.txt")
part = Whois::Record::Part.new(body: File.read(file))
described_class.new(part)
end

describe "#domain" do
it do
expect(subject.domain).to eq("www.kimdemolenaer.be")
end
end
describe "#status" do
it do
expect(subject.status).to eq(:invalid)
end
end
describe "#available?" do
it do
expect(subject.available?).to eq(false)
end
end
describe "#registered?" do
it do
expect(subject.registered?).to eq(false)
end
end
describe "#created_on" do
it do
expect(subject.created_on).to eq(nil)
end
end
describe "#updated_on" do
it do
expect { subject.updated_on }.to raise_error(Whois::AttributeNotSupported)
end
end
describe "#expires_on" do
it do
expect { subject.expires_on }.to raise_error(Whois::AttributeNotSupported)
end
end
describe "#registrar" do
it do
expect(subject.registrar).to eq(nil)
end
end
describe "#nameservers" do
it do
expect(subject.nameservers).to be_a(Array)
expect(subject.nameservers).to eq([])
end
end
describe "#response_throttled?" do
it do
expect(subject.response_throttled?).to eq(false)
end
end
describe "#invalid?" do
it do
expect(subject.invalid?).to eq(true)
end
end
end
Expand Up @@ -79,4 +79,14 @@
expect(subject.nameservers[3].name).to eq("ns2.google.com")
end
end
describe "#response_throttled?" do
it do
expect(subject.response_throttled?).to eq(false)
end
end
describe "#invalid?" do
it do
expect(subject.invalid?).to eq(false)
end
end
end

0 comments on commit 7602d3b

Please sign in to comment.