bin/mail-dkim

filter: Statementstmt 100% 26 / 26 Branchbran 75.0% 3 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 92.1% 35 / 38 CC 1 SCAR 0.0
CC
1
Cov
94%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« bin/dmarc-check-mail.pl ↑ Summary
1 #!/usr/bin/env perl
2 #
3 # mail-dkim - sign a message that arrives on stdin, then hand it to sendmail(1)
4 # with the arguments given on the command line.
5 #
6 # It exists to be dropped where a CGI script or a cron job calls
7 # /usr/sbin/sendmail directly: those messages go out with no signature, so a
8 # forwarded copy looks exactly like a forgery to the receiving site. Pointing
9 # that one call at this instead signs the mail without touching the script.
10 #
11 # The signing is in Mail::Send::DKIM; this is the command line around it, so
12 # that the module can be used and tested without a process and a pipe.
13  
14 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 5 ▶use FindBin qw($Bin);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 # Where the module is: beside this script in a checkout, and one level down
19 # under lib/perl5 when the distribution was installed with INSTALL_BASE - which
20 # is how perlbrew, local::lib and cpanm -l put it, and where @INC does not
21 # reach unless PERL5LIB is set for every caller, cron included.
22 5 ▶use lib grep { -d } map { "$Bin/../$_" } qw(lib lib/perl5);
Subroutine BEGIN: called CC=1 SCAR=0.0
23 5 ▶use Mail::Send::DKIM;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 5 my $dkim = Mail::Send::DKIM->new();
26  
27 5 ▶my $message = do { local $/; <STDIN> } // '';
Condition50%1/2
do { local $/; readline STDIN } // ""
l!l
50
MC/DC0%0/1
do { local $/; readline STDIN } // ""
do { local $/; readline STDIN }
Truth table50%1/2
A
A= do { local $/; readline STDIN }
Aresult
11
00
28 5 my $signed = $dkim->sign($message);
29 5 ▶$message = $signed if(defined($signed));
Branch: 1 branch
BranchTrueFalseTotal
if defined $signed 4 1 5
30  
31 5 my $status = $dkim->send($message, @ARGV);
32 5 ▶$dkim->log_send($message, @ARGV) if($status == 0);
Branch: 1 branch
BranchTrueFalseTotal
if $status == 0 5 0 5
33  
34 5 exit($status);
35  
36 __END__
« bin/dmarc-check-mail.pl ↑ Summary