github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/aws/ecs/enable_container_insight.go (about)

     1  package ecs
     2  
     3  import (
     4  	"github.com/khulnasoft-lab/defsec/internal/rules"
     5  	"github.com/khulnasoft-lab/defsec/pkg/providers"
     6  	"github.com/khulnasoft-lab/defsec/pkg/scan"
     7  	"github.com/khulnasoft-lab/defsec/pkg/severity"
     8  	"github.com/khulnasoft-lab/defsec/pkg/state"
     9  )
    10  
    11  var CheckEnableContainerInsight = rules.Register(
    12  	scan.Rule{
    13  		AVDID:       "AVD-AWS-0034",
    14  		Provider:    providers.AWSProvider,
    15  		Service:     "ecs",
    16  		ShortCode:   "enable-container-insight",
    17  		Summary:     "ECS clusters should have container insights enabled",
    18  		Impact:      "Not all metrics and logs may be gathered for containers when Container Insights isn't enabled",
    19  		Resolution:  "Enable Container Insights",
    20  		Explanation: `Cloudwatch Container Insights provide more metrics and logs for container based applications and micro services.`,
    21  		Links: []string{
    22  			"https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContainerInsights.html",
    23  		},
    24  		Terraform: &scan.EngineMetadata{
    25  			GoodExamples:        terraformEnableContainerInsightGoodExamples,
    26  			BadExamples:         terraformEnableContainerInsightBadExamples,
    27  			Links:               terraformEnableContainerInsightLinks,
    28  			RemediationMarkdown: terraformEnableContainerInsightRemediationMarkdown,
    29  		},
    30  		CloudFormation: &scan.EngineMetadata{
    31  			GoodExamples:        cloudFormationEnableContainerInsightGoodExamples,
    32  			BadExamples:         cloudFormationEnableContainerInsightBadExamples,
    33  			Links:               cloudFormationEnableContainerInsightLinks,
    34  			RemediationMarkdown: cloudFormationEnableContainerInsightRemediationMarkdown,
    35  		},
    36  		Severity: severity.Low,
    37  	},
    38  	func(s *state.State) (results scan.Results) {
    39  		for _, cluster := range s.AWS.ECS.Clusters {
    40  			if cluster.Settings.ContainerInsightsEnabled.IsFalse() {
    41  				results.Add(
    42  					"Cluster does not have container insights enabled.",
    43  					cluster.Settings.ContainerInsightsEnabled,
    44  				)
    45  			} else {
    46  				results.AddPassed(&cluster)
    47  			}
    48  		}
    49  		return
    50  	},
    51  )