blib/lib/Data/Validate/WithYAML/Plugin/PasswordPolicy.pm

filter: Statementstmt 100% 48 / 48 Branchbran 100% 34 / 34 Conditioncond 100% 21 / 21 MC/DCmcdc 100% 13 / 13 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 121 / 121 CC 28 SCAR 32.3
CC
28
Cov
100%
check
28.0
BEGIN
1.0
BEGIN
1.0
CRAP 25.4
↑ Summary
1 package Data::Validate::WithYAML::Plugin::PasswordPolicy;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # ABSTRACT: Plugin to check passwords against a policy
9  
10 1 our $VERSION = '0.03';
11  
12 206 ▶sub check {
Subroutine check: called CC=28 SCAR=33.3
Pod documented
13 206 my ($class, $value, $options) = @_;
14
15 206 ▶ return unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 14 192 206
16 192 ▶ return if $value eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "" 14 178 192
17  
18 178 ▶ return 1 if !$options;
Branch: 1 branch
BranchTrueFalseTotal
unless $options 6 172 178
19  
20 172 ▶ my %policy = %{ $options->{'x-policy'} || {} };
Condition100%2/2
$options->{'x-policy'} || {}
l!l
15616
MC/DC100%1/1
$options->{'x-policy'} || {}
$options->{'x-policy'}
Truth table100%2/2
A
A= $options->{'x-policy'}
Aresult
11
00
21 172 ▶ return 1 if !%policy;
Branch: 1 branch
BranchTrueFalseTotal
unless %policy 32 140 172
22  
23 140 my $return = 1;
24  
25 140 ▶ if ( $policy{length} && $policy{length} =~ /,/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($policy{'length'} and $policy{'length'} =~ /,/) { } 90 50 140
elsif ($policy{'length'}) { } 36 14 50
Condition100%3/3
$policy{"length"} and $policy{"length"} =~ /,/
!ll&&!rl&&r
143690
MC/DC100%2/2
$policy{"length"} and $policy{"length"} =~ /,/
$policy{"length"} $policy{"length"} =~ /,/
Truth table100%3/3
A and B
A= $policy{"length"}B= $policy{"length"} =~ /,/
ABresult
0X0
100
111
26 90 my ($min,$max) = $policy{length} =~ /\s*(\d+)\s*,(?:\s*(\d+)\s*)?/;
27 90 my $bool = 1;
28  
29 90 ▶ if(defined $min and length $value < $min){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $min and length $value < $min) 24 66 90
Condition100%3/3
defined $min and length $value < $min
!ll&&!rl&&r
66024
MC/DC100%2/2
defined $min and length $value < $min
defined $min length $value < $min
Truth table100%3/3
A and B
A= defined $minB= length $value < $min
ABresult
0X0
100
111
30 24 $bool = 0;
31 }
32  
33 90 ▶ if(defined $max and length $value > $max){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $max and length $value > $max) 12 78 90
Condition100%3/3
defined $max and length $value > $max
!ll&&!rl&&r
285012
MC/DC100%2/2
defined $max and length $value > $max
defined $max length $value > $max
Truth table100%3/3
A and B
A= defined $maxB= length $value > $max
ABresult
0X0
100
111
34 12 $bool = 0;
35 }
36  
37 90 $return &= $bool;
38 }
39 elsif ( $policy{length} ) {
40 36 $return &= ( $policy{length} == length $value );
41 }
42  
43 140 ▶ return if !$return;
Branch: 1 branch
BranchTrueFalseTotal
unless $return 57 83 140
44  
45 83 ▶ if ( defined $policy{chars} and !ref $policy{chars} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $policy{"chars"} and not ref $policy{"chars"}) 6 77 83
Condition100%3/3
defined $policy{"chars"} and not ref $policy{"chars"}
!ll&&!rl&&r
48296
MC/DC100%2/2
defined $policy{"chars"} and not ref $policy{"chars"}
defined $policy{"chars"} not ref $policy{"chars"}
Truth table100%3/3
A and not(B)
A= defined $policy{"chars"}B= not ref $policy{"chars"}
ABresult
0X0
100
111
46 6 $policy{chars} = [ $policy{chars} ];
47 }
48  
49 CLASS:
50 83 ▶ for my $class ( @{ $policy{chars} || [] } ) {
Condition100%2/2
$policy{'chars'} || []
l!l
3548
MC/DC100%1/1
$policy{'chars'} || []
$policy{'chars'}
Truth table100%2/2
A
A= $policy{'chars'}
Aresult
11
00
51 43 my $re = qr/[$class]/;
52 43 ▶ my $matches = $value =~ $re ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value =~ /$re/ ? : 30 13 43
53 43 $return &= $matches;
54  
55 43 ▶ last CLASS if !$return;
Branch: 1 branch
BranchTrueFalseTotal
unless $return 13 30 43
56 }
57
58 83 ▶ return if !$return;
Branch: 1 branch
BranchTrueFalseTotal
unless $return 13 70 83
59  
60 70 ▶ if ( defined $policy{chars_blacklist} and !ref $policy{chars_blacklist} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $policy{"chars_blacklist"} and not ref $policy{"chars_blacklist"}) 9 61 70
Condition100%3/3
defined $policy{"chars_blacklist"} and not ref $policy{"chars_blacklist"}
!ll&&!rl&&r
5299
MC/DC100%2/2
defined $policy{"chars_blacklist"} and not ref $policy{"chars_blacklist"}
defined $policy{"chars_blacklist"} not ref $policy{"chars_blacklist"}
Truth table100%3/3
A and not(B)
A= defined $policy{"chars_blacklist"}B= not ref $policy{"chars_blacklist"}
ABresult
0X0
100
111
61 9 $policy{chars_blacklist} = [ $policy{chars_blacklist} ];
62 }
63  
64 CLASS:
65 70 ▶ for my $class ( @{ $policy{chars_blacklist} || [] } ) {
Condition100%2/2
$policy{'chars_blacklist'} || []
l!l
1852
MC/DC100%1/1
$policy{'chars_blacklist'} || []
$policy{'chars_blacklist'}
Truth table100%2/2
A
A= $policy{'chars_blacklist'}
Aresult
11
00
66 18 my $re = qr/[$class]/;
67 18 ▶ my $matches = $value =~ $re ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$value =~ /$re/ ? : 6 12 18
68 18 $return &= $matches;
69  
70 18 ▶ last CLASS if !$return;
Branch: 1 branch
BranchTrueFalseTotal
unless $return 6 12 18
71 }
72
73 70 ▶ return if !$return;
Branch: 1 branch
BranchTrueFalseTotal
unless $return 6 64 70
74 64 return 1;
75 }
76  
77 1 1;
78  
79 __END__
↑ Summary