| 1 | 20 | ▶ | use v5.36; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 20 | ▶ | use feature 'class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 20 | ▶ | no warnings 'experimental::class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 20 | class Azure::SDK::Core::SecretString { | |||||||||||||||||||||||||||
| 6 | 20 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 20 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | use overload | ||||||||||||||||||||||||||||
| 9 | 3 | ▶ | '""' => sub { '[REDACTED]' }, | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | 'bool' => sub { 1 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | 'eq' => sub { $_[0]->equals($_[1]) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | 'ne' => sub { !$_[0]->equals($_[1]) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 20 | fallback => 1; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 20 | field $value :param = undef; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 227 | ▶ | ADJUST { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 18 | 227 | ▶ | croak 'Azure::SDK::Core::SecretString requires a value' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | unless defined $value; | ||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 201 | ▶ | method reveal () { | ||||||||||||||||||||||||||
|
Subroutine
reveal: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | 201 | return $value; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 6 | ▶ | method equals ($other) { | ||||||||||||||||||||||||||
|
Subroutine
equals: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 6 | ▶ | return 0 | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($other) and $other->isa("Azure::SDK::Core::SecretString")
MC/DC50%1/2
builtin::blessed($other) and $other->isa("Azure::SDK::Core::SecretString")
builtin::blessed($other)
$other->isa("Azure::SDK::Core::SecretString")
Truth table66%2/3
A and B
A= builtin::blessed($other)B= $other->isa("Azure::SDK::Core::SecretString")
| |||||||||||||||||||||||||||||
| 28 | unless blessed($other) | ||||||||||||||||||||||||||||
| 29 | && $other->isa('Azure::SDK::Core::SecretString'); | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 4 | return _constant_time_equals( $value, $other->reveal ); | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 4 | ▶ | sub _constant_time_equals ( $left, $right ) { | ||||||||||||||||||||||||||
|
Subroutine
_constant_time_equals: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||
| 35 | 4 | my $left_bytes = $left; | |||||||||||||||||||||||||||
| 36 | 4 | my $right_bytes = $right; | |||||||||||||||||||||||||||
| 37 | 4 | utf8::encode($left_bytes); | |||||||||||||||||||||||||||
| 38 | 4 | utf8::encode($right_bytes); | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 4 | my $left_length = length $left_bytes; | |||||||||||||||||||||||||||
| 41 | 4 | my $right_length = length $right_bytes; | |||||||||||||||||||||||||||
| 42 | 4 | ▶ | my $maximum_length = $left_length > $right_length ? $left_length : $right_length; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 4 | my $difference = $left_length ^ $right_length; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 4 | for my $index ( 0 .. $maximum_length - 1 ) { | |||||||||||||||||||||||||||
| 46 | 40 | ▶ | my $left_octet = $index < $left_length | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | ? ord substr( $left_bytes, $index, 1 ) | ||||||||||||||||||||||||||||
| 48 | : 0; | ||||||||||||||||||||||||||||
| 49 | 40 | ▶ | my $right_octet = $index < $right_length | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | ? ord substr( $right_bytes, $index, 1 ) | ||||||||||||||||||||||||||||
| 51 | : 0; | ||||||||||||||||||||||||||||
| 52 | 40 | $difference |= $left_octet ^ $right_octet; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 4 | return $difference == 0; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 20 | 1; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||||||||||