Skip to content

19 files changed

+1426
-0
lines changed

docs/rules/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,22 @@ These rules enforce best practices and naming conventions:
11551155
|aws_wafregional_web_acl_invalid_metric_name||
11561156
|aws_wafregional_web_acl_invalid_name||
11571157
|aws_wafregional_xss_match_set_invalid_name||
1158+
|aws_wafv2_ip_set_invalid_description||
1159+
|aws_wafv2_ip_set_invalid_ip_address_version||
1160+
|aws_wafv2_ip_set_invalid_name||
1161+
|aws_wafv2_ip_set_invalid_scope||
1162+
|aws_wafv2_regex_pattern_set_invalid_description||
1163+
|aws_wafv2_regex_pattern_set_invalid_name||
1164+
|aws_wafv2_regex_pattern_set_invalid_scope||
1165+
|aws_wafv2_rule_group_invalid_description||
1166+
|aws_wafv2_rule_group_invalid_name||
1167+
|aws_wafv2_rule_group_invalid_scope||
1168+
|aws_wafv2_web_acl_association_invalid_resource_arn||
1169+
|aws_wafv2_web_acl_association_invalid_web_acl_arn||
1170+
|aws_wafv2_web_acl_invalid_description||
1171+
|aws_wafv2_web_acl_invalid_name||
1172+
|aws_wafv2_web_acl_invalid_scope||
1173+
|aws_wafv2_web_acl_logging_configuration_invalid_resource_arn||
11581174
|aws_worklink_fleet_invalid_audit_stream_arn||
11591175
|aws_worklink_fleet_invalid_device_ca_certificate||
11601176
|aws_worklink_fleet_invalid_display_name||
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
"regexp"
9+
10+
hcl "github.com/hashicorp/hcl/v2"
11+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
12+
)
13+
14+
// AwsWafv2IPSetInvalidDescriptionRule checks the pattern is valid
15+
type AwsWafv2IPSetInvalidDescriptionRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsWafv2IPSetInvalidDescriptionRule returns new rule with default attributes
24+
func NewAwsWafv2IPSetInvalidDescriptionRule() *AwsWafv2IPSetInvalidDescriptionRule {
25+
return &AwsWafv2IPSetInvalidDescriptionRule{
26+
resourceType: "aws_wafv2_ip_set",
27+
attributeName: "description",
28+
max: 256,
29+
min: 1,
30+
pattern: regexp.MustCompile(`^[\w+=:#@/\-,\.][\w+=:#@/\-,\.\s]+[\w+=:#@/\-,\.]$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsWafv2IPSetInvalidDescriptionRule) Name() string {
36+
return "aws_wafv2_ip_set_invalid_description"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsWafv2IPSetInvalidDescriptionRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsWafv2IPSetInvalidDescriptionRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsWafv2IPSetInvalidDescriptionRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsWafv2IPSetInvalidDescriptionRule) Check(runner tflint.Runner) error {
56+
log.Printf("[TRACE] Check `%s` rule", r.Name())
57+
58+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
59+
var val string
60+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
61+
62+
return runner.EnsureNoError(err, func() error {
63+
if len(val) > r.max {
64+
runner.EmitIssueOnExpr(
65+
r,
66+
"description must be 256 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"description must be 1 characters or higher",
74+
attribute.Expr,
75+
)
76+
}
77+
if !r.pattern.MatchString(val) {
78+
runner.EmitIssueOnExpr(
79+
r,
80+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^[\w+=:#@/\-,\.][\w+=:#@/\-,\.\s]+[\w+=:#@/\-,\.]$`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
9+
hcl "github.com/hashicorp/hcl/v2"
10+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
11+
)
12+
13+
// AwsWafv2IPSetInvalidIPAddressVersionRule checks the pattern is valid
14+
type AwsWafv2IPSetInvalidIPAddressVersionRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsWafv2IPSetInvalidIPAddressVersionRule returns new rule with default attributes
21+
func NewAwsWafv2IPSetInvalidIPAddressVersionRule() *AwsWafv2IPSetInvalidIPAddressVersionRule {
22+
return &AwsWafv2IPSetInvalidIPAddressVersionRule{
23+
resourceType: "aws_wafv2_ip_set",
24+
attributeName: "ip_address_version",
25+
enum: []string{
26+
"IPV4",
27+
"IPV6",
28+
},
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsWafv2IPSetInvalidIPAddressVersionRule) Name() string {
34+
return "aws_wafv2_ip_set_invalid_ip_address_version"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsWafv2IPSetInvalidIPAddressVersionRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsWafv2IPSetInvalidIPAddressVersionRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsWafv2IPSetInvalidIPAddressVersionRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsWafv2IPSetInvalidIPAddressVersionRule) Check(runner tflint.Runner) error {
54+
log.Printf("[TRACE] Check `%s` rule", r.Name())
55+
56+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
57+
var val string
58+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
59+
60+
return runner.EnsureNoError(err, func() error {
61+
found := false
62+
for _, item := range r.enum {
63+
if item == val {
64+
found = true
65+
}
66+
}
67+
if !found {
68+
runner.EmitIssueOnExpr(
69+
r,
70+
fmt.Sprintf(`"%s" is an invalid value as ip_address_version`, truncateLongMessage(val)),
71+
attribute.Expr,
72+
)
73+
}
74+
return nil
75+
})
76+
})
77+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
"regexp"
9+
10+
hcl "github.com/hashicorp/hcl/v2"
11+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
12+
)
13+
14+
// AwsWafv2IPSetInvalidNameRule checks the pattern is valid
15+
type AwsWafv2IPSetInvalidNameRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsWafv2IPSetInvalidNameRule returns new rule with default attributes
24+
func NewAwsWafv2IPSetInvalidNameRule() *AwsWafv2IPSetInvalidNameRule {
25+
return &AwsWafv2IPSetInvalidNameRule{
26+
resourceType: "aws_wafv2_ip_set",
27+
attributeName: "name",
28+
max: 128,
29+
min: 1,
30+
pattern: regexp.MustCompile(`^[\w\-]+$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsWafv2IPSetInvalidNameRule) Name() string {
36+
return "aws_wafv2_ip_set_invalid_name"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsWafv2IPSetInvalidNameRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsWafv2IPSetInvalidNameRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsWafv2IPSetInvalidNameRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsWafv2IPSetInvalidNameRule) Check(runner tflint.Runner) error {
56+
log.Printf("[TRACE] Check `%s` rule", r.Name())
57+
58+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
59+
var val string
60+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
61+
62+
return runner.EnsureNoError(err, func() error {
63+
if len(val) > r.max {
64+
runner.EmitIssueOnExpr(
65+
r,
66+
"name must be 128 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"name must be 1 characters or higher",
74+
attribute.Expr,
75+
)
76+
}
77+
if !r.pattern.MatchString(val) {
78+
runner.EmitIssueOnExpr(
79+
r,
80+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^[\w\-]+$`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
9+
hcl "github.com/hashicorp/hcl/v2"
10+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
11+
)
12+
13+
// AwsWafv2IPSetInvalidScopeRule checks the pattern is valid
14+
type AwsWafv2IPSetInvalidScopeRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsWafv2IPSetInvalidScopeRule returns new rule with default attributes
21+
func NewAwsWafv2IPSetInvalidScopeRule() *AwsWafv2IPSetInvalidScopeRule {
22+
return &AwsWafv2IPSetInvalidScopeRule{
23+
resourceType: "aws_wafv2_ip_set",
24+
attributeName: "scope",
25+
enum: []string{
26+
"CLOUDFRONT",
27+
"REGIONAL",
28+
},
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsWafv2IPSetInvalidScopeRule) Name() string {
34+
return "aws_wafv2_ip_set_invalid_scope"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsWafv2IPSetInvalidScopeRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsWafv2IPSetInvalidScopeRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsWafv2IPSetInvalidScopeRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsWafv2IPSetInvalidScopeRule) Check(runner tflint.Runner) error {
54+
log.Printf("[TRACE] Check `%s` rule", r.Name())
55+
56+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
57+
var val string
58+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
59+
60+
return runner.EnsureNoError(err, func() error {
61+
found := false
62+
for _, item := range r.enum {
63+
if item == val {
64+
found = true
65+
}
66+
}
67+
if !found {
68+
runner.EmitIssueOnExpr(
69+
r,
70+
fmt.Sprintf(`"%s" is an invalid value as scope`, truncateLongMessage(val)),
71+
attribute.Expr,
72+
)
73+
}
74+
return nil
75+
})
76+
})
77+
}

0 commit comments

Comments
 (0)