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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Semgrep rules to discourage manual expanders and flatteners #39101

Merged
merged 1 commit into from
Sep 5, 2024
Merged
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
79 changes: 79 additions & 0 deletions .ci/semgrep/framework/flex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,82 @@ rules:
metavariable: $VALFUNC
comparison: re.match("\AValue", str($VALFUNC))
severity: WARNING

- id: manual-expander-functions
languages: [go]
message: Prefer `flex.Expand` to manually creating expand functions
paths:
exclude:
- internal/framework/flex/
# TODO: Remove the following exclusions
- internal/service/appfabric/ingestion_destination.go
- internal/service/auditmanager/assessment.go
- internal/service/auditmanager/control.go
- internal/service/auditmanager/framework.go
- internal/service/batch/job_queue.go
- internal/service/cognitoidp/user_pool_client.go
- internal/service/lexv2models/bot.go
- internal/service/lexv2models/bot_locale.go
- internal/service/lightsail/flex.go
- internal/service/opensearchserverless/security_config.go
- internal/service/quicksight/iam_policy_assignment.go
- internal/service/quicksight/refresh_schedule.go
- internal/service/securitylake/subscriber.go
- internal/service/securitylake/subscriber_notification.go
- internal/service/ssmcontacts/rotation.go
- internal/service/ssoadmin/application.go
- internal/service/ssoadmin/trusted_token_issuer.go
- internal/service/verifiedpermissions/schema.go
patterns:
- pattern: func $FUNC(ctx context.Context, ...)
- metavariable-comparison:
metavariable: $FUNC
comparison: re.match("expand\w+", str($FUNC))
- pattern-not-inside: |
import ("github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema")
...
severity: WARNING

- id: manual-flattener-functions
languages: [go]
message: Prefer `flex.Flatten` to manually creating flatten functions
paths:
exclude:
- internal/framework/flex/
# TODO: Remove the following exclusions
- internal/service/appconfig/environment.go
- internal/service/appfabric/ingestion_destination.go
- internal/service/auditmanager/assessment.go
- internal/service/auditmanager/control.go
- internal/service/auditmanager/framework.go
- internal/service/batch/job_queue.go
- internal/service/cognitoidp/user_pool_client.go
- internal/service/datazone/domain.go
- internal/service/datazone/environment_blueprint_configuration.go
- internal/service/ec2/vpc_security_group_ingress_rule.go
- internal/service/emr/supported_instance_types_data_source.go
- internal/service/lexv2models/bot.go
- internal/service/lexv2models/bot_locale.go
- internal/service/medialive/multiplex_program.go
- internal/service/networkfirewall/tls_inspection_configuration.go
- internal/service/opensearchserverless/security_config.go
- internal/service/quicksight/iam_policy_assignment.go
- internal/service/quicksight/refresh_schedule.go
- internal/service/securitylake/subscriber.go
- internal/service/servicequotas/templates_data_source.go
- internal/service/ssmcontacts/rotation.go
- internal/service/ssmcontacts/rotation_data_source.go
- internal/service/ssoadmin/application.go
- internal/service/ssoadmin/application_providers_data_source.go
- internal/service/ssoadmin/trusted_token_issuer.go
- internal/service/verifiedpermissions/identity_source.go
- internal/service/verifiedpermissions/schema.go
patterns:
- pattern: func $FUNC(ctx context.Context, ...)
- metavariable-comparison:
metavariable: $FUNC
comparison: re.match("flatten\w+", str($FUNC))
- pattern-not-inside: |
import ("github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema")
...
severity: WARNING
Loading