DNS/RR/TLSA.pm

filter: Statementstmt 100% 65 / 65 Branchbran 100% 4 / 4 Conditioncond 100% 8 / 8 MC/DCmcdc 100% 4 / 4 Subroutinesub 100% 17 / 17 Podpod 100% 7 / 7 totaltotal 100% 105 / 105 CC 12 SCAR 7.6
CC
12
Cov
100%
usage
3.0
selector
3.0
matchingtype
3.0
CRAP 2.1
« DNS/RR/SMIMEA.pm ↑ Summary DNS/RR/PX.pm »
1 package Net::DNS::RR::TLSA;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 our $VERSION = (qw$Id: TLSA.pm 2003 2025-01-21 12:06:06Z willem $)[2];
6  
7 2 ▶use base qw(Net::DNS::RR);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 =head1 NAME
11  
12 Net::DNS::RR::TLSA - DNS TLSA resource record
13  
14 =cut
15  
16 2 ▶use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use constant BABBLE => defined eval { require Digest::BubbleBabble };
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21  
22 13 ▶sub _decode_rdata { ## decode rdata from wire-format octet string
Subroutine _decode_rdata: called CC=1 SCAR=0.0
23 13 my ( $self, $data, $offset ) = @_;
24  
25 13 my $next = $offset + $self->{rdlength};
26  
27 13 @{$self}{qw(usage selector matchingtype)} = unpack "\@$offset C3", $$data;
28 13 $offset += 3;
29 13 $self->{certbin} = substr $$data, $offset, $next - $offset;
30 13 return;
31 }
32  
33  
34 5 ▶sub _encode_rdata { ## encode rdata as wire-format octet string
Subroutine _encode_rdata: called CC=1 SCAR=0.0
35 5 my $self = shift;
36  
37 5 return pack 'C3 a*', @{$self}{qw(usage selector matchingtype certbin)};
38 }
39  
40  
41 2 ▶sub _format_rdata { ## format rdata portion of RR string.
Subroutine _format_rdata: called CC=1 SCAR=0.0
42 2 my $self = shift;
43  
44 2 $self->_annotation( $self->babble ) if BABBLE;
45 2 my @cert = split /(\S{64})/, $self->cert;
46 2 my @rdata = ( $self->usage, $self->selector, $self->matchingtype, @cert );
47 2 return @rdata;
48 }
49  
50  
51 1 ▶sub _parse_rdata { ## populate RR from rdata in argument list
Subroutine _parse_rdata: called CC=2 SCAR=6.9
52 1 my ( $self, @argument ) = @_;
53  
54 1 for (qw(usage selector matchingtype)) { $self->$_( shift @argument ) }
55 1 $self->cert(@argument);
56 1 return;
57 }
58  
59  
60 6 ▶sub usage {
Subroutine usage: called CC=3 SCAR=11.0
Pod documented
61 6 my ( $self, @value ) = @_;
62 6 for (@value) { $self->{usage} = 0 + $_ }
63 6 ▶ return $self->{usage} || 0;
Condition100%2/2
$self->{'usage'} || 0
l!l
51
MC/DC100%1/1
$self->{'usage'} || 0
$self->{'usage'}
Truth table100%2/2
A
A= $self->{'usage'}
Aresult
11
00
64 }
65  
66  
67 6 ▶sub selector {
Subroutine selector: called CC=3 SCAR=11.0
Pod documented
68 6 my ( $self, @value ) = @_;
69 6 for (@value) { $self->{selector} = 0 + $_ }
70 6 ▶ return $self->{selector} || 0;
Condition100%2/2
$self->{'selector'} || 0
l!l
51
MC/DC100%1/1
$self->{'selector'} || 0
$self->{'selector'}
Truth table100%2/2
A
A= $self->{'selector'}
Aresult
11
00
71 }
72  
73  
74 6 ▶sub matchingtype {
Subroutine matchingtype: called CC=3 SCAR=11.0
Pod documented
75 6 my ( $self, @value ) = @_;
76 6 for (@value) { $self->{matchingtype} = 0 + $_ }
77 6 ▶ return $self->{matchingtype} || 0;
Condition100%2/2
$self->{'matchingtype'} || 0
l!l
51
MC/DC100%1/1
$self->{'matchingtype'} || 0
$self->{'matchingtype'}
Truth table100%2/2
A
A= $self->{'matchingtype'}
Aresult
11
00
78 }
79  
80  
81 7 ▶sub cert {
Subroutine cert: called CC=3 SCAR=11.0
Pod documented
82 7 my ( $self, @value ) = @_;
83 7 ▶ return unpack "H*", $self->certbin() unless scalar @value;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @value 4 3 7
84 3 ▶ my @hex = map { /^"*([\dA-Fa-f]*)"*$/ || croak("corrupt hex"); $1 } @value;
Branch: 1 branch
BranchTrueFalseTotal
/^"*([\dA-Fa-f]*)"*$/ or croak("corrupt hex") 3 1 4
85 2 return $self->certbin( pack "H*", join "", @hex );
86 }
87  
88  
89 12 ▶sub certbin {
Subroutine certbin: called CC=3 SCAR=11.0
Pod documented
90 12 my ( $self, @value ) = @_;
91 12 for (@value) { $self->{certbin} = $_ }
92 12 ▶ return $self->{certbin} || "";
Condition100%2/2
$self->{'certbin'} || ''
l!l
111
MC/DC100%1/1
$self->{'certbin'} || ''
$self->{'certbin'}
Truth table100%2/2
A
A= $self->{'certbin'}
Aresult
11
00
93 }
94  
95  
96 4 ▶sub certificate { return &cert; }
Subroutine certificate: called CC=1 SCAR=0.0
Pod documented
97  
98  
99 4 ▶sub babble {
Subroutine babble: called CC=1 SCAR=0.0
Pod documented
100 4 return BABBLE ? Digest::BubbleBabble::bubblebabble( Digest => shift->certbin ) : '';
101 }
102  
103  
104 2 1;
105 __END__
« DNS/RR/SMIMEA.pm ↑ Summary DNS/RR/PX.pm »