Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapping servicecatalog #241

Merged
merged 2 commits into from
Dec 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions docs/rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -892,9 +892,57 @@ These rules enforce best practices and naming conventions:
|aws_service_discovery_public_dns_namespace_invalid_description|✔|
|aws_service_discovery_public_dns_namespace_invalid_name|✔|
|aws_service_discovery_service_invalid_description|✔|
|aws_servicecatalog_budget_resource_association_invalid_budget_name|✔|
|aws_servicecatalog_budget_resource_association_invalid_resource_id|✔|
|aws_servicecatalog_constraint_invalid_accept_language|✔|
|aws_servicecatalog_constraint_invalid_description|✔|
|aws_servicecatalog_constraint_invalid_portfolio_id|✔|
|aws_servicecatalog_constraint_invalid_product_id|✔|
|aws_servicecatalog_constraint_invalid_type|✔|
|aws_servicecatalog_portfolio_invalid_description|✔|
|aws_servicecatalog_portfolio_invalid_name|✔|
|aws_servicecatalog_portfolio_invalid_provider_name|✔|
|aws_servicecatalog_portfolio_share_invalid_accept_language|✔|
|aws_servicecatalog_portfolio_share_invalid_portfolio_id|✔|
|aws_servicecatalog_portfolio_share_invalid_principal_id|✔|
|aws_servicecatalog_portfolio_share_invalid_type|✔|
|aws_servicecatalog_principal_portfolio_association_invalid_accept_language|✔|
|aws_servicecatalog_principal_portfolio_association_invalid_portfolio_id|✔|
|aws_servicecatalog_principal_portfolio_association_invalid_principal_arn|✔|
|aws_servicecatalog_principal_portfolio_association_invalid_principal_type|✔|
|aws_servicecatalog_product_invalid_accept_language|✔|
|aws_servicecatalog_product_invalid_description|✔|
|aws_servicecatalog_product_invalid_distributor|✔|
|aws_servicecatalog_product_invalid_name|✔|
|aws_servicecatalog_product_invalid_owner|✔|
|aws_servicecatalog_product_invalid_support_description|✔|
|aws_servicecatalog_product_invalid_support_email|✔|
|aws_servicecatalog_product_invalid_support_url|✔|
|aws_servicecatalog_product_invalid_type|✔|
|aws_servicecatalog_product_portfolio_association_invalid_accept_language|✔|
|aws_servicecatalog_product_portfolio_association_invalid_portfolio_id|✔|
|aws_servicecatalog_product_portfolio_association_invalid_product_id|✔|
|aws_servicecatalog_product_portfolio_association_invalid_source_portfolio_id|✔|
|aws_servicecatalog_provisioned_product_invalid_accept_language|✔|
|aws_servicecatalog_provisioned_product_invalid_name|✔|
|aws_servicecatalog_provisioned_product_invalid_path_id|✔|
|aws_servicecatalog_provisioned_product_invalid_path_name|✔|
|aws_servicecatalog_provisioned_product_invalid_product_id|✔|
|aws_servicecatalog_provisioned_product_invalid_product_name|✔|
|aws_servicecatalog_provisioned_product_invalid_provisioning_artifact_id|✔|
|aws_servicecatalog_provisioned_product_invalid_provisioning_artifact_name|✔|
|aws_servicecatalog_provisioning_artifact_invalid_accept_language|✔|
|aws_servicecatalog_provisioning_artifact_invalid_description|✔|
|aws_servicecatalog_provisioning_artifact_invalid_guidance|✔|
|aws_servicecatalog_provisioning_artifact_invalid_name|✔|
|aws_servicecatalog_provisioning_artifact_invalid_product_id|✔|
|aws_servicecatalog_provisioning_artifact_invalid_type|✔|
|aws_servicecatalog_service_action_invalid_accept_language|✔|
|aws_servicecatalog_service_action_invalid_description|✔|
|aws_servicecatalog_service_action_invalid_name|✔|
|aws_servicecatalog_tag_option_invalid_key|✔|
|aws_servicecatalog_tag_option_invalid_value|✔|
|aws_servicecatalog_tag_option_resource_association_invalid_tag_option_id|✔|
|aws_servicequotas_service_quota_invalid_quota_code|✔|
|aws_servicequotas_service_quota_invalid_service_code|✔|
|aws_ses_domain_mail_from_invalid_behavior_on_mx_failure|✔|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"log"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule checks the pattern is valid
type AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule struct {
resourceType string
attributeName string
max int
min int
}

// NewAwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule returns new rule with default attributes
func NewAwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule() *AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule {
return &AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule{
resourceType: "aws_servicecatalog_budget_resource_association",
attributeName: "budget_name",
max: 100,
min: 1,
}
}

