Skip to content

Commit

Permalink
Add a test for regex expressions in path segments
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
adamthom-amzn committed Dec 16, 2021
1 parent 225f130 commit 62edb56
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
28 changes: 27 additions & 1 deletion smithy-aws-protocol-tests/model/restJson1/http-labels.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions smithy-aws-protocol-tests/model/restJson1/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ service RestJson {
HttpRequestWithLabelsAndTimestampFormat,
HttpRequestWithGreedyLabelInPath,
HttpRequestWithFloatLabels,
HttpRequestWithRegexLiteral,

// @httpQuery and @httpQueryParams tests
AllQueryStringTypes,
Expand Down

0 comments on commit 62edb56

Please sign in to comment.