| 1 | package DBIx::Class::CryptColumn; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | $DBIx::Class::CryptColumn::VERSION = '0.007'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Sub::Util 1.40 'set_subname'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use parent 'DBIx::Class'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | __PACKAGE__->load_components(qw(InflateColumn::Crypt::Passphrase)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | my ($self, $attr, @rest) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | for my $col (grep { !/^-/ } keys %{ $attr }) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | next unless my $inflate = $self->column_info($col)->{inflate_passphrase}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | $attr->{$col} = $inflate->hash_password($attr->{$col}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | return $self->next::method($attr, @rest); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | sub _export_sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | my ($self, $name, $sub) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_export_sub: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | my $full_name = $self->result_class . "::$name"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | *$full_name = set_subname $full_name => $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | sub register_column { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | my ($self, $column, $info, @rest) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_column: called CC=6 SCAR=21.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | ▶ | if (my $args = $info->{inflate_passphrase}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | $self->throw_exception(q['inflate_passphrase' must be a hash reference]) unless ref $args eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | my $crypt_passphrase = Crypt::Passphrase->new(%{$args}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | ▶ | if (defined(my $name = $args->{verify_method})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | $self->_export_sub($name, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my ($row, $password) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Subroutine
verify_passphrase: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | return $crypt_passphrase->verify_password($password, $row->get_column($column)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | if (defined(my $name = $args->{rehash_method})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | $self->_export_sub($name, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | my $row = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Subroutine
passphrase_needs_rehash: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | return $crypt_passphrase->needs_rehash($row->get_column($column)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | if (defined(my $name = $args->{verify_and_rehash_method})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | $self->_export_sub($name, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | my ($row, $password) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=16.7
Subroutine
verify_and_rehash_password: called CC=3 SCAR=16.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my $hash = $row->get_column($column); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $result = $crypt_passphrase->verify_password($password, $hash); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if ($result && $crypt_passphrase->needs_rehash($hash)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%1/6
$result and $crypt_passphrase->needs_rehash($hash)
$result and $crypt_passphrase->needs_rehash($hash)
MC/DC0%0/2
$result and $crypt_passphrase->needs_rehash($hash)
$result
$crypt_passphrase->needs_rehash($hash)
MC/DC0%0/2
$result and $crypt_passphrase->needs_rehash($hash)
$result
$crypt_passphrase->needs_rehash($hash)
Truth table0%0/3
A and B
A= $resultB= $crypt_passphrase->needs_rehash($hash)
Truth table33%1/3
A and B
A= $resultB= $crypt_passphrase->needs_rehash($hash)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $row->update({ $column => $password })->discard_changes; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | $info->{inflate_passphrase} = $crypt_passphrase; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | $self->next::method($column, $info, @rest); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | sub set_column { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | ▶ | my ($self, $col, $val, @rest) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_column: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 3 | my $inflate = $self->column_info($col)->{inflate_passphrase}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 3 | ▶ | $val = $inflate->hash_password($val) if $inflate; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 3 | return $self->next::method($col, $val, @rest); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | sub set_inflated_column { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | ▶ | my ($self, $col, $val, @rest) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_inflated_column: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | local $self->column_info($col)->{inflate_passphrase}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | $self->next::method($col, $val, @rest); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # ABSTRACT: Automatically hash password/passphrase columns | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||