Skip to content

7 files changed

+375
-0
lines changed

docs/rules/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,10 @@ These rules enforce best practices and naming conventions:
11781178
|aws_sfn_state_machine_invalid_role_arn||
11791179
|aws_shield_protection_invalid_name||
11801180
|aws_shield_protection_invalid_resource_arn||
1181+
|aws_signer_signing_job_invalid_profile_name||
1182+
|aws_signer_signing_profile_invalid_name||
1183+
|aws_signer_signing_profile_permission_invalid_profile_name||
1184+
|aws_signer_signing_profile_permission_invalid_profile_version||
11811185
|aws_spot_fleet_request_invalid_allocation_strategy||
11821186
|aws_spot_fleet_request_invalid_fleet_type||
11831187
|aws_spot_fleet_request_invalid_instance_interruption_behaviour||
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+
// AwsSignerSigningJobInvalidProfileNameRule checks the pattern is valid
15+
type AwsSignerSigningJobInvalidProfileNameRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsSignerSigningJobInvalidProfileNameRule returns new rule with default attributes
24+
func NewAwsSignerSigningJobInvalidProfileNameRule() *AwsSignerSigningJobInvalidProfileNameRule {
25+
return &AwsSignerSigningJobInvalidProfileNameRule{
26+
resourceType: "aws_signer_signing_job",
27+
attributeName: "profile_name",
28+
max: 64,
29+
min: 2,
30+
pattern: regexp.MustCompile(`^[a-zA-Z0-9_]{2,}`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsSignerSigningJobInvalidProfileNameRule) Name() string {
36+
return "aws_signer_signing_job_invalid_profile_name"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsSignerSigningJobInvalidProfileNameRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsSignerSigningJobInvalidProfileNameRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsSignerSigningJobInvalidProfileNameRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsSignerSigningJobInvalidProfileNameRule) 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+
"profile_name must be 64 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"profile_name must be 2 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), `^[a-zA-Z0-9_]{2,}`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}
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+
// AwsSignerSigningProfileInvalidNameRule checks the pattern is valid
15+
type AwsSignerSigningProfileInvalidNameRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsSignerSigningProfileInvalidNameRule returns new rule with default attributes
24+
func NewAwsSignerSigningProfileInvalidNameRule() *AwsSignerSigningProfileInvalidNameRule {
25+
return &AwsSignerSigningProfileInvalidNameRule{
26+
resourceType: "aws_signer_signing_profile",
27+
attributeName: "name",
28+
max: 64,
29+
min: 2,
30+
pattern: regexp.MustCompile(`^[a-zA-Z0-9_]{2,}`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsSignerSigningProfileInvalidNameRule) Name() string {
36+
return "aws_signer_signing_profile_invalid_name"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsSignerSigningProfileInvalidNameRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsSignerSigningProfileInvalidNameRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsSignerSigningProfileInvalidNameRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsSignerSigningProfileInvalidNameRule) 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 64 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"name must be 2 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), `^[a-zA-Z0-9_]{2,}`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}
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+
// AwsSignerSigningProfilePermissionInvalidProfileNameRule checks the pattern is valid
15+
type AwsSignerSigningProfilePermissionInvalidProfileNameRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsSignerSigningProfilePermissionInvalidProfileNameRule returns new rule with default attributes
24+
func NewAwsSignerSigningProfilePermissionInvalidProfileNameRule() *AwsSignerSigningProfilePermissionInvalidProfileNameRule {
25+
return &AwsSignerSigningProfilePermissionInvalidProfileNameRule{
26+
resourceType: "aws_signer_signing_profile_permission",
27+
attributeName: "profile_name",
28+
max: 64,
29+
min: 2,
30+
pattern: regexp.MustCompile(`^[a-zA-Z0-9_]{2,}`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsSignerSigningProfilePermissionInvalidProfileNameRule) Name() string {
36+
return "aws_signer_signing_profile_permission_invalid_profile_name"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsSignerSigningProfilePermissionInvalidProfileNameRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsSignerSigningProfilePermissionInvalidProfileNameRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsSignerSigningProfilePermissionInvalidProfileNameRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsSignerSigningProfilePermissionInvalidProfileNameRule) 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+
"profile_name must be 64 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"profile_name must be 2 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), `^[a-zA-Z0-9_]{2,}`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}
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+
// AwsSignerSigningProfilePermissionInvalidProfileVersionRule checks the pattern is valid
15+
type AwsSignerSigningProfilePermissionInvalidProfileVersionRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsSignerSigningProfilePermissionInvalidProfileVersionRule returns new rule with default attributes
24+
func NewAwsSignerSigningProfilePermissionInvalidProfileVersionRule() *AwsSignerSigningProfilePermissionInvalidProfileVersionRule {
25+
return &AwsSignerSigningProfilePermissionInvalidProfileVersionRule{
26+
resourceType: "aws_signer_signing_profile_permission",
27+
attributeName: "profile_version",
28+
max: 10,
29+
min: 10,
30+
pattern: regexp.MustCompile(`^[a-zA-Z0-9]{10}$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsSignerSigningProfilePermissionInvalidProfileVersionRule) Name() string {
36+
return "aws_signer_signing_profile_permission_invalid_profile_version"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsSignerSigningProfilePermissionInvalidProfileVersionRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsSignerSigningProfilePermissionInvalidProfileVersionRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsSignerSigningProfilePermissionInvalidProfileVersionRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsSignerSigningProfilePermissionInvalidProfileVersionRule) 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+
"profile_version must be 10 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"profile_version must be 10 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), `^[a-zA-Z0-9]{10}$`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}

rules/models/mappings/signer.hcl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import = "aws-sdk-go/models/apis/signer/2017-08-25/api-2.json"
2+
3+
mapping "aws_signer_signing_job" {
4+
profile_name = ProfileName
5+
source = Source
6+
destination = Destination
7+
}
8+
9+
mapping "aws_signer_signing_profile" {
10+
platform_id = PlatformId
11+
name = ProfileName
12+
signature_validity_period = SignatureValidityPeriod
13+
tags = TagMap
14+
}
15+
16+
mapping "aws_signer_signing_profile_permission" {
17+
profile_name = ProfileName
18+
profile_version = ProfileVersion
19+
}

rules/models/provider.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,10 @@ var Rules = []tflint.Rule{
11061106
NewAwsSfnStateMachineInvalidRoleArnRule(),
11071107
NewAwsShieldProtectionInvalidNameRule(),
11081108
NewAwsShieldProtectionInvalidResourceArnRule(),
1109+
NewAwsSignerSigningJobInvalidProfileNameRule(),
1110+
NewAwsSignerSigningProfileInvalidNameRule(),
1111+
NewAwsSignerSigningProfilePermissionInvalidProfileNameRule(),
1112+
NewAwsSignerSigningProfilePermissionInvalidProfileVersionRule(),
11091113
NewAwsSpotFleetRequestInvalidAllocationStrategyRule(),
11101114
NewAwsSpotFleetRequestInvalidFleetTypeRule(),
11111115
NewAwsSpotFleetRequestInvalidInstanceInterruptionBehaviourRule(),

0 commit comments

Comments
 (0)