| 1 | package AWS::S3::Roles::Bucket; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 7 | ▶ | sub bucket_uri { | ||||||||||||||||||||||||||
|
Subroutine
bucket_uri: called CC=5 SCAR=16.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 6 | 7 | my ( $s,$path ) = @_; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 7 | ▶ | $path //= $s->bucket; | ||||||||||||||||||||||||||
|
Condition66%2/3
$path //= $s->bucket
MC/DC0%0/2
$path //= $s->bucket
$path
$s->bucket
Truth table66%2/3
A //= B
A= $pathB= $s->bucket
| |||||||||||||||||||||||||||||
| 9 | 7 | ▶ | my $protocol = $s->s3->secure ? 'https' : 'http'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 10 | 7 | my $endpoint = $s->s3->endpoint; | |||||||||||||||||||||||||||
| 11 | 7 | my $uri = "$protocol://$endpoint/$path"; | |||||||||||||||||||||||||||
| 12 | 7 | ▶ | if ( $path =~ m{^([^/?]+)(.*)} && $s->is_dns_bucket( $1 ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$path =~ m[^([^/?]+)(.*)] and $s->is_dns_bucket($1)
MC/DC50%1/2
$path =~ m[^([^/?]+)(.*)] and $s->is_dns_bucket($1)
$path =~ m[^([^/?]+)(.*)]
$s->is_dns_bucket($1)
Truth table66%2/3
A and B
A= $path =~ m[^([^/?]+)(.*)]B= $s->is_dns_bucket($1)
| |||||||||||||||||||||||||||||
| 13 | 5 | $uri = "$protocol://$1.$endpoint$2"; | |||||||||||||||||||||||||||
| 14 | } # end if() | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 7 | return $uri; | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 14 | ▶ | sub is_dns_bucket { | ||||||||||||||||||||||||||
|
Subroutine
is_dns_bucket: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 20 | 14 | my ( $s,$bucket ) = @_; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html | ||||||||||||||||||||||||||||
| 23 | 14 | ▶ | return 0 if ( length( $bucket ) < 3 or length( $bucket ) > 63 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
length $bucket < 3 or length $bucket > 63
MC/DC100%2/2
length $bucket < 3 or length $bucket > 63
length $bucket < 3
length $bucket > 63
Truth table100%3/3
A or B
A= length $bucket < 3B= length $bucket > 63
| |||||||||||||||||||||||||||||
| 24 | 12 | ▶ | return 0 if $bucket =~ /^(?:\d{1,3}\.){3}\d{1,3}$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # DNS bucket names can contain lowercase letters, numbers, and hyphens | ||||||||||||||||||||||||||||
| 27 | # so anything outside this range we say isn't a valid DNS bucket | ||||||||||||||||||||||||||||
| 28 | 11 | ▶ | return $bucket =~ /[^a-z0-9-\.]/ ? 0 : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 2 | 1; | |||||||||||||||||||||||||||