Skip to content

10 files changed

+594
-0
lines changed

docs/rules/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,13 +638,20 @@ These rules enforce best practices and naming conventions:
638638
|aws_glue_trigger_invalid_type||
639639
|aws_glue_user_defined_function_invalid_owner_type||
640640
|aws_guardduty_detector_invalid_finding_publishing_frequency||
641+
|aws_guardduty_filter_invalid_action||
642+
|aws_guardduty_filter_invalid_description||
643+
|aws_guardduty_filter_invalid_detector_id||
644+
|aws_guardduty_filter_invalid_name||
641645
|aws_guardduty_invite_accepter_invalid_detector_id||
642646
|aws_guardduty_ipset_invalid_detector_id||
643647
|aws_guardduty_ipset_invalid_format||
644648
|aws_guardduty_ipset_invalid_location||
645649
|aws_guardduty_ipset_invalid_name||
646650
|aws_guardduty_member_invalid_detector_id||
647651
|aws_guardduty_member_invalid_email||
652+
|aws_guardduty_organization_configuration_invalid_detector_id||
653+
|aws_guardduty_publishing_destination_invalid_destination_type||
654+
|aws_guardduty_publishing_destination_invalid_detector_id||
648655
|aws_guardduty_threatintelset_invalid_detector_id||
649656
|aws_guardduty_threatintelset_invalid_format||
650657
|aws_guardduty_threatintelset_invalid_location||
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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+
// AwsGuarddutyFilterInvalidActionRule checks the pattern is valid
14+
type AwsGuarddutyFilterInvalidActionRule struct {
15+
resourceType string
16+
attributeName string
17+
max int
18+
min int
19+
enum []string
20+
}
21+
22+
// NewAwsGuarddutyFilterInvalidActionRule returns new rule with default attributes
23+
func NewAwsGuarddutyFilterInvalidActionRule() *AwsGuarddutyFilterInvalidActionRule {
24+
return &AwsGuarddutyFilterInvalidActionRule{
25+
resourceType: "aws_guardduty_filter",
26+
attributeName: "action",
27+
max: 300,
28+
min: 1,
29+
enum: []string{
30+
"NOOP",
31+
"ARCHIVE",
32+
},
33+
}
34+
}
35+
36+
// Name returns the rule name
37+
func (r *AwsGuarddutyFilterInvalidActionRule) Name() string {
38+
return "aws_guardduty_filter_invalid_action"
39+
}
40+
41+
// Enabled returns whether the rule is enabled by default
42+
func (r *AwsGuarddutyFilterInvalidActionRule) Enabled() bool {
43+
return true
44+
}
45+
46+
// Severity returns the rule severity
47+
func (r *AwsGuarddutyFilterInvalidActionRule) Severity() string {
48+
return tflint.ERROR
49+
}
50+
51+
// Link returns the rule reference link
52+
func (r *AwsGuarddutyFilterInvalidActionRule) Link() string {
53+
return ""
54+
}
55+
56+
// Check checks the pattern is valid
57+
func (r *AwsGuarddutyFilterInvalidActionRule) Check(runner tflint.Runner) error {
58+
log.Printf("[TRACE] Check `%s` rule", r.Name())
59+
60+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
61+
var val string
62+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
63+
64+
return runner.EnsureNoError(err, func() error {
65+
if len(val) > r.max {
66+
runner.EmitIssueOnExpr(
67+
r,
68+
"action must be 300 characters or less",
69+
attribute.Expr,
70+
)
71+
}
72+
if len(val) < r.min {
73+
runner.EmitIssueOnExpr(
74+
r,
75+
"action must be 1 characters or higher",
76+
attribute.Expr,
77+
)
78+
}
79+
found := false
80+
for _, item := range r.enum {
81+
if item == val {
82+
found = true
83+
}
84+
}
85+
if !found {
86+
runner.EmitIssueOnExpr(
87+
r,
88+
fmt.Sprintf(`"%s" is an invalid value as action`, truncateLongMessage(val)),
89+
attribute.Expr,
90+
)
91+
}
92+
return nil
93+
})
94+
})
95+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"log"
7+
8+
hcl "github.com/hashicorp/hcl/v2"
9+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
10+
)
11+
12+
// AwsGuarddutyFilterInvalidDescriptionRule checks the pattern is valid
13+
type AwsGuarddutyFilterInvalidDescriptionRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
}
18+
19+
// NewAwsGuarddutyFilterInvalidDescriptionRule returns new rule with default attributes
20+
func NewAwsGuarddutyFilterInvalidDescriptionRule() *AwsGuarddutyFilterInvalidDescriptionRule {
21+
return &AwsGuarddutyFilterInvalidDescriptionRule{
22+
resourceType: "aws_guardduty_filter",
23+
attributeName: "description",
24+
max: 512,
25+
}
26+
}
27+
28+
// Name returns the rule name
29+
func (r *AwsGuarddutyFilterInvalidDescriptionRule) Name() string {
30+
return "aws_guardduty_filter_invalid_description"
31+
}
32+
33+
// Enabled returns whether the rule is enabled by default
34+
func (r *AwsGuarddutyFilterInvalidDescriptionRule) Enabled() bool {
35+
return true
36+
}
37+
38+
// Severity returns the rule severity
39+
func (r *AwsGuarddutyFilterInvalidDescriptionRule) Severity() string {
40+
return tflint.ERROR
41+
}
42+
43+
// Link returns the rule reference link
44+
func (r *AwsGuarddutyFilterInvalidDescriptionRule) Link() string {
45+
return ""
46+
}
47+
48+
// Check checks the pattern is valid
49+
func (r *AwsGuarddutyFilterInvalidDescriptionRule) Check(runner tflint.Runner) error {
50+
log.Printf("[TRACE] Check `%s` rule", r.Name())
51+
52+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
53+
var val string
54+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
55+
56+
return runner.EnsureNoError(err, func() error {
57+
if len(val) > r.max {
58+
runner.EmitIssueOnExpr(
59+
r,
60+
"description must be 512 characters or less",
61+
attribute.Expr,
62+
)
63+
}
64+
return nil
65+
})
66+
})
67+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"log"
7+
8+
hcl "github.com/hashicorp/hcl/v2"
9+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
10+
)
11+
12+
// AwsGuarddutyFilterInvalidDetectorIDRule checks the pattern is valid
13+
type AwsGuarddutyFilterInvalidDetectorIDRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
min int
18+
}
19+
20+
// NewAwsGuarddutyFilterInvalidDetectorIDRule returns new rule with default attributes
21+
func NewAwsGuarddutyFilterInvalidDetectorIDRule() *AwsGuarddutyFilterInvalidDetectorIDRule {
22+
return &AwsGuarddutyFilterInvalidDetectorIDRule{
23+
resourceType: "aws_guardduty_filter",
24+
attributeName: "detector_id",
25+
max: 300,
26+
min: 1,
27+
}
28+
}
29+
30+
// Name returns the rule name
31+
func (r *AwsGuarddutyFilterInvalidDetectorIDRule) Name() string {
32+
return "aws_guardduty_filter_invalid_detector_id"
33+
}
34+
35+
// Enabled returns whether the rule is enabled by default
36+
func (r *AwsGuarddutyFilterInvalidDetectorIDRule) Enabled() bool {
37+
return true
38+
}
39+
40+
// Severity returns the rule severity
41+
func (r *AwsGuarddutyFilterInvalidDetectorIDRule) Severity() string {
42+
return tflint.ERROR
43+
}
44+
45+
// Link returns the rule reference link
46+
func (r *AwsGuarddutyFilterInvalidDetectorIDRule) Link() string {
47+
return ""
48+
}
49+
50+
// Check checks the pattern is valid
51+
func (r *AwsGuarddutyFilterInvalidDetectorIDRule) Check(runner tflint.Runner) error {
52+
log.Printf("[TRACE] Check `%s` rule", r.Name())
53+
54+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
55+
var val string
56+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
57+
58+
return runner.EnsureNoError(err, func() error {
59+
if len(val) > r.max {
60+
runner.EmitIssueOnExpr(
61+
r,
62+
"detector_id must be 300 characters or less",
63+
attribute.Expr,
64+
)
65+
}
66+
if len(val) < r.min {
67+
runner.EmitIssueOnExpr(
68+
r,
69+
"detector_id must be 1 characters or higher",
70+
attribute.Expr,
71+
)
72+
}
73+
return nil
74+
})
75+
})
76+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"log"
7+
8+
hcl "github.com/hashicorp/hcl/v2"
9+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
10+
)
11+
12+
// AwsGuarddutyFilterInvalidNameRule checks the pattern is valid
13+
type AwsGuarddutyFilterInvalidNameRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
min int
18+
}
19+
20+
// NewAwsGuarddutyFilterInvalidNameRule returns new rule with default attributes
21+
func NewAwsGuarddutyFilterInvalidNameRule() *AwsGuarddutyFilterInvalidNameRule {
22+
return &AwsGuarddutyFilterInvalidNameRule{
23+
resourceType: "aws_guardduty_filter",
24+
attributeName: "name",
25+
max: 64,
26+
min: 3,
27+
}
28+
}
29+
30+
// Name returns the rule name
31+
func (r *AwsGuarddutyFilterInvalidNameRule) Name() string {
32+
return "aws_guardduty_filter_invalid_name"
33+
}
34+
35+
// Enabled returns whether the rule is enabled by default
36+
func (r *AwsGuarddutyFilterInvalidNameRule) Enabled() bool {
37+
return true
38+
}
39+
40+
// Severity returns the rule severity
41+
func (r *AwsGuarddutyFilterInvalidNameRule) Severity() string {
42+
return tflint.ERROR
43+
}
44+
45+
// Link returns the rule reference link
46+
func (r *AwsGuarddutyFilterInvalidNameRule) Link() string {
47+
return ""
48+
}
49+
50+
// Check checks the pattern is valid
51+
func (r *AwsGuarddutyFilterInvalidNameRule) Check(runner tflint.Runner) error {
52+
log.Printf("[TRACE] Check `%s` rule", r.Name())
53+
54+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
55+
var val string
56+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
57+
58+
return runner.EnsureNoError(err, func() error {
59+
if len(val) > r.max {
60+
runner.EmitIssueOnExpr(
61+
r,
62+
"name must be 64 characters or less",
63+
attribute.Expr,
64+
)
65+
}
66+
if len(val) < r.min {
67+
runner.EmitIssueOnExpr(
68+
r,
69+
"name must be 3 characters or higher",
70+
attribute.Expr,
71+
)
72+
}
73+
return nil
74+
})
75+
})
76+
}

0 commit comments

Comments
 (0)