AWS-S3

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


Changelog for perl module AWS::S3

3.00 2026-12-01
  - Security: XML escape object keys in delete_multi and the location in
    add_bucket, preventing XML injection (e.g. deleting unintended objects)
  - Security: bucket names are validated (letters, numbers, ".", "_" and "-"
    only) so they can't change the host a request is sent to, and object keys
    and list prefix/delimiter/marker values are escaped in request URLs
  - Security: a TemporaryRedirect is only followed to a trusted host (the
    endpoint, or an S3 host for AWS) and the request is signed again, using
    the region of the new host, instead of replaying the signed request
  - Security: requests are made over https by default (BREAKING: pass
    secure => 0 for plain http), and LWP::Protocol::https is now required
  - Security: responses containing a DOCTYPE are refused and the XML parser
    no longer expands entities or loads external DTDs or network resources
  - Remove the unused SigV2 signer (AWS::S3::Signer) and the dependency on
    Digest::HMAC_SHA1, AWS::S3::HTTPRequest now uses a v4 signature
  - Fix the code of a non-XML error response being the whole response body,
    it is now a leading number or the HTTP status, so an error response with
    no body is no longer treated as success

README.markdown  view on Meta::CPAN


Optional.  Boolean.

Default is `1`, requests are made over `https`. Set to `0` to use plain
`http` (for example for a local S3 compatible service for testing), but be
aware the requests, including the session token and any data, can then be read
or modified on the network.

