Skip to content

Commit 3f41554

Browse files
maskitcmcfarlen
authored andcommitted
Remove matrix parameters from s3_auth plugin (#11586)
* Remove matrix parameters from s3_auth plugin * Fix for clang-analyzer (cherry picked from commit 4bbe59a)
1 parent d859fc4 commit 3f41554

File tree

6 files changed

+6
-51
lines changed

6 files changed

+6
-51
lines changed

plugins/s3_auth/aws_auth_v4.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,6 @@ getCanonicalRequestSha256Hash(TsInterface &api, bool signPayload, const StringSe
315315
str = api.getPath(&length);
316316
String path("/");
317317
path.append(str, length);
318-
str = api.getParams(&length);
319-
if (length > 0) {
320-
path.append(";", 1);
321-
path.append(str, length);
322-
}
323318
String canonicalUri = canonicalEncode(path, /* isObjectName */ true);
324319
sha256Update(&canonicalRequestSha256Ctx, canonicalUri);
325320
sha256Update(&canonicalRequestSha256Ctx, "\n");

plugins/s3_auth/aws_auth_v4.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class TsInterface
4747
virtual const char *getMethod(int *length) = 0;
4848
virtual const char *getHost(int *length) = 0;
4949
virtual const char *getPath(int *length) = 0;
50-
virtual const char *getParams(int *length) = 0;
5150
virtual const char *getQuery(int *length) = 0;
5251
virtual HeaderIterator headerBegin() = 0;
5352
virtual HeaderIterator headerEnd() = 0;

plugins/s3_auth/aws_auth_v4_wrap.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@ class TsApi : public TsInterface
108108
return TSUrlPathGet(_bufp, _url, len);
109109
}
110110
const char *
111-
getParams(int *len) override
112-
{
113-
return TSUrlHttpParamsGet(_bufp, _url, len);
114-
}
115-
const char *
116111
getQuery(int *len) override
117112
{
118113
return TSUrlHttpQueryGet(_bufp, _url, len);

plugins/s3_auth/s3_auth.cc

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -841,12 +841,11 @@ S3Request::authorizeV2(S3Config *s3)
841841
{
842842
TSHttpStatus status = TS_HTTP_STATUS_INTERNAL_SERVER_ERROR;
843843
TSMLoc host_loc = TS_NULL_MLOC, md5_loc = TS_NULL_MLOC, contype_loc = TS_NULL_MLOC;
844-
int method_len = 0, path_len = 0, param_len = 0, host_len = 0, con_md5_len = 0, con_type_len = 0, date_len = 0;
845-
const char *method = nullptr, *path = nullptr, *param = nullptr, *host = nullptr, *con_md5 = nullptr, *con_type = nullptr,
846-
*host_endp = nullptr;
847-
char date[128]; // Plenty of space for a Date value
848-
time_t now = time(nullptr);
849-
struct tm now_tm;
844+
int method_len = 0, path_len = 0, host_len = 0, con_md5_len = 0, con_type_len = 0, date_len = 0;
845+
const char *method = nullptr, *path = nullptr, *host = nullptr, *con_md5 = nullptr, *con_type = nullptr, *host_endp = nullptr;
846+
char date[128]; // Plenty of space for a Date value
847+
time_t now = time(nullptr);
848+
struct tm now_tm;
850849

851850
// Start with some request resources we need
852851
if (nullptr == (method = TSHttpHdrMethodGet(_bufp, _hdr_loc, &method_len))) {
@@ -856,9 +855,6 @@ S3Request::authorizeV2(S3Config *s3)
856855
return TS_HTTP_STATUS_INTERNAL_SERVER_ERROR;
857856
}
858857

859-
// get matrix parameters
860-
param = TSUrlHttpParamsGet(_bufp, _url_loc, &param_len);
861-
862858
// Next, setup the Date: header, it's required.
863859
if (nullptr == gmtime_r(&now, &now_tm)) {
864860
return TS_HTTP_STATUS_INTERNAL_SERVER_ERROR;
@@ -920,12 +916,7 @@ S3Request::authorizeV2(S3Config *s3)
920916
loff += str_concat(&left[loff], (left_size - loff), "/", 1);
921917
}
922918

923-
loff += str_concat(&left[loff], (left_size - loff), path, path_len);
924-
925-
if (param) {
926-
loff += str_concat(&left[loff], (left_size - loff), ";", 1);
927-
str_concat(&left[loff], (left_size - loff), param, param_len);
928-
}
919+
str_concat(&left[loff], (left_size - loff), path, path_len);
929920

930921
Dbg(dbg_ctl, "%s", left);
931922
}
@@ -962,10 +953,6 @@ S3Request::authorizeV2(S3Config *s3)
962953
}
963954

964955
HMAC_Update(ctx, (unsigned char *)path, path_len);
965-
if (param) {
966-
HMAC_Update(ctx, reinterpret_cast<const unsigned char *>(";"), 1); // TSUrlHttpParamsGet() does not include ';'
967-
HMAC_Update(ctx, (unsigned char *)param, param_len);
968-
}
969956

970957
HMAC_Final(ctx, hmac, &hmac_len);
971958
#ifndef HAVE_HMAC_CTX_NEW

plugins/s3_auth/unit_tests/test_aws_auth_v4.cc

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ TEST_CASE("AWSAuthSpecByExample: GET Object", "[AWS][auth][SpecByExample]")
433433
api._method.assign("GET");
434434
api._host.assign("examplebucket.s3.amazonaws.com");
435435
api._path.assign("test.txt");
436-
api._params.assign("");
437436
api._query.assign("");
438437
api._headers.insert(std::make_pair("Host", "examplebucket.s3.amazonaws.com"));
439438
api._headers.insert(std::make_pair("Range", "bytes=0-9"));
@@ -479,7 +478,6 @@ TEST_CASE("AWSAuthSpecByExample: GET Bucket Lifecycle", "[AWS][auth][SpecByExamp
479478
api._method.assign("GET");
480479
api._host.assign("examplebucket.s3.amazonaws.com");
481480
api._path.assign("");
482-
api._params.assign("");
483481
api._query.assign("lifecycle");
484482
api._headers.insert(std::make_pair("Host", "examplebucket.s3.amazonaws.com"));
485483
api._headers.insert(std::make_pair("x-amz-content-sha256", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"));
@@ -524,7 +522,6 @@ TEST_CASE("AWSAuthSpecByExample: Get Bucket List Objects", "[AWS][auth][SpecByEx
524522
api._method.assign("GET");
525523
api._host.assign("examplebucket.s3.amazonaws.com");
526524
api._path.assign("");
527-
api._params.assign("");
528525
api._query.assign("max-keys=2&prefix=J");
529526
api._headers.insert(std::make_pair("Host", "examplebucket.s3.amazonaws.com"));
530527
api._headers.insert(std::make_pair("x-amz-content-sha256", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"));
@@ -616,7 +613,6 @@ TEST_CASE("AWSAuthSpecByExample: GET Bucket List Objects, unsigned pay-load, exc
616613
api._method.assign("GET");
617614
api._host.assign("examplebucket.s3.amazonaws.com");
618615
api._path.assign("");
619-
api._params.assign("");
620616
api._query.assign("max-keys=2&prefix=J");
621617
api._headers.insert(std::make_pair("Host", "examplebucket.s3.amazonaws.com"));
622618
api._headers.insert(std::make_pair("x-amz-content-sha256", "UNSIGNED-PAYLOAD"));
@@ -666,7 +662,6 @@ TEST_CASE("AWSAuthSpecByExample: GET Bucket List Objects, query param value alre
666662
api._method.assign("GET");
667663
api._host.assign("examplebucket.s3.amazonaws.com");
668664
api._path.assign("PATH==");
669-
api._params.assign("");
670665
api._query.assign("key=TEST==");
671666
api._headers.insert(std::make_pair("Host", "examplebucket.s3.amazonaws.com"));
672667
api._headers.insert(std::make_pair("x-amz-content-sha256", "UNSIGNED-PAYLOAD"));
@@ -713,7 +708,6 @@ TEST_CASE("S3AuthV4UtilParams: signing multiple same name fields", "[AWS][auth][
713708
api._method.assign("GET");
714709
api._host.assign("examplebucket.s3.amazonaws.com");
715710
api._path.assign("");
716-
api._params.assign("");
717711
api._query.assign("max-keys=2&prefix=J");
718712
api._headers.insert(std::make_pair("Host", "examplebucket.s3.amazonaws.com"));
719713
api._headers.insert(std::make_pair("Content-Type", "gzip"));
@@ -778,7 +772,6 @@ TEST_CASE("S3AuthV4UtilParams: include all headers by default", "[AWS][auth][uti
778772
api._method.assign("GET");
779773
api._host.assign("examplebucket.s3.amazonaws.com");
780774
api._path.assign("");
781-
api._params.assign("");
782775
api._query.assign("max-keys=2&prefix=J");
783776
api._headers.insert(std::make_pair("Host", "examplebucket.s3.amazonaws.com"));
784777
api._headers.insert(std::make_pair("Content-Type", "gzip"));
@@ -813,7 +806,6 @@ TEST_CASE("S3AuthV4UtilParams: include all headers explicit", "[AWS][auth][SpecB
813806
api._method.assign("GET");
814807
api._host.assign("examplebucket.s3.amazonaws.com");
815808
api._path.assign("");
816-
api._params.assign("");
817809
api._query.assign("max-keys=2&prefix=J");
818810
api._headers.insert(std::make_pair("Host", "examplebucket.s3.amazonaws.com"));
819811
api._headers.insert(std::make_pair("Content-Type", "gzip"));
@@ -884,7 +876,6 @@ TEST_CASE("S3AuthV4UtilParams: include/exclude non overlapping headers", "[AWS][
884876
api._method.assign("GET");
885877
api._host.assign("examplebucket.s3.amazonaws.com");
886878
api._path.assign("");
887-
api._params.assign("");
888879
api._query.assign("max-keys=2&prefix=J");
889880
api._headers.insert(std::make_pair("Host", "examplebucket.s3.amazonaws.com"));
890881
api._headers.insert(std::make_pair("Content-Type", "gzip"));
@@ -919,7 +910,6 @@ TEST_CASE("S3AuthV4UtilParams: include/exclude overlapping headers", "[AWS][auth
919910
api._method.assign("GET");
920911
api._host.assign("examplebucket.s3.amazonaws.com");
921912
api._path.assign("");
922-
api._params.assign("");
923913
api._query.assign("max-keys=2&prefix=J");
924914
api._headers.insert(std::make_pair("Host", "examplebucket.s3.amazonaws.com"));
925915
api._headers.insert(std::make_pair("Content-Type", "gzip"));
@@ -955,7 +945,6 @@ TEST_CASE("S3AuthV4UtilParams: include/exclude overlapping headers missing inclu
955945
api._method.assign("GET");
956946
api._host.assign("examplebucket.s3.amazonaws.com");
957947
api._path.assign("");
958-
api._params.assign("");
959948
api._query.assign("max-keys=2&prefix=J");
960949
api._headers.insert(std::make_pair("Host", "examplebucket.s3.amazonaws.com"));
961950
api._headers.insert(std::make_pair("Content-Type", "gzip"));
@@ -991,7 +980,6 @@ TEST_CASE("S3AuthV4UtilParams: include/exclude overlapping headers missing exclu
991980
api._method.assign("GET");
992981
api._host.assign("examplebucket.s3.amazonaws.com");
993982
api._path.assign("");
994-
api._params.assign("");
995983
api._query.assign("max-keys=2&prefix=J");
996984
api._headers.insert(std::make_pair("Host", "examplebucket.s3.amazonaws.com"));
997985
api._headers.insert(std::make_pair("Content-Type", "gzip"));
@@ -1030,7 +1018,6 @@ TEST_CASE("S3AuthV4UtilParams: include content type", "[AWS][auth][utility]")
10301018
api._method.assign("GET");
10311019
api._host.assign("examplebucket.s3.amazonaws.com");
10321020
api._path.assign("");
1033-
api._params.assign("");
10341021
api._query.assign("max-keys=2&prefix=J");
10351022
api._headers.insert(std::make_pair("Host", "examplebucket.s3.amazonaws.com"));
10361023
api._headers.insert(std::make_pair("Content-Type", "gzip"));
@@ -1064,7 +1051,6 @@ TEST_CASE("S3AuthV4UtilParams: include missing content type", "[AWS][auth][utili
10641051
api._method.assign("GET");
10651052
api._host.assign("examplebucket.s3.amazonaws.com");
10661053
api._path.assign("");
1067-
api._params.assign("");
10681054
api._query.assign("max-keys=2&prefix=J");
10691055
api._headers.insert(std::make_pair("Host", "examplebucket.s3.amazonaws.com"));
10701056
api._headers.insert(std::make_pair("x-amz-content-sha256", "UNSIGNED-PAYLOAD"));

plugins/s3_auth/unit_tests/test_aws_auth_v4.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,6 @@ class MockTsInterface : public TsInterface
9595
return _path.c_str();
9696
}
9797
const char *
98-
getParams(int *length) override
99-
{
100-
*length = _params.length();
101-
return _params.c_str();
102-
}
103-
const char *
10498
getQuery(int *length) override
10599
{
106100
*length = _query.length();
@@ -120,7 +114,6 @@ class MockTsInterface : public TsInterface
120114
String _method;
121115
String _host;
122116
String _path;
123-
String _params;
124117
String _query;
125118
HeaderMultiMap _headers;
126119
};

0 commit comments

Comments
 (0)