// Name returns the rule name
func (r *AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule) Name() string {
return "aws_servicecatalog_budget_resource_association_invalid_budget_name"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule) Severity() string {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule) Check(runner tflint.Runner) error {
log.Printf("[TRACE] Check `%s` rule", r.Name())

return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

return runner.EnsureNoError(err, func() error {
if len(val) > r.max {
runner.EmitIssueOnExpr(
r,
"budget_name must be 100 characters or less",
attribute.Expr,
)
}
if len(val) < r.min {
runner.EmitIssueOnExpr(
r,
"budget_name must be 1 characters or higher",
attribute.Expr,
)
}
return nil
})
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"fmt"
"log"
"regexp"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule checks the pattern is valid
type AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule struct {
resourceType string
attributeName string
max int
min int
pattern *regexp.Regexp
}

// NewAwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule returns new rule with default attributes
func NewAwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule() *AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule {
return &AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule{
resourceType: "aws_servicecatalog_budget_resource_association",
attributeName: "resource_id",
max: 100,
min: 1,
pattern: regexp.MustCompile(`^[a-zA-Z0-9_\-]*`),
}
}

// Name returns the rule name
func (r *AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule) Name() string {
return "aws_servicecatalog_budget_resource_association_invalid_resource_id"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule) Severity() string {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule) Check(runner tflint.Runner) error {
log.Printf("[TRACE] Check `%s` rule", r.Name())

return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

return runner.EnsureNoError(err, func() error {
if len(val) > r.max {
runner.EmitIssueOnExpr(
r,
"resource_id must be 100 characters or less",
attribute.Expr,
)
}
if len(val) < r.min {
runner.EmitIssueOnExpr(
r,
"resource_id must be 1 characters or higher",
attribute.Expr,
)
}
if !r.pattern.MatchString(val) {
runner.EmitIssueOnExpr(
r,
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^[a-zA-Z0-9_\-]*`),
attribute.Expr,
)
}
return nil
})
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"log"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// AwsServicecatalogConstraintInvalidAcceptLanguageRule checks the pattern is valid
type AwsServicecatalogConstraintInvalidAcceptLanguageRule struct {
resourceType string
attributeName string
max int
}

// NewAwsServicecatalogConstraintInvalidAcceptLanguageRule returns new rule with default attributes
func NewAwsServicecatalogConstraintInvalidAcceptLanguageRule() *AwsServicecatalogConstraintInvalidAcceptLanguageRule {
return &AwsServicecatalogConstraintInvalidAcceptLanguageRule{
resourceType: "aws_servicecatalog_constraint",
attributeName: "accept_language",
max: 100,
}
}

// Name returns the rule name
func (r *AwsServicecatalogConstraintInvalidAcceptLanguageRule) Name() string {
return "aws_servicecatalog_constraint_invalid_accept_language"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsServicecatalogConstraintInvalidAcceptLanguageRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *AwsServicecatalogConstraintInvalidAcceptLanguageRule) Severity() string {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *AwsServicecatalogConstraintInvalidAcceptLanguageRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsServicecatalogConstraintInvalidAcceptLanguageRule) Check(runner tflint.Runner) error {
log.Printf("[TRACE] Check `%s` rule", r.Name())

return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

return runner.EnsureNoError(err, func() error {
if len(val) > r.max {
runner.EmitIssueOnExpr(
r,
"accept_language must be 100 characters or less",
attribute.Expr,
)
}
return nil
})
})
}
67 changes: 67 additions & 0 deletions rules/models/aws_servicecatalog_constraint_invalid_description.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"log"

hcl "github.com/hashicorp/hcl/v2"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// AwsServicecatalogConstraintInvalidDescriptionRule checks the pattern is valid
type AwsServicecatalogConstraintInvalidDescriptionRule struct {
resourceType string
attributeName string
max int
}

// NewAwsServicecatalogConstraintInvalidDescriptionRule returns new rule with default attributes
func NewAwsServicecatalogConstraintInvalidDescriptionRule() *AwsServicecatalogConstraintInvalidDescriptionRule {
return &AwsServicecatalogConstraintInvalidDescriptionRule{
resourceType: "aws_servicecatalog_constraint",
attributeName: "description",
max: 2000,
}
}

// Name returns the rule name
func (r *AwsServicecatalogConstraintInvalidDescriptionRule) Name() string {
return "aws_servicecatalog_constraint_invalid_description"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsServicecatalogConstraintInvalidDescriptionRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *AwsServicecatalogConstraintInvalidDescriptionRule) Severity() string {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *AwsServicecatalogConstraintInvalidDescriptionRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsServicecatalogConstraintInvalidDescriptionRule) Check(runner tflint.Runner) error {
log.Printf("[TRACE] Check `%s` rule", r.Name())

return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
var val string
err := runner.EvaluateExpr(attribute.Expr, &val, nil)

return runner.EnsureNoError(err, func() error {
if len(val) > r.max {
runner.EmitIssueOnExpr(
r,
"description must be 2000 characters or less",
attribute.Expr,
)
}
return nil
})
})
}
Loading