From 4c1bccb840dcb1c053b829996c0e8088507ca524 Mon Sep 17 00:00:00 2001 From: Adam Thomas Date: Wed, 15 Dec 2021 16:49:41 -0800 Subject: [PATCH] Add a test for regex expressions in path segments Characters like (, ) and + can be present, unescaped, in a path segment but cause problems for protocol implementations that use regular expressions to process paths. This adds a simple protocol test to help discover problems with these implementations. --- .../model/restJson1/http-labels.smithy | 28 ++++++++++++++++++- .../model/restJson1/main.smithy | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/smithy-aws-protocol-tests/model/restJson1/http-labels.smithy b/smithy-aws-protocol-tests/model/restJson1/http-labels.smithy index 6e6c3b93c71..c7513506a7c 100644 --- a/smithy-aws-protocol-tests/model/restJson1/http-labels.smithy +++ b/smithy-aws-protocol-tests/model/restJson1/http-labels.smithy @@ -245,8 +245,34 @@ structure HttpRequestWithFloatLabelsInput { @httpLabel @required float: Float, - + @httpLabel @required double: Double, } + +apply HttpRequestWithRegexLiteral @httpRequestTests([ + { + id: "RestJsonToleratesRegexCharsInSegments", + documentation: "Path matching is not broken by regex expressions in literal segments", + protocol: restJson1, + method: "GET", + uri: "/ReDosLiteral/abc/(a+)+", + body: "", + params: { + str: "abc" + } + }, +]) + +@readonly +@http(method: "GET", uri: "/ReDosLiteral/{str}/(a+)+") +operation HttpRequestWithRegexLiteral { + input: HttpRequestWithRegexLiteralInput +} + +structure HttpRequestWithRegexLiteralInput { + @httpLabel + @required + str: String +} diff --git a/smithy-aws-protocol-tests/model/restJson1/main.smithy b/smithy-aws-protocol-tests/model/restJson1/main.smithy index 290d2daf6ae..be0f9bd91e9 100644 --- a/smithy-aws-protocol-tests/model/restJson1/main.smithy +++ b/smithy-aws-protocol-tests/model/restJson1/main.smithy @@ -35,6 +35,7 @@ service RestJson { HttpRequestWithLabelsAndTimestampFormat, HttpRequestWithGreedyLabelInPath, HttpRequestWithFloatLabels, + HttpRequestWithRegexLiteral, // @httpQuery and @httpQueryParams tests AllQueryStringTypes,