Skip to content

Commit fc5e7fe

Browse files
committed
Remove unnecessary WorkSpaces pattern transform
The Smithy pattern for WorkSpaces directory IDs has a redundant trailing $ anchor: `^(d-...$)|(wsd-...$)$` While the final $ is redundant (both branches already have $), it doesn't change behavior - the patterns are functionally identical. Master was missing this final $, but there's no benefit to removing it, so keep the Smithy pattern as-is to minimize diffs.
1 parent 71da4da commit fc5e7fe

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

rules/models/aws_workspaces_directory_invalid_directory_id.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func NewAwsWorkspacesDirectoryInvalidDirectoryIDRule() *AwsWorkspacesDirectoryIn
2929
attributeName: "directory_id",
3030
max: 65,
3131
min: 10,
32-
pattern: regexp.MustCompile(`(d-[0-9a-f]{8,63}$)|(wsd-[0-9a-z]{8,63}$)`),
32+
pattern: regexp.MustCompile(`^(d-[0-9a-f]{8,63}$)|(wsd-[0-9a-z]{8,63}$)$`),
3333
}
3434
}
3535

@@ -90,7 +90,7 @@ func (r *AwsWorkspacesDirectoryInvalidDirectoryIDRule) Check(runner tflint.Runne
9090
if !r.pattern.MatchString(val) {
9191
runner.EmitIssue(
9292
r,
93-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `(d-[0-9a-f]{8,63}$)|(wsd-[0-9a-z]{8,63}$)`),
93+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(d-[0-9a-f]{8,63}$)|(wsd-[0-9a-z]{8,63}$)$`),
9494
attribute.Expr.Range(),
9595
)
9696
}

rules/models/aws_workspaces_workspace_invalid_directory_id.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func NewAwsWorkspacesWorkspaceInvalidDirectoryIDRule() *AwsWorkspacesWorkspaceIn
2929
attributeName: "directory_id",
3030
max: 65,
3131
min: 10,
32-
pattern: regexp.MustCompile(`(d-[0-9a-f]{8,63}$)|(wsd-[0-9a-z]{8,63}$)`),
32+
pattern: regexp.MustCompile(`^(d-[0-9a-f]{8,63}$)|(wsd-[0-9a-z]{8,63}$)$`),
3333
}
3434
}
3535

@@ -90,7 +90,7 @@ func (r *AwsWorkspacesWorkspaceInvalidDirectoryIDRule) Check(runner tflint.Runne
9090
if !r.pattern.MatchString(val) {
9191
runner.EmitIssue(
9292
r,
93-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `(d-[0-9a-f]{8,63}$)|(wsd-[0-9a-z]{8,63}$)`),
93+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(d-[0-9a-f]{8,63}$)|(wsd-[0-9a-z]{8,63}$)$`),
9494
attribute.Expr.Range(),
9595
)
9696
}

rules/models/generator/rule.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,7 @@ func applyCompatibilityTransforms(pattern string) string {
217217
"^\\{####\\}$": "^.*\\{####\\}.*$",
218218
}
219219

220-
// WorkSpaces directory IDs: Smithy pattern has redundant end anchors ($)
221-
// inside each alternation branch AND at the end of the pattern.
222-
// Pattern "(foo$)|(bar$)$" is equivalent to "(foo)|(bar)" when the outer
223-
// anchors are present. Remove inner anchors for cleaner regex.
224-
workspacesDirectoryPatterns := map[string]string{
225-
"^(d-[0-9a-f]{8,63}$)|(wsd-[0-9a-z]{8,63}$)$": "(d-[0-9a-f]{8,63}$)|(wsd-[0-9a-z]{8,63}$)",
226-
}
227-
228-
for _, transforms := range []map[string]string{arnRolePatterns, cognitoMessagePatterns, workspacesDirectoryPatterns} {
220+
for _, transforms := range []map[string]string{arnRolePatterns, cognitoMessagePatterns} {
229221
if transformed, exists := transforms[pattern]; exists {
230222
return transformed
231223
}

0 commit comments

Comments
 (0)