Send Netdot-devel mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://osl.uoregon.edu/mailman/listinfo/netdot-devel
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Netdot-devel digest..."


Today's Topics:

   1. [Netdot - Bug #1852] (New) Length validation for DNS      records
      is incorrect ([email protected])
   2. [SCM] Netdot branch netdot-1.0 updated.
      netdot-1.0.7-8-g8b01e0b ([email protected])
   3. [SCM] Netdot branch master updated.       netdot-1.0.7-8-g8b01e0b
      ([email protected])
   4. [Netdot - Bug #1852] (Resolved) Length validation for DNS
      records is incorrect ([email protected])


----------------------------------------------------------------------

Message: 1
Date: Wed, 18 Mar 2015 12:46:50 -0700
From: [email protected]
Subject: [Netdot-devel] [Netdot - Bug #1852] (New) Length validation
        for DNS records is incorrect
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8


Issue #1852 has been reported by Carlos Vicente.

----------------------------------------
Bug #1852: Length validation for DNS records is incorrect
https://osl.uoregon.edu/redmine/issues/1852

Author: Carlos Vicente
Status: New
Priority: Normal
Assignee: Carlos Vicente
Category: DNS
Target version: 1.0.8
Resolution: 


The RR class is checking that the length of the DNS record (before the zone 
part) is 63 characters or less. RFC 1035 imposes that maximum length on labels, 
which are any part of the FQDN in between two dots.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://osl.uoregon.edu/redmine/my/account


------------------------------

Message: 2
Date: Wed, 18 Mar 2015 12:47:27 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch netdot-1.0 updated.
        netdot-1.0.7-8-g8b01e0b
To: [email protected]
Message-ID: <[email protected]>

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Netdot".

The branch, netdot-1.0 has been updated
       via  8b01e0b0f27e6fa4ca1e7036e6eac327d984a918 (commit)
      from  a083cd6ccd6db34c5d823ec49deea35e974cd11c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8b01e0b0f27e6fa4ca1e7036e6eac327d984a918
Author: Carlos Vicente <[email protected]>
Date:   Wed Mar 18 15:47:12 2015 -0400

    Fix for #1852 (Length validation for DNS records is incorrect)

diff --git a/lib/Netdot/Model/RR.pm b/lib/Netdot/Model/RR.pm
index 8fe9cd3..7b11f80 100644
--- a/lib/Netdot/Model/RR.pm
+++ b/lib/Netdot/Model/RR.pm
@@ -695,7 +695,10 @@ sub _validate_args {
        $zone = $self->zone;
     }
     if ( defined $argv->{zone} ){
-       if ( !ref($argv->{zone}) ){
+       if ( ref($argv->{zone}) ){
+           # We're being passed an object
+           $zone = $argv->{zone}
+       }else{
            if ( $argv->{zone} =~ /\D+/ ){
                $zone = Zone->search(name=>$argv->{zone})->first;
            }else{
@@ -716,11 +719,6 @@ sub _validate_args {
        # Remove commas
        $name =~ s/,//;
 
-       # Length restrictions
-       unless ( length($name) >= 1 && length($name) < 64 ){
-           $self->throw_user("Invalid name: $name. Length must be between 1 
and 63 characters");
-       }
-
        # Valid characters
        if ( $name =~ /[^A-Za-z0-9\.\-_@\*]/ ){
            $self->throw_user("Invalid name: $name. Contains invalid 
characters");
@@ -737,15 +735,20 @@ sub _validate_args {
        if ( $name =~ /^\-/ || $name =~ /\-$/ ){
            $self->throw_user("Invalid name: $name. Name must not start or end 
with a dash");
        }
-       if ( $zone ){
-           my $fqdn = $name.".".$zone->name;
-           if ( length($fqdn) > 255 ){
-               $self->throw_user("Invalid FQDN: $fqdn. Length exceeds 255 
characters");
+
+       # Length restrictions (RFC 1035)
+       my $fqdn = $name.".".$zone->name;
+       if ( length($fqdn) > 255 ){
+           $self->throw_user("Invalid FQDN: $fqdn. Length exceeds 255 
characters");
+       }
+       # labels (sections between dots) must not exceed 63 chars
+       foreach my $label ( split(/\./, $fqdn) ){
+           unless ( length($label) >= 1 && length($label) < 64 ){
+               $self->throw_user("Invalid label: $label. Each label must be 
between 1".
+                                 " and 63 characters long");
            }
        }
-
        $argv->{name} = $name;
-
     }
     1;
 }
diff --git a/t/RR.t b/t/RR.t
index e00fb87..6e4715c 100644
--- a/t/RR.t
+++ b/t/RR.t
@@ -30,14 +30,28 @@ if ( Zone->search(name=>$domain) ){
 if ( Zone->search(name=>$domainrev) ){
     Zone->search(name=>$domainrev)->first->delete();
 }
+
+# Create reverse zone first
+my $revzone = Zone->insert({name=>$domainrev});
+isa_ok($revzone, 'Netdot::Model::Zone', 'insert_rev_zone');
+
 # RR
 my $rr = RR->insert({name=>$name, zone=>$domain});
 isa_ok($rr, 'Netdot::Model::RR', 'insert_rr');
 is(RR->search(name=>"$name.$domain")->first, $rr, 'search' );
 is($rr->get_label, "$name.$domain", 'get_label');
 
+# Labels longer that 63 characters shoud throw a user exception
+my $long_name = 
'1234567890123456789012345678901234567890123456789012345678901234';
+eval{
+    RR->insert({name=>$long_name, zone=>$domain});
+};
+my $e = $@;
+isa_ok($e, 'Netdot::Util::Exception::User');
+
 # RRADDR
-my $rraddr = RR->insert({type=>'A', name=>$name, zone=>$domain, ttl=>3600, 
ipblock=>$v4address});
+my $rraddr = RR->insert({type=>'A', name=>$name, zone=>$domain, 
+                        ttl=>3600, ipblock=>$v4address });
 isa_ok($rraddr, 'Netdot::Model::RRADDR', 'insert_rraddr');
 is($rraddr->as_text, "$name.$domain.   3600    IN      A       $v4address", 
'as_text');
 
@@ -68,9 +82,9 @@ isa_ok($rrloc, 'Netdot::Model::RRLOC', 'insert_loc');
 is($rrloc->as_text, "testdomain.       3600    IN      LOC     596 31 23.648 S 
123 05 00.000 W 122.00m 1.00m 10000.00m 10.00m", 'as_text');
 
 # RRMX
-my $rrmx = RR->insert({type=>'MX', name=>$name, zone=>$domain, ttl=>3600, 
preference=>10, exchange=>"smtp.$domain"});
+my $rrmx = RR->insert({type=>'MX', name=>$name, zone=>$domain, ttl=>3600, 
preference=>10, exchange=>"smtp.example.net"});
 isa_ok($rrmx, 'Netdot::Model::RRMX', 'insert_mx');
-is($rrmx->as_text, "$name.$domain.     3600    IN      MX      10 
smtp.$domain.", 'as_text');
+is($rrmx->as_text, "$name.$domain.     3600    IN      MX      10 
smtp.example.net.", 'as_text');
 
 # RRNAPTR
 my $rrnaptr = RR->insert({type=>'NAPTR', name=>'@', zone=>$domain, ttl=>3600, 
order_field=>"100", preference=>"10", flags=>"u", services=>"E2U+sip",
@@ -84,6 +98,7 @@ isa_ok($rrns, 'Netdot::Model::RRNS', 'insert_ns');
 is($rrns->as_text, "$name.$domain.     3600    IN      NS      ns1.$domain.", 
'as_text');
 
 # RRPTR
+$rraddr->ipblock->ptr_records->first->delete();
 my $rrptr = RR->insert({type=>'PTR', name=>"10.1", ipblock=>$v4address, 
zone=>$domainrev, ttl=>3600, ptrdname=>"$name.$domain"});
 isa_ok($rrptr, 'Netdot::Model::RRPTR', 'insert_ptr');
 is($rrptr->as_text, "10.1.168.192.in-addr.arpa.        3600    IN      PTR     
$name.$domain.", 'as_text');
@@ -98,8 +113,7 @@ my $rrtxt = RR->insert({type=>'TXT', name=>$name, 
zone=>$domain, ttl=>3600, txtd
 isa_ok($rrtxt, 'Netdot::Model::RRTXT', 'insert_txt');
 is($rrtxt->as_text, "$name.$domain.    3600    IN      TXT     \"text 
record\"", 'as_text');
 
-my $zone    = $rr->zone;
-my $revzone = $rrptr->rr->zone;
+my $zone = $rr->zone;
 
 # We should have one of each in this zone (except a PTR)
 my $count = $zone->get_record_count;

-----------------------------------------------------------------------

Summary of changes:
 lib/Netdot/Model/RR.pm | 27 +++++++++++++++------------
 t/RR.t                 | 24 +++++++++++++++++++-----
 2 files changed, 34 insertions(+), 17 deletions(-)


hooks/post-receive
-- 
Netdot


------------------------------

Message: 3
Date: Wed, 18 Mar 2015 12:47:56 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch master updated.
        netdot-1.0.7-8-g8b01e0b
To: [email protected]
Message-ID: <[email protected]>

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Netdot".

The branch, master has been updated
       via  8b01e0b0f27e6fa4ca1e7036e6eac327d984a918 (commit)
       via  a083cd6ccd6db34c5d823ec49deea35e974cd11c (commit)
       via  7a17346c2163dc08268941df0c31e5344a77c3d9 (commit)
      from  36cf49854386ed58a152d7b7c47837b10195776a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 etc/Default.conf              | 13 +++++--
 htdocs/management/device.html | 21 ++++++++---
 lib/Netdot/Model/Device.pm    | 81 +++++++++++++++++++++++++++----------------
 lib/Netdot/Model/Ipblock.pm   | 23 ++++++++----
 lib/Netdot/Model/RR.pm        | 27 ++++++++-------
 lib/Netdot/Model/RRADDR.pm    |  2 +-
 t/RR.t                        | 24 ++++++++++---
 7 files changed, 130 insertions(+), 61 deletions(-)


hooks/post-receive
-- 
Netdot


------------------------------

Message: 4
Date: Wed, 18 Mar 2015 12:48:29 -0700
From: [email protected]
Subject: [Netdot-devel] [Netdot - Bug #1852] (Resolved) Length
        validation      for DNS records is incorrect
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8


Issue #1852 has been updated by Carlos Vicente.

Status changed from New to Resolved
Resolution set to fixed


----------------------------------------
Bug #1852: Length validation for DNS records is incorrect
https://osl.uoregon.edu/redmine/issues/1852#change-3272

Author: Carlos Vicente
Status: Resolved
Priority: Normal
Assignee: Carlos Vicente
Category: DNS
Target version: 1.0.8
Resolution: fixed


The RR class is checking that the length of the DNS record (before the zone 
part) is 63 characters or less. RFC 1035 imposes that maximum length on labels, 
which are any part of the FQDN in between two dots.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://osl.uoregon.edu/redmine/my/account


------------------------------

_______________________________________________
Netdot-devel mailing list
[email protected]
https://osl.uoregon.edu/mailman/listinfo/netdot-devel


End of Netdot-devel Digest, Vol 96, Issue 2
*******************************************

Reply via email to