Branch Coverage

blib/lib/Crypt/HSXKPasswd.pm
Criterion Covered Total %
branch 163 326 50.0


line true false branch
132 9 1 unless $options->{'dictionary_file_encoding'}
136 0 10 if ($_CLASS->module_config('DEBUG'))
143 1 9 if ($options->{'dictionary'}) { }
1 8 elsif ($options->{'dictionary_list'}) { }
2 6 elsif ($options->{'dictionary_file'}) { }
155 1 9 if ($options->{'config'}) { }
1 8 elsif ($options->{'config_json'}) { }
2 6 elsif ($options->{'preset'}) { }
167 1 9 if ($options->{'rng'}) { }
233 0 11 if ($config_key eq 'LOG_STREAM') { }
0 11 elsif ($config_key eq 'LOG_ERRORS') { }
10 1 elsif ($config_key eq 'DEBUG') { }
0 1 elsif ($config_key eq 'ENTROPY_MIN_BLIND') { }
0 1 elsif ($config_key eq 'ENTROPY_MIN_SEEN') { }
1 0 elsif ($config_key eq 'ENTROPY_WARNINGS') { }
235 0 0 if (defined $new_value)
237 0 0 unless &FileHandle()->check($new_value)
248 0 0 if (defined $new_value)
250 0 0 unless &TrueFalse()->check($new_value)
261 0 10 if (defined $new_value)
263 0 0 unless &TrueFalse()->check($new_value)
273 0 0 if (defined $new_value)
275 0 0 unless &PositiveInteger()->check($new_value)
285 0 0 if (defined $new_value)
287 0 0 unless &PositiveInteger()->check($new_value)
297 1 0 if (defined $new_value)
299 0 1 unless &EntropyWarningLevel()->check($new_value)
422 0 0 unless $preset_name
480 0 10 unless $preset_name
489 1 9 if (defined $overrides)
495 0 1 unless (&Config()->check($config))
538 0 0 unless (eval { do { $json_string = 'JSON'->new->encode($return_object); 1 } })
602 0 1 if (not $options->{'suppress_warnings'} and $options->{'warn_invalid_key_names'})
611 0 0 unless ($defined_keys_lookup{$test_key})
620 9 8 if (defined $hashref->{$key})
621 9 0 if (&ConfigKeyAssignment()->check({$key, $hashref->{$key}})) { }
624 0 0 unless $options->{'suppress_warnings'}
660 108 0 if (&Symbol()->check($potential_symbol)) { }
663 0 0 if ($warn or _do_debug())
665 0 0 if ($warn) { }
726 0 0 if (not $is_valid and $options->{'croak'})
757 0 1 unless (eval { do { $ans = &encode_json($config); 1 } })
791 56 114 unless defined $config->{$key}
794 108 6 if (ref $config->{$key} eq '') { }
6 0 elsif (ref $config->{$key} eq 'ARRAY') { }
0 0 elsif (ref $config->{$key} eq 'HASH') { }
843 0 0 unless $preset
889 0 0 if ($stats{'length_min'} == $stats{'length_max'}) { }
923 12 23 if ($config->{'case_transform'} eq 'RANDOM')
926 23 12 if ($config->{'separator_character'} eq 'RANDOM')
929 23 12 if (defined $config->{'padding_character'} and $config->{'padding_character'} eq 'RANDOM')
972 0 20 if ($config->{'padding_type'} eq 'ADAPTIVE') { }
977 12 8 if ($config->{'padding_type'} eq 'FIXED')
981 12 8 if ($config->{'padding_digits_before'} > 0)
983 12 0 if ($config->{'separator_character'} ne 'NONE')
987 12 8 if ($config->{'padding_digits_after'} > 0)
989 12 0 if ($config->{'separator_character'} ne 'NONE')
993 20 0 if ($config->{'separator_character'} ne 'NONE')
1006 10 10 if ($config->{'padding_type'} ne 'ADAPTIVE' and not $suppres_warnings)
1007 0 10 if (defined $config->{'character_substitutions'})
1010 0 0 if (length $config->{'character_substitutions'}{$char} > 1)
1066 10 0 unless $encoding
1069 0 10 unless (defined $dictionary_source)
1076 0 10 unless (defined $self->{'_CONFIG'}{'word_length_min'} and $self->{'_CONFIG'}{'word_length_max'})
1082 10 0 if (&blessed($dictionary_source) and $dictionary_source->isa($_DICTIONARY_BASE_CLASS)) { }
0 0 elsif (ref $dictionary_source eq '' or ref $dictionary_source eq 'ARRAY') { }
1105 0 10 if ($self->{'_CONFIG'}{'allow_accents'}) { }
1147 0 10 unless (defined $config_raw)
1155 9 1 if (ref $config_raw eq 'HASH') { }
1 0 elsif (ref $config_raw eq '') { }
1166 0 1 unless (eval { do { $config_from_json = &decode_json($config_raw); 1 } })
1174 0 1 unless (&Config()->check($config))
1258 0 0 unless defined $new_keys->{$key}
1271 0 0 unless (&Config()->check($new_config))
1278 0 0 if ($new_config->{'word_length_min'} ne $self->{'_CONFIG'}{'word_length_min'} or $new_config->{'word_length_max'} ne $self->{'_CONFIG'}{'word_length_max'})
1316 0 10 unless (defined $rng)
1392 5 4 if ($self->{'_CONFIG'}{'padding_digits_before'} > 0)
1395 5 4 if ($self->{'_CONFIG'}{'padding_digits_after'} > 0)
1402 5 4 if ($self->{'_CONFIG'}{'padding_type'} eq 'FIXED') { }
0 4 elsif ($self->{'_CONFIG'}{'padding_type'} eq 'ADAPTIVE') { }
1404 5 0 if ($self->{'_CONFIG'}{'padding_characters_before'} > 0)
1409 5 0 if ($self->{'_CONFIG'}{'padding_characters_after'} > 0)
1417 0 0 if ($pwlen < $self->{'_CONFIG'}{'pad_to_length'}) { }
0 0 elsif ($pwlen > $self->{'_CONFIG'}{'pad_to_length'}) { }
1429 1 9 unless (eval { do { _debug('starting to generate random words'); my(@words) = $self->_random_words; _debug('got random words=' . join(', ', @words)); $self->_transform_case(\@words); $self->_substitute_characters(\@words); my $separator = $self->_separator; _debug("got separator=$separator"); my $pad_char = $self->_padding_char($separator); _debug("got pad_char=$pad_char"); $password = join($separator, @words); _debug("assembled base password: $password"); if ($self->{'_CONFIG'}{'padding_digits_before'} > 0) { $password = $self->_random_digits($self->{'_CONFIG'}{'padding_digits_before'}) . $separator . $password; } ; if ($self->{'_CONFIG'}{'padding_digits_after'} > 0) { $password = $password . $separator . $self->_random_digits($self->{'_CONFIG'}{'padding_digits_after'}); } ; _debug("added random digits (as configured): $password"); if ($self->{'_CONFIG'}{'padding_type'} eq 'FIXED') { if ($self->{'_CONFIG'}{'padding_characters_before'} > 0) { foreach my $c (1 .. $self->{'_CONFIG'}{'padding_characters_before'}) { $password = $pad_char . $password; } ; } ; if ($self->{'_CONFIG'}{'padding_characters_after'} > 0) { foreach my $c (1 .. $self->{'_CONFIG'}{'padding_characters_after'}) { $password .= $pad_char; } ; } ; } elsif ($self->{'_CONFIG'}{'padding_type'} eq 'ADAPTIVE') { my $pwlen = length $password; if ($pwlen < $self->{'_CONFIG'}{'pad_to_length'}) { while (length $password < $self->{'_CONFIG'}{'pad_to_length'}) { $password .= $pad_char; } ; } elsif ($pwlen > $self->{'_CONFIG'}{'pad_to_length'}) { $password = substr($password, 0, $self->{'_CONFIG'}{'pad_to_length'}); } ; } ; _debug("added padding (as configured): $password"); 1 } })
1520 0 0 unless (eval { do { $json_string = 'JSON'->new->encode($response_obj); 1 } })
1660 0 10 $stats{'dictionary_contains_accents'} ? :
1673 0 10 if ($stats{'password_length_min'} == $stats{'password_length_max'}) { }
1681 0 10 if ($stats{'password_length_min'} == $stats{'password_length_max'}) { }
1691 0 10 if ($_Types_CLASS::_DEBUG)
1693 0 0 if ($_Types_CLASS::_CAN_STACK_TRACE) { }
1724 0 10 unless (eval { do { $hsxkpasswd = $_CLASS->new(@constructor_args); 1 } })
1753 0 0 if ($self->{'debug'})
1754 0 0 unless &Config()->check($clone)
1779 6 4 if ($config->{'symbol_alphabet'})
1782 0 10 if ($config->{'padding_alphabet'})
1785 0 10 if ($config->{'separator_alphabet'})
1821 0 10 unless ($max_len >= $min_len)
1833 0 11334 if $grapheme_length < $min_len
1836 585 10749 if $grapheme_length > $max_len
1839 10749 0 unless ($allow_accents)
1875 0 0 unless ($word eq $word_accents_stripped)
1958 15 76 unless (defined $num)
1968 0 90 unless (defined $num and $num =~ /^\d+([.]\d+)?$/sux and $num >= 0 and $num <= 1)
1995 0 15 unless (scalar @random_numbers)
1999 1 135 unless ($num =~ /^1|(0([.]\d+)?)$/sux)
2057 0 9 if ($sep eq 'NONE') { }
5 4 elsif ($sep eq 'RANDOM') { }
2060 0 5 if (defined $self->{'_CONFIG'}{'separator_alphabet'}) { }
2090 9 0 if ($sep)
2091 0 9 unless (&Symbol()->check($sep))
2097 4 5 if ($self->{'_CONFIG'}{'padding_type'} eq 'NONE')
2103 0 5 if ($padc eq 'SEPARATOR') { }
5 0 elsif ($padc eq 'RANDOM') { }
2106 0 5 if (defined $self->{'_CONFIG'}{'padding_alphabet'}) { }
2138 0 9 if ($self->{'_CONFIG'}{'case_transform'} eq 'NONE')
2144 0 9 if ($self->{'_CONFIG'}{'case_transform'} eq 'UPPER') { }
0 9 elsif ($self->{'_CONFIG'}{'case_transform'} eq 'LOWER') { }
0 9 elsif ($self->{'_CONFIG'}{'case_transform'} eq 'CAPITALISE') { }
0 9 elsif ($self->{'_CONFIG'}{'case_transform'} eq 'INVERT') { }
5 4 elsif ($self->{'_CONFIG'}{'case_transform'} eq 'ALTERNATE') { }
4 0 elsif ($self->{'_CONFIG'}{'case_transform'} eq 'RANDOM') { }
2162 5 0 $self->_random_int(2) % 2 == 0 ? :
2165 5 10 if (($i + $rand_bias) % 2 == 0) { }
2175 8 12 if ($self->_random_int(2) % 2 == 0) { }
2208 9 0 unless (defined $self->{'_CONFIG'}{'character_substitutions'} and scalar keys %{$$self{'_CONFIG'}{'character_substitutions'};})
2244 0 17 unless (&ConfigKeyDefinition()->check($key_definitions->{$key_name}))
2249 1 0 if ($num_problems == 0) { }
2277 0 8 unless (&PresetDefinition()->check($preset_defs->{$preset_name}))
2282 1 0 if ($num_problems == 0) { }
2320 0 9 unless (eval { do { $rng = 'Crypt::HSXKPasswd::RNG::Math_Random_Secure'->new } })
2323 9 0 if $rng
2326 0 0 unless (eval { do { $rng = 'Crypt::HSXKPasswd::RNG::Data_Entropy'->new } })
2329 0 0 if $rng
2332 0 0 unless (eval { do { $rng = 'Crypt::HSXKPasswd::RNG::DevUrandom'->new } })
2335 0 0 if $rng
2387 10 0 if ($self->{'_CONFIG'}{'case_transform'} =~ /^(ALTERNATE)|(CAPITALISE)|(INVERT)|(RANDOM)$/sux)
2390 6 4 if ($self->{'_CONFIG'}{'padding_digits_before'} > 0 or $self->{'_CONFIG'}{'padding_digits_after'} > 0)
2393 10 0 if ($self->_passwords_will_contain_symbol or $self->{'_CACHE_CONTAINS_ACCENTS'})
2412 4 6 if ($self->{'_CONFIG'}{'case_transform'} eq 'RANDOM') { }
6 0 elsif ($self->{'_CONFIG'}{'case_transform'} eq 'ALTERNATE') { }
2422 6 4 if ($self->{'_CONFIG'}{'separator_character'} eq 'RANDOM')
2423 0 6 if (defined $self->{'_CONFIG'}{'separator_alphabet'}) { }
2430 6 4 if ($self->{'_CONFIG'}{'padding_type'} ne 'NONE' and $self->{'_CONFIG'}{'padding_character'} eq 'RANDOM')
2431 0 6 if (defined $self->{'_CONFIG'}{'padding_alphabet'}) { }
2520 6 4 if ($self->{'_CONFIG'}{'padding_type'} ne 'NONE')
2521 6 0 if ($self->{'_CONFIG'}{'padding_character'} eq 'RANDOM') { }
2522 0 6 if (defined $self->{'_CONFIG'}{'padding_alphabet'}) { }
2524 0 0 if ($all_pad_chars =~ /[^0-9a-zA-Z]/sux)
2529 6 0 if ($all_pad_chars =~ /[^0-9a-zA-Z]/sux)
2534 0 0 if ($self->{'_CONFIG'}{'padding_character'} =~ /[^0-9a-zA-Z]/sux)
2541 10 0 if ($self->{'_CONFIG'}{'separator_character'} ne 'NONE')
2542 6 4 if ($self->{'_CONFIG'}{'separator_character'} eq 'RANDOM') { }
2543 0 6 if (defined $self->{'_CONFIG'}{'separator_alphabet'}) { }
2545 0 0 if ($all_sep_chars =~ /[^0-9a-zA-Z]/sux)
2550 6 0 if ($all_sep_chars =~ /[^0-9a-zA-Z]/sux)
2555 4 0 if ($self->{'_CONFIG'}{'separator_character'} =~ /[^0-9a-zA-Z]/sux)
2583 10 10 unless $self->{'_DICTIONARY_SOURCE'} and &blessed($self->{'_DICTIONARY_SOURCE'}) and $self->{'_DICTIONARY_SOURCE'}->isa($_DICTIONARY_BASE_CLASS)
2590 0 10 unless (uc $_ENTROPY_WARNINGS eq 'NONE')
2592 0 0 if ($self->{'_CACHE_ENTROPYSTATS'}{'entropy_blind_min'} < $_ENTROPY_MIN_BLIND)
2597 0 0 unless (uc $_ENTROPY_WARNINGS eq 'BLIND')
2598 0 0 if ($self->{'_CACHE_ENTROPYSTATS'}{'entropy_seen'} < $_ENTROPY_MIN_SEEN)
2630 0 40 if (scalar @chars < 3)