Authentication/Handler/Logger.pm

filter: Statementstmt 80.0% 40 / 50 Branchbran 58.3% 7 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod 0.0% 0 / 6 totaltotal 72.5% 58 / 80 CC 7 SCAR 6.9
CC
7
Cov
76%
header_callback
3.0
connect_callback
2.5
helo_callback
2.3
CRAP 2.0
« Authentication/App/ProcessLog/App.pm ↑ Summary Authentication/Handler/Auth.pm »
1 package Mail::Milter::Authentication::Handler::Logger;
2 1 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Mail::Milter::Authentication::Pragmas;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 # ABSTRACT: Handler class for logging of headerss
7 1 our $VERSION = '4.20261116'; # VERSION
8 1 ▶use base 'Mail::Milter::Authentication::Handler';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Sys::Syslog qw{:standard :macros};
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 0 ▶sub default_config {
Subroutine default_config: not called CC=1 SCAR=6.9
Pod undocumented
13 return {
14 0 connect => 0,
15 helo => 0,
16 envfrom => 0,
17 envrcpt => 0,
18 header => [
19 'from',
20 'to',
21 'message-id',
22 ],
23 };
24 }
25  
26 1 ▶sub connect_callback {
Subroutine connect_callback: called CC=2 SCAR=9.2
Pod undocumented
27 1 my ( $self, $hostname, $ip ) = @_;
28 1 my $config = $self->handler_config();
29 1 ▶ return if ! $config->{connect};
Branch: 1 branch
BranchTrueFalseTotal
unless $config->{"connect"} 1 0 1
30 0 $self->dbgout( 'Logger', 'Connection host: ' . $hostname, LOG_INFO );
31 0 $self->dbgout( 'Logger', 'Connection IP: ' . $ip->short(), LOG_INFO );
32 0 return;
33 }
34  
35 1 ▶sub helo_callback {
Subroutine helo_callback: called CC=2 SCAR=8.4
Pod undocumented
36 1 my ( $self, $helo_host ) = @_;
37 1 my $config = $self->handler_config();
38 1 ▶ return if ! $config->{helo};
Branch: 1 branch
BranchTrueFalseTotal
unless $config->{"helo"} 1 0 1
39 0 $self->dbgout( 'Logger', 'HELO: ' . $helo_host, LOG_INFO );
40 0 return;
41 }
42  
43 1 ▶sub envfrom_callback {
Subroutine envfrom_callback: called CC=2 SCAR=8.4
Pod undocumented
44 1 my ( $self, $env_from ) = @_;
45 1 my $config = $self->handler_config();
46 1 ▶ return if ! $config->{envfrom};
Branch: 1 branch
BranchTrueFalseTotal
unless $config->{"envfrom"} 1 0 1
47 0 $self->dbgout( 'Logger', 'MAIL FROM: ' . $env_from, LOG_INFO );
48 0 return;
49 }
50  
51 1 ▶sub envrcpt_callback {
Subroutine envrcpt_callback: called CC=2 SCAR=8.4
Pod undocumented
52 1 my ( $self, $env_to ) = @_;
53 1 my $config = $self->handler_config();
54 1 ▶ return if ! $config->{envrcpt};
Branch: 1 branch
BranchTrueFalseTotal
unless $config->{"envrcpt"} 1 0 1
55 0 $self->dbgout( 'Logger', 'RCPT TO: ' . $env_to, LOG_INFO );
56 0 return;
57 }
58  
59 3 ▶sub header_callback {
Subroutine header_callback: called CC=3 SCAR=11.0
Pod undocumented
60 3 my ( $self, $header, $value ) = @_;
61 3 my $config = $self->handler_config();
62 3 ▶ return if ! $config->{header};
Branch: 1 branch
BranchTrueFalseTotal
unless $config->{"header"} 0 3 3
63 3 my @wanted = map { lc $_ } sort $config->{header}->@*;
64 3 ▶ if ( grep { $_ eq lc( $header ) } @wanted ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq lc $header;} @wanted) 1 2 3
65 1 $self->dbgout( 'Logger', 'Header: ' . $header . ': ' . $value, LOG_INFO );
66 }
67 3 return;
68 }
69  
70 1 1;
71  
72 __END__
« Authentication/App/ProcessLog/App.pm ↑ Summary Authentication/Handler/Auth.pm »