| 1 | package App::S3Api; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use File::Temp qw(tempfile); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Role::Tiny::With; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 1 | with 'App::AWS'; | |||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use parent qw(App::Command); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | 1 | __PACKAGE__->follow_best_practice; | |||||||||||||||||||||||||||||||
| 15 | 1 | __PACKAGE__->mk_accessors(qw(region profile name policy)); | |||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub bucket_exists { | ||||||||||||||||||||||||||||||
|
Subroutine
bucket_exists: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 19 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 20 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 0 | my $bucket_name = $self->get_name; | |||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 0 | return $self->command( 'head-bucket' => [ '--bucket' => $bucket_name, ] ); | |||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub create_bucket { | ||||||||||||||||||||||||||||||
|
Subroutine
create_bucket: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 29 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 30 | 0 | my ( $self, $bucket_name ) = @_; | |||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | $bucket_name //= $self->get_name; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$bucket_name //= $self->get_name
MC/DC0%0/2
$bucket_name //= $self->get_name
$bucket_name
$self->get_name
Truth table0%0/3
A //= B
A= $bucket_nameB= $self->get_name
| |||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | 0 | my $region = $self->region; | |||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | my @location_constraint | ||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | = $region && $region ne 'us-east-1' | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$region and $region ne "us-east-1"
MC/DC0%0/2
$region and $region ne "us-east-1"
$region
$region ne "us-east-1"
Truth table0%0/3
A and B
A= $regionB= $region ne "us-east-1"
| |||||||||||||||||||||||||||||||||
| 38 | ? ( '--create-bucket-configuration' => sprintf 'LocationConstraint=%s', $region ) | ||||||||||||||||||||||||||||||||
| 39 | : (); | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 0 | my $result = $self->command( | |||||||||||||||||||||||||||||||
| 42 | 'create-bucket' => [ | ||||||||||||||||||||||||||||||||
| 43 | '--bucket' => $bucket_name, | ||||||||||||||||||||||||||||||||
| 44 | @location_constraint | ||||||||||||||||||||||||||||||||
| 45 | ] | ||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | die $self->get_error | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 49 | if $self->get_error; | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | 0 | return $result; | |||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub put_bucket_policy { | ||||||||||||||||||||||||||||||
|
Subroutine
put_bucket_policy: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 56 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 57 | 0 | my ( $self, $policy ) = @_; | |||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | 0 | my $bucket_name = $self->get_name; | |||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | $policy //= $self->get_policy; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$policy //= $self->get_policy
MC/DC0%0/2
$policy //= $self->get_policy
$policy
$self->get_policy
Truth table0%0/3
A //= B
A= $policyB= $self->get_policy
| |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | return | ||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if !$policy || !$bucket_name; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$policy and $bucket_name
MC/DC0%0/2
$policy and $bucket_name
$policy
$bucket_name
Truth table0%0/3
A and B
A= $policyB= $bucket_name
| |||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if ( $policy =~ /[.]json$/xms && -s $policy ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$policy =~ /[.]json$/msx and -s $policy
MC/DC0%0/2
$policy =~ /[.]json$/msx and -s $policy
$policy =~ /[.]json$/msx
-s $policy
Truth table0%0/3
A and B
A= $policy =~ /[.]json$/msxB= -s $policy
| |||||||||||||||||||||||||||||||||
| 66 | 0 | $policy = '--cli-input-json ' . $policy; | |||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | elsif ( $policy =~ /\s*{/xsm && eval { decode_json($policy) } ) { | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$policy =~ /\s*{/msx and eval {
do {
decode_json($policy)
}
}
MC/DC0%0/2
$policy =~ /\s*{/msx and eval {
do {
decode_json($policy)
}
}
$policy =~ /\s*{/msx
eval {
do {
decode_json($policy)
}
}
Truth table0%0/3
A and B
A= $policy =~ /\s*{/msxB= eval {
do {
decode_json($policy)
}
}
| |||||||||||||||||||||||||||||||||
| 69 | 0 | $policy = '--policy ' . $policy; | |||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||
| 71 | else { | ||||||||||||||||||||||||||||||||
| 72 | 0 | die sprintf "ERROR: policy [%s] is not found or invalid\n", $policy; | |||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | 0 | return $self->command( 'put-bucket-policy' => [ '--bucket' => $bucket_name, ] ); | |||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub policy_exists { | ||||||||||||||||||||||||||||||
|
Subroutine
policy_exists: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 80 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 81 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | 0 | my $bucket_name = $self->get_name; | |||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||
| 85 | 0 | return $self->command( 'get-bucket-policy' => [ '--bucket' => $bucket_name, ] ); | |||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | 1 | 1; | |||||||||||||||||||||||||||||||