Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add validation of GuardDuty filter name #21030

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion aws/resource_aws_guardduty_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ func resourceAwsGuardDutyFilter() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringLenBetween(3, 64),
validateFunc: validation.All(
validation.StringLenBetween(3, 64),
validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9_.-]+$`),
"only alphanumeric characters, hyphens, underscores, and periods are allowed"),
)
},
"description": {
Type: schema.TypeString,
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/guardduty_filter.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ resource "aws_guardduty_filter" "MyFilter" {
The following arguments are supported:

* `detector_id` - (Required) ID of a GuardDuty detector, attached to your account.
* `name` - (Required) The name of your filter.
* `name` - (Required) The name of your filter. Names can be between 3 and 64 characters long and the valid characters are a-z, A-Z, 0-9, '_' (underscore), '-' (hyphen), and '.' (period).
* `description` - (Optional) Description of the filter.
* `rank` - (Required) Specifies the position of the filter in the list of current filters. Also specifies the order in which this filter is applied to the findings.
* `action` - (Required) Specifies the action that is to be applied to the findings that match the filter. Can be one of `ARCHIVE` or `NOOP`.
Expand Down