cmoore-sp / plsql-aws-s3

Oracle PL/SQL tools for building an API to AWS S3 using HTTPS and the AWS4 signature
MIT License
36 stars 10 forks source link

get_object_list not using prefix so not filtering #4

Open capozzme opened 12 months ago

capozzme commented 12 months ago

In case anyone else runs into this issue.

I found that there was an issue on line 642 with the call to prep_aws_data. The p_query_string was passed in as null.

    l_signature := prep_aws_data (
        P_BUCKET                => P_BUCKET,
        P_HTTP_METHOD               => P_HTTP_METHOD,
        P_CANONICAL_URI             => P_OBJECT,
                P_QUERY_STRING              => NULL,
        P_DATE                  => l_date,
        P_CANONICAL_REQUEST             => l_canonical_request,
        P_PAYLOAD_HASH              => l_payload_hash,
        P_URL                   => l_url
        );

I changed Line 642 to P_QUERY_STRING => P_QUERY_STRING

After this change I got <Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>

I found that this issue was in the canonical_request function.

On line 395 we were escaping the query string which was different then the url l_query_string := aws4_escape(P_QUERY_STRING);

So the url we were calling was formatted like this list-type=2&max-keys=1000&prefix=RRS but the query_string passed to was list-type=2%26max-keys=1000%26prefix=RRS so the signature did not match

changed line 395 to l_query_string := P_QUERY_STRING;

So short summary this works Line 395 l_query_string := P_QUERY_STRING; Line 642 P_QUERY_STRING => P_QUERY_STRING

`