forked from hashicorp/terraform-provider-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.semgrep.yml
130 lines (125 loc) · 4.23 KB
/
.semgrep.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
rules:
- id: acceptance-test-naming-parent-disappears
languages: [go]
message: Prefer naming acceptance tests with _disappears_Parent suffix
paths:
include:
- 'aws/*_test.go'
patterns:
- pattern: func $FUNCNAME(t *testing.T) { ... }
- metavariable-regex:
metavariable: "$FUNCNAME"
regex: "^TestAcc[^_]+_([a-zA-Z]+[dD]isappears|[^_]+_disappears)$"
severity: WARNING
- id: aws-sdk-go-multiple-service-imports
languages: [go]
message: Resources should not implement multiple AWS service functionality
paths:
exclude:
- aws/config.go
- aws/structure.go
- aws/validators.go
- aws/*wafregional*.go
- aws/resource_aws_serverlessapplicationrepository_cloudformation_stack.go
- aws/*_test.go
- aws/internal/keyvaluetags/
- aws/internal/service/wafregional/
# Legacy resource handling
- aws/resource_aws_autoscaling_group.go
- aws/resource_aws_efs_mount_target.go
- aws/resource_aws_elastic_beanstalk_environment.go
- aws/resource_aws_elb.go
- aws/resource_aws_iam_server_certificate.go
- aws/resource_aws_lambda_event_source_mapping.go
- aws/resource_aws_launch_configuration.go
- aws/resource_aws_lb.go
- aws/resource_aws_s3_bucket_object.go
include:
- aws/
patterns:
- pattern: |
import ("$X")
import ("$Y")
- metavariable-regex:
metavariable: '$X'
regex: '^"github.com/aws/aws-sdk-go/service/[^/]+"$'
- metavariable-regex:
metavariable: '$Y'
regex: '^"github.com/aws/aws-sdk-go/service/[^/]+"$'
severity: WARNING
- id: aws-go-sdk-pointer-conversion-ResourceData-SetId
fix: d.SetId(aws.StringValue($VALUE))
languages: [go]
message: Prefer AWS Go SDK pointer conversion aws.StringValue() function for dereferencing during d.SetId()
paths:
include:
- aws/
pattern: 'd.SetId(*$VALUE)'
severity: WARNING
- id: helper-schema-Set-extraneous-NewSet-with-flattenStringList
languages: [go]
message: Prefer `flattenStringSet()` function for casting a list of string pointers to a set
paths:
include:
- aws/
patterns:
- pattern: schema.NewSet(schema.HashString, flattenStringList($APIOBJECT))
- pattern-not-inside: func flattenStringSet(list []*string) *schema.Set { ... }
severity: WARNING
- id: helper-schema-ResourceData-GetOk-with-extraneous-conditional
languages: [go]
message: Zero value conditional check after `d.GetOk()` is extraneous
paths:
include:
- aws/
patterns:
- pattern-either:
- pattern: if $VALUE, $OK := d.GetOk($KEY); $OK && $VALUE.(bool) { $BODY }
- pattern: if $VALUE, $OK := d.GetOk($KEY); $OK && $VALUE.(int) != 0 { $BODY }
- pattern: if $VALUE, $OK := d.GetOk($KEY); $OK && $VALUE.(int) > 0 { $BODY }
- pattern: if $VALUE, $OK := d.GetOk($KEY); $OK && $VALUE.(string) != "" { $BODY }
- pattern: if $VALUE, $OK := d.GetOk($KEY); $OK && len($VALUE.(string)) > 0 { $BODY }
severity: WARNING
- id: helper-schema-resource-Retry-without-TimeoutError-check
languages: [go]
message: Check resource.Retry() errors with tfresource.TimedOut()
paths:
exclude:
- "*_test.go"
include:
- aws/
patterns:
- pattern-either:
- pattern: |
$ERR := resource.Retry(...)
...
return ...
- pattern: |
$ERR = resource.Retry(...)
...
return ...
- pattern-not: |
$ERR := resource.Retry(...)
...
if isResourceTimeoutError($ERR) { ... }
...
return ...
- pattern-not: |
$ERR = resource.Retry(...)
...
if isResourceTimeoutError($ERR) { ... }
...
return ...
- pattern-not: |
$ERR := resource.Retry(...)
...
if tfresource.TimedOut($ERR) { ... }
...
return ...
- pattern-not: |
$ERR = resource.Retry(...)
...
if tfresource.TimedOut($ERR) { ... }
...
return ...
severity: WARNING