| 1 | package App::ZofCMS::Plugin::RandomPasswordGeneratorPurePerl; | ||||||||||||
| 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 | our $VERSION = '1.001010'; # VERSION | |||||||||||
| 7 | |||||||||||||
| 8 | 1 | ▶ | use Digest::MD5 (qw/md5_hex/); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 1 | ▶ | use base 'App::ZofCMS::Plugin::Base'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 0 | ▶ | sub _key { 'plug_random_password_generator_pure_perl_pure_perl' } | ||||||||||
|
Subroutine
_key: not called CC=1 SCAR=6.9
| |||||||||||||
| 12 | 0 | ▶ | sub _defaults { | ||||||||||
|
Subroutine
_defaults: not called CC=1 SCAR=6.9
| |||||||||||||
| 13 | return ( | ||||||||||||
| 14 | 0 | length => 8, | |||||||||||
| 15 | chars => [ 0..9, 'a'..'z', 'A'..'Z' ], | ||||||||||||
| 16 | cell => 'd', | ||||||||||||
| 17 | key => 'random_pass', | ||||||||||||
| 18 | md5_hex => 0, | ||||||||||||
| 19 | pass_num => 1, | ||||||||||||
| 20 | ); | ||||||||||||
| 21 | } | ||||||||||||
| 22 | 0 | ▶ | sub _do { | ||||||||||
|
Subroutine
_do: not called CC=7 SCAR=40.3
| |||||||||||||
| 23 | 0 | my ( $self, $conf, $template, $query, $config ) = @_; | |||||||||||
| 24 | |||||||||||||
| 25 | 0 | my @passwords; | |||||||||||
| 26 | |||||||||||||
| 27 | 0 | for ( 1 .. $conf->{pass_num} ) { | |||||||||||
| 28 | 0 | ▶ | my @chars = @{ $conf->{chars} || ['0'] }; | ||||||||||
|
Condition0%0/2
$conf->{'chars'} || ['0']
MC/DC0%0/1
$conf->{'chars'} || ['0']
$conf->{'chars'}
Truth table0%0/2
A
A= $conf->{'chars'}
| |||||||||||||
| 29 | 0 | ▶ | @chars = '0' | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 30 | unless @chars; | ||||||||||||
| 31 | |||||||||||||
| 32 | 0 | my $password = ''; | |||||||||||
| 33 | |||||||||||||
| 34 | 0 | ▶ | while ( $conf->{length} > length $password ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 35 | 0 | $password .= @chars[ rand @chars ]; | |||||||||||
| 36 | } | ||||||||||||
| 37 | |||||||||||||
| 38 | $password = [ $password, md5_hex($password) ] | ||||||||||||
| 39 | 0 | ▶ | if $conf->{md5_hex}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 40 | |||||||||||||
| 41 | 0 | push @passwords, $password; | |||||||||||
| 42 | } | ||||||||||||
| 43 | |||||||||||||
| 44 | $template->{ $conf->{cell} }{ $conf->{key} } | ||||||||||||
| 45 | 0 | ▶ | = @passwords > 1 ? \@passwords : $passwords[0]; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 46 | } | ||||||||||||
| 47 | |||||||||||||
| 48 | |||||||||||||
| 49 | 1 | 1; | |||||||||||
| 50 | __END__ | ||||||||||||