Skip to content

Commit 790573e

Browse files
committed
fix pattern bugs
1 parent ff4c09b commit 790573e

File tree

61 files changed

+128
-130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+128
-130
lines changed

rules/models/aws_config_config_rule_invalid_name.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func NewAwsConfigConfigRuleInvalidNameRule() *AwsConfigConfigRuleInvalidNameRule
2929
attributeName: "name",
3030
max: 128,
3131
min: 1,
32-
pattern: regexp.MustCompile(`^\S$`),
32+
pattern: regexp.MustCompile(`^\S+$`),
3333
}
3434
}
3535

@@ -90,7 +90,7 @@ func (r *AwsConfigConfigRuleInvalidNameRule) Check(runner tflint.Runner) error {
9090
if !r.pattern.MatchString(val) {
9191
runner.EmitIssue(
9292
r,
93-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S$`),
93+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S+$`),
9494
attribute.Expr.Range(),
9595
)
9696
}

rules/models/aws_config_remediation_configuration_invalid_config_rule_name.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func NewAwsConfigRemediationConfigurationInvalidConfigRuleNameRule() *AwsConfigR
2929
attributeName: "config_rule_name",
3030
max: 128,
3131
min: 1,
32-
pattern: regexp.MustCompile(`^\S$`),
32+
pattern: regexp.MustCompile(`^\S+$`),
3333
}
3434
}
3535

@@ -90,7 +90,7 @@ func (r *AwsConfigRemediationConfigurationInvalidConfigRuleNameRule) Check(runne
9090
if !r.pattern.MatchString(val) {
9191
runner.EmitIssue(
9292
r,
93-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S$`),
93+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S+$`),
9494
attribute.Expr.Range(),
9595
)
9696
}

rules/models/aws_elasticache_user_invalid_access_string.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func NewAwsElastiCacheUserInvalidAccessStringRule() *AwsElastiCacheUserInvalidAc
2525
return &AwsElastiCacheUserInvalidAccessStringRule{
2626
resourceType: "aws_elasticache_user",
2727
attributeName: "access_string",
28-
pattern: regexp.MustCompile(`^\S$`),
28+
pattern: regexp.MustCompile(`^\S+$`),
2929
}
3030
}
3131

@@ -72,7 +72,7 @@ func (r *AwsElastiCacheUserInvalidAccessStringRule) Check(runner tflint.Runner)
7272
if !r.pattern.MatchString(val) {
7373
runner.EmitIssue(
7474
r,
75-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S$`),
75+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S+$`),
7676
attribute.Expr.Range(),
7777
)
7878
}

rules/models/aws_gamelift_alias_invalid_name.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func NewAwsGameliftAliasInvalidNameRule() *AwsGameliftAliasInvalidNameRule {
2929
attributeName: "name",
3030
max: 1024,
3131
min: 1,
32-
pattern: regexp.MustCompile(`^\S$`),
32+
pattern: regexp.MustCompile(`^\S+$`),
3333
}
3434
}
3535

@@ -90,7 +90,7 @@ func (r *AwsGameliftAliasInvalidNameRule) Check(runner tflint.Runner) error {
9090
if !r.pattern.MatchString(val) {
9191
runner.EmitIssue(
9292
r,
93-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S$`),
93+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S+$`),
9494
attribute.Expr.Range(),
9595
)
9696
}

rules/models/aws_glue_schema_invalid_schema_definition.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func NewAwsGlueSchemaInvalidSchemaDefinitionRule() *AwsGlueSchemaInvalidSchemaDe
2929
attributeName: "schema_definition",
3030
max: 170000,
3131
min: 1,
32-
pattern: regexp.MustCompile(`^\S$`),
32+
pattern: regexp.MustCompile(`^\S+$`),
3333
}
3434
}
3535

@@ -90,7 +90,7 @@ func (r *AwsGlueSchemaInvalidSchemaDefinitionRule) Check(runner tflint.Runner) e
9090
if !r.pattern.MatchString(val) {
9191
runner.EmitIssue(
9292
r,
93-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S$`),
93+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S+$`),
9494
attribute.Expr.Range(),
9595
)
9696
}

rules/models/aws_guardduty_member_invalid_email.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
package models
44

