Skip to content

Commit a170c70

Browse files

File tree

32 files changed

+2255
-0
lines changed

32 files changed

+2255
-0
lines changed

docs/rules/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,35 @@ These rules enforce best practices and naming conventions:
644644
|aws_iam_user_ssh_key_invalid_public_key||
645645
|aws_iam_user_ssh_key_invalid_status||
646646
|aws_iam_user_ssh_key_invalid_username||
647+
|aws_imagebuilder_component_invalid_change_description||
648+
|aws_imagebuilder_component_invalid_data||
649+
|aws_imagebuilder_component_invalid_description||
650+
|aws_imagebuilder_component_invalid_kms_key_id||
651+
|aws_imagebuilder_component_invalid_name||
652+
|aws_imagebuilder_component_invalid_platform||
653+
|aws_imagebuilder_component_invalid_version||
654+
|aws_imagebuilder_distribution_configuration_invalid_description||
655+
|aws_imagebuilder_distribution_configuration_invalid_name||
656+
|aws_imagebuilder_image_invalid_distribution_configuration_arn||
657+
|aws_imagebuilder_image_invalid_image_recipe_arn||
658+
|aws_imagebuilder_image_invalid_infrastructure_configuration_arn||
659+
|aws_imagebuilder_image_pipeline_invalid_description||
660+
|aws_imagebuilder_image_pipeline_invalid_distribution_configuration_arn||
661+
|aws_imagebuilder_image_pipeline_invalid_image_recipe_arn||
662+
|aws_imagebuilder_image_pipeline_invalid_infrastructure_configuration_arn||
663+
|aws_imagebuilder_image_pipeline_invalid_name||
664+
|aws_imagebuilder_image_pipeline_invalid_status||
665+
|aws_imagebuilder_image_recipe_invalid_description||
666+
|aws_imagebuilder_image_recipe_invalid_name||
667+
|aws_imagebuilder_image_recipe_invalid_parent_image||
668+
|aws_imagebuilder_image_recipe_invalid_version||
669+
|aws_imagebuilder_image_recipe_invalid_working_directory||
670+
|aws_imagebuilder_infrastructure_configuration_invalid_description||
671+
|aws_imagebuilder_infrastructure_configuration_invalid_instance_profile_name||
672+
|aws_imagebuilder_infrastructure_configuration_invalid_key_pair||
673+
|aws_imagebuilder_infrastructure_configuration_invalid_name||
674+
|aws_imagebuilder_infrastructure_configuration_invalid_sns_topic_arn||
675+
|aws_imagebuilder_infrastructure_configuration_invalid_subnet_id||
647676
|aws_inspector_assessment_target_invalid_name||
648677
|aws_inspector_assessment_target_invalid_resource_group_arn||
649678
|aws_inspector_assessment_template_invalid_name||
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+
// AwsImagebuilderComponentInvalidChangeDescriptionRule checks the pattern is valid
13+
type AwsImagebuilderComponentInvalidChangeDescriptionRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
min int
18+
}
19+
20+
// NewAwsImagebuilderComponentInvalidChangeDescriptionRule returns new rule with default attributes
21+
func NewAwsImagebuilderComponentInvalidChangeDescriptionRule() *AwsImagebuilderComponentInvalidChangeDescriptionRule {
22+
return &AwsImagebuilderComponentInvalidChangeDescriptionRule{
23+
resourceType: "aws_imagebuilder_component",
24+
attributeName: "change_description",
25+
max: 1024,
26+
min: 1,
27+
}
28+
}
29+
30+
// Name returns the rule name
31+
func (r *AwsImagebuilderComponentInvalidChangeDescriptionRule) Name() string {
32+
return "aws_imagebuilder_component_invalid_change_description"
33+
}
34+
35+
// Enabled returns whether the rule is enabled by default
36+
func (r *AwsImagebuilderComponentInvalidChangeDescriptionRule) Enabled() bool {
37+
return true
38+
}
39+
40+
// Severity returns the rule severity
41+
func (r *AwsImagebuilderComponentInvalidChangeDescriptionRule) Severity() string {
42+
return tflint.ERROR
43+
}
44+
45+
// Link returns the rule reference link
46+
func (r *AwsImagebuilderComponentInvalidChangeDescriptionRule) Link() string {
47+
return ""
48+
}
49+
50+
// Check checks the pattern is valid
51+
func (r *AwsImagebuilderComponentInvalidChangeDescriptionRule) 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+
"change_description must be 1024 characters or less",
63+
attribute.Expr,
64+
)
65+
}
66+
if len(val) < r.min {
67+
runner.EmitIssueOnExpr(
68+
r,
69+
"change_description must be 1 characters or higher",
70+
attribute.Expr,
71+
)
72+
}
73+
return nil
74+
})
75+
})
76+
}
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+
// AwsImagebuilderComponentInvalidDataRule checks the pattern is valid
15+
type AwsImagebuilderComponentInvalidDataRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsImagebuilderComponentInvalidDataRule returns new rule with default attributes
24+
func NewAwsImagebuilderComponentInvalidDataRule() *AwsImagebuilderComponentInvalidDataRule {
25+
return &AwsImagebuilderComponentInvalidDataRule{
26+
resourceType: "aws_imagebuilder_component",
27+
attributeName: "data",
28+
max: 16000,
29+
min: 1,
30+
pattern: regexp.MustCompile(`^[^\x00]+$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsImagebuilderComponentInvalidDataRule) Name() string {
36+
return "aws_imagebuilder_component_invalid_data"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsImagebuilderComponentInvalidDataRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsImagebuilderComponentInvalidDataRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsImagebuilderComponentInvalidDataRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsImagebuilderComponentInvalidDataRule) 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+
"data must be 16000 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"data 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), `^[^\x00]+$`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}
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+
// AwsImagebuilderComponentInvalidDescriptionRule checks the pattern is valid
13+
type AwsImagebuilderComponentInvalidDescriptionRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
min int
18+
}
19+
20+
// NewAwsImagebuilderComponentInvalidDescriptionRule returns new rule with default attributes
21+
func NewAwsImagebuilderComponentInvalidDescriptionRule() *AwsImagebuilderComponentInvalidDescriptionRule {
22+
return &AwsImagebuilderComponentInvalidDescriptionRule{
23+
resourceType: "aws_imagebuilder_component",
24+
attributeName: "description",
25+
max: 1024,
26+
min: 1,
27+
}
28+
}
29+
30+
// Name returns the rule name
31+
func (r *AwsImagebuilderComponentInvalidDescriptionRule) Name() string {
32+
return "aws_imagebuilder_component_invalid_description"
33+
}
34+
35+
// Enabled returns whether the rule is enabled by default
36+
func (r *AwsImagebuilderComponentInvalidDescriptionRule) Enabled() bool {
37+
return true
38+
}
39+
40+
// Severity returns the rule severity
41+
func (r *AwsImagebuilderComponentInvalidDescriptionRule) Severity() string {
42+
return tflint.ERROR
43+
}
44+
45+
// Link returns the rule reference link
46+
func (r *AwsImagebuilderComponentInvalidDescriptionRule) Link() string {
47+
return ""
48+
}
49+
50+
// Check checks the pattern is valid
51+
func (r *AwsImagebuilderComponentInvalidDescriptionRule) 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+
"description must be 1024 characters or less",
63+
attribute.Expr,
64+
)
65+
}
66+
if len(val) < r.min {
67+
runner.EmitIssueOnExpr(
68+
r,
69+
"description 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+
// AwsImagebuilderComponentInvalidKmsKeyIDRule checks the pattern is valid
13+
type AwsImagebuilderComponentInvalidKmsKeyIDRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
min int
18+
}
19+
20+
// NewAwsImagebuilderComponentInvalidKmsKeyIDRule returns new rule with default attributes
21+
func NewAwsImagebuilderComponentInvalidKmsKeyIDRule() *AwsImagebuilderComponentInvalidKmsKeyIDRule {
22+
return &AwsImagebuilderComponentInvalidKmsKeyIDRule{
23+
resourceType: "aws_imagebuilder_component",
24+
attributeName: "kms_key_id",
25+
max: 1024,
26+
min: 1,
27+
}
28+
}
29+
30+
// Name returns the rule name
31+
func (r *AwsImagebuilderComponentInvalidKmsKeyIDRule) Name() string {
32+
return "aws_imagebuilder_component_invalid_kms_key_id"
33+
}
34+
35+
// Enabled returns whether the rule is enabled by default
36+
func (r *AwsImagebuilderComponentInvalidKmsKeyIDRule) Enabled() bool {
37+
return true
38+
}
39+
40+
// Severity returns the rule severity
41+
func (r *AwsImagebuilderComponentInvalidKmsKeyIDRule) Severity() string {
42+
return tflint.ERROR
43+
}
44+
45+
// Link returns the rule reference link
46+
func (r *AwsImagebuilderComponentInvalidKmsKeyIDRule) Link() string {
47+
return ""
48+
}
49+
50+
// Check checks the pattern is valid
51+
func (r *AwsImagebuilderComponentInvalidKmsKeyIDRule) 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+
"kms_key_id must be 1024 characters or less",
63+
attribute.Expr,
64+
)
65+
}
66+
if len(val) < r.min {
67+
runner.EmitIssueOnExpr(
68+
r,
69+
"kms_key_id must be 1 characters or higher",
70+
attribute.Expr,
71+
)
72+
}
73+
return nil
74+
})
75+
})
76+
}

0 commit comments

Comments
 (0)