| 1 | package Mail::TLSRPT::Failure; | ||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: TLSRPT failure object | ||||||||||||||||||||||||||||||||||||||||
| 3 | 9 | our $VERSION = '2.20261104'; # VERSION | |||||||||||||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use 5.20.0; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use Mail::TLSRPT::Pragmas; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 7 | 9 | ▶ | use Net::IP; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 8 | 9 | has result_type => (is => 'rw', isa => Enum[ qw( starttls-not-supported certificate-host-mismatch certificate-expired certificate-not-trusted validation-failure tlsa-invalid dnssec-invalid dane-required sts-policy-fetch-error sts-policy-invalid sts-webpki-invalid ) ], required => 1); | |||||||||||||||||||||||||||||||||||||||
| 9 | 27 | ▶ | has sending_mta_ip => (is => 'rw', isa => class_type('Net::IP'), required => 1,coerce => sub{&_coerce_ip}); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 10 | 9 | has receiving_mx_hostname => (is => 'rw', isa => Str, required => 1); | |||||||||||||||||||||||||||||||||||||||
| 11 | 9 | has receiving_mx_helo => (is => 'rw', isa => Str, required => 0); | |||||||||||||||||||||||||||||||||||||||
| 12 | 27 | ▶ | has receiving_ip => (is => 'rw', isa => class_type('Net::IP'), required => 0, coerce => sub{&_coerce_ip}); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 13 | 9 | has failed_session_count => (is => 'rw', isa => Int, required => 1); | |||||||||||||||||||||||||||||||||||||||
| 14 | 9 | has additional_information => (is => 'rw', isa => Str, required => 0); | |||||||||||||||||||||||||||||||||||||||
| 15 | 9 | has failure_reason_code => (is => 'rw', isa => Str, required => 0); | |||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||
| 17 | 54 | ▶ | sub _coerce_ip { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_coerce_ip: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||
| 18 | 54 | my $ip = shift; | |||||||||||||||||||||||||||||||||||||||
| 19 | 54 | ▶ | $ip = Net::IP->new($ip) unless ref $ip eq 'Net::IP'; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 20 | 54 | return $ip; | |||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||
| 24 | 13 | ▶ | sub new_from_data($class,$data) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_from_data: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 25 | my $self = $class->new( | ||||||||||||||||||||||||||||||||||||||||
| 26 | result_type => $data->{'result-type'}, | ||||||||||||||||||||||||||||||||||||||||
| 27 | sending_mta_ip => $data->{'sending-mta-ip'}, | ||||||||||||||||||||||||||||||||||||||||
| 28 | receiving_mx_hostname => $data->{'receiving-mx-hostname'}, | ||||||||||||||||||||||||||||||||||||||||
| 29 | $data->{'receiving-mx-helo'} ? ( receiving_mx_helo => $data->{'receiving-mx-helo'} ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 30 | $data->{'receiving-ip'} ? ( receiving_ip => $data->{'receiving-ip'} ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 31 | failed_session_count => $data->{'failed-session-count'} // 0, | ||||||||||||||||||||||||||||||||||||||||
| 32 | $data->{'additional-information'} ? ( additional_information => $data->{'additional-information'} ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 33 | 13 | ▶ | $data->{'failure-reason-code'} ? ( failure_reason_code => $data->{'failure-reason-code'} ) : (), | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition50%1/2
$data->{"failed-session-count"} // 0
MC/DC0%0/1
$data->{"failed-session-count"} // 0
$data->{"failed-session-count"}
Truth table50%1/2
A
A= $data->{"failed-session-count"}
| |||||||||||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||||||||||
| 35 | 13 | return $self; | |||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||
| 39 | 4 | ▶ | sub as_struct($self) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_struct: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 40 | return { | ||||||||||||||||||||||||||||||||||||||||
| 41 | 4 | ▶ | 'result-type' => $self->result_type, | ||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||
| 42 | $self->sending_mta_ip ? ( 'sending-mta-ip' => $self->sending_mta_ip->ip ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 43 | 'receiving-mx-hostname' => $self->receiving_mx_hostname, | ||||||||||||||||||||||||||||||||||||||||
| 44 | $self->receiving_mx_helo ? ( 'receiving-mx-helo' => $self->receiving_mx_helo ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 45 | $self->receiving_ip ? ( 'receiving-ip' => $self->receiving_ip->ip ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 46 | 'failed-session-count' => $self->failed_session_count, | ||||||||||||||||||||||||||||||||||||||||
| 47 | $self->additional_information ? ( 'additional-information' => $self->additional_information ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 48 | $self->failure_reason_code ? ( 'failure-reason-code' => $self->failure_reason_code ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 49 | }; | ||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||
| 53 | 5 | ▶ | sub as_string($self) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 54 | 5 | ▶ | my $receiving_ip = $self->receiving_ip ? ' ('.$self->receiving_ip->ip.')' : ''; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 55 | 5 | ▶ | return join( "\n", | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||
| 56 | ' Failure:', | ||||||||||||||||||||||||||||||||||||||||
| 57 | ' Result-Type: '.$self->result_type, | ||||||||||||||||||||||||||||||||||||||||
| 58 | $self->sending_mta_ip ? (' Sending-MTA-IP: '.$self->sending_mta_ip->ip) : (), | ||||||||||||||||||||||||||||||||||||||||
| 59 | ' Receiving-MX-Hostname: '.$self->receiving_mx_hostname . $receiving_ip, | ||||||||||||||||||||||||||||||||||||||||
| 60 | $self->receiving_mx_helo ? (' Receiving-MX-HELO: '.$self->receiving_mx_helo) : (), | ||||||||||||||||||||||||||||||||||||||||
| 61 | ' Failed-Session-Count: '.$self->failed_session_count, | ||||||||||||||||||||||||||||||||||||||||
| 62 | $self->additional_information ? (' Additional-Information: '.$self->additional_information ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 63 | $self->failure_reason_code ? (' Failure-Reason-Code: '.$self->failure_reason_code ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | ▶ | sub _register_prometheus($self,$prometheus) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_register_prometheus: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | $prometheus->declare('tlsrpt_failures_total', help=>'TLSRPT failures', type=>'counter' ); | |||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | ▶ | sub process_prometheus($self,$policy,$report,$prometheus) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_prometheus: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 73 | 3 | $self->_register_prometheus($prometheus); | |||||||||||||||||||||||||||||||||||||||
| 74 | 3 | ▶ | $prometheus->add('tlsrpt_failures_total',$self->failed_session_count,{ | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->receiving_mx_helo // ""
MC/DC0%0/1
$self->receiving_mx_helo // ""
$self->receiving_mx_helo
Truth table50%1/2
A
A= $self->receiving_mx_helo
| |||||||||||||||||||||||||||||||||||||||||
| 75 | organization_name=>$report->organization_name, | ||||||||||||||||||||||||||||||||||||||||
| 76 | policy_type=>$policy->policy_type, | ||||||||||||||||||||||||||||||||||||||||
| 77 | policy_domain=>$policy->policy_domain, | ||||||||||||||||||||||||||||||||||||||||
| 78 | policy_mx_host=>$policy->policy_mx_host, | ||||||||||||||||||||||||||||||||||||||||
| 79 | result_type=>$self->result_type, | ||||||||||||||||||||||||||||||||||||||||
| 80 | sending_mta_ip=>$self->sending_mta_ip, | ||||||||||||||||||||||||||||||||||||||||
| 81 | receiving_mx_hostname=>$self->receiving_mx_hostname, | ||||||||||||||||||||||||||||||||||||||||
| 82 | receiving_mx_helo=>$self->receiving_mx_helo // '', | ||||||||||||||||||||||||||||||||||||||||
| 83 | receiving_ip=>($self->receiving_ip?$self->receiving_ip->ip:''), | ||||||||||||||||||||||||||||||||||||||||
| 84 | }); | ||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | ▶ | sub _csv_headers($self) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_csv_headers: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 88 | return ( | ||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | 'result type', | |||||||||||||||||||||||||||||||||||||||
| 90 | 'sending mta ip', | ||||||||||||||||||||||||||||||||||||||||
| 91 | 'receiving mx hostname', | ||||||||||||||||||||||||||||||||||||||||
| 92 | 'receiving mx helo', | ||||||||||||||||||||||||||||||||||||||||
| 93 | 'receiving ip', | ||||||||||||||||||||||||||||||||||||||||
| 94 | 'failed session count', | ||||||||||||||||||||||||||||||||||||||||
| 95 | 'additional information', | ||||||||||||||||||||||||||||||||||||||||
| 96 | 'failure reason code', | ||||||||||||||||||||||||||||||||||||||||
| 97 | ); | ||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||
| 100 | 3 | ▶ | sub _csv_fragment($self) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_csv_fragment: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||
| 101 | return ( | ||||||||||||||||||||||||||||||||||||||||
| 102 | 3 | ▶ | $self->result_type, | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$self->receiving_mx_helo // ""
$self->additional_information // ""
$self->failure_reason_code // ""
MC/DC0%0/1
$self->receiving_mx_helo // ""
$self->receiving_mx_helo
MC/DC100%1/1
$self->additional_information // ""
$self->additional_information
MC/DC100%1/1
$self->failure_reason_code // ""
$self->failure_reason_code
Truth table50%1/2
A
A= $self->receiving_mx_helo
Truth table100%2/2
A
A= $self->additional_information
Truth table100%2/2
A
A= $self->failure_reason_code
| |||||||||||||||||||||||||||||||||||||||||
| 103 | $self->sending_mta_ip->ip, | ||||||||||||||||||||||||||||||||||||||||
| 104 | $self->receiving_mx_hostname, | ||||||||||||||||||||||||||||||||||||||||
| 105 | $self->receiving_mx_helo // '', | ||||||||||||||||||||||||||||||||||||||||
| 106 | $self->receiving_ip ? $self->receiving_ip->ip : '', | ||||||||||||||||||||||||||||||||||||||||
| 107 | $self->failed_session_count, | ||||||||||||||||||||||||||||||||||||||||
| 108 | $self->additional_information // '', | ||||||||||||||||||||||||||||||||||||||||
| 109 | $self->failure_reason_code // '', | ||||||||||||||||||||||||||||||||||||||||
| 110 | ); | ||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||
| 113 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||
| 115 | __END__ | ||||||||||||||||||||||||||||||||||||||||