55
import (
6-
"fmt"
7-
"regexp"
8-
96
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
107
"github.com/terraform-linters/tflint-plugin-sdk/logger"
118
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
@@ -19,7 +16,6 @@ type AwsGuarddutyMemberInvalidEmailRule struct {
1916
attributeName string
2017
max int
2118
min int
22-
pattern *regexp.Regexp
2319
}
2420

2521
// NewAwsGuarddutyMemberInvalidEmailRule returns new rule with default attributes
@@ -29,7 +25,6 @@ func NewAwsGuarddutyMemberInvalidEmailRule() *AwsGuarddutyMemberInvalidEmailRule
2925
attributeName: "email",
3026
max: 64,
3127
min: 6,
32-
pattern: regexp.MustCompile(`^See rules in parameter description$`),
3328
}
3429
}
3530

@@ -87,13 +82,6 @@ func (r *AwsGuarddutyMemberInvalidEmailRule) Check(runner tflint.Runner) error {
8782
attribute.Expr.Range(),
8883
)
8984
}
90-
if !r.pattern.MatchString(val) {
91-
runner.EmitIssue(
92-
r,
93-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^See rules in parameter description$`),
94-
attribute.Expr.Range(),
95-
)
96-
}
9785
return nil
9886
}, nil)
9987
if err != nil {

rules/models/aws_lightsail_instance_invalid_blueprint_id.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func NewAwsLightsailInstanceInvalidBlueprintIDRule() *AwsLightsailInstanceInvali
2525
return &AwsLightsailInstanceInvalidBlueprintIDRule{
2626
resourceType: "aws_lightsail_instance",
2727
attributeName: "blueprint_id",
28-
pattern: regexp.MustCompile(`^\S$`),
28+
pattern: regexp.MustCompile(`^\S+$`),
2929
}
3030
}
3131

@@ -72,7 +72,7 @@ func (r *AwsLightsailInstanceInvalidBlueprintIDRule) Check(runner tflint.Runner)
7272
if !r.pattern.MatchString(val) {
7373
runner.EmitIssue(
7474
r,
75-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S$`),
75+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S+$`),
7676
attribute.Expr.Range(),
7777
)
7878
}

rules/models/aws_lightsail_instance_invalid_bundle_id.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func NewAwsLightsailInstanceInvalidBundleIDRule() *AwsLightsailInstanceInvalidBu
2525
return &AwsLightsailInstanceInvalidBundleIDRule{
2626
resourceType: "aws_lightsail_instance",
2727
attributeName: "bundle_id",
28-
pattern: regexp.MustCompile(`^\S$`),
28+
pattern: regexp.MustCompile(`^\S+$`),
2929
}
3030
}
3131

@@ -72,7 +72,7 @@ func (r *AwsLightsailInstanceInvalidBundleIDRule) Check(runner tflint.Runner) er
7272
if !r.pattern.MatchString(val) {
7373
runner.EmitIssue(
7474
r,
75-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S$`),
75+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S+$`),
7676
attribute.Expr.Range(),
7777
)
7878
}

rules/models/aws_memorydb_user_invalid_access_string.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func NewAwsMemoryDBUserInvalidAccessStringRule() *AwsMemoryDBUserInvalidAccessSt
2525
return &AwsMemoryDBUserInvalidAccessStringRule{
2626
resourceType: "aws_memorydb_user",
2727
attributeName: "access_string",
28-
pattern: regexp.MustCompile(`^\S$`),
28+
pattern: regexp.MustCompile(`^\S+$`),
2929
}
3030
}
3131

@@ -72,7 +72,7 @@ func (r *AwsMemoryDBUserInvalidAccessStringRule) Check(runner tflint.Runner) err
7272
if !r.pattern.MatchString(val) {
7373
runner.EmitIssue(
7474
r,
75-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S$`),
75+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S+$`),
7676
attribute.Expr.Range(),
7777
)
7878
}

rules/models/aws_networkfirewall_resource_policy_invalid_policy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func NewAwsNetworkfirewallResourcePolicyInvalidPolicyRule() *AwsNetworkfirewallR
2929
attributeName: "policy",
3030
max: 395000,
3131
min: 1,
32-
pattern: regexp.MustCompile(`^\S$`),
32+
pattern: regexp.MustCompile(`^\S+$`),
3333
}
3434
}
3535

@@ -90,7 +90,7 @@ func (r *AwsNetworkfirewallResourcePolicyInvalidPolicyRule) Check(runner tflint.
9090
if !r.pattern.MatchString(val) {
9191
runner.EmitIssue(
9292
r,
93-
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S$`),
93+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^\S+$`),
9494
attribute.Expr.Range(),
9595
)
9696
}

0 commit comments

Comments
 (0)