ZoneParse/Parser/Native/DNSext.pm

filter: Statementstmt 48.2% 14 / 29 Branchbran 37.5% 3 / 8 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 28.5% 2 / 7 Podpod 0.0% 0 / 6 totaltotal 41.5% 22 / 53 CC 6 SCAR 15.6
CC
6
Cov
49%
new_serial
12.0
dns_fqdn
3.0
_dns_expand_chars
2.0
CRAP 4.8
« ZoneParse/Generator/Native.pm ↑ Summary ZoneParse/Parser/DNSZoneParse.pm »
1 package Net::DNS::ZoneParse::Parser::Native::DNSext;
2  
3 # This package contains code only needed to extent Net::DNS::RR.
4 # according patches had been sent, but until they are merged,
5 # requiring this file provides a suitable workaround.
6  
7 package Net::DNS::RR;
8  
9 =head3 $fqdn = $self->dns_fqdn($domain, $origin)
10  
11 If $domain isn't fully qualified and thus not ending with a dot, the origin
12 will be appended. In both cases the finalizing dot will be cut off afterwards.
13  
14 This functions is inteded to be used by the extension of Net::DNS::RR::xx
15 parsing functionality.
16  
17 =cut
18  
19 8 ▶sub dns_fqdn {
Subroutine dns_fqdn: called CC=3 SCAR=11.0
Pod undocumented
20 8 my ($self, $name, $origin) = @_;
21 8 $name = $self->_dns_expand_chars($name, $origin);
22 8 ▶ $name = $origin unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 8 8
23 8 ▶ $name .= ".".$origin unless(substr($name, -1) eq ".");
Branch: 1 branch
BranchTrueFalseTotal
unless substr($name, -1) eq "." 2 6 8
24 8 return substr($name, 0, -1); # last char must be a dot now
25 }
26  
27 # expand any special character within one item
28 # called as
29 # $self->_dns_expand_chars($string, $origin)
30 8 ▶sub _dns_expand_chars {
Subroutine _dns_expand_chars: called CC=2 SCAR=6.9
31 8 local($_);
32 8 $_ = $_[1];
33 8 ▶ my $origin = $_[2] || "";
Condition100%2/2
$_[2] || ''
l!l
62
MC/DC100%1/1
$_[2] || ''
$_[2]
Truth table100%2/2
A
A= $_[2]
Aresult
11
00
34 8 s/(?<![\w\\])@/$origin/;
35 0 s/\\(\d+)/pack("C",$1)/e;
36 8 s/\\//;
37 8 $_[1] = $_;
38 8 return $_;
39 }
40  
41 # extend Net::DNS::RR to make it possible to parse the string differently
42 # from files and from packets
43 #
44 # the default is to reuse the new_from_string
45 #
46 0 ▶sub new_from_filestring {
Subroutine new_from_filestring: not called CC=1 SCAR=6.9
Pod undocumented
47 0 my ($self, $ele, $data, $param) = @_;
48 return $self->new_from_string($ele, $self->_dns_expand_chars(
49 0 $data, $param->{origin}));
50 }
51  
52 package Net::DNS::RR::CNAME;
53  
54 0 ▶sub new_from_filestring {
Subroutine new_from_filestring: not called CC=1 SCAR=6.9
Pod undocumented
55 0 my ($self, $ele, $data, $param) = @_;
56 return $self->new_from_string($ele,
57 0 $self->dns_fqdn($data, $param->{origin}));
58 }
59  
60 package Net::DNS::RR::MX;
61  
62 0 ▶sub new_from_filestring {
Subroutine new_from_filestring: not called CC=1 SCAR=6.9
Pod undocumented
63 0 my ($self, $ele, $data, $param) = @_;
64 # as the exchange is the only host and always the last item,
65 # it is possible to simply use dns_fqdn here, too
66 return $self->new_from_string($ele,
67 0 $self->dns_fqdn($data, $param->{origin}));
68 }
69  
70 package Net::DNS::RR::NS;
71  
72 0 ▶sub new_from_filestring {
Subroutine new_from_filestring: not called CC=1 SCAR=6.9
Pod undocumented
73 0 my ($self, $ele, $data, $param) = @_;
74 return $self->new_from_string($ele,
75 0 $self->dns_fqdn($data, $param->{origin}));
76 }
77  
78  
79 package Net::DNS::RR::SOA;
80  
81 0 ▶sub new_serial {
Subroutine new_serial: not called CC=3 SCAR=24.8
Pod undocumented
82 0 my ($self, $inc) = @_;
83  
84 0 ▶ if($inc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($inc) { } 0 0 0
85 0 $self->serial += $inc;
86 } else {
87 0 my $newserial = strftime("%Y%m%d%H", localtime(time));
88 0 ▶ $self->serial = ($newserial > $self->serial)
Branch: 1 branch
BranchTrueFalseTotal
$newserial > $self->serial ? : 0 0 0
89 ? $newserial
90 : $self->serial + 1;
91 }
92 0 return $self->serial;
93 }
94  
95  
96 5 1;
97  
« ZoneParse/Generator/Native.pm ↑ Summary ZoneParse/Parser/DNSZoneParse.pm »