lib/App/Tel/Passwd/KeePass.pm

filter: Statementstmt 76.3% 29 / 38 Branchbran 50.0% 4 / 8 Conditioncond 50.0% 4 / 8 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 83.3% 5 / 6 Podpod 100% 2 / 2 totaltotal 67.1% 45 / 67 CC 8 SCAR 17.5
CC
8
Cov
69%
new
8.4
passwd
6.0
BEGIN
1.0
CRAP 5.7
« lib/App/Tel/Color/Cisco.pm ↑ Summary lib/App/Tel/Color.pm »
1 package App::Tel::Passwd::KeePass;
2  
3 =head1 name
4  
5 App::Tel::Passwd::KeePass - Passwd module for KeePass
6  
7 =cut
8  
9 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Module::Load;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 our $_debug = 0;
15  
16 =head1 METHODS
17  
18 =head2 new
19  
20 my $passwd = App::Tel::Passwd::KeePass->new( file => $filename, passwd => $password );
21  
22 Initializes a new passwd object. This will return a Passwd::KeePass Object if the module
23 exists and return undef if it doesn't.
24  
25 Requires filename and password for the file.
26  
27 =cut
28  
29 4 ▶sub new {
Subroutine new: called CC=7 SCAR=21.2
Pod documented
30 4 my $proto = shift;
31 4 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
040
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
32 4 my %args = @_;
33 4 my $self = { debug => $_debug,
34 %args
35 };
36  
37 4 ▶ if (!defined($self->{file}) || ! -r $self->{file} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"file"} and -r $self->{"file"}) 1 3 4
Condition66%2/3
defined $self->{"file"} and -r $self->{"file"}
!ll&&!rl&&r
103
MC/DC50%1/2
defined $self->{"file"} and -r $self->{"file"}
defined $self->{"file"} -r $self->{"file"}
Truth table66%2/3
A and B
A= defined $self->{"file"}B= -r $self->{"file"}
ABresult
0X0
100
111
38 1 ▶ $self->{file} ||= '<undefined>';
Condition50%1/2
$self->{"file"} ||= "<undefined>"
l!l
01
MC/DC0%0/1
$self->{"file"} ||= "<undefined>"
$self->{"file"}
Truth table50%1/2
A
A= $self->{"file"}
Aresult
11
00
39 1 croak "$class: Can't read file $self->{file}";
40 }
41  
42  
43 3 $self->{keepass} = eval {
44 3 load File::KeePass;
45 3 return File::KeePass->new();
46 };
47  
48 3 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 3 3
49 0 croak $@;
50 }
51  
52 # load failure on bad password or bad filename
53 3 my $k = eval { $self->{keepass}->load_db($self->{file}, $self->{passwd}); };
54 3 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 3 0 3
55 3 croak $@;
56 }
57 0 $k->unlock;
58 0 $self->{k} = $k;
59  
60 0 return bless( $self, $class );
61 }
62  
63 =head2 passwd
64  
65 $passwd->passwd($entry);
66  
67 This takes the entry for a key database and returns the password. It returns
68 a blank string if the entry wasn't found.
69  
70 =cut
71  
72 0 ▶sub passwd {
Subroutine passwd: not called CC=2 SCAR=17.9
Pod documented
73 0 my $self = shift;
74 0 my $k = $self->{k};
75 0 my $entry = shift;
76  
77 0 my $e = $k->find_entry({title => $entry});
78 0 ▶ return !defined($e->{'password'}) ? '' : $e->{'password'};
Branch: 1 branch
BranchTrueFalseTotal
!defined($e->{'password'}) ? : 0 0 0
79 }
80  
81 2 1;
« lib/App/Tel/Color/Cisco.pm ↑ Summary lib/App/Tel/Color.pm »