[LWP::Protocol::https](https://metacpan.org/pod/LWP%3A%3AProtocol%3A%3Ahttps) is required for `https`.

## endpoint

Optional.  String.

Default is `s3.amazonaws.com`

## ua

Optional.  Should be an instance of [LWP::UserAgent](https://metacpan.org/pod/LWP%3A%3AUserAgent) or a subclass of it.

Defaults to creating a new instance of [LWP::UserAgent::Determined](https://metacpan.org/pod/LWP%3A%3AUserAgent%3A%3ADetermined)

README.markdown  view on Meta::CPAN

String.  Read-only

## secret\_access\_key

String.  Read-only.

## secure

Boolean.  Read-only.

## endpoint

String.  Read-only.

## ua

[LWP::UserAgent](https://metacpan.org/pod/LWP%3A%3AUserAgent) object.  Read-only.

## owner

[AWS::S3::Owner](https://metacpan.org/pod/AWS%3A%3AS3%3A%3AOwner) object.  Read-only.

lib/AWS/S3.pm  view on Meta::CPAN


# use https unless told otherwise, over http the request can be read and
# modified on the network, including the session token and the contents
has 'secure' => (
    is      => 'ro',
    isa     => 'Bool',
    lazy    => 1,
    default => 1
);

has 'endpoint' => (
    is      => 'ro',
    isa     => 'Str',
    lazy    => 1,
    default => sub {
        my ( $s ) = @_;

        if ( my $region = $s->region ) {
            return "s3.$region.amazonaws.com"
        } else {
            return "s3.amazonaws.com"

lib/AWS/S3.pm  view on Meta::CPAN

    return $class->new( %args, s3 => $s, type => $type );
}    # end request()

sub owner {
    my $s = shift;

    my $type     = 'ListAllMyBuckets';
    my $request  = $s->request( $type );
    my $response = $request->request();

    # Linode/Akamai E3 endpoints do not include the `xmlns` in
    # ListAllMyBuckets, so use the localname to work with or
    # without a declared XML namespace.
    my $xml      = $response->xml;
    my ($node)   = $xml->getElementsByLocalName('Owner');
    return AWS::S3::Owner->new(
        id           => $node->getElementsByLocalName('ID')->string_value,
        display_name => $node->getElementsByLocalName('DisplayName')->string_value,
    );
}    # end owner()

sub buckets {
    my ( $s ) = @_;

    my $type     = 'ListAllMyBuckets';
    my $request  = $s->request( $type );
    my $response = $request->request();

    # Linode/Akamai E3 endpoints do not include the `xmlns` in
    # ListAllMyBuckets, so use the localname to work with or
    # without a declared XML namespace.
    my $xml     = $response->xml;
    my @buckets = ();
    foreach my $node ( $xml->getElementsByLocalName( 'Bucket' ) ) {
        push @buckets,
          AWS::S3::Bucket->new(
            name          => $node->getElementsByLocalName('Name')->string_value,
            creation_date => $node->getElementsByLocalName('CreationDate')->string_value,
            s3            => $s,

lib/AWS/S3.pm  view on Meta::CPAN


Optional.  Boolean.

Default is C<1>, requests are made over C<https>. Set to C<0> to use plain
C<http> (for example for a local S3 compatible service for testing), but be
aware the requests, including the session token and any data, can then be read
or modified on the network.

L<LWP::Protocol::https> is required for C<https>.

=head2 endpoint

Optional.  String.

Default is C<s3.amazonaws.com>

=head2 ua

Optional.  Should be an instance of L<LWP::UserAgent> or a subclass of it.

Defaults to creating a new instance of L<LWP::UserAgent::Determined>

lib/AWS/S3.pm  view on Meta::CPAN

String.  Read-only

=head2 secret_access_key

String.  Read-only.

=head2 secure

Boolean.  Read-only.

=head2 endpoint

String.  Read-only.

=head2 ua

L<LWP::UserAgent> object.  Read-only.

=head2 owner

L<AWS::S3::Owner> object.  Read-only.

lib/AWS/S3/Request/CreateBucket.pm  view on Meta::CPAN

    my $xml = q{};
    if ( $s->location && $s->location ne 'us-east-1' ) {
        $xml = <<"XML";
<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> 
  <LocationConstraint>@{[ $s->_xml_escape( $s->location ) ]}</LocationConstraint>
</CreateBucketConfiguration>
XML
    }

    return $s->_send_request(
        PUT => URI->new( $s->protocol . '://' . $s->bucket . '.' . $s->endpoint . '/' ) => {
            Date           => $s->_http_date,
            'content-type' => 'text/plain',
        },
        $xml
    );
}

__PACKAGE__->meta->make_immutable;

lib/AWS/S3/Request/SetBucketAccessControl.pm  view on Meta::CPAN

    is       => 'ro',
    isa      => 'Str',
    required => 0,
);

has '+_expect_nothing' => ( default => 1 );

sub request {
    my $s = shift;

    my $uri = URI->new( $s->protocol . '://' . $s->bucket . '.' . $s->endpoint . '/?acl' );

    if ( $s->acl_short ) {
        return $s->_send_request(
            PUT => $uri => {
                Date          => $s->_http_date,
                'x-amz-acl'   => $s->acl_short
            },
            $s->acl_xml
        );
    } elsif ( $s->acl_xml ) {

lib/AWS/S3/Request/SetFileContents.pm  view on Meta::CPAN

    } elsif ( ref( $s->file->contents ) eq 'SCALAR' ) {
        $contents = $s->file->contents;
    }    # end if()

    my %other_args = ();
    $other_args{'x-amz-server-side-encryption'} = 'AES256' if $s->file->is_encrypted;

    # the key must be escaped, otherwise characters such as "?" or "#" in it
    # change the meaning of the request (e.g. a key of "foo?acl" would become
    # a PUT of the "acl" subresource rather than an upload of an object)
    my $uri = $s->protocol . '://' . $s->bucket . '.' . $s->endpoint . '/' . $s->_escape_key( $s->file->key );

    $s->_send_request(
        PUT => URI->new( $uri ) => {
            Date                  => $s->_http_date,
            'content-type'        => $s->content_type,
            'content-md5'         => $contents ? $s->_content_md5( $$contents ) : '',
            'x-amz-storage-class' => $s->file->storage_class,
        },
        $$contents
    );

lib/AWS/S3/Roles/Bucket.pm  view on Meta::CPAN

package AWS::S3::Roles::Bucket;

use Moose::Role;

sub bucket_uri {
    my ( $s,$path ) = @_;

    $path      //= $s->bucket;
    my $protocol = $s->s3->secure ? 'https' : 'http';
    my $endpoint = $s->s3->endpoint;
    my $uri = "$protocol://$endpoint/$path";
    if ( $path =~ m{^([^/?]+)(.*)} && $s->is_dns_bucket( $1 ) ) {
        $uri = "$protocol://$1.$endpoint$2";
    }    # end if()

    return $uri;
}

sub is_dns_bucket {
    my ( $s,$bucket ) = @_;

    # https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html
    return 0 if ( length( $bucket ) < 3 or length( $bucket ) > 63 );

lib/AWS/S3/Roles/Request.pm  view on Meta::CPAN


has 'protocol' => (
    is      => 'ro',
    isa     => 'Str',
    lazy    => 1,
    default => sub {
        shift->s3->secure ? 'https' : 'http';
    }
);

has 'endpoint' => (
    is      => 'ro',
    isa     => 'Str',
    lazy    => 1,
    default => sub {
        shift->s3->endpoint;
    }
);

# XXX should be required=>1; https://rt.cpan.org/Ticket/Display.html?id=77863
has "_action" => (
    isa       => 'Str',
    is        => 'ro',
    init_arg  => undef,
    #required  => 1
);

lib/AWS/S3/Roles/Request.pm  view on Meta::CPAN

    isa     => Uri,
    is      => 'ro',
    lazy    => 1,
    default => sub {
        my $self = shift;
        my $m = $self->meta;

        my $uri = URI->new(
            $self->protocol . '://'
            . ( $m->has_attribute('bucket') ? $self->bucket . '.' : '' )
            . $self->endpoint
            . '/'
        );

		# note we add some extra exceptions to uri_escape to prevent
		# encoding of things like "/", ":", "="
        if ( $m->has_attribute('key') ) {
            my $escaped_path = $self->_escape_key( $self->key );

            # if we have a leading slash in the key name we need to add *another*
            # slash in the call to ->path to ensure it is retained

lib/AWS/S3/Roles/Request.pm  view on Meta::CPAN

        # the body) to somewhere we have no reason to trust, the response may
        # have been tampered with, particularly if we are not using https
        unless ( defined $location && $s->_is_trusted_redirect( $location ) ) {
            ( my $safe = $res->header( 'location' ) ) =~ s/[^\x21-\x7e]/?/g;
            $LOG->error( 'Refusing to follow redirect to untrusted location', { location => $safe } );
            die "Refusing to follow redirect to untrusted location '$safe'";
        }

        # the signature covers the host so the request must be signed again,
        # and the region may differ, a bucket in another region redirects us to
        # the regional endpoint, so take it from the host where we can
        $req->uri( $location );
        $req->remove_header( qw( Authorization Host X-Amz-Date ) );
        my ( undef, $region ) = $s->signerv4->parse_host( $req->uri->host );
        $s->_sign( $req, $region );
        $res = $s->s3->ua->request( $req );
    }
    return $s->parse_response( $res );
}

# A redirect is only trusted if it stays within the configured endpoint (or
# is an S3 hostname when that is an AWS endpoint), keeps to the same port, and
# doesn't downgrade from https.
sub _is_trusted_redirect {
    my ( $s, $location ) = @_;

    my $uri = eval { URI->new( $location ) } or return 0;

    my $scheme = $uri->scheme // '';
    return 0 unless $scheme eq 'http' || $scheme eq 'https';
    return 0 if $s->s3->secure && $scheme ne 'https';
    return 0 if defined $uri->userinfo;

    my $host = lc( $uri->host // '' );
    $host =~ s/\.\z//;
    return 0 unless length $host;

    my ( $endpoint_host, $endpoint_port ) = lc( $s->endpoint ) =~ m{\A([^:/]+)(?::(\d+))?\z}
        or return 0;
    $endpoint_host =~ s/\.\z//;
    return 0 unless length $endpoint_host;

    my $port = defined $endpoint_port ? $endpoint_port : $uri->default_port;
    return 0 unless $uri->port == $port;

    # S3 redirects to regional endpoints (e.g. bucket.s3-us-west-2.amazonaws.com)
    # so for AWS only trust S3 hostnames, not anything under amazonaws.com
    # (which includes things like ec2 and api gateway hostnames)
    if ( $endpoint_host =~ m{(?:\A|\.)(amazonaws\.com(?:\.cn)?)\z} ) {
        my $aws_domain = $1;
        return $host =~ m{(?:\A|\.)s3(?:[.-][a-z0-9-]+)*\.\Q$aws_domain\E\z} ? 1 : 0;
    }

    return ( $host eq $endpoint_host || $host =~ m{\.\Q$endpoint_host\E\z} ) ? 1 : 0;
}

sub _sign {
  my ($s, $request, $region) = @_;
  $region = $s->s3->region unless defined $region;
  my $signer = $s->signerv4;
  if (defined $s->s3->session_token) {
    $request->header('X-Amz-Security-Token', $s->s3->session_token);
  }
  my $digest = Digest::SHA::sha256_hex($request->content);

lib/AWS/S3/Signer/V4.pm  view on Meta::CPAN



If a security token is provided, it overrides any values given for
-access_key or -secret_key.

If the environment variables EC2_ACCESS_KEY and/or EC2_SECRET_KEY are
set, their contents are used as defaults for -access_key and
-secret_key.

If -service and/or -region is not provided, they are automtically determined
according to endpoint.

=cut

sub new {
    my $self = shift;
    my %args = @_;

    my ( $id, $secret, $token, $region, $service );
    if ( ref $args{-security_token}
        && $args{-security_token}->can('access_key_id') )

lib/AWS/S3/Signer/V4.pm  view on Meta::CPAN


sub access_key { shift->{access_key} }
sub secret_key { shift->{secret_key} }

=item $signer->sign($request [,$region] [,$payload_sha256_hex])

Given an HTTP::Request object, add the headers required by AWS and
then sign it with a version 4 signature by adding an "Authorization"
header.

The request must include a URL from which the AWS endpoint and service
can be derived, such as "ec2.us-east-1.amazonaws.com." In some cases
(e.g. S3 bucket operations) the endpoint does not indicate the
region. In this case, the region can be forced by passing a defined
value for $region. The current date and time will be added to the
request using an "X-Amz-Date header." To force the date and time to a
fixed value, include the "Date" header in the request.

The request content, or "payload" is retrieved from the HTTP::Request
object by calling its content() method.. Under some circumstances the
payload is not included directly in the request, but is in an external
file that will be uploaded as the request is executed. In this case,
you must pass a second argument containing the results of running

lib/AWS/S3/Signer/V4.pm  view on Meta::CPAN

sub sign {
    my $self = shift;
    my ( $request, $region, $payload_sha256_hex ) = @_;
    $self->_add_date_header($request);
    $self->_sign( $request, $region, $payload_sha256_hex );
}

=item my $url $signer->signed_url($request_or_uri [,$expires] [,$verb])

Pass an HTTP::Request, a URI object, or just a plain URL string
containing the proper endpoint and parameters needed for an AWS REST
API Call. This method will return an appropriately signed request as a
URI object, which can be shared with non-AWS users for the purpose of,
e.g., accessing an object in a private S3 bucket.

Pass an optional $expires argument to indicate that the URL will only
be valid for a finite period of time. The value of the argument is in
seconds.

Pass an optional verb which is useful for HEAD requests, this defaults to GET.

t/aws/s3.t  view on Meta::CPAN

use Data::Section::Simple 'get_data_section';

use Carp 'confess';
$SIG{__DIE__} = \&confess;

use_ok('AWS::S3');

my $s3 = AWS::S3->new(
  access_key_id     => $ENV{AWS_ACCESS_KEY_ID}     // 'foo',
  secret_access_key => $ENV{AWS_SECRET_ACCESS_KEY} // 'bar',
  endpoint          => 'bad.hostname.',
  secure            => 0,    # these tests assert on http:// URIs
);

my $bucket_name = "aws-s3-test-" . int(rand() * 1_000_000) . '-' . time() . "-foo";

eval {
    my $bucket = $s3->add_bucket( name => $bucket_name, location => 'us-west-1' );
};

like(
    $@,
    qr/Can't connect to aws-s3-test-.*?bad\.hostname/,
    'endpoint was used'
);

isa_ok(
	$s3->request( 'CreateBucket',bucket => 'foo' ),
	'AWS::S3::Request::CreateBucket'
);

subtest 'create bucket strange temporary redirect' => sub {
    plan tests => 8;    # make sure all tests in here get run

t/aws/s3/bucket.t  view on Meta::CPAN


use Carp 'confess';
$SIG{__DIE__} = \&confess;

use_ok('AWS::S3');

note( "construction" );
my $s3 = AWS::S3->new(
    access_key_id     => $ENV{AWS_ACCESS_KEY_ID}     // 'foo',
    secret_access_key => $ENV{AWS_SECRET_ACCESS_KEY} // 'bar',
    endpoint          => $ENV{AWS_ENDPOINT}          // 's3.baz.com',
);

use_ok('AWS::S3::Bucket');

isa_ok(
    my $bucket = AWS::S3::Bucket->new(
        s3   => $s3,
        name => $ENV{AWS_TEST_BUCKET} // 'maibucket',
    ),
    'AWS::S3::Bucket'

t/aws/s3/file.t  view on Meta::CPAN

$SIG{__DIE__} = \&confess;

use_ok('AWS::S3');

note( "construction" );

foreach my $leading_slashes ( 0,1 ) {
my $s3 = AWS::S3->new(
    access_key_id     => $ENV{AWS_ACCESS_KEY_ID}     // 'foo',
    secret_access_key => $ENV{AWS_SECRET_ACCESS_KEY} // 'bar',
    endpoint          => $ENV{AWS_ENDPOINT}          // 's3.baz.com',
	honor_leading_slashes => $leading_slashes,
);

use_ok('AWS::S3::File');
use_ok('AWS::S3::Bucket');
use_ok('AWS::S3::Request::SetFileContents');

monkey_patch_module();

my $path = '/path/to/';

t/aws/s3/file_iterator.t  view on Meta::CPAN

use Carp 'confess';
$SIG{__DIE__} = \&confess;

use_ok('AWS::S3');
use_ok('AWS::S3::FileIterator');
use_ok('AWS::S3::Bucket');

my $s3 = AWS::S3->new(
    access_key_id     => $ENV{AWS_ACCESS_KEY_ID}     // 'foo',
    secret_access_key => $ENV{AWS_SECRET_ACCESS_KEY} // 'bar',
    endpoint          => $ENV{AWS_ENDPOINT}          // 's3.baz.com',
);

isa_ok(
    my $bucket = AWS::S3::Bucket->new(
        s3   => $s3,
        name => $ENV{AWS_TEST_BUCKET} // 'maibucket',
    ),
    'AWS::S3::Bucket'
);

t/aws/s3/http_request.t  view on Meta::CPAN


use Carp 'confess';
$SIG{__DIE__} = \&confess;

use_ok('AWS::S3');

note( "construction" );
my $s3 = AWS::S3->new(
    access_key_id     => $ENV{AWS_ACCESS_KEY_ID}     // 'foo',
    secret_access_key => $ENV{AWS_SECRET_ACCESS_KEY} // 'bar',
    endpoint          => $ENV{AWS_ENDPOINT}          // 's3.baz.com',
);

use_ok('AWS::S3::HTTPRequest');

isa_ok(
    my $request = AWS::S3::HTTPRequest->new(
		s3     => $s3,
		method => 'POST',
		path   => '/foo/bar',
    ),

t/aws/s3/request/headers.t  view on Meta::CPAN


use_ok( 'AWS::S3' );
use_ok( 'AWS::S3::Bucket' );
use_ok( 'AWS::S3::File' );
use_ok( 'AWS::S3::HTTPRequest' );

my $s3 = AWS::S3->new(
    access_key_id     => 'foo',
    secret_access_key => 'bar',
    session_token     => 'TOKEN',
    endpoint          => 's3.baz.com',
    ua                => Capturing::UA->new,
);

my $bucket = AWS::S3::Bucket->new( s3 => $s3, name => 'maibucket' );

sub _md5 {
    # md5_base64 has no padding, Content-MD5 does
    my $md5 = md5_base64( $_[0] );
    return $md5 . '=' x ( ( 4 - length( $md5 ) % 4 ) % 4 );
}

t/aws/s3/request/redirect.t  view on Meta::CPAN

}

sub _s3 {
    my ( %args ) = @_;

    return AWS::S3->new(
        access_key_id     => 'foo',
        secret_access_key => 'bar',
        session_token     => 'SECRET-SESSION-TOKEN',
        region            => 'us-east-1',
        endpoint          => 's3.amazonaws.com',
        secure            => 1,
        ua                => Scripted::UA->new,
        %args,
    );
}

# the request classes all share the same _send_request
sub _create_bucket {
    my ( $s3 ) = @_;
    return $s3->request( 'CreateBucket', bucket => 'maibucket' )->request;
}

note( "_is_trusted_redirect" );
{
    my @cases = (
        # endpoint, secure, location, trusted?
        [ 's3.amazonaws.com', 1, 'https://maibucket.s3.amazonaws.com/',             1 ],
        [ 's3.amazonaws.com', 1, 'https://maibucket.s3-us-west-2.amazonaws.com/',   1 ],
        [ 's3.amazonaws.com', 1, 'https://maibucket.s3.us-west-2.amazonaws.com/',   1 ],
        [ 's3.amazonaws.com', 1, 'https://s3.eu-west-1.amazonaws.com/maibucket/',   1 ],
        [ 's3.amazonaws.com', 1, 'https://s3.dualstack.us-east-1.amazonaws.com/',   1 ],
        [ 's3.amazonaws.com', 1, 'https://MAIBUCKET.S3.AMAZONAWS.COM/',             1 ],
        [ 's3.eu-west-1.amazonaws.com', 1, 'https://maibucket.s3.amazonaws.com/',   1 ],
        [ 's3.amazonaws.com', 0, 'http://maibucket.s3.amazonaws.com/',              1 ],
        [ 's3.amazonaws.com', 0, 'https://maibucket.s3.amazonaws.com/',             1 ],

t/aws/s3/request/redirect.t  view on Meta::CPAN

        [ 's3.amazonaws.com', 1, 'https://s3.amazonaws.com@evil.com/',              0 ],
        [ 's3.amazonaws.com', 1, 'https://user:pw@maibucket.s3.amazonaws.com/',     0 ],
        [ 's3.amazonaws.com', 1, 'https://evil.com/maibucket.s3.amazonaws.com',     0 ],
        [ 's3.amazonaws.com', 1, 'https://evil.com/?h=s3.amazonaws.com',            0 ],
        [ 's3.amazonaws.com', 1, 'http://maibucket.s3.amazonaws.com/',              0 ],  # downgrade
        [ 's3.amazonaws.com', 1, 'https://maibucket.s3.amazonaws.com:8443/',        0 ],  # other port
        [ 's3.amazonaws.com', 1, 'ftp://maibucket.s3.amazonaws.com/',               0 ],
        [ 's3.amazonaws.com', 1, 'file:///etc/passwd',                              0 ],
        [ 's3.amazonaws.com', 1, '',                                                0 ],

        # custom endpoint (S3 compatible service): only that domain is trusted
        [ 's3.example.com', 1, 'https://s3.example.com/',                           1 ],
        [ 's3.example.com', 1, 'https://maibucket.s3.example.com/',                 1 ],
        [ 's3.example.com', 1, 'https://maibucket.s3.amazonaws.com/',               0 ],
        [ 's3.example.com', 1, 'https://s3.example.com.evil.com/',                  0 ],
        [ 's3.example.com', 1, 'https://nots3.example.com/',                        0 ],
        [ 's3.example.com', 1, 'https://evil.com/',                                 0 ],

        # a trailing dot on the host is the same host
        [ 'bad.hostname.',  0, 'http://bar.eu.bad.hostname./',                      1 ],
        [ 'bad.hostname.',  0, 'http://bad.hostname.evil.com./',                    0 ],

        # custom endpoints with a port must stay on that port
        [ 's3.example.com:9000', 1, 'https://maibucket.s3.example.com:9000/',       1 ],
        [ 's3.example.com:9000', 1, 'https://maibucket.s3.example.com/',            0 ],
        [ 's3.example.com:9000', 1, 'https://maibucket.s3.example.com:9001/',       0 ],
    );

    foreach my $case ( @cases ) {
        my ( $endpoint, $secure, $location, $trusted ) = @{ $case };

        my $req = _s3( endpoint => $endpoint, secure => $secure )
            ->request( 'CreateBucket', bucket => 'maibucket' );

        is(
            $req->_is_trusted_redirect( $location ) ? 1 : 0,
            $trusted,
            ( $trusted ? 'trusts' : 'refuses' ) . " '$location' for endpoint '$endpoint'"
                . ( $secure ? ' (secure)' : '' ),
        );
    }
}

note( "an untrusted redirect is not followed" );
foreach my $location (
    'https://evil.com/',
    'https://maibucket.s3.amazonaws.com.evil.com/',
    'https://ec2.us-east-1.amazonaws.com/',

t/aws/s3/request/secure_default.t  view on Meta::CPAN

use Test::More;

use_ok( 'AWS::S3' );

sub _s3 {
    my ( %args ) = @_;

    return AWS::S3->new(
        access_key_id     => 'foo',
        secret_access_key => 'bar',
        endpoint          => 's3.baz.com',
        ua                => Capturing::UA->new,
        %args,
    );
}

# every way a request URI is built: ->_uri (BucketAction and friends),
# the ones that build their own URI, and ->bucket_uri (ListBucket)
my %requests = (
    ListAllMyBuckets       => { },
    CreateBucket           => { bucket => 'maibucket' },

t/aws/s3/request/uri_injection.t  view on Meta::CPAN

use Test::More;

use_ok( 'AWS::S3' );
use_ok( 'AWS::S3::Bucket' );
use_ok( 'AWS::S3::File' );
use_ok( 'AWS::S3::Types' );

my $s3 = AWS::S3->new(
    access_key_id     => 'foo',
    secret_access_key => 'bar',
    endpoint          => 's3.baz.com',
    ua                => Capturing::UA->new,
);

my $bucket = AWS::S3::Bucket->new( s3 => $s3, name => 'maibucket' );

# no contents passed so nothing is fetched or sent when the object is built
my $file = AWS::S3::File->new(
    key          => 'k',
    bucket       => $bucket,
    is_encrypted => 0,

t/aws/s3/request/xml_escape.t  view on Meta::CPAN

package main;

use Test::More;
use XML::LibXML;

use_ok( 'AWS::S3' );

my $s3 = AWS::S3->new(
    access_key_id     => 'foo',
    secret_access_key => 'bar',
    endpoint          => 's3.baz.com',
    ua                => Capturing::UA->new,
);

sub _parse_body {
    my ( $req ) = @_;
    return XML::LibXML->new->parse_string( $req->content );
}

note( "_xml_escape" );
{



( run in 1.448 second using v1.01-cache-2.11-cpan-eb134014566 )