Linting for Unsafe Root TypeList to AWS Structure Expansion #16953
Labels
bug
Addresses a defect in current functionality.
crash
Results from or addresses a Terraform crash or kernel panic.
linter
Pertains to changes to or issues with the various linters.
provider
Pertains to the provider itself, rather than any interaction with AWS.
stale
Old or inactive issues managed by automation, if no further action taken these will get closed.
Community Note
Description
When setting up resource logic to read an AWS structure-like field (can only be represented in the Terraform Plugin SDK as a TypeList currently), the desired convention is the following: https://github.com/hashicorp/terraform-provider-aws/blob/master/docs/contributing/data-handling-and-conversion.md#root-typelist-of-resource-and-aws-structure
Currently there are quite a few resources that perform this operation in an unsafe way (either slice index reference or type assertion panics), e.g.
In this case, we may be able to setup
semgrep
rules to discover and report these, e.g. a pattern like this would directly catch this particular logic (the$TFMAP
line is likely extraneous unless there are a lot of initial reports):However there are likely other similar patterns that will need to be created as well.
References
The text was updated successfully, but these errors were encountered: