diff --git a/checks/cloud/aws/accessanalyzer/enable_access_analyzer.go b/checks/cloud/aws/accessanalyzer/enable_access_analyzer.go deleted file mode 100755 index 4453db45..00000000 --- a/checks/cloud/aws/accessanalyzer/enable_access_analyzer.go +++ /dev/null @@ -1,58 +0,0 @@ -package accessanalyzer - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var CheckEnableAccessAnalyzer = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0175", - Provider: providers.AWSProvider, - Service: "accessanalyzer", - ShortCode: "enable-access-analyzer", - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_4: {"1.20"}, - }, - Summary: "Enable IAM Access analyzer for IAM policies about all resources in each region.", - Impact: "Reduced visibility of externally shared resources.", - Resolution: "Enable IAM Access analyzer across all regions.", - Explanation: ` -AWS IAM Access Analyzer helps you identify the resources in your organization and -accounts, such as Amazon S3 buckets or IAM roles, that are shared with an external entity. -This lets you identify unintended access to your resources and data. Access Analyzer -identifies resources that are shared with external principals by using logic-based reasoning -to analyze the resource-based policies in your AWS environment. IAM Access Analyzer -continuously monitors all policies for S3 bucket, IAM roles, KMS(Key Management Service) -keys, AWS Lambda functions, and Amazon SQS(Simple Queue Service) queues. -`, - Links: []string{ - "https://docs.aws.amazon.com/IAM/latest/UserGuide/what-is-access-analyzer.html", - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - var enabled bool - for _, analyzer := range s.AWS.AccessAnalyzer.Analyzers { - if analyzer.Active.IsTrue() { - enabled = true - break - } - } - if !enabled { - results.Add( - "Access Analyzer is not enabled.", - trivyTypes.NewUnmanagedMetadata(), - ) - } else { - results.AddPassed(trivyTypes.NewUnmanagedMetadata()) - } - return - }, -) diff --git a/checks/cloud/aws/apigateway/enable_access_logging.cf.go b/checks/cloud/aws/apigateway/enable_access_logging.cf.go deleted file mode 100644 index ff01998c..00000000 --- a/checks/cloud/aws/apigateway/enable_access_logging.cf.go +++ /dev/null @@ -1,40 +0,0 @@ -package apigateway - -var cloudFormationEnableAccessLoggingGoodExamples = []string{ - `--- -AWSTemplateFormatVersion: 2010-09-09 -Description: Good Example of ApiGateway -Resources: - GoodApi: - Type: AWS::ApiGatewayV2::Api - GoodApiStage: - Type: AWS::ApiGatewayV2::Stage - Properties: - AccessLogSettings: - DestinationArn: gateway-logging - Format: json - ApiId: !Ref GoodApi - StageName: GoodApiStage -`, -} - -var cloudFormationEnableAccessLoggingBadExamples = []string{ - `--- -AWSTemplateFormatVersion: 2010-09-09 -Description: Bad Example of ApiGateway -Resources: - BadApi: - Type: AWS::ApiGatewayV2::Api - BadApiStage: - Type: AWS::ApiGatewayV2::Stage - Properties: - AccessLogSettings: - Format: json - ApiId: !Ref BadApi - StageName: BadApiStage -`, -} - -var cloudFormationEnableAccessLoggingLinks []string - -var cloudFormationEnableAccessLoggingRemediationMarkdown = `` diff --git a/checks/cloud/aws/apigateway/enable_access_logging.go b/checks/cloud/aws/apigateway/enable_access_logging.go deleted file mode 100755 index 376fdec4..00000000 --- a/checks/cloud/aws/apigateway/enable_access_logging.go +++ /dev/null @@ -1,72 +0,0 @@ -package apigateway - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableAccessLogging = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0001", - Provider: providers.AWSProvider, - Service: "api-gateway", - ShortCode: "enable-access-logging", - Summary: "API Gateway stages for V1 and V2 should have access logging enabled", - Impact: "Logging provides vital information about access and usage", - Resolution: "Enable logging for API Gateway stages", - Explanation: `API Gateway stages should have access log settings block configured to track all access to a particular stage. This should be applied to both v1 and v2 gateway stages.`, - Links: []string{ - "https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-logging.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableAccessLoggingGoodExamples, - BadExamples: terraformEnableAccessLoggingBadExamples, - Links: terraformEnableAccessLoggingLinks, - RemediationMarkdown: terraformEnableAccessLoggingRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnableAccessLoggingGoodExamples, - BadExamples: cloudFormationEnableAccessLoggingBadExamples, - Links: cloudFormationEnableAccessLoggingLinks, - RemediationMarkdown: cloudFormationEnableAccessLoggingRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, api := range s.AWS.APIGateway.V1.APIs { - for _, stage := range api.Stages { - if stage.Metadata.IsUnmanaged() { - continue - } - if stage.AccessLogging.CloudwatchLogGroupARN.IsEmpty() { - results.Add( - "Access logging is not configured.", - stage.AccessLogging.CloudwatchLogGroupARN, - ) - } else { - results.AddPassed(&api) - } - } - } - for _, api := range s.AWS.APIGateway.V2.APIs { - for _, stage := range api.Stages { - if stage.Metadata.IsUnmanaged() { - continue - } - if stage.AccessLogging.CloudwatchLogGroupARN.IsEmpty() { - results.Add( - "Access logging is not configured.", - stage.AccessLogging.CloudwatchLogGroupARN, - ) - } else { - results.AddPassed(&api) - } - } - } - return - }, -) diff --git a/checks/cloud/aws/apigateway/enable_access_logging.tf.go b/checks/cloud/aws/apigateway/enable_access_logging.tf.go deleted file mode 100644 index 69981cf3..00000000 --- a/checks/cloud/aws/apigateway/enable_access_logging.tf.go +++ /dev/null @@ -1,47 +0,0 @@ -package apigateway - -var terraformEnableAccessLoggingGoodExamples = []string{ - ` - resource "aws_apigatewayv2_stage" "good_example" { - api_id = aws_apigatewayv2_api.example.id - name = "example-stage" - - access_log_settings { - destination_arn = "arn:aws:logs:region:0123456789:log-group:access_logging" - format = "json" - } - } - - resource "aws_api_gateway_stage" "good_example" { - deployment_id = aws_api_gateway_deployment.example.id - rest_api_id = aws_api_gateway_rest_api.example.id - stage_name = "example" - - access_log_settings { - destination_arn = "arn:aws:logs:region:0123456789:log-group:access_logging" - format = "json" - } - } - `, -} - -var terraformEnableAccessLoggingBadExamples = []string{ - ` - resource "aws_apigatewayv2_stage" "bad_example" { - api_id = aws_apigatewayv2_api.example.id - name = "example-stage" - } - - resource "aws_apigatewayv2_stage" "bad_example" { - deployment_id = aws_api_gateway_deployment.example.id - rest_api_id = aws_api_gateway_rest_api.example.id - stage_name = "example" - } - `, -} - -var terraformEnableAccessLoggingLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/apigatewayv2_stage#access_log_settings`, -} - -var terraformEnableAccessLoggingRemediationMarkdown = `` diff --git a/checks/cloud/aws/apigateway/enable_cache.go b/checks/cloud/aws/apigateway/enable_cache.go deleted file mode 100644 index 32308e62..00000000 --- a/checks/cloud/aws/apigateway/enable_cache.go +++ /dev/null @@ -1,58 +0,0 @@ -package apigateway - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableCache = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0190", - Provider: providers.AWSProvider, - Service: "api-gateway", - ShortCode: "enable-cache", - Summary: "Ensure that response caching is enabled for your Amazon API Gateway REST APIs.", - Impact: "Reduce the number of calls made to your API endpoint and also improve the latency of requests to your API with response caching.", - Resolution: "Enable cache", - Explanation: "A REST API in API Gateway is a collection of resources and methods that are integrated with backend HTTP endpoints, Lambda functions, or other AWS services. You can enable API caching in Amazon API Gateway to cache your endpoint responses. With caching, you can reduce the number of calls made to your endpoint and also improve the latency of requests to your API.", - Links: []string{"https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-caching.html"}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableCacheGoodExamples, - BadExamples: terraformEnableCacheBadExamples, - Links: terraformEnableCacheLinks, - RemediationMarkdown: terraformEnableCacheRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, api := range s.AWS.APIGateway.V1.APIs { - if api.Metadata.IsUnmanaged() { - continue - } - for _, stage := range api.Stages { - if stage.Metadata.IsUnmanaged() { - continue - } - for _, settings := range stage.RESTMethodSettings { - if settings.Metadata.IsUnmanaged() { - continue - } - if settings.CacheEnabled.IsFalse() { - results.Add( - "Cache data is not enabled.", - settings.CacheEnabled, - ) - } else { - results.AddPassed(&settings) - } - - } - } - } - return - }, -) diff --git a/checks/cloud/aws/apigateway/enable_cache.tf.go b/checks/cloud/aws/apigateway/enable_cache.tf.go deleted file mode 100644 index 4b7afc00..00000000 --- a/checks/cloud/aws/apigateway/enable_cache.tf.go +++ /dev/null @@ -1,55 +0,0 @@ -package apigateway - -var terraformEnableCacheGoodExamples = []string{ - ` - resource "aws_api_gateway_rest_api" "example" { - - } - - resource "aws_api_gateway_stage" "example" { - - } - - resource "aws_api_gateway_method_settings" "good_example" { - rest_api_id = aws_api_gateway_rest_api.example.id - stage_name = aws_api_gateway_stage.example.stage_name - method_path = "path1/GET" - - settings { - metrics_enabled = true - logging_level = "INFO" - caching_enabled = true - } - } - `, -} - -var terraformEnableCacheBadExamples = []string{ - ` - resource "aws_api_gateway_rest_api" "example" { - - } - - resource "aws_api_gateway_stage" "example" { - rest_api_id = aws_api_gateway_rest_api.example.id - } - - resource "aws_api_gateway_method_settings" "bad_example" { - rest_api_id = aws_api_gateway_rest_api.example.id - stage_name = aws_api_gateway_stage.example.stage_name - method_path = "path1/GET" - - settings { - metrics_enabled = true - logging_level = "INFO" - caching_enabled = false - } - } - `, -} - -var terraformEnableCacheLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method_settings#cache_enabled`, -} - -var terraformEnableCacheRemediationMarkdown = `` diff --git a/checks/cloud/aws/apigateway/enable_cache_encryption.go b/checks/cloud/aws/apigateway/enable_cache_encryption.go deleted file mode 100755 index 5d28b5c4..00000000 --- a/checks/cloud/aws/apigateway/enable_cache_encryption.go +++ /dev/null @@ -1,60 +0,0 @@ -package apigateway - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableCacheEncryption = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0002", - Provider: providers.AWSProvider, - Service: "api-gateway", - ShortCode: "enable-cache-encryption", - Summary: "API Gateway must have cache enabled", - Impact: "Data stored in the cache that is unencrypted may be vulnerable to compromise", - Resolution: "Enable cache encryption", - Explanation: `Method cache encryption ensures that any sensitive data in the cache is not vulnerable to compromise in the event of interception`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableCacheEncryptionGoodExamples, - BadExamples: terraformEnableCacheEncryptionBadExamples, - Links: terraformEnableCacheEncryptionLinks, - RemediationMarkdown: terraformEnableCacheEncryptionRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, api := range s.AWS.APIGateway.V1.APIs { - if api.Metadata.IsUnmanaged() { - continue - } - for _, stage := range api.Stages { - if stage.Metadata.IsUnmanaged() { - continue - } - for _, settings := range stage.RESTMethodSettings { - if settings.Metadata.IsUnmanaged() { - continue - } - if settings.CacheEnabled.IsFalse() { - continue - } - if settings.CacheDataEncrypted.IsFalse() { - results.Add( - "Cache data is not encrypted.", - settings.CacheDataEncrypted, - ) - } else { - results.AddPassed(&settings) - } - } - } - } - return - }, -) diff --git a/checks/cloud/aws/apigateway/enable_cache_encryption.tf.go b/checks/cloud/aws/apigateway/enable_cache_encryption.tf.go deleted file mode 100644 index e782b5e1..00000000 --- a/checks/cloud/aws/apigateway/enable_cache_encryption.tf.go +++ /dev/null @@ -1,57 +0,0 @@ -package apigateway - -var terraformEnableCacheEncryptionGoodExamples = []string{ - ` - resource "aws_api_gateway_rest_api" "example" { - - } - - resource "aws_api_gateway_stage" "example" { - - } - - resource "aws_api_gateway_method_settings" "good_example" { - rest_api_id = aws_api_gateway_rest_api.example.id - stage_name = aws_api_gateway_stage.example.stage_name - method_path = "path1/GET" - - settings { - metrics_enabled = true - logging_level = "INFO" - caching_enabled = true - cache_data_encrypted = true - } - } - `, -} - -var terraformEnableCacheEncryptionBadExamples = []string{ - ` - resource "aws_api_gateway_rest_api" "example" { - - } - - resource "aws_api_gateway_stage" "example" { - rest_api_id = aws_api_gateway_rest_api.example.id - } - - resource "aws_api_gateway_method_settings" "bad_example" { - rest_api_id = aws_api_gateway_rest_api.example.id - stage_name = aws_api_gateway_stage.example.stage_name - method_path = "path1/GET" - - settings { - metrics_enabled = true - logging_level = "INFO" - caching_enabled = true - cache_data_encrypted = false - } - } - `, -} - -var terraformEnableCacheEncryptionLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method_settings#cache_data_encrypted`, -} - -var terraformEnableCacheEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/apigateway/enable_tracing.go b/checks/cloud/aws/apigateway/enable_tracing.go deleted file mode 100755 index c1882010..00000000 --- a/checks/cloud/aws/apigateway/enable_tracing.go +++ /dev/null @@ -1,52 +0,0 @@ -package apigateway - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableTracing = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0003", - Provider: providers.AWSProvider, - Service: "api-gateway", - ShortCode: "enable-tracing", - Summary: "API Gateway must have X-Ray tracing enabled", - Impact: "Without full tracing enabled it is difficult to trace the flow of logs", - Resolution: "Enable tracing", - Explanation: `X-Ray tracing enables end-to-end debugging and analysis of all API Gateway HTTP requests.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableTracingGoodExamples, - BadExamples: terraformEnableTracingBadExamples, - Links: terraformEnableTracingLinks, - RemediationMarkdown: terraformEnableTracingRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, api := range s.AWS.APIGateway.V1.APIs { - if api.Metadata.IsUnmanaged() { - continue - } - for _, stage := range api.Stages { - if stage.Metadata.IsUnmanaged() { - continue - } - if stage.XRayTracingEnabled.IsFalse() { - results.Add( - "X-Ray tracing is not enabled,", - stage.XRayTracingEnabled, - ) - } else { - results.AddPassed(&stage) - } - } - } - return - }, -) diff --git a/checks/cloud/aws/apigateway/enable_tracing.tf.go b/checks/cloud/aws/apigateway/enable_tracing.tf.go deleted file mode 100644 index 07304ebe..00000000 --- a/checks/cloud/aws/apigateway/enable_tracing.tf.go +++ /dev/null @@ -1,37 +0,0 @@ -package apigateway - -var terraformEnableTracingGoodExamples = []string{ - ` - resource "aws_api_gateway_rest_api" "test" { - - } - - resource "aws_api_gateway_stage" "good_example" { - stage_name = "prod" - rest_api_id = aws_api_gateway_rest_api.test.id - deployment_id = aws_api_gateway_deployment.test.id - xray_tracing_enabled = true - } - `, -} - -var terraformEnableTracingBadExamples = []string{ - ` - resource "aws_api_gateway_rest_api" "test" { - - } - - resource "aws_api_gateway_stage" "bad_example" { - stage_name = "prod" - rest_api_id = aws_api_gateway_rest_api.test.id - deployment_id = aws_api_gateway_deployment.test.id - xray_tracing_enabled = false - } - `, -} - -var terraformEnableTracingLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_stage#xray_tracing_enabled`, -} - -var terraformEnableTracingRemediationMarkdown = `` diff --git a/checks/cloud/aws/apigateway/no_public_access.go b/checks/cloud/aws/apigateway/no_public_access.go deleted file mode 100755 index 976c5e51..00000000 --- a/checks/cloud/aws/apigateway/no_public_access.go +++ /dev/null @@ -1,58 +0,0 @@ -package apigateway - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - v1 "github.com/aquasecurity/trivy/pkg/iac/providers/aws/apigateway/v1" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicAccess = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0004", - Provider: providers.AWSProvider, - Service: "api-gateway", - ShortCode: "no-public-access", - Summary: "No unauthorized access to API Gateway methods", - Impact: "API gateway methods can be accessed without authorization.", - Resolution: "Use and authorization method or require API Key", - Explanation: `API Gateway methods should generally be protected by authorization or api key. OPTION verb calls can be used without authorization`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicAccessGoodExamples, - BadExamples: terraformNoPublicAccessBadExamples, - Links: terraformNoPublicAccessLinks, - RemediationMarkdown: terraformNoPublicAccessRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, api := range s.AWS.APIGateway.V1.APIs { - if api.Metadata.IsUnmanaged() { - continue - } - for _, resource := range api.Resources { - for _, method := range resource.Methods { - if method.HTTPMethod.EqualTo("OPTION") { - continue - } - if method.APIKeyRequired.IsTrue() { - continue - } - if method.AuthorizationType.EqualTo(v1.AuthorizationNone) { - results.Add( - "Authorization is not enabled for this method.", - method.AuthorizationType, - ) - } else { - results.AddPassed(&method) - } - } - } - } - return - }, -) diff --git a/checks/cloud/aws/apigateway/no_public_access.tf.go b/checks/cloud/aws/apigateway/no_public_access.tf.go deleted file mode 100644 index a7c8abdf..00000000 --- a/checks/cloud/aws/apigateway/no_public_access.tf.go +++ /dev/null @@ -1,76 +0,0 @@ -package apigateway - -var terraformNoPublicAccessGoodExamples = []string{ - ` - resource "aws_api_gateway_rest_api" "MyDemoAPI" { - - } - - resource "aws_api_gateway_resource" "MyDemoResource" { - rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id - } - - resource "aws_api_gateway_method" "good_example" { - rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id - resource_id = aws_api_gateway_resource.MyDemoResource.id - http_method = "GET" - authorization = "AWS_IAM" - } - `, ` - resource "aws_api_gateway_rest_api" "MyDemoAPI" { - - } - - resource "aws_api_gateway_resource" "MyDemoResource" { - rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id - } - - resource "aws_api_gateway_method" "good_example" { - rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id - resource_id = aws_api_gateway_resource.MyDemoResource.id - http_method = "GET" - authorization = "NONE" - api_key_required = true - } - `, ` - resource "aws_api_gateway_rest_api" "MyDemoAPI" { - - } - - resource "aws_api_gateway_resource" "MyDemoResource" { - rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id - } - - resource "aws_api_gateway_method" "good_example" { - rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id - resource_id = aws_api_gateway_resource.MyDemoResource.id - http_method = "OPTION" - authorization = "NONE" - } - `, -} - -var terraformNoPublicAccessBadExamples = []string{ - ` - resource "aws_api_gateway_rest_api" "MyDemoAPI" { - - } - - resource "aws_api_gateway_resource" "MyDemoResource" { - rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id - } - - resource "aws_api_gateway_method" "bad_example" { - rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id - resource_id = aws_api_gateway_resource.MyDemoResource.id - http_method = "GET" - authorization = "NONE" - } - `, -} - -var terraformNoPublicAccessLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_method#authorization`, -} - -var terraformNoPublicAccessRemediationMarkdown = `` diff --git a/checks/cloud/aws/apigateway/use_secure_tls_policy.go b/checks/cloud/aws/apigateway/use_secure_tls_policy.go deleted file mode 100755 index 7ce35af3..00000000 --- a/checks/cloud/aws/apigateway/use_secure_tls_policy.go +++ /dev/null @@ -1,56 +0,0 @@ -package apigateway - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckUseSecureTlsPolicy = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0005", - Provider: providers.AWSProvider, - Service: "api-gateway", - ShortCode: "use-secure-tls-policy", - Summary: "API Gateway domain name uses outdated SSL/TLS protocols.", - Impact: "Outdated SSL policies increase exposure to known vulnerabilities", - Resolution: "Use the most modern TLS/SSL policies available", - Explanation: `You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.`, - Links: []string{ - "https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-custom-domain-tls-version.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformUseSecureTlsPolicyGoodExamples, - BadExamples: terraformUseSecureTlsPolicyBadExamples, - Links: terraformUseSecureTlsPolicyLinks, - RemediationMarkdown: terraformUseSecureTlsPolicyRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, domain := range s.AWS.APIGateway.V1.DomainNames { - if domain.SecurityPolicy.NotEqualTo("TLS_1_2") { - results.Add( - "Domain name is configured with an outdated TLS policy.", - domain.SecurityPolicy, - ) - } else { - results.AddPassed(&domain) - } - } - for _, domain := range s.AWS.APIGateway.V2.DomainNames { - if domain.SecurityPolicy.NotEqualTo("TLS_1_2") { - results.Add( - "Domain name is configured with an outdated TLS policy.", - domain.SecurityPolicy, - ) - } else { - results.AddPassed(&domain) - } - } - return - }, -) diff --git a/checks/cloud/aws/apigateway/use_secure_tls_policy.tf.go b/checks/cloud/aws/apigateway/use_secure_tls_policy.tf.go deleted file mode 100644 index a51a9cd0..00000000 --- a/checks/cloud/aws/apigateway/use_secure_tls_policy.tf.go +++ /dev/null @@ -1,23 +0,0 @@ -package apigateway - -var terraformUseSecureTlsPolicyGoodExamples = []string{ - ` - resource "aws_api_gateway_domain_name" "good_example" { - security_policy = "TLS_1_2" - } - `, -} - -var terraformUseSecureTlsPolicyBadExamples = []string{ - ` - resource "aws_api_gateway_domain_name" "bad_example" { - security_policy = "TLS_1_0" - } - `, -} - -var terraformUseSecureTlsPolicyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_domain_name#security_policy`, -} - -var terraformUseSecureTlsPolicyRemediationMarkdown = `` diff --git a/checks/cloud/aws/athena/enable_at_rest_encryption.cf.go b/checks/cloud/aws/athena/enable_at_rest_encryption.cf.go deleted file mode 100644 index 1290ff27..00000000 --- a/checks/cloud/aws/athena/enable_at_rest_encryption.cf.go +++ /dev/null @@ -1,31 +0,0 @@ -package athena - -var cloudFormationEnableAtRestEncryptionGoodExamples = []string{ - `--- -Resources: - GoodExample: - Properties: - Name: goodExample - WorkGroupConfiguration: - ResultConfiguration: - EncryptionConfiguration: - EncryptionOption: SSE_KMS - Type: AWS::Athena::WorkGroup -`, -} - -var cloudFormationEnableAtRestEncryptionBadExamples = []string{ - `--- -Resources: - BadExample: - Properties: - Name: badExample - WorkGroupConfiguration: - ResultConfiguration: - Type: AWS::Athena::WorkGroup -`, -} - -var cloudFormationEnableAtRestEncryptionLinks = []string{} - -var cloudFormationEnableAtRestEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/athena/enable_at_rest_encryption.go b/checks/cloud/aws/athena/enable_at_rest_encryption.go deleted file mode 100755 index 32d5d367..00000000 --- a/checks/cloud/aws/athena/enable_at_rest_encryption.go +++ /dev/null @@ -1,69 +0,0 @@ -package athena - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/athena" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableAtRestEncryption = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0006", - Provider: providers.AWSProvider, - Service: "athena", - ShortCode: "enable-at-rest-encryption", - Summary: "Athena databases and workgroup configurations are created unencrypted at rest by default, they should be encrypted", - Impact: "Data can be read if the Athena Database is compromised", - Resolution: "Enable encryption at rest for Athena databases and workgroup configurations", - Explanation: `Athena databases and workspace result sets should be encrypted at rests. These databases and query sets are generally derived from data in S3 buckets and should have the same level of at rest protection.`, - Links: []string{ - "https://docs.aws.amazon.com/athena/latest/ug/encryption.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableAtRestEncryptionGoodExamples, - BadExamples: terraformEnableAtRestEncryptionBadExamples, - Links: terraformEnableAtRestEncryptionLinks, - RemediationMarkdown: terraformEnableAtRestEncryptionRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnableAtRestEncryptionGoodExamples, - BadExamples: cloudFormationEnableAtRestEncryptionBadExamples, - Links: cloudFormationEnableAtRestEncryptionLinks, - RemediationMarkdown: cloudFormationEnableAtRestEncryptionRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, workgroup := range s.AWS.Athena.Workgroups { - if workgroup.Metadata.IsUnmanaged() { - continue - } - if workgroup.Encryption.Type.EqualTo(athena.EncryptionTypeNone) { - results.Add( - "Workgroup does not have encryption configured.", - workgroup.Encryption.Type, - ) - } else { - results.AddPassed(&workgroup) - } - } - for _, database := range s.AWS.Athena.Databases { - if database.Metadata.IsUnmanaged() { - continue - } - if database.Encryption.Type.EqualTo(athena.EncryptionTypeNone) { - results.Add( - "Database does not have encryption configured.", - database.Encryption.Type, - ) - } else { - results.AddPassed(&database) - } - } - return - }, -) diff --git a/checks/cloud/aws/athena/enable_at_rest_encryption.tf.go b/checks/cloud/aws/athena/enable_at_rest_encryption.tf.go deleted file mode 100644 index c33d4c7a..00000000 --- a/checks/cloud/aws/athena/enable_at_rest_encryption.tf.go +++ /dev/null @@ -1,61 +0,0 @@ -package athena - -var terraformEnableAtRestEncryptionGoodExamples = []string{ - ` - resource "aws_athena_database" "good_example" { - name = "database_name" - bucket = aws_s3_bucket.hoge.bucket - - encryption_configuration { - encryption_option = "SSE_KMS" - kms_key_arn = aws_kms_key.example.arn - } - } - - resource "aws_athena_workgroup" "good_example" { - name = "example" - - configuration { - enforce_workgroup_configuration = true - publish_cloudwatch_metrics_enabled = true - - result_configuration { - output_location = "s3://${aws_s3_bucket.example.bucket}/output/" - - encryption_configuration { - encryption_option = "SSE_KMS" - kms_key_arn = aws_kms_key.example.arn - } - } - } - } - `, -} - -var terraformEnableAtRestEncryptionBadExamples = []string{ - ` - resource "aws_athena_database" "bad_example" { - name = "database_name" - bucket = aws_s3_bucket.hoge.bucket - } - - resource "aws_athena_workgroup" "bad_example" { - name = "example" - - configuration { - enforce_workgroup_configuration = true - publish_cloudwatch_metrics_enabled = true - - result_configuration { - output_location = "s3://${aws_s3_bucket.example.bucket}/output/" - } - } - } - `, -} - -var terraformEnableAtRestEncryptionLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/athena_workgroup#encryption_configuration`, `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/athena_database#encryption_configuration`, -} - -var terraformEnableAtRestEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/athena/no_encryption_override.cf.go b/checks/cloud/aws/athena/no_encryption_override.cf.go deleted file mode 100644 index a6df83bb..00000000 --- a/checks/cloud/aws/athena/no_encryption_override.cf.go +++ /dev/null @@ -1,35 +0,0 @@ -package athena - -var cloudFormationNoEncryptionOverrideGoodExamples = []string{ - `--- -Resources: - GoodExample: - Properties: - Name: goodExample - WorkGroupConfiguration: - EnforceWorkGroupConfiguration: true - ResultConfiguration: - EncryptionConfiguration: - EncryptionOption: SSE_KMS - Type: AWS::Athena::WorkGroup -`, -} - -var cloudFormationNoEncryptionOverrideBadExamples = []string{ - `--- -Resources: - BadExample: - Properties: - Name: badExample - WorkGroupConfiguration: - EnforceWorkGroupConfiguration: false - ResultConfiguration: - EncryptionConfiguration: - EncryptionOption: SSE_KMS - Type: AWS::Athena::WorkGroup -`, -} - -var cloudFormationNoEncryptionOverrideLinks = []string{} - -var cloudFormationNoEncryptionOverrideRemediationMarkdown = `` diff --git a/checks/cloud/aws/athena/no_encryption_override.go b/checks/cloud/aws/athena/no_encryption_override.go deleted file mode 100755 index ba40c161..00000000 --- a/checks/cloud/aws/athena/no_encryption_override.go +++ /dev/null @@ -1,53 +0,0 @@ -package athena - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoEncryptionOverride = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0007", - Provider: providers.AWSProvider, - Service: "athena", - ShortCode: "no-encryption-override", - Summary: "Athena workgroups should enforce configuration to prevent client disabling encryption", - Impact: "Clients can ignore encryption requirements", - Resolution: "Enforce the configuration to prevent client overrides", - Explanation: `Athena workgroup configuration should be enforced to prevent client side changes to disable encryption settings.`, - Links: []string{ - "https://docs.aws.amazon.com/athena/latest/ug/manage-queries-control-costs-with-workgroups.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoEncryptionOverrideGoodExamples, - BadExamples: terraformNoEncryptionOverrideBadExamples, - Links: terraformNoEncryptionOverrideLinks, - RemediationMarkdown: terraformNoEncryptionOverrideRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationNoEncryptionOverrideGoodExamples, - BadExamples: cloudFormationNoEncryptionOverrideBadExamples, - Links: cloudFormationNoEncryptionOverrideLinks, - RemediationMarkdown: cloudFormationNoEncryptionOverrideRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, workgroup := range s.AWS.Athena.Workgroups { - if workgroup.Metadata.IsUnmanaged() { - continue - } - if workgroup.EnforceConfiguration.IsFalse() { - results.Add( - "The workgroup configuration is not enforced.", - workgroup.EnforceConfiguration, - ) - } - } - return - }, -) diff --git a/checks/cloud/aws/athena/no_encryption_override.tf.go b/checks/cloud/aws/athena/no_encryption_override.tf.go deleted file mode 100644 index a653b9f2..00000000 --- a/checks/cloud/aws/athena/no_encryption_override.tf.go +++ /dev/null @@ -1,56 +0,0 @@ -package athena - -var terraformNoEncryptionOverrideGoodExamples = []string{ - ` - resource "aws_athena_workgroup" "good_example" { - name = "example" - - configuration { - enforce_workgroup_configuration = true - publish_cloudwatch_metrics_enabled = true - - result_configuration { - output_location = "s3://${aws_s3_bucket.example.bucket}/output/" - - encryption_configuration { - encryption_option = "SSE_KMS" - kms_key_arn = aws_kms_key.example.arn - } - } - } - } - `, -} - -var terraformNoEncryptionOverrideBadExamples = []string{ - ` - resource "aws_athena_workgroup" "bad_example" { - name = "example" - - configuration { - enforce_workgroup_configuration = false - publish_cloudwatch_metrics_enabled = true - - result_configuration { - output_location = "s3://${aws_s3_bucket.example.bucket}/output/" - - encryption_configuration { - encryption_option = "SSE_KMS" - kms_key_arn = aws_kms_key.example.arn - } - } - } - } - - resource "aws_athena_workgroup" "bad_example" { - name = "example" - - } - `, -} - -var terraformNoEncryptionOverrideLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/athena_workgroup#configuration`, -} - -var terraformNoEncryptionOverrideRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudfront/enable_logging.cf.go b/checks/cloud/aws/cloudfront/enable_logging.cf.go deleted file mode 100644 index 46e9d919..00000000 --- a/checks/cloud/aws/cloudfront/enable_logging.cf.go +++ /dev/null @@ -1,41 +0,0 @@ -package cloudfront - -var cloudFormationEnableLoggingGoodExamples = []string{ - `--- -Resources: - GoodExample: - Properties: - DistributionConfig: - DefaultCacheBehavior: - TargetOriginId: target - ViewerProtocolPolicy: https-only - Enabled: true - Logging: - Bucket: logging-bucket - Origins: - - DomainName: https://some.domain - Id: somedomain1 - Type: AWS::CloudFront::Distribution -`, -} - -var cloudFormationEnableLoggingBadExamples = []string{ - `--- -Resources: - BadExample: - Properties: - DistributionConfig: - DefaultCacheBehavior: - TargetOriginId: target - ViewerProtocolPolicy: https-only - Enabled: true - Origins: - - DomainName: https://some.domain - Id: somedomain1 - Type: AWS::CloudFront::Distribution -`, -} - -var cloudFormationEnableLoggingLinks = []string{} - -var cloudFormationEnableLoggingRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudfront/enable_logging.go b/checks/cloud/aws/cloudfront/enable_logging.go deleted file mode 100755 index f40ff916..00000000 --- a/checks/cloud/aws/cloudfront/enable_logging.go +++ /dev/null @@ -1,52 +0,0 @@ -package cloudfront - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableLogging = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0010", - Provider: providers.AWSProvider, - Service: "cloudfront", - ShortCode: "enable-logging", - Summary: "Cloudfront distribution should have Access Logging configured", - Impact: "Logging provides vital information about access and usage", - Resolution: "Enable logging for CloudFront distributions", - Explanation: `You should configure CloudFront Access Logging to create log files that contain detailed information about every user request that CloudFront receives`, - Links: []string{ - "https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AccessLogs.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableLoggingGoodExamples, - BadExamples: terraformEnableLoggingBadExamples, - Links: terraformEnableLoggingLinks, - RemediationMarkdown: terraformEnableLoggingRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnableLoggingGoodExamples, - BadExamples: cloudFormationEnableLoggingBadExamples, - Links: cloudFormationEnableLoggingLinks, - RemediationMarkdown: cloudFormationEnableLoggingRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, dist := range s.AWS.Cloudfront.Distributions { - if dist.Logging.Bucket.IsEmpty() { - results.Add( - "Distribution does not have logging enabled.", - dist.Logging.Bucket, - ) - } else { - results.AddPassed(&dist) - } - } - return - }, -) diff --git a/checks/cloud/aws/cloudfront/enable_logging.tf.go b/checks/cloud/aws/cloudfront/enable_logging.tf.go deleted file mode 100644 index 90ee0c6c..00000000 --- a/checks/cloud/aws/cloudfront/enable_logging.tf.go +++ /dev/null @@ -1,29 +0,0 @@ -package cloudfront - -var terraformEnableLoggingGoodExamples = []string{ - ` - resource "aws_cloudfront_distribution" "good_example" { - // other config - logging_config { - include_cookies = false - bucket = "mylogs.s3.amazonaws.com" - prefix = "myprefix" - } - } - `, -} - -var terraformEnableLoggingBadExamples = []string{ - ` - resource "aws_cloudfront_distribution" "bad_example" { - // other config - // no logging_config - } - `, -} - -var terraformEnableLoggingLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution#logging_config`, -} - -var terraformEnableLoggingRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudfront/enable_waf.cf.go b/checks/cloud/aws/cloudfront/enable_waf.cf.go deleted file mode 100644 index b1861e81..00000000 --- a/checks/cloud/aws/cloudfront/enable_waf.cf.go +++ /dev/null @@ -1,44 +0,0 @@ -package cloudfront - -var cloudFormationEnableWafGoodExamples = []string{ - `--- -Resources: - GoodExample: - Properties: - DistributionConfig: - DefaultCacheBehavior: - TargetOriginId: target - ViewerProtocolPolicy: https-only - Enabled: true - Logging: - Bucket: logging-bucket - Origins: - - DomainName: https://some.domain - Id: somedomain1 - WebACLId: waf_id - Type: AWS::CloudFront::Distribution -`, -} - -var cloudFormationEnableWafBadExamples = []string{ - `--- -Resources: - BadExample: - Properties: - DistributionConfig: - DefaultCacheBehavior: - TargetOriginId: target - ViewerProtocolPolicy: https-only - Enabled: true - Logging: - Bucket: logging-bucket - Origins: - - DomainName: https://some.domain - Id: somedomain1 - Type: AWS::CloudFront::Distribution -`, -} - -var cloudFormationEnableWafLinks = []string{} - -var cloudFormationEnableWafRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudfront/enable_waf.go b/checks/cloud/aws/cloudfront/enable_waf.go deleted file mode 100755 index e28ec9e0..00000000 --- a/checks/cloud/aws/cloudfront/enable_waf.go +++ /dev/null @@ -1,52 +0,0 @@ -package cloudfront - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableWaf = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0011", - Provider: providers.AWSProvider, - Service: "cloudfront", - ShortCode: "enable-waf", - Summary: "CloudFront distribution does not have a WAF in front.", - Impact: "Complex web application attacks can more easily be performed without a WAF", - Resolution: "Enable WAF for the CloudFront distribution", - Explanation: `You should configure a Web Application Firewall in front of your CloudFront distribution. This will mitigate many types of attacks on your web application.`, - Links: []string{ - "https://docs.aws.amazon.com/waf/latest/developerguide/cloudfront-features.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableWafGoodExamples, - BadExamples: terraformEnableWafBadExamples, - Links: terraformEnableWafLinks, - RemediationMarkdown: terraformEnableWafRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnableWafGoodExamples, - BadExamples: cloudFormationEnableWafBadExamples, - Links: cloudFormationEnableWafLinks, - RemediationMarkdown: cloudFormationEnableWafRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, dist := range s.AWS.Cloudfront.Distributions { - if dist.WAFID.IsEmpty() { - results.Add( - "Distribution does not utilise a WAF.", - dist.WAFID, - ) - } else { - results.AddPassed(&dist) - } - } - return - }, -) diff --git a/checks/cloud/aws/cloudfront/enable_waf.tf.go b/checks/cloud/aws/cloudfront/enable_waf.tf.go deleted file mode 100644 index 23198861..00000000 --- a/checks/cloud/aws/cloudfront/enable_waf.tf.go +++ /dev/null @@ -1,78 +0,0 @@ -package cloudfront - -var terraformEnableWafGoodExamples = []string{ - ` - resource "aws_cloudfront_distribution" "good_example" { - - origin { - domain_name = aws_s3_bucket.primary.bucket_regional_domain_name - origin_id = "primaryS3" - - s3_origin_config { - origin_access_identity = aws_cloudfront_origin_access_identity.default.cloudfront_access_identity_path - } - } - - origin { - domain_name = aws_s3_bucket.failover.bucket_regional_domain_name - origin_id = "failoverS3" - - s3_origin_config { - origin_access_identity = aws_cloudfront_origin_access_identity.default.cloudfront_access_identity_path - } - } - - default_cache_behavior { - target_origin_id = "groupS3" - } - - web_acl_id = "waf_id" - } - `, -} - -var terraformEnableWafBadExamples = []string{ - ` - resource "aws_cloudfront_distribution" "bad_example" { - origin_group { - origin_id = "groupS3" - - failover_criteria { - status_codes = [403, 404, 500, 502] - } - - member { - origin_id = "primaryS3" - } - } - - origin { - domain_name = aws_s3_bucket.primary.bucket_regional_domain_name - origin_id = "primaryS3" - - s3_origin_config { - origin_access_identity = aws_cloudfront_origin_access_identity.default.cloudfront_access_identity_path - } - } - - origin { - domain_name = aws_s3_bucket.failover.bucket_regional_domain_name - origin_id = "failoverS3" - - s3_origin_config { - origin_access_identity = aws_cloudfront_origin_access_identity.default.cloudfront_access_identity_path - } - } - - default_cache_behavior { - target_origin_id = "groupS3" - } - } - `, -} - -var terraformEnableWafLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution#web_acl_id`, -} - -var terraformEnableWafRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudfront/enforce_https.cf.go b/checks/cloud/aws/cloudfront/enforce_https.cf.go deleted file mode 100644 index 67b5195b..00000000 --- a/checks/cloud/aws/cloudfront/enforce_https.cf.go +++ /dev/null @@ -1,45 +0,0 @@ -package cloudfront - -var cloudFormationEnforceHttpsGoodExamples = []string{ - `--- -Resources: - GoodExample: - Properties: - DistributionConfig: - DefaultCacheBehavior: - TargetOriginId: target - ViewerProtocolPolicy: https-only - Enabled: true - Logging: - Bucket: logging-bucket - Origins: - - DomainName: https://some.domain - Id: somedomain1 - WebACLId: waf_id - Type: AWS::CloudFront::Distribution -`, -} - -var cloudFormationEnforceHttpsBadExamples = []string{ - `--- -Resources: - BadExample: - Properties: - DistributionConfig: - DefaultCacheBehavior: - TargetOriginId: target - ViewerProtocolPolicy: allow-all - Enabled: true - Logging: - Bucket: logging-bucket - Origins: - - DomainName: https://some.domain - Id: somedomain1 - WebACLId: waf_id - Type: AWS::CloudFront::Distribution -`, -} - -var cloudFormationEnforceHttpsLinks = []string{} - -var cloudFormationEnforceHttpsRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudfront/enforce_https.go b/checks/cloud/aws/cloudfront/enforce_https.go deleted file mode 100755 index f9cba9c0..00000000 --- a/checks/cloud/aws/cloudfront/enforce_https.go +++ /dev/null @@ -1,66 +0,0 @@ -package cloudfront - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudfront" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnforceHttps = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0012", - Provider: providers.AWSProvider, - Service: "cloudfront", - ShortCode: "enforce-https", - Summary: "CloudFront distribution allows unencrypted (HTTP) communications.", - Impact: "CloudFront is available through an unencrypted connection", - Resolution: "Only allow HTTPS for CloudFront distribution communication", - Explanation: `Plain HTTP is unencrypted and human-readable. This means that if a malicious actor was to eavesdrop on your connection, they would be able to see all of your data flowing back and forth. - -You should use HTTPS, which is HTTP over an encrypted (TLS) connection, meaning eavesdroppers cannot read your traffic.`, - Links: []string{ - "https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-https-cloudfront-to-s3-origin.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnforceHttpsGoodExamples, - BadExamples: terraformEnforceHttpsBadExamples, - Links: terraformEnforceHttpsLinks, - RemediationMarkdown: terraformEnforceHttpsRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnforceHttpsGoodExamples, - BadExamples: cloudFormationEnforceHttpsBadExamples, - Links: cloudFormationEnforceHttpsLinks, - RemediationMarkdown: cloudFormationEnforceHttpsRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, dist := range s.AWS.Cloudfront.Distributions { - if dist.DefaultCacheBehaviour.ViewerProtocolPolicy.EqualTo(cloudfront.ViewerPolicyProtocolAllowAll) { - results.Add( - "Distribution allows unencrypted communications.", - dist.DefaultCacheBehaviour.ViewerProtocolPolicy, - ) - } else { - results.AddPassed(&dist) - } - for _, behaviour := range dist.OrdererCacheBehaviours { - if behaviour.ViewerProtocolPolicy.EqualTo(cloudfront.ViewerPolicyProtocolAllowAll) { - results.Add( - "Distribution allows unencrypted communications.", - behaviour.ViewerProtocolPolicy, - ) - } else { - results.AddPassed(&behaviour) - } - } - - } - return - }, -) diff --git a/checks/cloud/aws/cloudfront/enforce_https.tf.go b/checks/cloud/aws/cloudfront/enforce_https.tf.go deleted file mode 100644 index 5097728d..00000000 --- a/checks/cloud/aws/cloudfront/enforce_https.tf.go +++ /dev/null @@ -1,27 +0,0 @@ -package cloudfront - -var terraformEnforceHttpsGoodExamples = []string{ - ` - resource "aws_cloudfront_distribution" "good_example" { - default_cache_behavior { - viewer_protocol_policy = "redirect-to-https" - } - } - `, -} - -var terraformEnforceHttpsBadExamples = []string{ - ` - resource "aws_cloudfront_distribution" "bad_example" { - default_cache_behavior { - viewer_protocol_policy = "allow-all" - } - } - `, -} - -var terraformEnforceHttpsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution#viewer_protocol_policy`, -} - -var terraformEnforceHttpsRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudfront/use_secure_tls_policy.cf.go b/checks/cloud/aws/cloudfront/use_secure_tls_policy.cf.go deleted file mode 100644 index f5e4afaa..00000000 --- a/checks/cloud/aws/cloudfront/use_secure_tls_policy.cf.go +++ /dev/null @@ -1,47 +0,0 @@ -package cloudfront - -var cloudFormationUseSecureTlsPolicyGoodExamples = []string{ - `--- -Resources: - GoodExample: - Properties: - DistributionConfig: - DefaultCacheBehavior: - TargetOriginId: target - ViewerProtocolPolicy: https-only - Enabled: true - Logging: - Bucket: logging-bucket - Origins: - - DomainName: https://some.domain - Id: somedomain1 - ViewerCertificate: - MinimumProtocolVersion: TLSv1.2_2021 - Type: AWS::CloudFront::Distribution -`, -} - -var cloudFormationUseSecureTlsPolicyBadExamples = []string{ - `--- -Resources: - BadExample: - Properties: - DistributionConfig: - DefaultCacheBehavior: - TargetOriginId: target - ViewerProtocolPolicy: https-only - Enabled: true - Logging: - Bucket: logging-bucket - Origins: - - DomainName: https://some.domain - Id: somedomain1 - ViewerCertificate: - MinimumProtocolVersion: TLSv1.0 - Type: AWS::CloudFront::Distribution -`, -} - -var cloudFormationUseSecureTlsPolicyLinks = []string{} - -var cloudFormationUseSecureTlsPolicyRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudfront/use_secure_tls_policy.go b/checks/cloud/aws/cloudfront/use_secure_tls_policy.go deleted file mode 100755 index 12675dce..00000000 --- a/checks/cloud/aws/cloudfront/use_secure_tls_policy.go +++ /dev/null @@ -1,60 +0,0 @@ -package cloudfront - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudfront" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckUseSecureTlsPolicy = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0013", - Provider: providers.AWSProvider, - Service: "cloudfront", - ShortCode: "use-secure-tls-policy", - Summary: "CloudFront distribution uses outdated SSL/TLS protocols.", - Impact: "Outdated SSL policies increase exposure to known vulnerabilities", - Resolution: "Use the most modern TLS/SSL policies available", - Explanation: `You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+. - -Note: that setting *minimum_protocol_version = "TLSv1.2_2021"* is only possible when *cloudfront_default_certificate* is false (eg. you are not using the cloudfront.net domain name). -If *cloudfront_default_certificate* is true then the Cloudfront API will only allow setting *minimum_protocol_version = "TLSv1"*, and setting it to any other value will result in a perpetual diff in your *terraform plan*'s. -The only option when using the cloudfront.net domain name is to ignore this rule.`, - Links: []string{ - "https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/secure-connections-supported-viewer-protocols-ciphers.html", - "https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesGeneral", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformUseSecureTlsPolicyGoodExamples, - BadExamples: terraformUseSecureTlsPolicyBadExamples, - Links: terraformUseSecureTlsPolicyLinks, - RemediationMarkdown: terraformUseSecureTlsPolicyRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationUseSecureTlsPolicyGoodExamples, - BadExamples: cloudFormationUseSecureTlsPolicyBadExamples, - Links: cloudFormationUseSecureTlsPolicyLinks, - RemediationMarkdown: cloudFormationUseSecureTlsPolicyRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, dist := range s.AWS.Cloudfront.Distributions { - vc := dist.ViewerCertificate - if vc.CloudfrontDefaultCertificate.IsFalse() && - vc.MinimumProtocolVersion.NotEqualTo(cloudfront.ProtocolVersionTLS1_2) { - results.Add( - "Distribution allows unencrypted communications.", - vc.MinimumProtocolVersion, - ) - } else { - results.AddPassed(&dist) - } - } - return - }, -) diff --git a/checks/cloud/aws/cloudfront/use_secure_tls_policy.tf.go b/checks/cloud/aws/cloudfront/use_secure_tls_policy.tf.go deleted file mode 100644 index b65865f6..00000000 --- a/checks/cloud/aws/cloudfront/use_secure_tls_policy.tf.go +++ /dev/null @@ -1,29 +0,0 @@ -package cloudfront - -var terraformUseSecureTlsPolicyGoodExamples = []string{ - ` - resource "aws_cloudfront_distribution" "good_example" { - viewer_certificate { - cloudfront_default_certificate = false - minimum_protocol_version = "TLSv1.2_2021" - } - } - `, -} - -var terraformUseSecureTlsPolicyBadExamples = []string{ - ` - resource "aws_cloudfront_distribution" "bad_example" { - viewer_certificate { - cloudfront_default_certificate = false - minimum_protocol_version = "TLSv1.0" - } - } - `, -} - -var terraformUseSecureTlsPolicyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution#minimum_protocol_version`, -} - -var terraformUseSecureTlsPolicyRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudtrail/enable_all_regions.cf.go b/checks/cloud/aws/cloudtrail/enable_all_regions.cf.go deleted file mode 100644 index 8f093cbc..00000000 --- a/checks/cloud/aws/cloudtrail/enable_all_regions.cf.go +++ /dev/null @@ -1,33 +0,0 @@ -package cloudtrail - -var cloudFormationEnableAllRegionsGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::CloudTrail::Trail - Properties: - IsLogging: true - IsMultiRegionTrail: true - S3BucketName: "CloudtrailBucket" - S3KeyPrefix: "/trailing" - TrailName: "Cloudtrail" -`, -} - -var cloudFormationEnableAllRegionsBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::CloudTrail::Trail - Properties: - IsLogging: true - IsMultiRegionTrail: false - S3BucketName: "CloudtrailBucket" - S3KeyPrefix: "/trailing" - TrailName: "Cloudtrail" -`, -} - -var cloudFormationEnableAllRegionsLinks = []string{} - -var cloudFormationEnableAllRegionsRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudtrail/enable_all_regions.go b/checks/cloud/aws/cloudtrail/enable_all_regions.go deleted file mode 100755 index 153ca0cf..00000000 --- a/checks/cloud/aws/cloudtrail/enable_all_regions.go +++ /dev/null @@ -1,57 +0,0 @@ -package cloudtrail - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableAllRegions = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0014", - Provider: providers.AWSProvider, - Service: "cloudtrail", - ShortCode: "enable-all-regions", - Frameworks: map[framework.Framework][]string{ - framework.Default: nil, - framework.CIS_AWS_1_2: {"2.5"}, - }, - Summary: "Cloudtrail should be enabled in all regions regardless of where your AWS resources are generally homed", - Impact: "Activity could be happening in your account in a different region", - Resolution: "Enable Cloudtrail in all regions", - Explanation: `When creating Cloudtrail in the AWS Management Console the trail is configured by default to be multi-region, this isn't the case with the Terraform resource. Cloudtrail should cover the full AWS account to ensure you can track changes in regions you are not actively operting in.`, - Links: []string{ - "https://docs.aws.amazon.com/awscloudtrail/latest/userguide/receive-cloudtrail-log-files-from-multiple-regions.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableAllRegionsGoodExamples, - BadExamples: terraformEnableAllRegionsBadExamples, - Links: terraformEnableAllRegionsLinks, - RemediationMarkdown: terraformEnableAllRegionsRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnableAllRegionsGoodExamples, - BadExamples: cloudFormationEnableAllRegionsBadExamples, - Links: cloudFormationEnableAllRegionsLinks, - RemediationMarkdown: cloudFormationEnableAllRegionsRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, trail := range s.AWS.CloudTrail.Trails { - if trail.IsMultiRegion.IsFalse() { - results.Add( - "Trail is not enabled across all regions.", - trail.IsMultiRegion, - ) - } else { - results.AddPassed(&trail) - } - } - return - }, -) diff --git a/checks/cloud/aws/cloudtrail/enable_all_regions.tf.go b/checks/cloud/aws/cloudtrail/enable_all_regions.tf.go deleted file mode 100644 index 176ee251..00000000 --- a/checks/cloud/aws/cloudtrail/enable_all_regions.tf.go +++ /dev/null @@ -1,41 +0,0 @@ -package cloudtrail - -var terraformEnableAllRegionsGoodExamples = []string{ - ` - resource "aws_cloudtrail" "good_example" { - is_multi_region_trail = true - - event_selector { - read_write_type = "All" - include_management_events = true - - data_resource { - type = "AWS::S3::Object" - values = ["${data.aws_s3_bucket.important-bucket.arn}/"] - } - } - } - `, -} - -var terraformEnableAllRegionsBadExamples = []string{ - ` - resource "aws_cloudtrail" "bad_example" { - event_selector { - read_write_type = "All" - include_management_events = true - - data_resource { - type = "AWS::S3::Object" - values = ["${data.aws_s3_bucket.important-bucket.arn}/"] - } - } - } - `, -} - -var terraformEnableAllRegionsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudtrail#is_multi_region_trail`, -} - -var terraformEnableAllRegionsRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudtrail/enable_log_validation.cf.go b/checks/cloud/aws/cloudtrail/enable_log_validation.cf.go deleted file mode 100644 index 080fba33..00000000 --- a/checks/cloud/aws/cloudtrail/enable_log_validation.cf.go +++ /dev/null @@ -1,34 +0,0 @@ -package cloudtrail - -var cloudFormationEnableLogValidationGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::CloudTrail::Trail - Properties: - IsLogging: true - IsMultiRegionTrail: true - EnableLogFileValidation: true - S3BucketName: "CloudtrailBucket" - S3KeyPrefix: "/trailing" - TrailName: "Cloudtrail" -`, -} - -var cloudFormationEnableLogValidationBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::CloudTrail::Trail - Properties: - IsLogging: true - IsMultiRegionTrail: false - S3BucketName: "CloudtrailBucket" - S3KeyPrefix: "/trailing" - TrailName: "Cloudtrail" -`, -} - -var cloudFormationEnableLogValidationLinks = []string{} - -var cloudFormationEnableLogValidationRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudtrail/enable_log_validation.go b/checks/cloud/aws/cloudtrail/enable_log_validation.go deleted file mode 100755 index 1afa5ecb..00000000 --- a/checks/cloud/aws/cloudtrail/enable_log_validation.go +++ /dev/null @@ -1,52 +0,0 @@ -package cloudtrail - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableLogValidation = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0016", - Provider: providers.AWSProvider, - Service: "cloudtrail", - ShortCode: "enable-log-validation", - Summary: "Cloudtrail log validation should be enabled to prevent tampering of log data", - Impact: "Illicit activity could be removed from the logs", - Resolution: "Turn on log validation for Cloudtrail", - Explanation: `Log validation should be activated on Cloudtrail logs to prevent the tampering of the underlying data in the S3 bucket. It is feasible that a rogue actor compromising an AWS account might want to modify the log data to remove trace of their actions.`, - Links: []string{ - "https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-log-file-validation-intro.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableLogValidationGoodExamples, - BadExamples: terraformEnableLogValidationBadExamples, - Links: terraformEnableLogValidationLinks, - RemediationMarkdown: terraformEnableLogValidationRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnableLogValidationGoodExamples, - BadExamples: cloudFormationEnableLogValidationBadExamples, - Links: cloudFormationEnableLogValidationLinks, - RemediationMarkdown: cloudFormationEnableLogValidationRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, trail := range s.AWS.CloudTrail.Trails { - if trail.EnableLogFileValidation.IsFalse() { - results.Add( - "Trail does not have log validation enabled.", - trail.EnableLogFileValidation, - ) - } else { - results.AddPassed(&trail) - } - } - return - }, -) diff --git a/checks/cloud/aws/cloudtrail/enable_log_validation.tf.go b/checks/cloud/aws/cloudtrail/enable_log_validation.tf.go deleted file mode 100644 index a0f00ce1..00000000 --- a/checks/cloud/aws/cloudtrail/enable_log_validation.tf.go +++ /dev/null @@ -1,44 +0,0 @@ -package cloudtrail - -var terraformEnableLogValidationGoodExamples = []string{ - ` - resource "aws_cloudtrail" "good_example" { - is_multi_region_trail = true - enable_log_file_validation = true - - event_selector { - read_write_type = "All" - include_management_events = true - - data_resource { - type = "AWS::S3::Object" - values = ["${data.aws_s3_bucket.important-bucket.arn}/"] - } - } - } - `, -} - -var terraformEnableLogValidationBadExamples = []string{ - ` - resource "aws_cloudtrail" "bad_example" { - is_multi_region_trail = true - - event_selector { - read_write_type = "All" - include_management_events = true - - data_resource { - type = "AWS::S3::Object" - values = ["${data.aws_s3_bucket.important-bucket.arn}/"] - } - } - } - `, -} - -var terraformEnableLogValidationLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudtrail#enable_log_file_validation`, -} - -var terraformEnableLogValidationRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudtrail/encryption_customer_key.cf.go b/checks/cloud/aws/cloudtrail/encryption_customer_key.cf.go deleted file mode 100644 index 9bb1247f..00000000 --- a/checks/cloud/aws/cloudtrail/encryption_customer_key.cf.go +++ /dev/null @@ -1,34 +0,0 @@ -package cloudtrail - -var cloudFormationEncryptionCustomerManagedKeyGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::CloudTrail::Trail - Properties: - IsLogging: true - IsMultiRegionTrail: true - KmsKeyId: "alias/CloudtrailKey" - S3BucketName: "CloudtrailBucket" - S3KeyPrefix: "/trailing" - TrailName: "Cloudtrail" -`, -} - -var cloudFormationEncryptionCustomerManagedKeyBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::CloudTrail::Trail - Properties: - IsLogging: true - IsMultiRegionTrail: false - S3BucketName: "CloudtrailBucket" - S3KeyPrefix: "/trailing" - TrailName: "Cloudtrail" -`, -} - -var cloudFormationEncryptionCustomerManagedKeyLinks = []string{ - "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudtrail-trail.html#cfn-cloudtrail-trail-kmskeyid", -} diff --git a/checks/cloud/aws/cloudtrail/encryption_customer_key.go b/checks/cloud/aws/cloudtrail/encryption_customer_key.go deleted file mode 100755 index 5d39d117..00000000 --- a/checks/cloud/aws/cloudtrail/encryption_customer_key.go +++ /dev/null @@ -1,53 +0,0 @@ -package cloudtrail - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var EncryptionCustomerManagedKey = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0015", - Provider: providers.AWSProvider, - Service: "cloudtrail", - ShortCode: "encryption-customer-managed-key", - Summary: "CloudTrail should use Customer managed keys to encrypt the logs", - Impact: "Using AWS managed keys does not allow for fine grained control", - Resolution: "Use Customer managed key", - Explanation: `Using Customer managed keys provides comprehensive control over cryptographic keys, enabling management of policies, permissions, and rotation, thus enhancing security and compliance measures for sensitive data and systems.`, - Links: []string{ - "https://docs.aws.amazon.com/awscloudtrail/latest/userguide/encrypting-cloudtrail-log-files-with-aws-kms.html", - "https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-mgmt", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEncryptionCustomerManagedKeyGoodExamples, - BadExamples: terraformEncryptionCustomerManagedKeyBadExamples, - Links: terraformEncryptionCustomerManagedKeyLinks, - RemediationMarkdown: ``, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEncryptionCustomerManagedKeyGoodExamples, - BadExamples: cloudFormationEncryptionCustomerManagedKeyBadExamples, - Links: cloudFormationEncryptionCustomerManagedKeyLinks, - RemediationMarkdown: ``, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, trail := range s.AWS.CloudTrail.Trails { - if trail.KMSKeyID.IsEmpty() { - results.Add( - "CloudTrail does not use a customer managed key to encrypt the logs.", - trail.KMSKeyID, - ) - } else { - results.AddPassed(&trail) - } - } - return - }, -) diff --git a/checks/cloud/aws/cloudtrail/encryption_customer_key.tf.go b/checks/cloud/aws/cloudtrail/encryption_customer_key.tf.go deleted file mode 100644 index b4a950e5..00000000 --- a/checks/cloud/aws/cloudtrail/encryption_customer_key.tf.go +++ /dev/null @@ -1,43 +0,0 @@ -package cloudtrail - -var terraformEncryptionCustomerManagedKeyGoodExamples = []string{ - ` - resource "aws_cloudtrail" "good_example" { - is_multi_region_trail = true - enable_log_file_validation = true - kms_key_id = var.kms_id - - event_selector { - read_write_type = "All" - include_management_events = true - - data_resource { - type = "AWS::S3::Object" - values = ["${data.aws_s3_bucket.important-bucket.arn}/"] - } - } - } - `, -} - -var terraformEncryptionCustomerManagedKeyBadExamples = []string{ - ` - resource "aws_cloudtrail" "bad_example" { - is_multi_region_trail = true - - event_selector { - read_write_type = "All" - include_management_events = true - - data_resource { - type = "AWS::S3::Object" - values = ["${data.aws_s3_bucket.important-bucket.arn}/"] - } - } - } - `, -} - -var terraformEncryptionCustomerManagedKeyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudtrail#kms_key_id`, -} diff --git a/checks/cloud/aws/cloudtrail/ensure_cloudwatch_integration.cf.go b/checks/cloud/aws/cloudtrail/ensure_cloudwatch_integration.cf.go deleted file mode 100644 index 89e21081..00000000 --- a/checks/cloud/aws/cloudtrail/ensure_cloudwatch_integration.cf.go +++ /dev/null @@ -1,26 +0,0 @@ -package cloudtrail - -var cloudFormationEnsureCloudwatchIntegrationGoodExamples = []string{ - `--- -Resources: - GoodExampleTrail: - Type: AWS::CloudTrail::Trail - Properties: - TrailName: "Cloudtrail" - CloudWatchLogsLogGroupArn: "arn:aws:logs:us-east-1:123456789012:log-group:CloudTrail/DefaultLogGroup:*" -`, -} - -var cloudFormationEnsureCloudwatchIntegrationBadExamples = []string{ - `--- -Resources: - BadExampleTrail: - Type: AWS::CloudTrail::Trail - Properties: - TrailName: "Cloudtrail" -`, -} - -var cloudFormationEnsureCloudwatchIntegrationLinks = []string{} - -var cloudFormationEnsureCloudwatchIntegrationRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudtrail/ensure_cloudwatch_integration.go b/checks/cloud/aws/cloudtrail/ensure_cloudwatch_integration.go deleted file mode 100755 index 969baa67..00000000 --- a/checks/cloud/aws/cloudtrail/ensure_cloudwatch_integration.go +++ /dev/null @@ -1,61 +0,0 @@ -package cloudtrail - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnsureCloudwatchIntegration = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0162", - Provider: providers.AWSProvider, - Service: "cloudtrail", - ShortCode: "ensure-cloudwatch-integration", - Frameworks: map[framework.Framework][]string{ - framework.Default: nil, - framework.CIS_AWS_1_2: {"2.4"}, - framework.CIS_AWS_1_4: {"3.4"}, - }, - Summary: "CloudTrail logs should be stored in S3 and also sent to CloudWatch Logs", - Impact: "Realtime log analysis is not available without enabling CloudWatch logging", - Resolution: "Enable logging to CloudWatch", - Explanation: ` -CloudTrail is a web service that records AWS API calls made in a given account. The recorded information includes the identity of the API caller, the time of the API call, the source IP address of the API caller, the request parameters, and the response elements returned by the AWS service. - -CloudTrail uses Amazon S3 for log file storage and delivery, so log files are stored durably. In addition to capturing CloudTrail logs in a specified Amazon S3 bucket for long-term analysis, you can perform real-time analysis by configuring CloudTrail to send logs to CloudWatch Logs. - -For a trail that is enabled in all Regions in an account, CloudTrail sends log files from all those Regions to a CloudWatch Logs log group. -`, - Links: []string{ - "https://docs.aws.amazon.com/awscloudtrail/latest/userguide/send-cloudtrail-events-to-cloudwatch-logs.html#send-cloudtrail-events-to-cloudwatch-logs-console", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnsureCloudwatchIntegrationGoodExamples, - BadExamples: terraformEnsureCloudwatchIntegrationBadExamples, - Links: terraformEnsureCloudwatchIntegrationLinks, - RemediationMarkdown: terraformEnsureCloudwatchIntegrationRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnsureCloudwatchIntegrationGoodExamples, - BadExamples: cloudFormationEnsureCloudwatchIntegrationBadExamples, - Links: cloudFormationEnsureCloudwatchIntegrationLinks, - RemediationMarkdown: cloudFormationEnsureCloudwatchIntegrationRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, trail := range s.AWS.CloudTrail.Trails { - if trail.CloudWatchLogsLogGroupArn.IsEmpty() { - results.Add("Trail does not have CloudWatch logging configured", &trail) - } else { - results.AddPassed(&trail) - } - } - return - }, -) diff --git a/checks/cloud/aws/cloudtrail/ensure_cloudwatch_integration.tf.go b/checks/cloud/aws/cloudtrail/ensure_cloudwatch_integration.tf.go deleted file mode 100644 index 90490620..00000000 --- a/checks/cloud/aws/cloudtrail/ensure_cloudwatch_integration.tf.go +++ /dev/null @@ -1,47 +0,0 @@ -package cloudtrail - -var terraformEnsureCloudwatchIntegrationGoodExamples = []string{ - ` - resource "aws_cloudtrail" "good_example" { - is_multi_region_trail = true - cloud_watch_logs_group_arn = "${aws_cloudwatch_log_group.example.arn}:*" - - - event_selector { - read_write_type = "All" - include_management_events = true - - data_resource { - type = "AWS::S3::Object" - values = ["${data.aws_s3_bucket.important-bucket.arn}/"] - } - } - } - -resource "aws_cloudwatch_log_group" "example" { - name = "Example" -} - `, -} - -var terraformEnsureCloudwatchIntegrationBadExamples = []string{ - ` -resource "aws_cloudtrail" "bad_example" { - event_selector { - read_write_type = "All" - include_management_events = true - - data_resource { - type = "AWS::S3::Object" - values = ["${data.aws_s3_bucket.important-bucket.arn}/"] - } - } -} - `, -} - -var terraformEnsureCloudwatchIntegrationLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudtrail`, -} - -var terraformEnsureCloudwatchIntegrationRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudtrail/no_public_log_access.cf.go b/checks/cloud/aws/cloudtrail/no_public_log_access.cf.go deleted file mode 100644 index ea733418..00000000 --- a/checks/cloud/aws/cloudtrail/no_public_log_access.cf.go +++ /dev/null @@ -1,39 +0,0 @@ -package cloudtrail - -var cloudFormationNoPublicLogAccessGoodExamples = []string{ - `--- -Resources: - GoodExampleTrail: - Type: AWS::CloudTrail::Trail - Properties: - IsLogging: true - S3BucketName: "my-bucket" - TrailName: "Cloudtrail" - GoodExampleBucket: - Type: AWS::S3::Bucket - Properties: - BucketName: "my-bucket" - AccessControl: Private -`, -} - -var cloudFormationNoPublicLogAccessBadExamples = []string{ - `--- -Resources: - BadExampleTrail: - Type: AWS::CloudTrail::Trail - Properties: - IsLogging: true - S3BucketName: "my-bucket" - TrailName: "Cloudtrail" - BadExampleBucket: - Type: AWS::S3::Bucket - Properties: - BucketName: "my-bucket" - AccessControl: AuthenticatedRead -`, -} - -var cloudFormationNoPublicLogAccessLinks = []string{} - -var cloudFormationNoPublicLogAccessRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudtrail/no_public_log_access.go b/checks/cloud/aws/cloudtrail/no_public_log_access.go deleted file mode 100755 index ac6cedd9..00000000 --- a/checks/cloud/aws/cloudtrail/no_public_log_access.go +++ /dev/null @@ -1,63 +0,0 @@ -package cloudtrail - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicLogAccess = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0161", - Provider: providers.AWSProvider, - Service: "cloudtrail", - ShortCode: "no-public-log-access", - Frameworks: map[framework.Framework][]string{ - framework.Default: nil, - framework.CIS_AWS_1_2: {"2.3"}, - framework.CIS_AWS_1_4: {"3.3"}, - }, - Summary: "The S3 Bucket backing Cloudtrail should be private", - Impact: "CloudTrail logs will be publicly exposed, potentially containing sensitive information", - Resolution: "Restrict public access to the S3 bucket", - Explanation: ` -CloudTrail logs a record of every API call made in your account. These log files are stored in an S3 bucket. CIS recommends that the S3 bucket policy, or access control list (ACL), applied to the S3 bucket that CloudTrail logs to prevents public access to the CloudTrail logs. Allowing public access to CloudTrail log content might aid an adversary in identifying weaknesses in the affected account's use or configuration. -`, - Links: []string{ - "https://docs.aws.amazon.com/AmazonS3/latest/userguide/configuring-block-public-access-bucket.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicLogAccessGoodExamples, - BadExamples: terraformNoPublicLogAccessBadExamples, - Links: terraformNoPublicLogAccessLinks, - RemediationMarkdown: terraformNoPublicLogAccessRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationNoPublicLogAccessGoodExamples, - BadExamples: cloudFormationNoPublicLogAccessBadExamples, - Links: cloudFormationNoPublicLogAccessLinks, - RemediationMarkdown: cloudFormationNoPublicLogAccessRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, trail := range s.AWS.CloudTrail.Trails { - if trail.BucketName.IsNotEmpty() { - for _, bucket := range s.AWS.S3.Buckets { - if bucket.Name.EqualTo(trail.BucketName.Value()) { - if bucket.HasPublicExposureACL() { - results.Add("Trail S3 bucket is publicly exposed", &bucket) - } else { - results.AddPassed(&bucket) - } - } - } - } - } - return - }, -) diff --git a/checks/cloud/aws/cloudtrail/no_public_log_access.tf.go b/checks/cloud/aws/cloudtrail/no_public_log_access.tf.go deleted file mode 100644 index 8d485c6b..00000000 --- a/checks/cloud/aws/cloudtrail/no_public_log_access.tf.go +++ /dev/null @@ -1,53 +0,0 @@ -package cloudtrail - -var terraformNoPublicLogAccessGoodExamples = []string{ - ` - resource "aws_cloudtrail" "good_example" { - is_multi_region_trail = true - s3_bucket_name = "abcdefgh" - - event_selector { - read_write_type = "All" - include_management_events = true - - data_resource { - type = "AWS::S3::Object" - values = ["${data.aws_s3_bucket.important-bucket.arn}/"] - } - } - } - -resource "aws_s3_bucket" "good_example" { - bucket = "abcdefgh" - acl = "private" -} - `, -} - -var terraformNoPublicLogAccessBadExamples = []string{ - ` -resource "aws_cloudtrail" "bad_example" { - s3_bucket_name = "abcdefgh" - event_selector { - read_write_type = "All" - include_management_events = true - - data_resource { - type = "AWS::S3::Object" - values = ["${data.aws_s3_bucket.important-bucket.arn}/"] - } - } -} - -resource "aws_s3_bucket" "good_example" { - bucket = "abcdefgh" - acl = "public-read" -} - `, -} - -var terraformNoPublicLogAccessLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudtrail#is_multi_region_trail`, -} - -var terraformNoPublicLogAccessRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudtrail/require_bucket_access_logging.cf.go b/checks/cloud/aws/cloudtrail/require_bucket_access_logging.cf.go deleted file mode 100644 index 746db6b9..00000000 --- a/checks/cloud/aws/cloudtrail/require_bucket_access_logging.cf.go +++ /dev/null @@ -1,40 +0,0 @@ -package cloudtrail - -var cloudFormationBucketAccessLoggingRequiredGoodExamples = []string{ - `--- -Resources: - GoodExampleTrail: - Type: AWS::CloudTrail::Trail - Properties: - IsLogging: true - S3BucketName: "my-bucket" - TrailName: "Cloudtrail" - GoodExampleBucket: - Type: AWS::S3::Bucket - Properties: - BucketName: "my-bucket" - LoggingConfiguration: - DestinationBucketName: logging-bucket - LogFilePrefix: accesslogs/ -`, -} - -var cloudFormationBucketAccessLoggingRequiredBadExamples = []string{ - `--- -Resources: - BadExampleTrail: - Type: AWS::CloudTrail::Trail - Properties: - IsLogging: true - S3BucketName: "my-bucket" - TrailName: "Cloudtrail" - BadExampleBucket: - Type: AWS::S3::Bucket - Properties: - BucketName: "my-bucket" -`, -} - -var cloudFormationBucketAccessLoggingRequiredLinks = []string{} - -var cloudFormationBucketAccessLoggingRequiredRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudtrail/require_bucket_access_logging.go b/checks/cloud/aws/cloudtrail/require_bucket_access_logging.go deleted file mode 100755 index e181f7b7..00000000 --- a/checks/cloud/aws/cloudtrail/require_bucket_access_logging.go +++ /dev/null @@ -1,66 +0,0 @@ -package cloudtrail - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckBucketAccessLoggingRequired = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0163", - Provider: providers.AWSProvider, - Service: "cloudtrail", - ShortCode: "require-bucket-access-logging", - Frameworks: map[framework.Framework][]string{ - framework.Default: nil, - framework.CIS_AWS_1_2: {"2.6"}, - framework.CIS_AWS_1_4: {"3.6"}, - }, - Summary: "You should enable bucket access logging on the CloudTrail S3 bucket.", - Impact: "There is no way to determine the access to this bucket", - Resolution: "Enable access logging on the bucket", - Explanation: `Amazon S3 bucket access logging generates a log that contains access records for each request made to your S3 bucket. An access log record contains details about the request, such as the request type, the resources specified in the request worked, and the time and date the request was processed. - -CIS recommends that you enable bucket access logging on the CloudTrail S3 bucket. - -By enabling S3 bucket logging on target S3 buckets, you can capture all events that might affect objects in a target bucket. Configuring logs to be placed in a separate bucket enables access to log information, which can be useful in security and incident response workflows. -`, - Links: []string{ - "https://docs.aws.amazon.com/AmazonS3/latest/userguide/ServerLogs.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformBucketAccessLoggingRequiredGoodExamples, - BadExamples: terraformBucketAccessLoggingRequiredBadExamples, - Links: terraformBucketAccessLoggingRequiredLinks, - RemediationMarkdown: terraformBucketAccessLoggingRequiredRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationBucketAccessLoggingRequiredGoodExamples, - BadExamples: cloudFormationBucketAccessLoggingRequiredBadExamples, - Links: cloudFormationBucketAccessLoggingRequiredLinks, - RemediationMarkdown: cloudFormationBucketAccessLoggingRequiredRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, trail := range s.AWS.CloudTrail.Trails { - if trail.BucketName.IsNotEmpty() { - for _, bucket := range s.AWS.S3.Buckets { - if bucket.Name.EqualTo(trail.BucketName.Value()) { - if bucket.Logging.Enabled.IsFalse() { - results.Add("Trail S3 bucket does not have logging enabled", &bucket) - } else { - results.AddPassed(&bucket) - } - } - } - } - } - return - }, -) diff --git a/checks/cloud/aws/cloudtrail/require_bucket_access_logging.tf.go b/checks/cloud/aws/cloudtrail/require_bucket_access_logging.tf.go deleted file mode 100644 index e234956d..00000000 --- a/checks/cloud/aws/cloudtrail/require_bucket_access_logging.tf.go +++ /dev/null @@ -1,55 +0,0 @@ -package cloudtrail - -var terraformBucketAccessLoggingRequiredGoodExamples = []string{ - ` - resource "aws_cloudtrail" "good_example" { - is_multi_region_trail = true - s3_bucket_name = "abcdefgh" - - event_selector { - read_write_type = "All" - include_management_events = true - - data_resource { - type = "AWS::S3::Object" - values = ["${data.aws_s3_bucket.important-bucket.arn}/"] - } - } - } - -resource "aws_s3_bucket" "good_example" { - bucket = "abcdefgh" - logging { - target_bucket = "target-bucket" - } -} - `, -} - -var terraformBucketAccessLoggingRequiredBadExamples = []string{ - ` -resource "aws_cloudtrail" "bad_example" { - s3_bucket_name = "abcdefgh" - event_selector { - read_write_type = "All" - include_management_events = true - - data_resource { - type = "AWS::S3::Object" - values = ["${data.aws_s3_bucket.important-bucket.arn}/"] - } - } -} - -resource "aws_s3_bucket" "good_example" { - bucket = "abcdefgh" - -} - `, -} - -var terraformBucketAccessLoggingRequiredLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudtrail#is_multi_region_trail`, -} - -var terraformBucketAccessLoggingRequiredRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudwatch/log_group_customer_key.cf.go b/checks/cloud/aws/cloudwatch/log_group_customer_key.cf.go deleted file mode 100644 index d4023e1d..00000000 --- a/checks/cloud/aws/cloudwatch/log_group_customer_key.cf.go +++ /dev/null @@ -1,29 +0,0 @@ -package cloudwatch - -var cloudFormationLogGroupCustomerKeyGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::Logs::LogGroup - Properties: - KmsKeyId: "arn:aws:kms:us-west-2:111122223333:key/lambdalogging" - LogGroupName: "aws/lambda/goodExample" - RetentionInDays: 30 -`, -} - -var cloudFormationLogGroupCustomerKeyBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::Logs::LogGroup - Properties: - KmsKeyId: "" - LogGroupName: "aws/lambda/badExample" - RetentionInDays: 30 -`, -} - -var cloudFormationLogGroupCustomerKeyLinks = []string{} - -var cloudFormationLogGroupCustomerKeyRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudwatch/log_group_customer_key.go b/checks/cloud/aws/cloudwatch/log_group_customer_key.go deleted file mode 100755 index 21155ac3..00000000 --- a/checks/cloud/aws/cloudwatch/log_group_customer_key.go +++ /dev/null @@ -1,52 +0,0 @@ -package cloudwatch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckLogGroupCustomerKey = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0017", - Provider: providers.AWSProvider, - Service: "cloudwatch", - ShortCode: "log-group-customer-key", - Summary: "CloudWatch log groups should be encrypted using CMK", - Impact: "Log data may be leaked if the logs are compromised. No auditing of who have viewed the logs.", - Resolution: "Enable CMK encryption of CloudWatch Log Groups", - Explanation: `CloudWatch log groups are encrypted by default, however, to get the full benefit of controlling key rotation and other KMS aspects a KMS CMK should be used.`, - Links: []string{ - "https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/encrypt-log-data-kms.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformLogGroupCustomerKeyGoodExamples, - BadExamples: terraformLogGroupCustomerKeyBadExamples, - Links: terraformLogGroupCustomerKeyLinks, - RemediationMarkdown: terraformLogGroupCustomerKeyRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationLogGroupCustomerKeyGoodExamples, - BadExamples: cloudFormationLogGroupCustomerKeyBadExamples, - Links: cloudFormationLogGroupCustomerKeyLinks, - RemediationMarkdown: cloudFormationLogGroupCustomerKeyRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.AWS.CloudWatch.LogGroups { - if group.KMSKeyID.IsEmpty() { - results.Add( - "Log group is not encrypted.", - group.KMSKeyID, - ) - } else { - results.AddPassed(&group) - } - } - return - }, -) diff --git a/checks/cloud/aws/cloudwatch/log_group_customer_key.tf.go b/checks/cloud/aws/cloudwatch/log_group_customer_key.tf.go deleted file mode 100644 index ddc0b7cb..00000000 --- a/checks/cloud/aws/cloudwatch/log_group_customer_key.tf.go +++ /dev/null @@ -1,26 +0,0 @@ -package cloudwatch - -var terraformLogGroupCustomerKeyGoodExamples = []string{ - ` - resource "aws_cloudwatch_log_group" "good_example" { - name = "good_example" - - kms_key_id = aws_kms_key.log_key.arn - } - `, -} - -var terraformLogGroupCustomerKeyBadExamples = []string{ - ` - resource "aws_cloudwatch_log_group" "bad_example" { - name = "bad_example" - - } - `, -} - -var terraformLogGroupCustomerKeyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group#kms_key_id`, -} - -var terraformLogGroupCustomerKeyRemediationMarkdown = `` diff --git a/checks/cloud/aws/cloudwatch/require_cloudtrail_change_alarm.go b/checks/cloud/aws/cloudwatch/require_cloudtrail_change_alarm.go deleted file mode 100644 index 65b9cb19..00000000 --- a/checks/cloud/aws/cloudwatch/require_cloudtrail_change_alarm.go +++ /dev/null @@ -1,76 +0,0 @@ -package cloudwatch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var requireCloudTrailChangeAlarm = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0151", - Provider: providers.AWSProvider, - Service: "cloudwatch", - ShortCode: "require-cloud-trail-change-alarm", - Summary: "Ensure a log metric filter and alarm exist for CloudTrail configuration changes", - Impact: "CloudTrail tracks all changes through the API, attempts to change the configuration may indicate malicious activity. Without alerting on changes, visibility of this activity is reduced.", - Resolution: "Create an alarm to alert on CloudTrail configuration changes", - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_2: { - "3.5", - }, - framework.CIS_AWS_1_4: { - "4.5", - }, - }, - Explanation: `You can do real-time monitoring of API calls by directing CloudTrail logs to CloudWatch Logs and establishing corresponding metric filters and alarms. - -CIS recommends that you create a metric filter and alarm for changes to CloudTrail configuration settings. Monitoring these changes helps ensure sustained visibility to activities in the account.`, - Links: []string{ - "https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudwatch-alarms-for-cloudtrail.html", - }, - Terraform: &scan.EngineMetadata{}, - CloudFormation: &scan.EngineMetadata{}, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - multiRegionTrails := s.AWS.CloudTrail.MultiRegionTrails() - for _, trail := range multiRegionTrails { - logGroup := s.AWS.CloudWatch.GetLogGroupByArn(trail.CloudWatchLogsLogGroupArn.Value()) - if logGroup == nil || trail.IsLogging.IsFalse() { - continue - } - - var metricFilter cloudwatch.MetricFilter - var found bool - for _, filter := range logGroup.MetricFilters { - if filter.FilterPattern.Contains(`{($.eventName=CreateTrail) || ($.eventName=UpdateTrail) || ($.eventName=DeleteTrail) || ($.eventName=StartLogging) || ($.eventName=StopLogging)}`, types.IgnoreWhitespace) { - metricFilter = filter - found = true - break - } - } - - if !found { - results.Add("Cloudtrail has no IAM policy change log filter", trail) - continue - } - - if metricAlarm := s.AWS.CloudWatch.GetAlarmByMetricName(metricFilter.FilterName.Value()); metricAlarm == nil { - results.Add("Cloudtrail has no IAM Policy change alarm", trail) - continue - } - - results.AddPassed(trail) - } - - return - }, -) diff --git a/checks/cloud/aws/cloudwatch/require_cmk_disabled_alarm.go b/checks/cloud/aws/cloudwatch/require_cmk_disabled_alarm.go deleted file mode 100644 index e67f00f1..00000000 --- a/checks/cloud/aws/cloudwatch/require_cmk_disabled_alarm.go +++ /dev/null @@ -1,76 +0,0 @@ -package cloudwatch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var requireCMKDisabledAlarm = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0153", - Provider: providers.AWSProvider, - Service: "cloudwatch", - ShortCode: "require-cmk-disabled-alarm", - Summary: "Ensure a log metric filter and alarm exist for disabling or scheduled deletion of customer managed keys", - Impact: "CloudTrail tracks all changes through the API, attempts to change the configuration may indicate malicious activity. Without alerting on changes, visibility of this activity is reduced.", - Resolution: "Create an alarm to alert on CMKs being disabled or scheduled for deletion", - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_2: { - "3.7", - }, - framework.CIS_AWS_1_4: { - "4.7", - }, - }, - Explanation: `You can do real-time monitoring of API calls by directing CloudTrail logs to CloudWatch Logs and establishing corresponding metric filters and alarms. - - CIS recommends that you create a metric filter and alarm for customer managed keys that have changed state to disabled or scheduled deletion. Data encrypted with disabled or deleted keys is no longer accessible. `, - Links: []string{ - "https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudwatch-alarms-for-cloudtrail.html", - }, - Terraform: &scan.EngineMetadata{}, - CloudFormation: &scan.EngineMetadata{}, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - multiRegionTrails := s.AWS.CloudTrail.MultiRegionTrails() - for _, trail := range multiRegionTrails { - logGroup := s.AWS.CloudWatch.GetLogGroupByArn(trail.CloudWatchLogsLogGroupArn.Value()) - if logGroup == nil || trail.IsLogging.IsFalse() { - continue - } - - var metricFilter cloudwatch.MetricFilter - var found bool - for _, filter := range logGroup.MetricFilters { - if filter.FilterPattern.Contains(`{($.eventSource=kms.amazonaws.com) && (($.eventName=DisableKey) || ($.eventName=ScheduleKeyDeletion))}`, types.IgnoreWhitespace) { - metricFilter = filter - found = true - break - } - } - - if !found { - results.Add("Cloudtrail has no CMK disabling or deletion log filter", trail) - continue - } - - if metricAlarm := s.AWS.CloudWatch.GetAlarmByMetricName(metricFilter.FilterName.Value()); metricAlarm == nil { - results.Add("Cloudtrail has no CMK disabled of scheduled deletion alarm", trail) - continue - } - - results.AddPassed(trail) - } - - return - }, -) diff --git a/checks/cloud/aws/cloudwatch/require_config_configuration_change_alarm.go b/checks/cloud/aws/cloudwatch/require_config_configuration_change_alarm.go deleted file mode 100644 index 83e681f3..00000000 --- a/checks/cloud/aws/cloudwatch/require_config_configuration_change_alarm.go +++ /dev/null @@ -1,76 +0,0 @@ -package cloudwatch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var requireConfigConfigurationChangeAlarm = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0155", - Provider: providers.AWSProvider, - Service: "cloudwatch", - ShortCode: "require-config-configuration-changes-alarm", - Summary: "Ensure a log metric filter and alarm exist for AWS Config configuration changes", - Impact: "Changes to the configuration of AWS Config may indicate malicious activity. Without alerting on changes, visibility of this activity is reduced.", - Resolution: "Create an alarm to alert on AWS Config configuration changes", - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_2: { - "3.9", - }, - framework.CIS_AWS_1_4: { - "4.9", - }, - }, - Explanation: `You can do real-time monitoring of API calls by directing CloudTrail logs to CloudWatch Logs and establishing corresponding metric filters and alarms. - -CIS recommends that you create a metric filter and alarm for changes to AWS Config configuration settings. Monitoring these changes helps ensure sustained visibility of configuration items in the account.`, - Links: []string{ - "https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudwatch-alarms-for-cloudtrail.html", - }, - Terraform: &scan.EngineMetadata{}, - CloudFormation: &scan.EngineMetadata{}, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - multiRegionTrails := s.AWS.CloudTrail.MultiRegionTrails() - for _, trail := range multiRegionTrails { - logGroup := s.AWS.CloudWatch.GetLogGroupByArn(trail.CloudWatchLogsLogGroupArn.Value()) - if logGroup == nil || trail.IsLogging.IsFalse() { - continue - } - - var metricFilter cloudwatch.MetricFilter - var found bool - for _, filter := range logGroup.MetricFilters { - if filter.FilterPattern.Contains(`{($.eventSource=config.amazonaws.com) && (($.eventName=StopConfigurationRecorder) || ($.eventName=DeleteDeliveryChannel) || ($.eventName=PutDeliveryChannel) || ($.eventName=PutConfigurationRecorder))}`, types.IgnoreWhitespace) { - metricFilter = filter - found = true - break - } - } - - if !found { - results.Add("Cloudtrail has no Config configuration change log filter", trail) - continue - } - - if metricAlarm := s.AWS.CloudWatch.GetAlarmByMetricName(metricFilter.FilterName.Value()); metricAlarm == nil { - results.Add("Cloudtrail has no Config configuration change alarm", trail) - continue - } - - results.AddPassed(trail) - } - - return - }, -) diff --git a/checks/cloud/aws/cloudwatch/require_console_login_failure_alarm.go b/checks/cloud/aws/cloudwatch/require_console_login_failure_alarm.go deleted file mode 100644 index ca497ede..00000000 --- a/checks/cloud/aws/cloudwatch/require_console_login_failure_alarm.go +++ /dev/null @@ -1,76 +0,0 @@ -package cloudwatch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var requireConsoleLoginFailureAlarm = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0152", - Provider: providers.AWSProvider, - Service: "cloudwatch", - ShortCode: "require-console-login-failures-alarm", - Summary: "Ensure a log metric filter and alarm exist for AWS Management Console authentication failures", - Impact: "Failed attempts to log into the Management console may indicate an attempt to maliciously access an account. Failure to alert reduces visibility of this activity.", - Resolution: "Create an alarm to alert on console login failures", - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_2: { - "3.6", - }, - framework.CIS_AWS_1_4: { - "4.6", - }, - }, - Explanation: `You can do real-time monitoring of API calls by directing CloudTrail logs to CloudWatch Logs and establishing corresponding metric filters and alarms. - -CIS recommends that you create a metric filter and alarm for failed console authentication attempts. Monitoring failed console logins might decrease lead time to detect an attempt to brute-force a credential, which might provide an indicator, such as source IP, that you can use in other event correlations.`, - Links: []string{ - "https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-aws-console-sign-in-events.html", - }, - Terraform: &scan.EngineMetadata{}, - CloudFormation: &scan.EngineMetadata{}, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - multiRegionTrails := s.AWS.CloudTrail.MultiRegionTrails() - for _, trail := range multiRegionTrails { - logGroup := s.AWS.CloudWatch.GetLogGroupByArn(trail.CloudWatchLogsLogGroupArn.Value()) - if logGroup == nil || trail.IsLogging.IsFalse() { - continue - } - - var metricFilter cloudwatch.MetricFilter - var found bool - for _, filter := range logGroup.MetricFilters { - if filter.FilterPattern.Contains(`{($.eventName=ConsoleLogin) && ($.errorMessage="Failed authentication")}`, types.IgnoreWhitespace) { - metricFilter = filter - found = true - break - } - } - - if !found { - results.Add("Cloudtrail has no console login failure log filter", trail) - continue - } - - if metricAlarm := s.AWS.CloudWatch.GetAlarmByMetricName(metricFilter.FilterName.Value()); metricAlarm == nil { - results.Add("Cloudtrail has no console login failure alarm", trail) - continue - } - - results.AddPassed(trail) - } - - return - }, -) diff --git a/checks/cloud/aws/cloudwatch/require_iam_policy_change_alarm.go b/checks/cloud/aws/cloudwatch/require_iam_policy_change_alarm.go deleted file mode 100644 index 437e51c0..00000000 --- a/checks/cloud/aws/cloudwatch/require_iam_policy_change_alarm.go +++ /dev/null @@ -1,91 +0,0 @@ -package cloudwatch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var requireIAMPolicyChangeAlarm = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0150", - Provider: providers.AWSProvider, - Service: "cloudwatch", - ShortCode: "require-iam-policy-change-alarm", - Summary: "Ensure a log metric filter and alarm exist for IAM policy changes", - Impact: "IAM Policy changes could lead to excessive permissions and may have been performed maliciously.", - Resolution: "Create an alarm to alert on IAM Policy changes", - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_2: { - "3.4", - }, - framework.CIS_AWS_1_4: { - "4.4", - }, - }, - Explanation: ` You can do real-time monitoring of API calls by directing CloudTrail logs to CloudWatch Logs and establishing corresponding metric filters and alarms. - -CIS recommends that you create a metric filter and alarm for changes made to IAM policies. Monitoring these changes helps ensure that authentication and authorization controls remain intact.`, - Links: []string{ - "https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudwatch-alarms-for-cloudtrail.html", - }, - Terraform: &scan.EngineMetadata{}, - CloudFormation: &scan.EngineMetadata{}, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - multiRegionTrails := s.AWS.CloudTrail.MultiRegionTrails() - for _, trail := range multiRegionTrails { - logGroup := s.AWS.CloudWatch.GetLogGroupByArn(trail.CloudWatchLogsLogGroupArn.Value()) - if logGroup == nil || trail.IsLogging.IsFalse() { - continue - } - - var metricFilter cloudwatch.MetricFilter - var found bool - for _, filter := range logGroup.MetricFilters { - if filter.FilterPattern.Contains(`{($.eventName=DeleteGroupPolicy) || -($.eventName=DeleteRolePolicy) || -($.eventName=DeleteUserPolicy) || -($.eventName=PutGroupPolicy) || -($.eventName=PutRolePolicy) || -($.eventName=PutUserPolicy) || -($.eventName=CreatePolicy) || -($.eventName=DeletePolicy) || -($.eventName=CreatePolicyVersion) || -($.eventName=DeletePolicyVersion) || -($.eventName=AttachRolePolicy) || -($.eventName=DetachRolePolicy) || -($.eventName=AttachUserPolicy) || -($.eventName=DetachUserPolicy) || -($.eventName=AttachGroupPolicy) || -($.eventName=DetachGroupPolicy)}`, types.IgnoreWhitespace) { - metricFilter = filter - found = true - break - } - } - - if !found { - results.Add("Cloudtrail has no IAM policy change log filter", trail) - continue - } - - if metricAlarm := s.AWS.CloudWatch.GetAlarmByMetricName(metricFilter.FilterName.Value()); metricAlarm == nil { - results.Add("Cloudtrail has no IAM Policy change alarm", trail) - continue - } - - results.AddPassed(trail) - } - - return - }, -) diff --git a/checks/cloud/aws/cloudwatch/require_nacl_change_alarm.go b/checks/cloud/aws/cloudwatch/require_nacl_change_alarm.go deleted file mode 100644 index b2ea0921..00000000 --- a/checks/cloud/aws/cloudwatch/require_nacl_change_alarm.go +++ /dev/null @@ -1,80 +0,0 @@ -package cloudwatch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var requireNACLChangeAlarm = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0157", - Provider: providers.AWSProvider, - Service: "cloudwatch", - ShortCode: "require-nacl-changes-alarm", - Summary: "Ensure a log metric filter and alarm exist for changes to Network Access Control Lists (NACL)", - Impact: "Network ACLs control the ingress and egress, changes could be made to maliciously allow egress of data or external ingress. Without alerting, this could go unnoticed.", - Resolution: "Create an alarm to alert on network acl changes", - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_2: { - "3.11", - }, - framework.CIS_AWS_1_4: { - "4.11", - }, - }, - Explanation: `You can do real-time monitoring of API calls by directing CloudTrail logs to CloudWatch Logs and establishing corresponding metric filters and alarms. -NACLs are used as a stateless packet filter to control ingress and egress traffic for subnets in a VPC. - -CIS recommends that you create a metric filter and alarm for changes to NACLs. Monitoring these changes helps ensure that AWS resources and services aren't unintentionally exposed.`, - Links: []string{ - "https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudwatch-alarms-for-cloudtrail.html", - }, - Terraform: &scan.EngineMetadata{}, - CloudFormation: &scan.EngineMetadata{}, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - multiRegionTrails := s.AWS.CloudTrail.MultiRegionTrails() - for _, trail := range multiRegionTrails { - logGroup := s.AWS.CloudWatch.GetLogGroupByArn(trail.CloudWatchLogsLogGroupArn.Value()) - if logGroup == nil || trail.IsLogging.IsFalse() { - continue - } - - var metricFilter cloudwatch.MetricFilter - var found bool - for _, filter := range logGroup.MetricFilters { - if filter.FilterPattern.Contains(`{($.eventName=CreateNetworkAcl) || - ($.eventName=CreateNetworkAclEntry) || ($.eventName=DeleteNetworkAcl) || - ($.eventName=DeleteNetworkAclEntry) || ($.eventName=ReplaceNetworkAclEntry) || - ($.eventName=ReplaceNetworkAclAssociation)}`, types.IgnoreWhitespace) { - metricFilter = filter - found = true - break - } - } - - if !found { - results.Add("Cloudtrail has no network ACL change log filter", trail) - continue - } - - if metricAlarm := s.AWS.CloudWatch.GetAlarmByMetricName(metricFilter.FilterName.Value()); metricAlarm == nil { - results.Add("Cloudtrail has no network ACL change alarm", trail) - continue - } - - results.AddPassed(trail) - } - - return - }, -) diff --git a/checks/cloud/aws/cloudwatch/require_network_gateway_change_alarm.go b/checks/cloud/aws/cloudwatch/require_network_gateway_change_alarm.go deleted file mode 100644 index a455e0b5..00000000 --- a/checks/cloud/aws/cloudwatch/require_network_gateway_change_alarm.go +++ /dev/null @@ -1,80 +0,0 @@ -package cloudwatch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var requireNetworkGatewayChangeAlarm = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0158", - Provider: providers.AWSProvider, - Service: "cloudwatch", - ShortCode: "require-network-gateway-changes-alarm", - Summary: "Ensure a log metric filter and alarm exist for changes to network gateways", - Impact: "Network gateways control the ingress and egress, changes could be made to maliciously allow egress of data or external ingress. Without alerting, this could go unnoticed.", - Resolution: "Create an alarm to alert on network gateway changes", - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_2: { - "3.12", - }, - framework.CIS_AWS_1_4: { - "4.12", - }, - }, - Explanation: `You can do real-time monitoring of API calls by directing CloudTrail logs to CloudWatch Logs and establishing corresponding metric filters and alarms. -Network gateways are required to send and receive traffic to a destination outside a VPC. - -CIS recommends that you create a metric filter and alarm for changes to network gateways. Monitoring these changes helps ensure that all ingress and egress traffic traverses the VPC border via a controlled path.`, - Links: []string{ - "https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudwatch-alarms-for-cloudtrail.html", - }, - Terraform: &scan.EngineMetadata{}, - CloudFormation: &scan.EngineMetadata{}, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - multiRegionTrails := s.AWS.CloudTrail.MultiRegionTrails() - for _, trail := range multiRegionTrails { - logGroup := s.AWS.CloudWatch.GetLogGroupByArn(trail.CloudWatchLogsLogGroupArn.Value()) - if logGroup == nil || trail.IsLogging.IsFalse() { - continue - } - - var metricFilter cloudwatch.MetricFilter - var found bool - for _, filter := range logGroup.MetricFilters { - if filter.FilterPattern.Contains(`{($.eventName=CreateCustomerGateway) || - ($.eventName=DeleteCustomerGateway) || ($.eventName=AttachInternetGateway) || - ($.eventName=CreateInternetGateway) || ($.eventName=DeleteInternetGateway) || - ($.eventName=DetachInternetGateway)}`, types.IgnoreWhitespace) { - metricFilter = filter - found = true - break - } - } - - if !found { - results.Add("Cloudtrail has no network gateway change log filter", trail) - continue - } - - if metricAlarm := s.AWS.CloudWatch.GetAlarmByMetricName(metricFilter.FilterName.Value()); metricAlarm == nil { - results.Add("Cloudtrail has no network gateway change alarm", trail) - continue - } - - results.AddPassed(trail) - } - - return - }, -) diff --git a/checks/cloud/aws/cloudwatch/require_non_mfa_login_alarm.go b/checks/cloud/aws/cloudwatch/require_non_mfa_login_alarm.go deleted file mode 100644 index 6f9b02a6..00000000 --- a/checks/cloud/aws/cloudwatch/require_non_mfa_login_alarm.go +++ /dev/null @@ -1,79 +0,0 @@ -package cloudwatch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var requireNonMFALoginAlarm = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0148", - Provider: providers.AWSProvider, - Service: "cloudwatch", - ShortCode: "require-non-mfa-login-alarm", - Summary: "Ensure a log metric filter and alarm exist for AWS Management Console sign-in without MFA", - Impact: "Not alerting on logins with no MFA allows the risk to go un-notified.", - Resolution: "Create an alarm to alert on non MFA logins", - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_2: { - "3.2", - }, - framework.CIS_AWS_1_4: { - "4.2", - }, - }, - Explanation: `You can do real-time monitoring of API calls by directing CloudTrail logs to CloudWatch Logs and establishing corresponding metric filters and alarms. - - CIS recommends that you create a metric filter and alarm console logins that aren't protected by MFA. Monitoring for single-factor console logins increases visibility into accounts that aren't protected by MFA.`, - Links: []string{ - "https://aws.amazon.com/iam/features/mfa/", - }, - Terraform: &scan.EngineMetadata{}, - CloudFormation: &scan.EngineMetadata{}, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - multiRegionTrails := s.AWS.CloudTrail.MultiRegionTrails() - for _, trail := range multiRegionTrails { - logGroup := s.AWS.CloudWatch.GetLogGroupByArn(trail.CloudWatchLogsLogGroupArn.Value()) - if logGroup == nil || trail.IsLogging.IsFalse() { - continue - } - - var metricFilter cloudwatch.MetricFilter - var found bool - for _, filter := range logGroup.MetricFilters { - if filter.FilterPattern.Contains(`($.eventName = "ConsoleLogin") && -($.additionalEventData.MFAUsed != "Yes") && -($.userIdentity.type=="IAMUser") && -($.responseElements.ConsoleLogin == "Success")`, types.IgnoreWhitespace) { - metricFilter = filter - found = true - break - } - } - - if !found { - results.Add("Cloudtrail has no non-MFA login log filter", trail) - continue - } - - if metricAlarm := s.AWS.CloudWatch.GetAlarmByMetricName(metricFilter.FilterName.Value()); metricAlarm == nil { - results.Add("Cloudtrail has no non-MFA login alarm", trail) - continue - } - - results.AddPassed(trail) - } - - return - }, -) diff --git a/checks/cloud/aws/cloudwatch/require_org_changes_alarm.go b/checks/cloud/aws/cloudwatch/require_org_changes_alarm.go deleted file mode 100644 index df48678d..00000000 --- a/checks/cloud/aws/cloudwatch/require_org_changes_alarm.go +++ /dev/null @@ -1,77 +0,0 @@ -package cloudwatch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var CheckRequireOrgChangesAlarm = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0174", - Provider: providers.AWSProvider, - Service: "cloudwatch", - ShortCode: "require-org-changes-alarm", - Summary: "Ensure a log metric filter and alarm exist for organisation changes", - Impact: "Lack of observability into critical organisation changes", - Resolution: "Create an alarm to alert on organisation changes", - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_4: { - "4.15", - }, - }, - Explanation: ` -Monitoring AWS Organizations changes can help you prevent any unwanted, accidental or -intentional modifications that may lead to unauthorized access or other security breaches. -This monitoring technique helps you to ensure that any unexpected changes performed -within your AWS Organizations can be investigated and any unwanted changes can be -rolled back. -`, - Links: []string{ - "https://docs.aws.amazon.com/organizations/latest/userguide/orgs_security_incident-response.html", - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, trail := range s.AWS.CloudTrail.MultiRegionTrails() { - logGroup := s.AWS.CloudWatch.GetLogGroupByArn(trail.CloudWatchLogsLogGroupArn.Value()) - if logGroup == nil || trail.IsLogging.IsFalse() { - continue - } - - var metricFilter cloudwatch.MetricFilter - var found bool - for _, filter := range logGroup.MetricFilters { - if filter.FilterPattern.Contains(`$.eventSource = organizations.amazonaws.com`, types.IgnoreWhitespace) { - metricFilter = filter - found = true - break - } - if filter.FilterPattern.Contains(`$.eventSource = "organizations.amazonaws.com"`, types.IgnoreWhitespace) { - metricFilter = filter - found = true - break - } - } - - if !found { - results.Add("Cloudwatch has no organisation changes log filter", trail) - continue - } - - if metricAlarm := s.AWS.CloudWatch.GetAlarmByMetricName(metricFilter.FilterName.Value()); metricAlarm == nil { - results.Add("Cloudwatch has organisation changes alarm", trail) - continue - } - - results.AddPassed(trail) - } - return - }, -) diff --git a/checks/cloud/aws/cloudwatch/require_root_user_usage_alarm.go b/checks/cloud/aws/cloudwatch/require_root_user_usage_alarm.go deleted file mode 100644 index 6cefaa84..00000000 --- a/checks/cloud/aws/cloudwatch/require_root_user_usage_alarm.go +++ /dev/null @@ -1,76 +0,0 @@ -package cloudwatch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var requireRootUserUsageAlarm = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0149", - Provider: providers.AWSProvider, - Service: "cloudwatch", - ShortCode: "require-root-user-usage-alarm", - Summary: "Ensure a log metric filter and alarm exist for usage of root user", - Impact: "The root user has significant permissions and should not be used for day to day tasks.", - Resolution: "Create an alarm to alert on root user login", - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_2: { - "3.3", - }, - framework.CIS_AWS_1_4: { - "4.3", - }, - }, - Explanation: ` You can do real-time monitoring of API calls directing CloudTrail logs to CloudWatch Logs and establishing corresponding metric filters and alarms. - -CIS recommends that you create a metric filter and alarm for root user login attempts. Monitoring for root user logins provides visibility into the use of a fully privileged account and an opportunity to reduce the use of it.`, - Links: []string{ - "https://aws.amazon.com/iam/features/mfa/", - }, - Terraform: &scan.EngineMetadata{}, - CloudFormation: &scan.EngineMetadata{}, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - multiRegionTrails := s.AWS.CloudTrail.MultiRegionTrails() - for _, trail := range multiRegionTrails { - logGroup := s.AWS.CloudWatch.GetLogGroupByArn(trail.CloudWatchLogsLogGroupArn.Value()) - if logGroup == nil || trail.IsLogging.IsFalse() { - continue - } - - var metricFilter cloudwatch.MetricFilter - var found bool - for _, filter := range logGroup.MetricFilters { - if filter.FilterPattern.Contains(`$.userIdentity.type = "Root" && $.userIdentity.invokedBy NOT EXISTS && &.eventType != "AwsServiceEvent"`, types.IgnoreWhitespace) { - metricFilter = filter - found = true - break - } - } - - if !found { - results.Add("Cloudtrail has no root user usage log filter", trail) - continue - } - - if metricAlarm := s.AWS.CloudWatch.GetAlarmByMetricName(metricFilter.FilterName.Value()); metricAlarm == nil { - results.Add("Cloudtrail has no root user usage alarm", trail) - continue - } - - results.AddPassed(trail) - } - - return - }, -) diff --git a/checks/cloud/aws/cloudwatch/require_route_table_change_alarm.go b/checks/cloud/aws/cloudwatch/require_route_table_change_alarm.go deleted file mode 100644 index 7cfc115b..00000000 --- a/checks/cloud/aws/cloudwatch/require_route_table_change_alarm.go +++ /dev/null @@ -1,80 +0,0 @@ -package cloudwatch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var requireRouteTableChangeAlarm = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0159", - Provider: providers.AWSProvider, - Service: "cloudwatch", - ShortCode: "require-network-gateway-changes-alarm", - Summary: "Ensure a log metric filter and alarm exist for route table changes", - Impact: "Route tables control the flow of network traffic, changes could be made to maliciously allow egress of data or external ingress. Without alerting, this could go unnoticed.", - Resolution: "Create an alarm to alert on route table changes", - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_2: { - "3.13", - }, - framework.CIS_AWS_1_4: { - "4.13", - }, - }, - Explanation: `You can do real-time monitoring of API calls by directing CloudTrail logs to CloudWatch Logs and establishing corresponding metric filters and alarms. -Routing tables route network traffic between subnets and to network gateways. - -CIS recommends that you create a metric filter and alarm for changes to route tables. Monitoring these changes helps ensure that all VPC traffic flows through an expected path.`, - Links: []string{ - "https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudwatch-alarms-for-cloudtrail.html", - }, - Terraform: &scan.EngineMetadata{}, - CloudFormation: &scan.EngineMetadata{}, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - multiRegionTrails := s.AWS.CloudTrail.MultiRegionTrails() - for _, trail := range multiRegionTrails { - logGroup := s.AWS.CloudWatch.GetLogGroupByArn(trail.CloudWatchLogsLogGroupArn.Value()) - if logGroup == nil || trail.IsLogging.IsFalse() { - continue - } - - var metricFilter cloudwatch.MetricFilter - var found bool - for _, filter := range logGroup.MetricFilters { - if filter.FilterPattern.Contains(`{($.eventName=CreateRoute) || - ($.eventName=CreateRouteTable) || ($.eventName=ReplaceRoute) || - ($.eventName=ReplaceRouteTableAssociation) || ($.eventName=DeleteRouteTable) || - ($.eventName=DeleteRoute) || ($.eventName=DisassociateRouteTable)}`, types.IgnoreWhitespace) { - metricFilter = filter - found = true - break - } - } - - if !found { - results.Add("Cloudtrail has no route table change log filter", trail) - continue - } - - if metricAlarm := s.AWS.CloudWatch.GetAlarmByMetricName(metricFilter.FilterName.Value()); metricAlarm == nil { - results.Add("Cloudtrail has no route table change alarm", trail) - continue - } - - results.AddPassed(trail) - } - - return - }, -) diff --git a/checks/cloud/aws/cloudwatch/require_s3_bucket_policy_change_alarm.go b/checks/cloud/aws/cloudwatch/require_s3_bucket_policy_change_alarm.go deleted file mode 100644 index 94186e10..00000000 --- a/checks/cloud/aws/cloudwatch/require_s3_bucket_policy_change_alarm.go +++ /dev/null @@ -1,79 +0,0 @@ -package cloudwatch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var requireS3BucketPolicyChangeAlarm = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0154", - Provider: providers.AWSProvider, - Service: "cloudwatch", - ShortCode: "require-s3-bucket-policy-change-alarm", - Summary: "Ensure a log metric filter and alarm exist for S3 bucket policy changes", - Impact: "Misconfigured policies on S3 buckets could lead to data leakage, without alerting visibility of this is reduced.", - Resolution: "Create an alarm to alert on S3 Bucket policy changes", - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_2: { - "3.8", - }, - framework.CIS_AWS_1_4: { - "4.8", - }, - }, - Explanation: `You can do real-time monitoring of API calls by directing CloudTrail logs to CloudWatch Logs and establishing corresponding metric filters and alarms. - -CIS recommends that you create a metric filter and alarm for changes to S3 bucket policies. Monitoring these changes might reduce time to detect and correct permissive policies on sensitive S3 buckets.`, - Links: []string{ - "https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudwatch-alarms-for-cloudtrail.html", - }, - Terraform: &scan.EngineMetadata{}, - CloudFormation: &scan.EngineMetadata{}, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - multiRegionTrails := s.AWS.CloudTrail.MultiRegionTrails() - for _, trail := range multiRegionTrails { - logGroup := s.AWS.CloudWatch.GetLogGroupByArn(trail.CloudWatchLogsLogGroupArn.Value()) - if logGroup == nil || trail.IsLogging.IsFalse() { - continue - } - - var metricFilter cloudwatch.MetricFilter - var found bool - for _, filter := range logGroup.MetricFilters { - if filter.FilterPattern.Contains(`{($.eventSource=s3.amazonaws.com) && (($.eventName=PutBucketAcl) || - ($.eventName=PutBucketPolicy) || ($.eventName=PutBucketCors) || ($.eventName=PutBucketLifecycle) || - ($.eventName=PutBucketReplication) || ($.eventName=DeleteBucketPolicy) || ($.eventName=DeleteBucketCors) || - ($.eventName=DeleteBucketLifecycle) || ($.eventName=DeleteBucketReplication))}`, types.IgnoreWhitespace) { - metricFilter = filter - found = true - break - } - } - - if !found { - results.Add("Cloudtrail has no S3 bucket policy change log filter", trail) - continue - } - - if metricAlarm := s.AWS.CloudWatch.GetAlarmByMetricName(metricFilter.FilterName.Value()); metricAlarm == nil { - results.Add("Cloudtrail has no S3 bucket policy change alarm", trail) - continue - } - - results.AddPassed(trail) - } - - return - }, -) diff --git a/checks/cloud/aws/cloudwatch/require_security_group_change_alarm.go b/checks/cloud/aws/cloudwatch/require_security_group_change_alarm.go deleted file mode 100644 index 98d2d5b3..00000000 --- a/checks/cloud/aws/cloudwatch/require_security_group_change_alarm.go +++ /dev/null @@ -1,80 +0,0 @@ -package cloudwatch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var requireSecurityGroupChangeAlarm = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0156", - Provider: providers.AWSProvider, - Service: "cloudwatch", - ShortCode: "require-sg-change-alarms", - Summary: "Ensure a log metric filter and alarm exist for security group changes", - Impact: "Security groups control the ingress and egress, changes could be made to maliciously allow egress of data or external ingress. Without alerting, this could go unnoticed.", - Resolution: "Create an alarm to alert on security group changes", - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_2: { - "3.10", - }, - framework.CIS_AWS_1_4: { - "4.10", - }, - }, - Explanation: `You can do real-time monitoring of API calls by directing CloudTrail logs to CloudWatch Logs and establishing corresponding metric filters and alarms. -Security groups are a stateful packet filter that controls ingress and egress traffic in a VPC. - -CIS recommends that you create a metric filter and alarm for changes to security groups. Monitoring these changes helps ensure that resources and services aren't unintentionally exposed.`, - Links: []string{ - "https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudwatch-alarms-for-cloudtrail.html", - }, - Terraform: &scan.EngineMetadata{}, - CloudFormation: &scan.EngineMetadata{}, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - multiRegionTrails := s.AWS.CloudTrail.MultiRegionTrails() - for _, trail := range multiRegionTrails { - logGroup := s.AWS.CloudWatch.GetLogGroupByArn(trail.CloudWatchLogsLogGroupArn.Value()) - if logGroup == nil || trail.IsLogging.IsFalse() { - continue - } - - var metricFilter cloudwatch.MetricFilter - var found bool - for _, filter := range logGroup.MetricFilters { - if filter.FilterPattern.Contains(`{($.eventName=AuthorizeSecurityGroupIngress) || - ($.eventName=AuthorizeSecurityGroupEgress) || ($.eventName=RevokeSecurityGroupIngress) || - ($.eventName=RevokeSecurityGroupEgress) || ($.eventName=CreateSecurityGroup) || - ($.eventName=DeleteSecurityGroup)}`, types.IgnoreWhitespace) { - metricFilter = filter - found = true - break - } - } - - if !found { - results.Add("Cloudtrail has no Security Group change log filter", trail) - continue - } - - if metricAlarm := s.AWS.CloudWatch.GetAlarmByMetricName(metricFilter.FilterName.Value()); metricAlarm == nil { - results.Add("Cloudtrail has no Security Group change alarm", trail) - continue - } - - results.AddPassed(trail) - } - - return - }, -) diff --git a/checks/cloud/aws/cloudwatch/require_unauthorised_api_call_alarm.go b/checks/cloud/aws/cloudwatch/require_unauthorised_api_call_alarm.go deleted file mode 100644 index eee04afc..00000000 --- a/checks/cloud/aws/cloudwatch/require_unauthorised_api_call_alarm.go +++ /dev/null @@ -1,76 +0,0 @@ -package cloudwatch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var requireUnauthorizedApiCallAlarm = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0147", - Provider: providers.AWSProvider, - Service: "cloudwatch", - ShortCode: "require-unauthorised-api-call-alarm", - Summary: "Ensure a log metric filter and alarm exist for unauthorized API calls", - Impact: "Unauthorized API Calls may be attempted without being notified. CloudTrail logs these actions but without the alarm you aren't actively notified.", - Resolution: "Create an alarm to alert on unauthorized API calls", - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_2: { - "3.1", - }, - framework.CIS_AWS_1_4: { - "4.1", - }, - }, - Explanation: `You can do real-time monitoring of API calls by directing CloudTrail logs to CloudWatch Logs and establishing corresponding metric filters and alarms. You can have more than one VPC in an account, and you can create a peer connection between two VPCs, enabling network traffic to route between VPCs. - -CIS recommends that you create a metric filter and alarm for changes to VPCs. Monitoring these changes helps ensure that authentication and authorization controls remain intact.`, - Links: []string{ - "https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/encrypt-log-data-kms.html", - }, - Terraform: &scan.EngineMetadata{}, - CloudFormation: &scan.EngineMetadata{}, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - multiRegionTrails := s.AWS.CloudTrail.MultiRegionTrails() - for _, trail := range multiRegionTrails { - logGroup := s.AWS.CloudWatch.GetLogGroupByArn(trail.CloudWatchLogsLogGroupArn.Value()) - if logGroup == nil || trail.IsLogging.IsFalse() { - continue - } - - var metricFilter cloudwatch.MetricFilter - var found bool - for _, filter := range logGroup.MetricFilters { - if filter.FilterPattern.Contains(`($.errorCode = "*UnauthorizedOperation") || ($.errorCode = "AccessDenied*")`, types.IgnoreWhitespace) { - metricFilter = filter - found = true - break - } - } - - if !found { - results.Add("Cloudtrail has no unauthorized API log filter", trail) - continue - } - - if metricAlarm := s.AWS.CloudWatch.GetAlarmByMetricName(metricFilter.FilterName.Value()); metricAlarm == nil { - results.Add("Cloudtrail has no unauthorized API alarm", trail) - continue - } - - results.AddPassed(trail) - } - - return - }, -) diff --git a/checks/cloud/aws/cloudwatch/require_vpc_change_alarm.go b/checks/cloud/aws/cloudwatch/require_vpc_change_alarm.go deleted file mode 100644 index 82a2dc86..00000000 --- a/checks/cloud/aws/cloudwatch/require_vpc_change_alarm.go +++ /dev/null @@ -1,82 +0,0 @@ -package cloudwatch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var requireVPCChangeAlarm = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0160", - Provider: providers.AWSProvider, - Service: "cloudwatch", - ShortCode: "require-vpc-changes-alarm", - Summary: "Ensure a log metric filter and alarm exist for VPC changes", - Impact: "Route tables control the flow of network traffic, changes could be made to maliciously allow egress of data or external ingress. Without alerting, this could go unnoticed.", - Resolution: "Create an alarm to alert on route table changes", - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_2: { - "3.14", - }, - framework.CIS_AWS_1_4: { - "4.14", - }, - }, - Explanation: `You can do real-time monitoring of API calls by directing CloudTrail logs to CloudWatch Logs and establishing corresponding metric filters and alarms. -You can have more than one VPC in an account, and you can create a peer connection between two VPCs, enabling network traffic to route between VPCs. - -CIS recommends that you create a metric filter and alarm for changes to VPCs. Monitoring these changes helps ensure that authentication and authorization controls remain intact. `, - Links: []string{ - "https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudwatch-alarms-for-cloudtrail.html", - }, - Terraform: &scan.EngineMetadata{}, - CloudFormation: &scan.EngineMetadata{}, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - multiRegionTrails := s.AWS.CloudTrail.MultiRegionTrails() - for _, trail := range multiRegionTrails { - logGroup := s.AWS.CloudWatch.GetLogGroupByArn(trail.CloudWatchLogsLogGroupArn.Value()) - if logGroup == nil || trail.IsLogging.IsFalse() { - continue - } - - var metricFilter cloudwatch.MetricFilter - var found bool - for _, filter := range logGroup.MetricFilters { - if filter.FilterPattern.Contains(`{($.eventName=CreateVpc) || - ($.eventName=DeleteVpc) || ($.eventName=ModifyVpcAttribute) || - ($.eventName=AcceptVpcPeeringConnection) || ($.eventName=CreateVpcPeeringConnection) || - ($.eventName=DeleteVpcPeeringConnection) || ($.eventName=RejectVpcPeeringConnection) || - ($.eventName=AttachClassicLinkVpc) || ($.eventName=DetachClassicLinkVpc) || - ($.eventName=DisableVpcClassicLink) || ($.eventName=EnableVpcClassicLink)}`, types.IgnoreWhitespace) { - metricFilter = filter - found = true - break - } - } - - if !found { - results.Add("Cloudtrail has no vpc change log filter", trail) - continue - } - - if metricAlarm := s.AWS.CloudWatch.GetAlarmByMetricName(metricFilter.FilterName.Value()); metricAlarm == nil { - results.Add("Cloudtrail has no vpc change alarm", trail) - continue - } - - results.AddPassed(trail) - } - - return - }, -) diff --git a/checks/cloud/aws/codebuild/enable_encryption.cf.go b/checks/cloud/aws/codebuild/enable_encryption.cf.go deleted file mode 100644 index 7c7547e4..00000000 --- a/checks/cloud/aws/codebuild/enable_encryption.cf.go +++ /dev/null @@ -1,88 +0,0 @@ -package codebuild - -var cloudFormationEnableEncryptionGoodExamples = []string{ - `--- -Resources: - GoodProject: - Type: AWS::CodeBuild::Project - Properties: - Artifacts: - ArtifactIdentifier: "String" - EncryptionDisabled: false - Location: "String" - Name: "String" - NamespaceType: "String" - OverrideArtifactName: false - Packaging: "String" - Path: "String" - Type: "String" - SecondaryArtifacts: - - ArtifactIdentifier: "String" - EncryptionDisabled: false - Location: "String" - Name: "String" - NamespaceType: "String" - OverrideArtifactName: false - Packaging: "String" - Path: "String" - Type: "String" -`, -} - -var cloudFormationEnableEncryptionBadExamples = []string{ - `--- -Resources: - GoodProject: - Type: AWS::CodeBuild::Project - Properties: - Artifacts: - ArtifactIdentifier: "String" - EncryptionDisabled: true - Location: "String" - Name: "String" - NamespaceType: "String" - OverrideArtifactName: false - Packaging: "String" - Path: "String" - Type: "String" - SecondaryArtifacts: - - ArtifactIdentifier: "String" - EncryptionDisabled: false - Location: "String" - Name: "String" - NamespaceType: "String" - OverrideArtifactName: false - Packaging: "String" - Path: "String" - Type: "String" -`, `--- -Resources: - GoodProject: - Type: AWS::CodeBuild::Project - Properties: - Artifacts: - ArtifactIdentifier: "String" - EncryptionDisabled: false - Location: "String" - Name: "String" - NamespaceType: "String" - OverrideArtifactName: false - Packaging: "String" - Path: "String" - Type: "String" - SecondaryArtifacts: - - ArtifactIdentifier: "String" - EncryptionDisabled: true - Location: "String" - Name: "String" - NamespaceType: "String" - OverrideArtifactName: false - Packaging: "String" - Path: "String" - Type: "String" -`, -} - -var cloudFormationEnableEncryptionLinks = []string{} - -var cloudFormationEnableEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/codebuild/enable_encryption.go b/checks/cloud/aws/codebuild/enable_encryption.go deleted file mode 100755 index 921ce2d4..00000000 --- a/checks/cloud/aws/codebuild/enable_encryption.go +++ /dev/null @@ -1,65 +0,0 @@ -package codebuild - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableEncryption = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0018", - Provider: providers.AWSProvider, - Service: "codebuild", - ShortCode: "enable-encryption", - Summary: "CodeBuild Project artifacts encryption should not be disabled", - Impact: "CodeBuild project artifacts are unencrypted", - Resolution: "Enable encryption for CodeBuild project artifacts", - Explanation: `All artifacts produced by your CodeBuild project pipeline should always be encrypted`, - Links: []string{ - "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codebuild-project-artifacts.html", - "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableEncryptionGoodExamples, - BadExamples: terraformEnableEncryptionBadExamples, - Links: terraformEnableEncryptionLinks, - RemediationMarkdown: terraformEnableEncryptionRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnableEncryptionGoodExamples, - BadExamples: cloudFormationEnableEncryptionBadExamples, - Links: cloudFormationEnableEncryptionLinks, - RemediationMarkdown: cloudFormationEnableEncryptionRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, project := range s.AWS.CodeBuild.Projects { - if project.ArtifactSettings.EncryptionEnabled.IsFalse() { - results.Add( - "Encryption is not enabled for project artifacts.", - project.ArtifactSettings.EncryptionEnabled, - ) - } else { - results.AddPassed(&project) - } - - for _, setting := range project.SecondaryArtifactSettings { - if setting.EncryptionEnabled.IsFalse() { - results.Add( - "Encryption is not enabled for secondary project artifacts.", - setting.EncryptionEnabled, - ) - } else { - results.AddPassed(&setting) - } - } - - } - return - }, -) diff --git a/checks/cloud/aws/codebuild/enable_encryption.tf.go b/checks/cloud/aws/codebuild/enable_encryption.tf.go deleted file mode 100644 index 08f3f6ea..00000000 --- a/checks/cloud/aws/codebuild/enable_encryption.tf.go +++ /dev/null @@ -1,73 +0,0 @@ -package codebuild - -var terraformEnableEncryptionGoodExamples = []string{ - ` - resource "aws_codebuild_project" "good_example" { - // other config - - artifacts { - // other artifacts config - - encryption_disabled = false - } - } - - resource "aws_codebuild_project" "good_example" { - // other config - - artifacts { - // other artifacts config - } - } - - resource "aws_codebuild_project" "codebuild" { - // other config - - secondary_artifacts { - // other artifacts config - - encryption_disabled = false - } - - secondary_artifacts { - // other artifacts config - } - } - `, -} - -var terraformEnableEncryptionBadExamples = []string{ - ` - resource "aws_codebuild_project" "bad_example" { - // other config - - artifacts { - // other artifacts config - - encryption_disabled = true - } - } - - resource "aws_codebuild_project" "bad_example" { - // other config including primary artifacts - - secondary_artifacts { - // other artifacts config - - encryption_disabled = false - } - - secondary_artifacts { - // other artifacts config - - encryption_disabled = true - } - } - `, -} - -var terraformEnableEncryptionLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codebuild_project#encryption_disabled`, -} - -var terraformEnableEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/config/aggregate_all_regions.cf.go b/checks/cloud/aws/config/aggregate_all_regions.cf.go deleted file mode 100644 index 6ba48964..00000000 --- a/checks/cloud/aws/config/aggregate_all_regions.cf.go +++ /dev/null @@ -1,35 +0,0 @@ -package config - -var cloudFormationAggregateAllRegionsGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::Config::ConfigurationAggregator - Properties: - AccountAggregationSources: - - AllAwsRegions: true - ConfigurationAggregatorName: "GoodAccountLevelAggregation" -`, `--- -Resources: - GoodExample: - Type: AWS::Config::ConfigurationAggregator - Properties: - OrganizationAggregationSource: - AllAwsRegions: true - ConfigurationAggregatorName: "GoodAccountLevelAggregation" -`, -} - -var cloudFormationAggregateAllRegionsBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::Config::ConfigurationAggregator - Properties: - ConfigurationAggregatorName: "BadAccountLevelAggregation" -`, -} - -var cloudFormationAggregateAllRegionsLinks = []string{} - -var cloudFormationAggregateAllRegionsRemediationMarkdown = `` diff --git a/checks/cloud/aws/config/aggregate_all_regions.go b/checks/cloud/aws/config/aggregate_all_regions.go deleted file mode 100755 index 1a9c987e..00000000 --- a/checks/cloud/aws/config/aggregate_all_regions.go +++ /dev/null @@ -1,55 +0,0 @@ -package config - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckAggregateAllRegions = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0019", - Provider: providers.AWSProvider, - Service: "config", - ShortCode: "aggregate-all-regions", - Summary: "Config configuration aggregator should be using all regions for source", - Impact: "Sources that aren't covered by the aggregator are not include in the configuration", - Resolution: "Set the aggregator to cover all regions", - Explanation: `The configuration aggregator should be configured with all_regions for the source. - -This will help limit the risk of any unmonitored configuration in regions that are thought to be unused.`, - Links: []string{ - "https://docs.aws.amazon.com/config/latest/developerguide/aggregate-data.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformAggregateAllRegionsGoodExamples, - BadExamples: terraformAggregateAllRegionsBadExamples, - Links: terraformAggregateAllRegionsLinks, - RemediationMarkdown: terraformAggregateAllRegionsRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationAggregateAllRegionsGoodExamples, - BadExamples: cloudFormationAggregateAllRegionsBadExamples, - Links: cloudFormationAggregateAllRegionsLinks, - RemediationMarkdown: cloudFormationAggregateAllRegionsRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - if s.AWS.Config.ConfigurationAggregrator.Metadata.IsUnmanaged() { - return - } - if s.AWS.Config.ConfigurationAggregrator.SourceAllRegions.IsFalse() { - results.Add( - "Configuration aggregation is not set to source from all regions.", - s.AWS.Config.ConfigurationAggregrator.SourceAllRegions, - ) - } else { - results.AddPassed(s.AWS.Config.ConfigurationAggregrator.SourceAllRegions) - } - return - }, -) diff --git a/checks/cloud/aws/config/aggregate_all_regions.tf.go b/checks/cloud/aws/config/aggregate_all_regions.tf.go deleted file mode 100644 index de8b0c8a..00000000 --- a/checks/cloud/aws/config/aggregate_all_regions.tf.go +++ /dev/null @@ -1,33 +0,0 @@ -package config - -var terraformAggregateAllRegionsGoodExamples = []string{ - ` - resource "aws_config_configuration_aggregator" "good_example" { - name = "example" - - account_aggregation_source { - account_ids = ["123456789012"] - all_regions = true - } - } - `, -} - -var terraformAggregateAllRegionsBadExamples = []string{ - ` - resource "aws_config_configuration_aggregator" "bad_example" { - name = "example" - - account_aggregation_source { - account_ids = ["123456789012"] - regions = ["us-west-2", "eu-west-1"] - } - } - `, -} - -var terraformAggregateAllRegionsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/config_configuration_aggregator#all_regions`, -} - -var terraformAggregateAllRegionsRemediationMarkdown = `` diff --git a/checks/cloud/aws/documentdb/enable_log_export.cf.go b/checks/cloud/aws/documentdb/enable_log_export.cf.go deleted file mode 100644 index 813800d9..00000000 --- a/checks/cloud/aws/documentdb/enable_log_export.cf.go +++ /dev/null @@ -1,51 +0,0 @@ -package documentdb - -var cloudFormationEnableLogExportGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: "AWS::DocDB::DBCluster" - Properties: - BackupRetentionPeriod : 8 - DBClusterIdentifier : "sample-cluster" - DBClusterParameterGroupName : "default.docdb3.6" - KmsKeyId : "your-kms-key-id" - EnableCloudwatchLogsExports: - - audit - - profiler - InstanceInstanceExample: - Type: "AWS::DocDB::DBInstance" - Properties: - AutoMinorVersionUpgrade: true - AvailabilityZone: "us-east-1c" - DBClusterIdentifier: "sample-cluster" - DBInstanceClass: "db.r5.large" - DBInstanceIdentifier: "sample-cluster-instance-0" - PreferredMaintenanceWindow: "sat:06:54-sat:07:24" -`, -} - -var cloudFormationEnableLogExportBadExamples = []string{ - `--- - Resources: - BadExample: - Type: "AWS::DocDB::DBCluster" - Properties: - BackupRetentionPeriod: 8 - DBClusterIdentifier: sample-cluster - DBClusterParameterGroupName: default.docdb3.6 - BadInstanceExample: - Type: "AWS::DocDB::DBInstance" - Properties: - AutoMinorVersionUpgrade: true - AvailabilityZone: us-east-1c - DBClusterIdentifier: sample-cluster - DBInstanceClass: db.r5.large - DBInstanceIdentifier: sample-cluster-instance-0 - PreferredMaintenanceWindow: 'sat:06:54-sat:07:24' -`, -} - -var cloudFormationEnableLogExportLinks = []string{} - -var cloudFormationEnableLogExportRemediationMarkdown = `` diff --git a/checks/cloud/aws/documentdb/enable_log_export.go b/checks/cloud/aws/documentdb/enable_log_export.go deleted file mode 100755 index 889d33b9..00000000 --- a/checks/cloud/aws/documentdb/enable_log_export.go +++ /dev/null @@ -1,64 +0,0 @@ -package documentdb - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/documentdb" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableLogExport = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0020", - Provider: providers.AWSProvider, - Service: "documentdb", - ShortCode: "enable-log-export", - Summary: "DocumentDB logs export should be enabled", - Impact: "Limited visibility of audit trail for changes to the DocumentDB", - Resolution: "Enable export logs", - Explanation: `Document DB does not have auditing by default. To ensure that you are able to accurately audit the usage of your DocumentDB cluster you should enable export logs.`, - Links: []string{ - "https://docs.aws.amazon.com/documentdb/latest/developerguide/event-auditing.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableLogExportGoodExamples, - BadExamples: terraformEnableLogExportBadExamples, - Links: terraformEnableLogExportLinks, - RemediationMarkdown: terraformEnableLogExportRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnableLogExportGoodExamples, - BadExamples: cloudFormationEnableLogExportBadExamples, - Links: cloudFormationEnableLogExportLinks, - RemediationMarkdown: cloudFormationEnableLogExportRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.AWS.DocumentDB.Clusters { - var hasAudit bool - var hasProfiler bool - - for _, log := range cluster.EnabledLogExports { - if log.EqualTo(documentdb.LogExportAudit) { - hasAudit = true - } - if log.EqualTo(documentdb.LogExportProfiler) { - hasProfiler = true - } - } - if !hasAudit && !hasProfiler { - results.Add( - "Neither CloudWatch audit nor profiler log exports are enabled.", - &cluster, - ) - } else { - results.AddPassed(&cluster) - } - } - return - }, -) diff --git a/checks/cloud/aws/documentdb/enable_log_export.tf.go b/checks/cloud/aws/documentdb/enable_log_export.tf.go deleted file mode 100644 index 7bd4a92e..00000000 --- a/checks/cloud/aws/documentdb/enable_log_export.tf.go +++ /dev/null @@ -1,37 +0,0 @@ -package documentdb - -var terraformEnableLogExportGoodExamples = []string{ - ` - resource "aws_docdb_cluster" "good_example" { - cluster_identifier = "my-docdb-cluster" - engine = "docdb" - master_username = "foo" - master_password = "mustbeeightchars" - backup_retention_period = 5 - preferred_backup_window = "07:00-09:00" - skip_final_snapshot = true - enabled_cloudwatch_logs_exports = "audit" - } - `, -} - -var terraformEnableLogExportBadExamples = []string{ - ` - resource "aws_docdb_cluster" "bad_example" { - cluster_identifier = "my-docdb-cluster" - engine = "docdb" - master_username = "foo" - master_password = "mustbeeightchars" - backup_retention_period = 5 - preferred_backup_window = "07:00-09:00" - skip_final_snapshot = true - enabled_cloudwatch_logs_exports = "something" - } - `, -} - -var terraformEnableLogExportLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/docdb_cluster#enabled_cloudwatch_logs_exports`, -} - -var terraformEnableLogExportRemediationMarkdown = `` diff --git a/checks/cloud/aws/documentdb/enable_storage_encryption.cf.go b/checks/cloud/aws/documentdb/enable_storage_encryption.cf.go deleted file mode 100644 index 674aef93..00000000 --- a/checks/cloud/aws/documentdb/enable_storage_encryption.cf.go +++ /dev/null @@ -1,52 +0,0 @@ -package documentdb - -var cloudFormationEnableStorageEncryptionGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: "AWS::DocDB::DBCluster" - Properties: - BackupRetentionPeriod : 8 - DBClusterIdentifier : "sample-cluster" - DBClusterParameterGroupName : "default.docdb3.6" - KmsKeyId : "your-kms-key-id" - StorageEncrypted: true - EnableCloudwatchLogsExports: - - audit - - profiler - InstanceInstanceExample: - Type: "AWS::DocDB::DBInstance" - Properties: - AutoMinorVersionUpgrade: true - AvailabilityZone: "us-east-1c" - DBClusterIdentifier: "sample-cluster" - DBInstanceClass: "db.r5.large" - DBInstanceIdentifier: "sample-cluster-instance-0" - PreferredMaintenanceWindow: "sat:06:54-sat:07:24" -`, -} - -var cloudFormationEnableStorageEncryptionBadExamples = []string{ - `--- - Resources: - BadExample: - Type: "AWS::DocDB::DBCluster" - Properties: - BackupRetentionPeriod: 8 - DBClusterIdentifier: sample-cluster - DBClusterParameterGroupName: default.docdb3.6 - BadInstanceExample: - Type: "AWS::DocDB::DBInstance" - Properties: - AutoMinorVersionUpgrade: true - AvailabilityZone: us-east-1c - DBClusterIdentifier: sample-cluster - DBInstanceClass: db.r5.large - DBInstanceIdentifier: sample-cluster-instance-0 - PreferredMaintenanceWindow: 'sat:06:54-sat:07:24' -`, -} - -var cloudFormationEnableStorageEncryptionLinks = []string{} - -var cloudFormationEnableStorageEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/documentdb/enable_storage_encryption.go b/checks/cloud/aws/documentdb/enable_storage_encryption.go deleted file mode 100755 index c34c98d5..00000000 --- a/checks/cloud/aws/documentdb/enable_storage_encryption.go +++ /dev/null @@ -1,50 +0,0 @@ -package documentdb - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableStorageEncryption = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0021", - Provider: providers.AWSProvider, - Service: "documentdb", - ShortCode: "enable-storage-encryption", - Summary: "DocumentDB storage must be encrypted", - Impact: "Unencrypted sensitive data is vulnerable to compromise.", - Resolution: "Enable storage encryption", - Explanation: `Encryption of the underlying storage used by DocumentDB ensures that if their is compromise of the disks, the data is still protected.`, - Links: []string{"https://docs.aws.amazon.com/documentdb/latest/developerguide/encryption-at-rest.html"}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableStorageEncryptionGoodExamples, - BadExamples: terraformEnableStorageEncryptionBadExamples, - Links: terraformEnableStorageEncryptionLinks, - RemediationMarkdown: terraformEnableStorageEncryptionRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnableStorageEncryptionGoodExamples, - BadExamples: cloudFormationEnableStorageEncryptionBadExamples, - Links: cloudFormationEnableStorageEncryptionLinks, - RemediationMarkdown: cloudFormationEnableStorageEncryptionRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.AWS.DocumentDB.Clusters { - if cluster.StorageEncrypted.IsFalse() { - results.Add( - "Cluster storage does not have encryption enabled.", - cluster.StorageEncrypted, - ) - } else { - results.AddPassed(&cluster) - } - } - return - }, -) diff --git a/checks/cloud/aws/documentdb/enable_storage_encryption.tf.go b/checks/cloud/aws/documentdb/enable_storage_encryption.tf.go deleted file mode 100644 index 9d7d7a0d..00000000 --- a/checks/cloud/aws/documentdb/enable_storage_encryption.tf.go +++ /dev/null @@ -1,37 +0,0 @@ -package documentdb - -var terraformEnableStorageEncryptionGoodExamples = []string{ - ` - resource "aws_docdb_cluster" "good_example" { - cluster_identifier = "my-docdb-cluster" - engine = "docdb" - master_username = "foo" - master_password = "mustbeeightchars" - backup_retention_period = 5 - preferred_backup_window = "07:00-09:00" - skip_final_snapshot = true - storage_encrypted = true - } - `, -} - -var terraformEnableStorageEncryptionBadExamples = []string{ - ` - resource "aws_docdb_cluster" "bad_example" { - cluster_identifier = "my-docdb-cluster" - engine = "docdb" - master_username = "foo" - master_password = "mustbeeightchars" - backup_retention_period = 5 - preferred_backup_window = "07:00-09:00" - skip_final_snapshot = true - storage_encrypted = false - } - `, -} - -var terraformEnableStorageEncryptionLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/docdb_cluster#storage_encrypted`, -} - -var terraformEnableStorageEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/documentdb/encryption_customer_key.cf.go b/checks/cloud/aws/documentdb/encryption_customer_key.cf.go deleted file mode 100644 index 5be36b0f..00000000 --- a/checks/cloud/aws/documentdb/encryption_customer_key.cf.go +++ /dev/null @@ -1,51 +0,0 @@ -package documentdb - -var cloudFormationEncryptionCustomerKeyGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: "AWS::DocDB::DBCluster" - Properties: - BackupRetentionPeriod : 8 - DBClusterIdentifier : "sample-cluster" - DBClusterParameterGroupName : "default.docdb3.6" - KmsKeyId : "your-kms-key-id" - EnableCloudwatchLogsExports: - - audit - - profiler - InstanceInstanceExample: - Type: "AWS::DocDB::DBInstance" - Properties: - AutoMinorVersionUpgrade: true - AvailabilityZone: "us-east-1c" - DBClusterIdentifier: "sample-cluster" - DBInstanceClass: "db.r5.large" - DBInstanceIdentifier: "sample-cluster-instance-0" - PreferredMaintenanceWindow: "sat:06:54-sat:07:24" -`, -} - -var cloudFormationEncryptionCustomerKeyBadExamples = []string{ - `--- - Resources: - BadExample: - Type: "AWS::DocDB::DBCluster" - Properties: - BackupRetentionPeriod: 8 - DBClusterIdentifier: sample-cluster - DBClusterParameterGroupName: default.docdb3.6 - BadInstanceExample: - Type: "AWS::DocDB::DBInstance" - Properties: - AutoMinorVersionUpgrade: true - AvailabilityZone: us-east-1c - DBClusterIdentifier: sample-cluster - DBInstanceClass: db.r5.large - DBInstanceIdentifier: sample-cluster-instance-0 - PreferredMaintenanceWindow: 'sat:06:54-sat:07:24' -`, -} - -var cloudFormationEncryptionCustomerKeyLinks = []string{} - -var cloudFormationEncryptionCustomerKeyRemediationMarkdown = `` diff --git a/checks/cloud/aws/documentdb/encryption_customer_key.go b/checks/cloud/aws/documentdb/encryption_customer_key.go deleted file mode 100755 index c23f6376..00000000 --- a/checks/cloud/aws/documentdb/encryption_customer_key.go +++ /dev/null @@ -1,64 +0,0 @@ -package documentdb - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEncryptionCustomerKey = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0022", - Provider: providers.AWSProvider, - Service: "documentdb", - ShortCode: "encryption-customer-key", - Summary: "DocumentDB encryption should use Customer Managed Keys", - Impact: "Using AWS managed keys does not allow for fine grained control", - Resolution: "Enable encryption using customer managed keys", - Explanation: `Encryption using AWS keys provides protection for your DocumentDB underlying storage. To increase control of the encryption and manage factors like rotation use customer managed keys.`, - Links: []string{"https://docs.aws.amazon.com/documentdb/latest/developerguide/security.encryption.ssl.public-key.html"}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEncryptionCustomerKeyGoodExamples, - BadExamples: terraformEncryptionCustomerKeyBadExamples, - Links: terraformEncryptionCustomerKeyLinks, - RemediationMarkdown: terraformEncryptionCustomerKeyRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEncryptionCustomerKeyGoodExamples, - BadExamples: cloudFormationEncryptionCustomerKeyBadExamples, - Links: cloudFormationEncryptionCustomerKeyLinks, - RemediationMarkdown: cloudFormationEncryptionCustomerKeyRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.AWS.DocumentDB.Clusters { - if cluster.Metadata.IsManaged() && cluster.KMSKeyID.IsEmpty() { - results.Add( - "Cluster encryption does not use a customer-managed KMS key.", - cluster.KMSKeyID, - ) - } else { - results.AddPassed(&cluster) - } - for _, instance := range cluster.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.KMSKeyID.IsEmpty() { - results.Add( - "Instance encryption does not use a customer-managed KMS key.", - instance.KMSKeyID, - ) - } else { - results.AddPassed(&cluster) - } - - } - } - return - }, -) diff --git a/checks/cloud/aws/documentdb/encryption_customer_key.tf.go b/checks/cloud/aws/documentdb/encryption_customer_key.tf.go deleted file mode 100644 index 845c1b01..00000000 --- a/checks/cloud/aws/documentdb/encryption_customer_key.tf.go +++ /dev/null @@ -1,40 +0,0 @@ -package documentdb - -var terraformEncryptionCustomerKeyGoodExamples = []string{ - ` - resource "aws_kms_key" "docdb_encryption" { - enable_key_rotation = true - } - - resource "aws_docdb_cluster" "docdb" { - cluster_identifier = "my-docdb-cluster" - engine = "docdb" - master_username = "foo" - master_password = "mustbeeightchars" - backup_retention_period = 5 - preferred_backup_window = "07:00-09:00" - skip_final_snapshot = true - kms_key_id = aws_kms_key.docdb_encryption.arn - } - `, -} - -var terraformEncryptionCustomerKeyBadExamples = []string{ - ` - resource "aws_docdb_cluster" "docdb" { - cluster_identifier = "my-docdb-cluster" - engine = "docdb" - master_username = "foo" - master_password = "mustbeeightchars" - backup_retention_period = 5 - preferred_backup_window = "07:00-09:00" - skip_final_snapshot = true - } - `, -} - -var terraformEncryptionCustomerKeyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/docdb_cluster#kms_key_id`, -} - -var terraformEncryptionCustomerKeyRemediationMarkdown = `` diff --git a/checks/cloud/aws/dynamodb/enable_at_rest_encryption.cf.go b/checks/cloud/aws/dynamodb/enable_at_rest_encryption.cf.go deleted file mode 100644 index 0bbdf666..00000000 --- a/checks/cloud/aws/dynamodb/enable_at_rest_encryption.cf.go +++ /dev/null @@ -1,36 +0,0 @@ -package dynamodb - -var cloudFormationEnableAtRestEncryptionGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::DAX::Cluster - Properties: - ClusterName: "MyDAXCluster" - NodeType: "dax.r3.large" - ReplicationFactor: 1 - IAMRoleARN: "arn:aws:iam::111122223333:role/DaxAccess" - Description: "DAX cluster with encryption at rest" - SSESpecification: - SSEEnabled: true -`, -} - -var cloudFormationEnableAtRestEncryptionBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::DAX::Cluster - Properties: - ClusterName: "MyDAXCluster" - NodeType: "dax.r3.large" - ReplicationFactor: 1 - IAMRoleARN: "arn:aws:iam::111122223333:role/DaxAccess" - Description: "DAX cluster without encryption at rest" - SubnetGroupName: !Ref subnetGroupClu -`, -} - -var cloudFormationEnableAtRestEncryptionLinks = []string{} - -var cloudFormationEnableAtRestEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/dynamodb/enable_at_rest_encryption.go b/checks/cloud/aws/dynamodb/enable_at_rest_encryption.go deleted file mode 100755 index 444b0d47..00000000 --- a/checks/cloud/aws/dynamodb/enable_at_rest_encryption.go +++ /dev/null @@ -1,56 +0,0 @@ -package dynamodb - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableAtRestEncryption = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0023", - Provider: providers.AWSProvider, - Service: "dynamodb", - ShortCode: "enable-at-rest-encryption", - Summary: "DAX Cluster should always encrypt data at rest", - Impact: "Data can be freely read if compromised", - Resolution: "Enable encryption at rest for DAX Cluster", - Explanation: `Amazon DynamoDB Accelerator (DAX) encryption at rest provides an additional layer of data protection by helping secure your data from unauthorized access to the underlying storage.`, - Links: []string{ - "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DAXEncryptionAtRest.html", - "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dax-cluster.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableAtRestEncryptionGoodExamples, - BadExamples: terraformEnableAtRestEncryptionBadExamples, - Links: terraformEnableAtRestEncryptionLinks, - RemediationMarkdown: terraformEnableAtRestEncryptionRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnableAtRestEncryptionGoodExamples, - BadExamples: cloudFormationEnableAtRestEncryptionBadExamples, - Links: cloudFormationEnableAtRestEncryptionLinks, - RemediationMarkdown: cloudFormationEnableAtRestEncryptionRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.AWS.DynamoDB.DAXClusters { - if cluster.Metadata.IsUnmanaged() { - continue - } - if cluster.ServerSideEncryption.Enabled.IsFalse() { - results.Add( - "DAX encryption is not enabled.", - cluster.ServerSideEncryption.Enabled, - ) - } else { - results.AddPassed(&cluster) - } - } - return - }, -) diff --git a/checks/cloud/aws/dynamodb/enable_at_rest_encryption.tf.go b/checks/cloud/aws/dynamodb/enable_at_rest_encryption.tf.go deleted file mode 100644 index fb767538..00000000 --- a/checks/cloud/aws/dynamodb/enable_at_rest_encryption.tf.go +++ /dev/null @@ -1,43 +0,0 @@ -package dynamodb - -var terraformEnableAtRestEncryptionGoodExamples = []string{ - ` - resource "aws_dax_cluster" "good_example" { - // other DAX config - - server_side_encryption { - enabled = true // enabled server side encryption - } - } - `, -} - -var terraformEnableAtRestEncryptionBadExamples = []string{ - ` - resource "aws_dax_cluster" "bad_example" { - // no server side encryption at all - } - - resource "aws_dax_cluster" "bad_example" { - // other DAX config - - server_side_encryption { - // empty server side encryption config - } - } - - resource "aws_dax_cluster" "bad_example" { - // other DAX config - - server_side_encryption { - enabled = false // disabled server side encryption - } - } - `, -} - -var terraformEnableAtRestEncryptionLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dax_cluster#server_side_encryption`, -} - -var terraformEnableAtRestEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/dynamodb/enable_recovery.go b/checks/cloud/aws/dynamodb/enable_recovery.go deleted file mode 100755 index 0cf2b6dc..00000000 --- a/checks/cloud/aws/dynamodb/enable_recovery.go +++ /dev/null @@ -1,64 +0,0 @@ -package dynamodb - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableRecovery = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0024", - Provider: providers.AWSProvider, - Service: "dynamodb", - ShortCode: "enable-recovery", - Summary: "Point in time recovery should be enabled to protect DynamoDB table", - Impact: "Accidental or malicious writes and deletes can't be rolled back", - Resolution: "Enable point in time recovery", - Explanation: `DynamoDB tables should be protected against accidentally or malicious write/delete actions by ensuring that there is adequate protection. - -By enabling point-in-time-recovery you can restore to a known point in the event of loss of data.`, - Links: []string{ - "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/PointInTimeRecovery.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableRecoveryGoodExamples, - BadExamples: terraformEnableRecoveryBadExamples, - Links: terraformEnableRecoveryLinks, - RemediationMarkdown: terraformEnableRecoveryRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.AWS.DynamoDB.DAXClusters { - if cluster.Metadata.IsUnmanaged() { - continue - } - if cluster.PointInTimeRecovery.IsFalse() { - results.Add( - "Point-in-time recovery is not enabled.", - cluster.PointInTimeRecovery, - ) - } else { - results.AddPassed(&cluster) - } - } - for _, table := range s.AWS.DynamoDB.Tables { - if table.Metadata.IsUnmanaged() { - continue - } - if table.PointInTimeRecovery.IsFalse() { - results.Add( - "Point-in-time recovery is not enabled.", - table.PointInTimeRecovery, - ) - } else { - results.AddPassed(&table) - } - } - return - }, -) diff --git a/checks/cloud/aws/dynamodb/enable_recovery.tf.go b/checks/cloud/aws/dynamodb/enable_recovery.tf.go deleted file mode 100644 index 0367e0f5..00000000 --- a/checks/cloud/aws/dynamodb/enable_recovery.tf.go +++ /dev/null @@ -1,45 +0,0 @@ -package dynamodb - -var terraformEnableRecoveryGoodExamples = []string{ - ` - resource "aws_dynamodb_table" "good_example" { - name = "example" - hash_key = "TestTableHashKey" - billing_mode = "PAY_PER_REQUEST" - stream_enabled = true - stream_view_type = "NEW_AND_OLD_IMAGES" - - attribute { - name = "TestTableHashKey" - type = "S" - } - - point_in_time_recovery { - enabled = true - } - } - `, -} - -var terraformEnableRecoveryBadExamples = []string{ - ` - resource "aws_dynamodb_table" "bad_example" { - name = "example" - hash_key = "TestTableHashKey" - billing_mode = "PAY_PER_REQUEST" - stream_enabled = true - stream_view_type = "NEW_AND_OLD_IMAGES" - - attribute { - name = "TestTableHashKey" - type = "S" - } - } - `, -} - -var terraformEnableRecoveryLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dynamodb_table#point_in_time_recovery`, -} - -var terraformEnableRecoveryRemediationMarkdown = `` diff --git a/checks/cloud/aws/dynamodb/table_customer_key.go b/checks/cloud/aws/dynamodb/table_customer_key.go deleted file mode 100755 index e0dbca69..00000000 --- a/checks/cloud/aws/dynamodb/table_customer_key.go +++ /dev/null @@ -1,56 +0,0 @@ -package dynamodb - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/dynamodb" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckTableCustomerKey = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0025", - Provider: providers.AWSProvider, - Service: "dynamodb", - ShortCode: "table-customer-key", - Summary: "DynamoDB tables should use at rest encryption with a Customer Managed Key", - Impact: "Using AWS managed keys does not allow for fine grained control", - Resolution: "Enable server side encryption with a customer managed key", - Explanation: `DynamoDB tables are encrypted by default using AWS managed encryption keys. To increase control of the encryption and control the management of factors like key rotation, use a Customer Managed Key.`, - Links: []string{ - "https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/EncryptionAtRest.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformTableCustomerKeyGoodExamples, - BadExamples: terraformTableCustomerKeyBadExamples, - Links: terraformTableCustomerKeyLinks, - RemediationMarkdown: terraformTableCustomerKeyRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, table := range s.AWS.DynamoDB.Tables { - if table.Metadata.IsUnmanaged() { - continue - } - if table.ServerSideEncryption.Enabled.IsFalse() { - results.Add( - "Table encryption does not use a customer-managed KMS key.", - table.ServerSideEncryption.KMSKeyID, - ) - } else if table.ServerSideEncryption.KMSKeyID.IsEmpty() || - table.ServerSideEncryption.KMSKeyID.EqualTo(dynamodb.DefaultKMSKeyID) { - results.Add( - "Table encryption explicitly uses the default KMS key.", - table.ServerSideEncryption.KMSKeyID, - ) - } else { - results.AddPassed(&table) - } - } - return - }, -) diff --git a/checks/cloud/aws/dynamodb/table_customer_key.tf.go b/checks/cloud/aws/dynamodb/table_customer_key.tf.go deleted file mode 100644 index c15eef9d..00000000 --- a/checks/cloud/aws/dynamodb/table_customer_key.tf.go +++ /dev/null @@ -1,66 +0,0 @@ -package dynamodb - -var terraformTableCustomerKeyGoodExamples = []string{ - ` - resource "aws_kms_key" "dynamo_db_kms" { - enable_key_rotation = true - } - - resource "aws_dynamodb_table" "good_example" { - name = "example" - hash_key = "TestTableHashKey" - billing_mode = "PAY_PER_REQUEST" - stream_enabled = true - stream_view_type = "NEW_AND_OLD_IMAGES" - - attribute { - name = "TestTableHashKey" - type = "S" - } - - replica { - region_name = "us-east-2" - } - - replica { - region_name = "us-west-2" - } - - server_side_encryption { - enabled = true - kms_key_arn = aws_kms_key.dynamo_db_kms.key_id - } - } - `, -} - -var terraformTableCustomerKeyBadExamples = []string{ - ` - resource "aws_dynamodb_table" "bad_example" { - name = "example" - hash_key = "TestTableHashKey" - billing_mode = "PAY_PER_REQUEST" - stream_enabled = true - stream_view_type = "NEW_AND_OLD_IMAGES" - - attribute { - name = "TestTableHashKey" - type = "S" - } - - replica { - region_name = "us-east-2" - } - - replica { - region_name = "us-west-2" - } - } - `, -} - -var terraformTableCustomerKeyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dynamodb_table#server_side_encryption`, -} - -var terraformTableCustomerKeyRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/add_description_to_security_group.cf.go b/checks/cloud/aws/ec2/add_description_to_security_group.cf.go deleted file mode 100644 index d85f2899..00000000 --- a/checks/cloud/aws/ec2/add_description_to_security_group.cf.go +++ /dev/null @@ -1,30 +0,0 @@ -package ec2 - -var cloudFormationAddDescriptionToSecurityGroupGoodExamples = []string{ - `--- -Resources: - GoodSecurityGroup: - Type: AWS::EC2::SecurityGroup - Properties: - GroupDescription: Limits security group egress traffic - SecurityGroupEgress: - - CidrIp: 127.0.0.1/32 - IpProtocol: "-1" -`, -} - -var cloudFormationAddDescriptionToSecurityGroupBadExamples = []string{ - `--- -Resources: - BadSecurityGroup: - Type: AWS::EC2::SecurityGroup - Properties: - SecurityGroupEgress: - - CidrIp: 127.0.0.1/32 - IpProtocol: "-1" -`, -} - -var cloudFormationAddDescriptionToSecurityGroupLinks = []string{} - -var cloudFormationAddDescriptionToSecurityGroupRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/add_description_to_security_group.go b/checks/cloud/aws/ec2/add_description_to_security_group.go deleted file mode 100755 index 09bd2234..00000000 --- a/checks/cloud/aws/ec2/add_description_to_security_group.go +++ /dev/null @@ -1,63 +0,0 @@ -package ec2 - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckAddDescriptionToSecurityGroup = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0099", - Aliases: []string{"aws-vpc-add-description-to-security-group"}, - Provider: providers.AWSProvider, - Service: "ec2", - ShortCode: "add-description-to-security-group", - Summary: "Missing description for security group.", - Impact: "Descriptions provide context for the firewall rule reasons", - Resolution: "Add descriptions for all security groups", - Explanation: `Security groups should include a description for auditing purposes. - -Simplifies auditing, debugging, and managing security groups.`, - Links: []string{ - "https://www.cloudconformity.com/knowledge-base/aws/EC2/security-group-rules-description.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformAddDescriptionToSecurityGroupGoodExamples, - BadExamples: terraformAddDescriptionToSecurityGroupBadExamples, - Links: terraformAddDescriptionToSecurityGroupLinks, - RemediationMarkdown: terraformAddDescriptionToSecurityGroupRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationAddDescriptionToSecurityGroupGoodExamples, - BadExamples: cloudFormationAddDescriptionToSecurityGroupBadExamples, - Links: cloudFormationAddDescriptionToSecurityGroupLinks, - RemediationMarkdown: cloudFormationAddDescriptionToSecurityGroupRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.AWS.EC2.SecurityGroups { - if group.Metadata.IsUnmanaged() { - continue - } - if group.Description.IsEmpty() { - results.Add( - "Security group does not have a description.", - group.Description, - ) - } else if group.Description.EqualTo("Managed by Terraform") { - results.Add( - "Security group explicitly uses the default description.", - group.Description, - ) - } else { - results.AddPassed(&group) - } - } - return - }, -) diff --git a/checks/cloud/aws/ec2/add_description_to_security_group.tf.go b/checks/cloud/aws/ec2/add_description_to_security_group.tf.go deleted file mode 100644 index 33c305c7..00000000 --- a/checks/cloud/aws/ec2/add_description_to_security_group.tf.go +++ /dev/null @@ -1,41 +0,0 @@ -package ec2 - -var terraformAddDescriptionToSecurityGroupGoodExamples = []string{ - ` - resource "aws_security_group" "good_example" { - name = "http" - description = "Allow inbound HTTP traffic" - - ingress { - description = "HTTP from VPC" - from_port = 80 - to_port = 80 - protocol = "tcp" - cidr_blocks = [aws_vpc.main.cidr_block] - } - } - `, -} - -var terraformAddDescriptionToSecurityGroupBadExamples = []string{ - ` - resource "aws_security_group" "bad_example" { - name = "http" - description = "" - - ingress { - description = "HTTP from VPC" - from_port = 80 - to_port = 80 - protocol = "tcp" - cidr_blocks = [aws_vpc.main.cidr_block] - } - } - `, -} - -var terraformAddDescriptionToSecurityGroupLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group`, `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule`, -} - -var terraformAddDescriptionToSecurityGroupRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/add_description_to_security_group_rule.cf.go b/checks/cloud/aws/ec2/add_description_to_security_group_rule.cf.go deleted file mode 100644 index 0a01c832..00000000 --- a/checks/cloud/aws/ec2/add_description_to_security_group_rule.cf.go +++ /dev/null @@ -1,32 +0,0 @@ -package ec2 - -var cloudFormationAddDescriptionToSecurityGroupRuleGoodExamples = []string{ - `--- -Resources: - GoodSecurityGroup: - Type: AWS::EC2::SecurityGroup - Properties: - GroupDescription: Limits security group egress traffic - SecurityGroupEgress: - - CidrIp: 127.0.0.1/32 - Description: "Can connect to loopback" - IpProtocol: "-1" -`, -} - -var cloudFormationAddDescriptionToSecurityGroupRuleBadExamples = []string{ - `--- -Resources: - BadSecurityGroup: - Type: AWS::EC2::SecurityGroup - Properties: - GroupDescription: Limits security group egress traffic - SecurityGroupEgress: - - CidrIp: 127.0.0.1/32 - IpProtocol: "-1" -`, -} - -var cloudFormationAddDescriptionToSecurityGroupRuleLinks = []string{} - -var cloudFormationAddDescriptionToSecurityGroupRuleRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/add_description_to_security_group_rule.go b/checks/cloud/aws/ec2/add_description_to_security_group_rule.go deleted file mode 100755 index 13a74d76..00000000 --- a/checks/cloud/aws/ec2/add_description_to_security_group_rule.go +++ /dev/null @@ -1,58 +0,0 @@ -package ec2 - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckAddDescriptionToSecurityGroupRule = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0124", - Aliases: []string{"aws-vpc-add-description-to-security-group-rule"}, - Provider: providers.AWSProvider, - Service: "ec2", - ShortCode: "add-description-to-security-group-rule", - Summary: "Missing description for security group rule.", - Impact: "Descriptions provide context for the firewall rule reasons", - Resolution: "Add descriptions for all security groups rules", - Explanation: `Security group rules should include a description for auditing purposes. - -Simplifies auditing, debugging, and managing security groups.`, - Links: []string{ - "https://www.cloudconformity.com/knowledge-base/aws/EC2/security-group-rules-description.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformAddDescriptionToSecurityGroupRuleGoodExamples, - BadExamples: terraformAddDescriptionToSecurityGroupRuleBadExamples, - Links: terraformAddDescriptionToSecurityGroupRuleLinks, - RemediationMarkdown: terraformAddDescriptionToSecurityGroupRuleRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationAddDescriptionToSecurityGroupRuleGoodExamples, - BadExamples: cloudFormationAddDescriptionToSecurityGroupRuleBadExamples, - Links: cloudFormationAddDescriptionToSecurityGroupRuleLinks, - RemediationMarkdown: cloudFormationAddDescriptionToSecurityGroupRuleRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.AWS.EC2.SecurityGroups { - for _, rule := range append(group.EgressRules, group.IngressRules...) { - if rule.Description.IsEmpty() { - results.Add( - "Security group rule does not have a description.", - rule.Description, - ) - } else { - results.AddPassed(&rule) - } - } - - } - return - }, -) diff --git a/checks/cloud/aws/ec2/add_description_to_security_group_rule.tf.go b/checks/cloud/aws/ec2/add_description_to_security_group_rule.tf.go deleted file mode 100644 index 98e714d6..00000000 --- a/checks/cloud/aws/ec2/add_description_to_security_group_rule.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package ec2 - -var terraformAddDescriptionToSecurityGroupRuleGoodExamples = []string{ - ` - resource "aws_security_group" "good_example" { - name = "http" - description = "Allow inbound HTTP traffic" - - ingress { - description = "HTTP from VPC" - from_port = 80 - to_port = 80 - protocol = "tcp" - cidr_blocks = [aws_vpc.main.cidr_block] - } - } - `, -} - -var terraformAddDescriptionToSecurityGroupRuleBadExamples = []string{ - ` - resource "aws_security_group" "bad_example" { - name = "http" - - ingress { - from_port = 80 - to_port = 80 - protocol = "tcp" - cidr_blocks = [aws_vpc.main.cidr_block] - } - } - `, -} - -var terraformAddDescriptionToSecurityGroupRuleLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group`, `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule`, -} - -var terraformAddDescriptionToSecurityGroupRuleRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/as_enable_at_rest_encryption.cf.go b/checks/cloud/aws/ec2/as_enable_at_rest_encryption.cf.go deleted file mode 100644 index ba90473c..00000000 --- a/checks/cloud/aws/ec2/as_enable_at_rest_encryption.cf.go +++ /dev/null @@ -1,38 +0,0 @@ -package ec2 - -var cloudFormationASEnableAtRestEncryptionGoodExamples = []string{ - `--- -Resources: - GoodExample: - Properties: - BlockDeviceMappings: - - DeviceName: root - Ebs: - Encrypted: true - ImageId: ami-123456 - InstanceType: t2.small - Type: AWS::AutoScaling::LaunchConfiguration -`, -} - -var cloudFormationASEnableAtRestEncryptionBadExamples = []string{ - `--- -Resources: - BadExample: - Properties: - BlockDeviceMappings: - - DeviceName: root - Ebs: - Encrypted: true - - DeviceName: data - Ebs: - Encrypted: false - ImageId: ami-123456 - InstanceType: t2.small - Type: AWS::AutoScaling::LaunchConfiguration -`, -} - -var cloudFormationASEnableAtRestEncryptionLinks = []string{} - -var cloudFormationASEnableAtRestEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/as_enable_at_rest_encryption.go b/checks/cloud/aws/ec2/as_enable_at_rest_encryption.go deleted file mode 100755 index 3e3922a7..00000000 --- a/checks/cloud/aws/ec2/as_enable_at_rest_encryption.go +++ /dev/null @@ -1,63 +0,0 @@ -package ec2 - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckASEnableAtRestEncryption = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0008", - Aliases: []string{"aws-autoscaling-enable-at-rest-encryption"}, - Provider: providers.AWSProvider, - Service: "ec2", - ShortCode: "enable-launch-config-at-rest-encryption", - Summary: "Launch configuration with unencrypted block device.", - Impact: "The block device could be compromised and read from", - Resolution: "Turn on encryption for all block devices", - Explanation: `Block devices should be encrypted to ensure sensitive data is held securely at rest.`, - Links: []string{ - "https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/RootDeviceStorage.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformASEnableAtRestEncryptionGoodExamples, - BadExamples: terraformASEnableAtRestEncryptionBadExamples, - Links: terraformASEnableAtRestEncryptionLinks, - RemediationMarkdown: terraformASEnableAtRestEncryptionRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationASEnableAtRestEncryptionGoodExamples, - BadExamples: cloudFormationASEnableAtRestEncryptionBadExamples, - Links: cloudFormationASEnableAtRestEncryptionLinks, - RemediationMarkdown: cloudFormationASEnableAtRestEncryptionRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, launchConfig := range s.AWS.EC2.LaunchConfigurations { - if launchConfig.RootBlockDevice != nil && launchConfig.RootBlockDevice.Encrypted.IsFalse() { - results.Add( - "Root block device is not encrypted.", - launchConfig.RootBlockDevice.Encrypted, - ) - } else { - results.AddPassed(&launchConfig) - } - for _, device := range launchConfig.EBSBlockDevices { - if device.Encrypted.IsFalse() { - results.Add( - "EBS block device is not encrypted.", - device.Encrypted, - ) - } else { - results.AddPassed(device) - } - } - } - return - }, -) diff --git a/checks/cloud/aws/ec2/as_enable_at_rest_encryption.tf.go b/checks/cloud/aws/ec2/as_enable_at_rest_encryption.tf.go deleted file mode 100644 index 49bd80c5..00000000 --- a/checks/cloud/aws/ec2/as_enable_at_rest_encryption.tf.go +++ /dev/null @@ -1,27 +0,0 @@ -package ec2 - -var terraformASEnableAtRestEncryptionGoodExamples = []string{ - ` - resource "aws_launch_configuration" "good_example" { - root_block_device { - encrypted = true - } - } - `, -} - -var terraformASEnableAtRestEncryptionBadExamples = []string{ - ` - resource "aws_launch_configuration" "bad_example" { - root_block_device { - encrypted = false - } - } - `, -} - -var terraformASEnableAtRestEncryptionLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#ebs-ephemeral-and-root-block-devices`, -} - -var terraformASEnableAtRestEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/as_enforce_http_token_imds.cf.go b/checks/cloud/aws/ec2/as_enforce_http_token_imds.cf.go deleted file mode 100644 index 01f70013..00000000 --- a/checks/cloud/aws/ec2/as_enforce_http_token_imds.cf.go +++ /dev/null @@ -1,29 +0,0 @@ -package ec2 - -var cloudformationASEnforceHttpTokenImdsGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::AutoScaling::LaunchConfiguration - Properties: - MetadataOptions: - HttpTokens: required - HttpEndpoint: enabled - `, -} - -var cloudformationASEnforceHttpTokenImdsBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::AutoScaling::LaunchConfiguration - Properties: - MetadataOptions: - HttpTokens: optional - HttpEndpoint: enabled - `, -} - -var cloudformationASEnforceHttpTokenImdsLinks = []string{} - -var cloudformationASEnforceHttpTokenImdsRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/as_enforce_http_token_imds.go b/checks/cloud/aws/ec2/as_enforce_http_token_imds.go deleted file mode 100755 index 3304b928..00000000 --- a/checks/cloud/aws/ec2/as_enforce_http_token_imds.go +++ /dev/null @@ -1,69 +0,0 @@ -package ec2 - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckASIMDSAccessRequiresToken = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0130", - Aliases: []string{"aws-autoscaling-enforce-http-token-imds"}, - Provider: providers.AWSProvider, - Service: "ec2", - ShortCode: "enforce-launch-config-http-token-imds", - Summary: "aws_instance should activate session tokens for Instance Metadata Service.", - Impact: "Instance metadata service can be interacted with freely", - Resolution: "Enable HTTP token requirement for IMDS", - Explanation: ` -IMDS v2 (Instance Metadata Service) introduced session authentication tokens which improve security when talking to IMDS. -By default aws_instance resource sets IMDS session auth tokens to be optional. -To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required. -`, - - Links: []string{ - "https://aws.amazon.com/blogs/security/defense-in-depth-open-firewalls-reverse-proxies-ssrf-vulnerabilities-ec2-instance-metadata-service", - }, - - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformASEnforceHttpTokenImdsGoodExamples, - BadExamples: terraformASEnforceHttpTokenImdsBadExamples, - Links: terraformASEnforceHttpTokenImdsLinks, - RemediationMarkdown: terraformASEnforceHttpTokenImdsRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudformationASEnforceHttpTokenImdsGoodExamples, - BadExamples: cloudformationASEnforceHttpTokenImdsBadExamples, - Links: cloudformationASEnforceHttpTokenImdsLinks, - RemediationMarkdown: cloudformationASEnforceHttpTokenImdsRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, configuration := range s.AWS.EC2.LaunchConfigurations { - if !configuration.RequiresIMDSToken() && !configuration.HasHTTPEndpointDisabled() { - results.Add( - "Launch configuration does not require IMDS access to require a token", - configuration.MetadataOptions.HttpTokens, - ) - } else { - results.AddPassed(&configuration) - } - } - for _, instance := range s.AWS.EC2.LaunchTemplates { - if !instance.RequiresIMDSToken() && !instance.HasHTTPEndpointDisabled() { - results.Add( - "Launch template does not require IMDS access to require a token", - instance.MetadataOptions.HttpTokens, - ) - } else { - results.AddPassed(&instance) - } - } - return results - }, -) diff --git a/checks/cloud/aws/ec2/as_enforce_http_token_imds.tf.go b/checks/cloud/aws/ec2/as_enforce_http_token_imds.tf.go deleted file mode 100644 index 3f505134..00000000 --- a/checks/cloud/aws/ec2/as_enforce_http_token_imds.tf.go +++ /dev/null @@ -1,28 +0,0 @@ -package ec2 - -var terraformASEnforceHttpTokenImdsGoodExamples = []string{ - ` - resource "aws_launch_template" "good_example" { - image_id = "ami-005e54dee72cc1d00" - instance_type = "t2.micro" - metadata_options { - http_tokens = "required" - } - } - `, -} - -var terraformASEnforceHttpTokenImdsBadExamples = []string{ - ` - resource "aws_launch_template" "bad_example" { - image_id = "ami-005e54dee72cc1d00" - instance_type = "t2.micro" - } - `, -} - -var terraformASEnforceHttpTokenImdsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#metadata-options`, -} - -var terraformASEnforceHttpTokenImdsRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/as_no_secrets_in_user_data.cf.go b/checks/cloud/aws/ec2/as_no_secrets_in_user_data.cf.go deleted file mode 100644 index 4accf01a..00000000 --- a/checks/cloud/aws/ec2/as_no_secrets_in_user_data.cf.go +++ /dev/null @@ -1,65 +0,0 @@ -package ec2 - -var cloudFormationASNoSecretsInUserDataGoodExamples = []string{ - `--- -Resources: - InstanceProfile: - Type: AWS::IAM::InstanceProfile - Properties: - InstanceProfileName: MyIamInstanceProfile - Path: "/" - Roles: - - MyAdminRole - GoodExample: - Type: AWS::EC2::LaunchTemplate - Properties: - LaunchTemplateName: MyLaunchTemplate - LaunchTemplateData: - IamInstanceProfile: - Arn: !GetAtt - - MyIamInstanceProfile - - Arn - DisableApiTermination: true - ImageId: ami-04d5cc9b88example - UserData: export SSM_PATH=/database/creds - InstanceType: t2.micro - KeyName: MyKeyPair - MetadataOptions: - - HttpTokens: required - SecurityGroupIds: - - sg-083cd3bfb8example -`, -} - -var cloudFormationASNoSecretsInUserDataBadExamples = []string{ - `--- -Resources: - InstanceProfile: - Type: AWS::IAM::InstanceProfile - Properties: - InstanceProfileName: MyIamInstanceProfile - Path: "/" - Roles: - - MyAdminRole - BadExample: - Type: AWS::EC2::LaunchTemplate - Properties: - LaunchTemplateName: MyLaunchTemplate - LaunchTemplateData: - IamInstanceProfile: - Arn: !GetAtt - - MyIamInstanceProfile - - Arn - DisableApiTermination: true - ImageId: ami-04d5cc9b88example - UserData: export DATABASE_PASSWORD=password1234 - InstanceType: t2.micro - KeyName: MyKeyPair - SecurityGroupIds: - - sg-083cd3bfb8example -`, -} - -var cloudFormationASNoSecretsInUserDataLinks = []string{} - -var cloudFormationASNoSecretsInUserDataRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/as_no_secrets_in_user_data.go b/checks/cloud/aws/ec2/as_no_secrets_in_user_data.go deleted file mode 100755 index 549f587b..00000000 --- a/checks/cloud/aws/ec2/as_no_secrets_in_user_data.go +++ /dev/null @@ -1,66 +0,0 @@ -package ec2 - -import ( - "fmt" - - "github.com/aquasecurity/trivy/pkg/iac/severity" - - "github.com/aquasecurity/trivy/pkg/iac/state" - - "github.com/aquasecurity/trivy/pkg/iac/scan" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - - "github.com/aquasecurity/trivy/pkg/iac/providers" - - "github.com/owenrumney/squealer/pkg/squealer" -) - -var scanner = squealer.NewStringScanner() - -var CheckASNoSecretsInUserData = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0129", - Aliases: []string{"aws-autoscaling-no-secrets-in-user-data"}, - Provider: providers.AWSProvider, - Service: "ec2", - ShortCode: "no-secrets-in-launch-template-user-data", - Summary: "User data for EC2 instances must not contain sensitive AWS keys", - Impact: "User data is visible through the AWS Management console", - Resolution: "Remove sensitive data from the EC2 instance user-data generated by launch templates", - Explanation: `EC2 instance data is used to pass start up information into the EC2 instance. This userdata must not contain access key credentials. Instead use an IAM Instance Profile assigned to the instance to grant access to other AWS Services.`, - Links: []string{ - "https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-add-user-data.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformASNoSecretsInUserDataGoodExamples, - BadExamples: terraformASNoSecretsInUserDataBadExamples, - Links: terraformASNoSecretsInUserDataLinks, - RemediationMarkdown: terraformASNoSecretsInUserDataRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationASNoSecretsInUserDataGoodExamples, - BadExamples: cloudFormationASNoSecretsInUserDataBadExamples, - Links: cloudFormationASNoSecretsInUserDataLinks, - RemediationMarkdown: cloudFormationASNoSecretsInUserDataRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.AWS.EC2.LaunchTemplates { - if instance.Metadata.IsUnmanaged() { - continue - } - if result := scanner.Scan(instance.UserData.Value()); result.TransgressionFound { - results.Add( - fmt.Sprintf("Sensitive data found in launch template user data: %s", result.Description), - instance.UserData, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/aws/ec2/as_no_secrets_in_user_data.tf.go b/checks/cloud/aws/ec2/as_no_secrets_in_user_data.tf.go deleted file mode 100644 index 65770ed2..00000000 --- a/checks/cloud/aws/ec2/as_no_secrets_in_user_data.tf.go +++ /dev/null @@ -1,43 +0,0 @@ -package ec2 - -var terraformASNoSecretsInUserDataGoodExamples = []string{ - ` - resource "aws_iam_instance_profile" "good_example" { - // ... - } - - resource "aws_launch_template" "good_example" { - image_id = "ami-12345667" - instance_type = "t2.small" - - iam_instance_profile { - name = aws_iam_instance_profile.good_profile.arn - } - user_data = <aws_instance resource sets IMDS session auth tokens to be optional. -To fully protect IMDS you need to enable session tokens by using metadata_options block and its http_tokens variable set to required. -`, - - Links: []string{ - "https://aws.amazon.com/blogs/security/defense-in-depth-open-firewalls-reverse-proxies-ssrf-vulnerabilities-ec2-instance-metadata-service", - }, - - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnforceHttpTokenImdsGoodExamples, - BadExamples: terraformEnforceHttpTokenImdsBadExamples, - Links: terraformEnforceHttpTokenImdsLinks, - RemediationMarkdown: terraformEnforceHttpTokenImdsRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.AWS.EC2.Instances { - if !instance.RequiresIMDSToken() && !instance.HasHTTPEndpointDisabled() { - results.Add( - "Instance does not require IMDS access to require a token", - instance.MetadataOptions.HttpTokens, - ) - } else { - results.AddPassed(&instance) - } - } - return results - }, -) diff --git a/checks/cloud/aws/ec2/enforce_http_token_imds.tf.go b/checks/cloud/aws/ec2/enforce_http_token_imds.tf.go deleted file mode 100644 index 836e2811..00000000 --- a/checks/cloud/aws/ec2/enforce_http_token_imds.tf.go +++ /dev/null @@ -1,28 +0,0 @@ -package ec2 - -var terraformEnforceHttpTokenImdsGoodExamples = []string{ - ` - resource "aws_instance" "good_example" { - ami = "ami-005e54dee72cc1d00" - instance_type = "t2.micro" - metadata_options { - http_tokens = "required" - } - } - `, -} - -var terraformEnforceHttpTokenImdsBadExamples = []string{ - ` - resource "aws_instance" "bad_example" { - ami = "ami-005e54dee72cc1d00" - instance_type = "t2.micro" - } - `, -} - -var terraformEnforceHttpTokenImdsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#metadata-options`, -} - -var terraformEnforceHttpTokenImdsRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/no_default_vpc.go b/checks/cloud/aws/ec2/no_default_vpc.go deleted file mode 100755 index bf513faa..00000000 --- a/checks/cloud/aws/ec2/no_default_vpc.go +++ /dev/null @@ -1,45 +0,0 @@ -package ec2 - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoDefaultVpc = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0101", - Aliases: []string{"aws-vpc-no-default-vpc"}, - Provider: providers.AWSProvider, - Service: "ec2", - ShortCode: "no-default-vpc", - Summary: "AWS best practice to not use the default VPC for workflows", - Impact: "The default VPC does not have critical security features applied", - Resolution: "Create a non-default vpc for resources to be created in", - Explanation: `Default VPC does not have a lot of the critical security features that standard VPC comes with, new resources should not be created in the default VPC and it should not be present in the Terraform.`, - Links: []string{ - "https://docs.aws.amazon.com/vpc/latest/userguide/default-vpc.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoDefaultVpcGoodExamples, - BadExamples: terraformNoDefaultVpcBadExamples, - Links: terraformNoDefaultVpcLinks, - RemediationMarkdown: terraformNoDefaultVpcRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, def := range s.AWS.EC2.VPCs { - if def.IsDefault.IsTrue() { - results.Add( - "Default VPC is used.", - &def, - ) - } - } - return - }, -) diff --git a/checks/cloud/aws/ec2/no_default_vpc.tf.go b/checks/cloud/aws/ec2/no_default_vpc.tf.go deleted file mode 100644 index 39ea5152..00000000 --- a/checks/cloud/aws/ec2/no_default_vpc.tf.go +++ /dev/null @@ -1,23 +0,0 @@ -package ec2 - -var terraformNoDefaultVpcGoodExamples = []string{ - ` - # no aws default vpc present - `, -} - -var terraformNoDefaultVpcBadExamples = []string{ - ` - resource "aws_default_vpc" "default" { - tags = { - Name = "Default VPC" - } - } - `, -} - -var terraformNoDefaultVpcLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/default_vpc`, -} - -var terraformNoDefaultVpcRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/no_excessive_port_access.cf.go b/checks/cloud/aws/ec2/no_excessive_port_access.cf.go deleted file mode 100644 index 50a889ec..00000000 --- a/checks/cloud/aws/ec2/no_excessive_port_access.cf.go +++ /dev/null @@ -1,45 +0,0 @@ -package ec2 - -var cloudFormationNoExcessivePortAccessGoodExamples = []string{ - `--- -AWSTemplateFormatVersion: 2010-09-09 -Description: Good example of excessive ports -Resources: - NetworkACL: - Type: AWS::EC2::NetworkAcl - Properties: - VpcId: "something" - RuleAction: "allow" - Rule: - Type: AWS::EC2::NetworkAclEntry - Properties: - RuleAction: "allow" - NetworkAclId: - Ref: NetworkACL - Protocol: 6 -`, -} - -var cloudFormationNoExcessivePortAccessBadExamples = []string{ - `--- -AWSTemplateFormatVersion: 2010-09-09 -Description: Bad example of excessive ports -Resources: - NetworkACL: - Type: AWS::EC2::NetworkAcl - Properties: - VpcId: "something" - RuleAction: "allow" - Rule: - Type: AWS::EC2::NetworkAclEntry - Properties: - NetworkAclId: - Ref: NetworkACL - Protocol: -1 - RuleAction: "allow" -`, -} - -var cloudFormationNoExcessivePortAccessLinks = []string{} - -var cloudFormationNoExcessivePortAccessRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/no_excessive_port_access.go b/checks/cloud/aws/ec2/no_excessive_port_access.go deleted file mode 100755 index 84bfff35..00000000 --- a/checks/cloud/aws/ec2/no_excessive_port_access.go +++ /dev/null @@ -1,55 +0,0 @@ -package ec2 - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoExcessivePortAccess = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0102", - Aliases: []string{"aws-vpc-no-excessive-port-access"}, - Provider: providers.AWSProvider, - Service: "ec2", - ShortCode: "no-excessive-port-access", - Summary: "An Network ACL rule allows ALL ports.", - Impact: "All ports exposed for ingressing/egressing data", - Resolution: "Set specific allowed ports", - Explanation: `Ensure access to specific required ports is allowed, and nothing else.`, - Links: []string{ - "https://docs.aws.amazon.com/vpc/latest/userguide/vpc-network-acls.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoExcessivePortAccessGoodExamples, - BadExamples: terraformNoExcessivePortAccessBadExamples, - Links: terraformNoExcessivePortAccessLinks, - RemediationMarkdown: terraformNoExcessivePortAccessRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationNoExcessivePortAccessGoodExamples, - BadExamples: cloudFormationNoExcessivePortAccessBadExamples, - Links: cloudFormationNoExcessivePortAccessLinks, - RemediationMarkdown: cloudFormationNoExcessivePortAccessRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, acl := range s.AWS.EC2.NetworkACLs { - for _, rule := range acl.Rules { - if rule.Action.EqualTo("allow") && rule.Protocol.EqualTo("-1") || rule.Protocol.EqualTo("all") { - results.Add( - "Network ACL rule allows access using ALL ports.", - rule.Protocol, - ) - } else { - results.AddPassed(&rule) - } - } - } - return - }, -) diff --git a/checks/cloud/aws/ec2/no_excessive_port_access.tf.go b/checks/cloud/aws/ec2/no_excessive_port_access.tf.go deleted file mode 100644 index c0cc585d..00000000 --- a/checks/cloud/aws/ec2/no_excessive_port_access.tf.go +++ /dev/null @@ -1,31 +0,0 @@ -package ec2 - -var terraformNoExcessivePortAccessGoodExamples = []string{ - ` - resource "aws_network_acl_rule" "good_example" { - egress = false - protocol = "tcp" - from_port = 22 - to_port = 22 - rule_action = "allow" - cidr_block = "0.0.0.0/0" - } - `, -} - -var terraformNoExcessivePortAccessBadExamples = []string{ - ` - resource "aws_network_acl_rule" "bad_example" { - egress = false - protocol = "all" - rule_action = "allow" - cidr_block = "0.0.0.0/0" - } - `, -} - -var terraformNoExcessivePortAccessLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_acl_rule#to_port`, -} - -var terraformNoExcessivePortAccessRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/no_public_egress_sgr.cf.go b/checks/cloud/aws/ec2/no_public_egress_sgr.cf.go deleted file mode 100644 index d0f4cd4e..00000000 --- a/checks/cloud/aws/ec2/no_public_egress_sgr.cf.go +++ /dev/null @@ -1,35 +0,0 @@ -package ec2 - -var cloudFormationNoPublicEgressSgrGoodExamples = []string{ - `--- -AWSTemplateFormatVersion: 2010-09-09 -Description: Good example of egress rule -Resources: - BadSecurityGroup: - Type: AWS::EC2::SecurityGroup - Properties: - GroupDescription: Limits security group egress traffic - SecurityGroupEgress: - - CidrIp: 127.0.0.1/32 - IpProtocol: "6" -`, -} - -var cloudFormationNoPublicEgressSgrBadExamples = []string{ - `--- -AWSTemplateFormatVersion: 2010-09-09 -Description: Bad example of egress rule -Resources: - BadSecurityGroup: - Type: AWS::EC2::SecurityGroup - Properties: - GroupDescription: Limits security group egress traffic - SecurityGroupEgress: - - CidrIp: 0.0.0.0/0 - IpProtocol: "6" -`, -} - -var cloudFormationNoPublicEgressSgrLinks = []string{} - -var cloudFormationNoPublicEgressSgrRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/no_public_egress_sgr.go b/checks/cloud/aws/ec2/no_public_egress_sgr.go deleted file mode 100755 index ef1a1334..00000000 --- a/checks/cloud/aws/ec2/no_public_egress_sgr.go +++ /dev/null @@ -1,61 +0,0 @@ -package ec2 - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicEgressSgr = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0104", - Aliases: []string{"aws-vpc-no-public-egress-sgr"}, - Provider: providers.AWSProvider, - Service: "ec2", - ShortCode: "no-public-egress-sgr", - Summary: "An egress security group rule allows traffic to /0.", - Impact: "Your port is egressing data to the internet", - Resolution: "Set a more restrictive cidr range", - Explanation: `Opening up ports to connect out to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that are explicitly required where possible.`, - Links: []string{ - "https://docs.aws.amazon.com/whitepapers/latest/building-scalable-secure-multi-vpc-network-infrastructure/centralized-egress-to-internet.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicEgressSgrGoodExamples, - BadExamples: terraformNoPublicEgressSgrBadExamples, - Links: terraformNoPublicEgressSgrLinks, - RemediationMarkdown: terraformNoPublicEgressSgrRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationNoPublicEgressSgrGoodExamples, - BadExamples: cloudFormationNoPublicEgressSgrBadExamples, - Links: cloudFormationNoPublicEgressSgrLinks, - RemediationMarkdown: cloudFormationNoPublicEgressSgrRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.AWS.EC2.SecurityGroups { - for _, rule := range group.EgressRules { - var fail bool - for _, block := range rule.CIDRs { - if cidr.IsPublic(block.Value()) && cidr.CountAddresses(block.Value()) > 1 { - fail = true - results.Add( - "Security group rule allows egress to multiple public internet addresses.", - block, - ) - } - } - if !fail { - results.AddPassed(&rule) - } - } - } - return - }, -) diff --git a/checks/cloud/aws/ec2/no_public_egress_sgr.tf.go b/checks/cloud/aws/ec2/no_public_egress_sgr.tf.go deleted file mode 100644 index ef34c231..00000000 --- a/checks/cloud/aws/ec2/no_public_egress_sgr.tf.go +++ /dev/null @@ -1,27 +0,0 @@ -package ec2 - -var terraformNoPublicEgressSgrGoodExamples = []string{ - ` - resource "aws_security_group" "good_example" { - egress { - cidr_blocks = ["1.2.3.4/32"] - } - } - `, -} - -var terraformNoPublicEgressSgrBadExamples = []string{ - ` - resource "aws_security_group" "bad_example" { - egress { - cidr_blocks = ["0.0.0.0/0"] - } - } - `, -} - -var terraformNoPublicEgressSgrLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group`, -} - -var terraformNoPublicEgressSgrRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/no_public_egress_sgr_test.go b/checks/cloud/aws/ec2/no_public_egress_sgr_test.go deleted file mode 100644 index 33dcf709..00000000 --- a/checks/cloud/aws/ec2/no_public_egress_sgr_test.go +++ /dev/null @@ -1,80 +0,0 @@ -package ec2 - -import ( - "testing" - - trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types" - - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/ec2" - - "github.com/aquasecurity/trivy/pkg/iac/state" - - "github.com/aquasecurity/trivy/pkg/iac/scan" - - "github.com/stretchr/testify/assert" -) - -func TestCheckNoPublicEgressSgr(t *testing.T) { - tests := []struct { - name string - input ec2.EC2 - expected bool - }{ - { - name: "AWS VPC security group rule with wildcard address", - input: ec2.EC2{ - SecurityGroups: []ec2.SecurityGroup{ - { - Metadata: trivyTypes.NewTestMetadata(), - EgressRules: []ec2.SecurityGroupRule{ - { - Metadata: trivyTypes.NewTestMetadata(), - CIDRs: []trivyTypes.StringValue{ - trivyTypes.String("0.0.0.0/0", trivyTypes.NewTestMetadata()), - }, - }, - }, - }, - }, - }, - expected: true, - }, - { - name: "AWS VPC security group rule with private address", - input: ec2.EC2{ - SecurityGroups: []ec2.SecurityGroup{ - { - Metadata: trivyTypes.NewTestMetadata(), - EgressRules: []ec2.SecurityGroupRule{ - { - Metadata: trivyTypes.NewTestMetadata(), - CIDRs: []trivyTypes.StringValue{ - trivyTypes.String("10.0.0.0/16", trivyTypes.NewTestMetadata()), - }, - }, - }, - }, - }, - }, - expected: false, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - var testState state.State - testState.AWS.EC2 = test.input - results := CheckNoPublicEgressSgr.Evaluate(&testState) - var found bool - for _, result := range results { - if result.Status() == scan.StatusFailed && result.Rule().LongID() == CheckNoPublicEgressSgr.LongID() { - found = true - } - } - if test.expected { - assert.True(t, found, "Rule should have been found") - } else { - assert.False(t, found, "Rule should not have been found") - } - }) - } -} diff --git a/checks/cloud/aws/ec2/no_public_ingress_acl.cf.go b/checks/cloud/aws/ec2/no_public_ingress_acl.cf.go deleted file mode 100644 index dd3f4882..00000000 --- a/checks/cloud/aws/ec2/no_public_ingress_acl.cf.go +++ /dev/null @@ -1,45 +0,0 @@ -package ec2 - -var cloudFormationNoPublicIngressAclGoodExamples = []string{ - `--- -AWSTemplateFormatVersion: 2010-09-09 -Description: Godd example of excessive ports -Resources: - NetworkACL: - Type: AWS::EC2::NetworkAcl - Properties: - VpcId: "something" - Rule: - Type: AWS::EC2::NetworkAclEntry - Properties: - NetworkAclId: - Ref: NetworkACL - Protocol: 6 - CidrBlock: 10.0.0.0/8 - RuleAction: allow -`, -} - -var cloudFormationNoPublicIngressAclBadExamples = []string{ - `--- -AWSTemplateFormatVersion: 2010-09-09 -Description: Bad example of excessive ports -Resources: - NetworkACL: - Type: AWS::EC2::NetworkAcl - Properties: - VpcId: "something" - Rule: - Type: AWS::EC2::NetworkAclEntry - Properties: - NetworkAclId: - Ref: NetworkACL - Protocol: 6 - CidrBlock: 0.0.0.0/0 - RuleAction: allow -`, -} - -var cloudFormationNoPublicIngressAclLinks = []string{} - -var cloudFormationNoPublicIngressAclRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/no_public_ingress_acl.go b/checks/cloud/aws/ec2/no_public_ingress_acl.go deleted file mode 100755 index b576d684..00000000 --- a/checks/cloud/aws/ec2/no_public_ingress_acl.go +++ /dev/null @@ -1,68 +0,0 @@ -package ec2 - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/ec2" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicIngress = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0105", - Aliases: []string{"aws-vpc-no-public-ingress-acl"}, - Provider: providers.AWSProvider, - Service: "ec2", - ShortCode: "no-public-ingress-acl", - Summary: "An ingress Network ACL rule allows specific ports from /0.", - Impact: "The ports are exposed for ingressing data to the internet", - Resolution: "Set a more restrictive cidr range", - Explanation: `Opening up ACLs to the public internet is potentially dangerous. You should restrict access to IP addresses or ranges that explicitly require it where possible.`, - Links: []string{ - "https://docs.aws.amazon.com/vpc/latest/userguide/vpc-network-acls.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicIngressAclGoodExamples, - BadExamples: terraformNoPublicIngressAclBadExamples, - Links: terraformNoPublicIngressAclLinks, - RemediationMarkdown: terraformNoPublicIngressAclRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationNoPublicIngressAclGoodExamples, - BadExamples: cloudFormationNoPublicIngressAclBadExamples, - Links: cloudFormationNoPublicIngressAclLinks, - RemediationMarkdown: cloudFormationNoPublicIngressAclRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, acl := range s.AWS.EC2.NetworkACLs { - for _, rule := range acl.Rules { - if !rule.Type.EqualTo(ec2.TypeIngress) { - continue - } - if !rule.Action.EqualTo(ec2.ActionAllow) { - continue - } - var fail bool - for _, block := range rule.CIDRs { - if cidr.IsPublic(block.Value()) && cidr.CountAddresses(block.Value()) > 1 { - fail = true - results.Add( - "Network ACL rule allows ingress from public internet.", - block, - ) - } - } - if !fail { - results.AddPassed(&rule) - } - } - } - return - }, -) diff --git a/checks/cloud/aws/ec2/no_public_ingress_acl.tf.go b/checks/cloud/aws/ec2/no_public_ingress_acl.tf.go deleted file mode 100644 index b6ef11c9..00000000 --- a/checks/cloud/aws/ec2/no_public_ingress_acl.tf.go +++ /dev/null @@ -1,33 +0,0 @@ -package ec2 - -var terraformNoPublicIngressAclGoodExamples = []string{ - ` - resource "aws_network_acl_rule" "good_example" { - egress = false - protocol = "tcp" - from_port = 22 - to_port = 22 - rule_action = "allow" - cidr_block = "10.0.0.0/16" - } - `, -} - -var terraformNoPublicIngressAclBadExamples = []string{ - ` - resource "aws_network_acl_rule" "bad_example" { - egress = false - protocol = "tcp" - from_port = 22 - to_port = 22 - rule_action = "allow" - cidr_block = "0.0.0.0/0" - } - `, -} - -var terraformNoPublicIngressAclLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_acl_rule#cidr_block`, -} - -var terraformNoPublicIngressAclRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/no_public_ingress_acl_test.go b/checks/cloud/aws/ec2/no_public_ingress_acl_test.go deleted file mode 100644 index dd5b7d95..00000000 --- a/checks/cloud/aws/ec2/no_public_ingress_acl_test.go +++ /dev/null @@ -1,84 +0,0 @@ -package ec2 - -import ( - "testing" - - trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types" - - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/ec2" - - "github.com/aquasecurity/trivy/pkg/iac/state" - - "github.com/aquasecurity/trivy/pkg/iac/scan" - - "github.com/stretchr/testify/assert" -) - -func TestCheckNoPublicIngress(t *testing.T) { - tests := []struct { - name string - input ec2.EC2 - expected bool - }{ - { - name: "AWS VPC network ACL rule with wildcard address", - input: ec2.EC2{ - NetworkACLs: []ec2.NetworkACL{ - { - Metadata: trivyTypes.NewTestMetadata(), - Rules: []ec2.NetworkACLRule{ - { - Metadata: trivyTypes.NewTestMetadata(), - Type: trivyTypes.String(ec2.TypeIngress, trivyTypes.NewTestMetadata()), - Action: trivyTypes.String(ec2.ActionAllow, trivyTypes.NewTestMetadata()), - CIDRs: []trivyTypes.StringValue{ - trivyTypes.String("0.0.0.0/0", trivyTypes.NewTestMetadata()), - }, - }, - }, - }, - }, - }, - expected: true, - }, - { - name: "AWS VPC network ACL rule with private address", - input: ec2.EC2{ - NetworkACLs: []ec2.NetworkACL{ - { - Metadata: trivyTypes.NewTestMetadata(), - Rules: []ec2.NetworkACLRule{ - { - Metadata: trivyTypes.NewTestMetadata(), - Type: trivyTypes.String(ec2.TypeIngress, trivyTypes.NewTestMetadata()), - Action: trivyTypes.String(ec2.ActionAllow, trivyTypes.NewTestMetadata()), - CIDRs: []trivyTypes.StringValue{ - trivyTypes.String("10.0.0.0/16", trivyTypes.NewTestMetadata()), - }, - }, - }, - }, - }, - }, - expected: false, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - var testState state.State - testState.AWS.EC2 = test.input - results := CheckNoPublicIngress.Evaluate(&testState) - var found bool - for _, result := range results { - if result.Status() == scan.StatusFailed && result.Rule().LongID() == CheckNoPublicIngress.LongID() { - found = true - } - } - if test.expected { - assert.True(t, found, "Rule should have been found") - } else { - assert.False(t, found, "Rule should not have been found") - } - }) - } -} diff --git a/checks/cloud/aws/ec2/no_public_ingress_sgr.cf.go b/checks/cloud/aws/ec2/no_public_ingress_sgr.cf.go deleted file mode 100644 index 03118337..00000000 --- a/checks/cloud/aws/ec2/no_public_ingress_sgr.cf.go +++ /dev/null @@ -1,31 +0,0 @@ -package ec2 - -var cloudFormationNoPublicIngressSgrGoodExamples = []string{ - `--- -Resources: - GoodSecurityGroup: - Type: AWS::EC2::SecurityGroup - Properties: - GroupDescription: Limits security group egress traffic - SecurityGroupIngress: - - CidrIp: 127.0.0.1/32 - IpProtocol: "6" -`, -} - -var cloudFormationNoPublicIngressSgrBadExamples = []string{ - `--- -Resources: - BadSecurityGroup: - Type: AWS::EC2::SecurityGroup - Properties: - GroupDescription: Limits security group egress traffic - SecurityGroupIngress: - - CidrIp: 0.0.0.0/0 - IpProtocol: "6" -`, -} - -var cloudFormationNoPublicIngressSgrLinks = []string{} - -var cloudFormationNoPublicIngressSgrRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/no_public_ingress_sgr.go b/checks/cloud/aws/ec2/no_public_ingress_sgr.go deleted file mode 100755 index fa2fb6c1..00000000 --- a/checks/cloud/aws/ec2/no_public_ingress_sgr.go +++ /dev/null @@ -1,66 +0,0 @@ -package ec2 - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicIngressSgr = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0107", - Aliases: []string{"aws-vpc-no-public-ingress-sgr"}, - Provider: providers.AWSProvider, - Service: "ec2", - ShortCode: "no-public-ingress-sgr", - Frameworks: map[framework.Framework][]string{ - framework.Default: nil, - framework.CIS_AWS_1_2: {"4.1", "4.2"}, - }, - Summary: "An ingress security group rule allows traffic from /0.", - Impact: "Your port exposed to the internet", - Resolution: "Set a more restrictive cidr range", - Explanation: `Opening up ports to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that explicitly require it where possible.`, - Links: []string{ - "https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/security-group-rules-reference.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicIngressSgrGoodExamples, - BadExamples: terraformNoPublicIngressSgrBadExamples, - Links: terraformNoPublicIngressSgrLinks, - RemediationMarkdown: terraformNoPublicIngressSgrRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationNoPublicIngressSgrGoodExamples, - BadExamples: cloudFormationNoPublicIngressSgrBadExamples, - Links: cloudFormationNoPublicIngressSgrLinks, - RemediationMarkdown: cloudFormationNoPublicIngressSgrRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.AWS.EC2.SecurityGroups { - for _, rule := range group.IngressRules { - var failed bool - for _, block := range rule.CIDRs { - if cidr.IsPublic(block.Value()) && cidr.CountAddresses(block.Value()) > 1 { - failed = true - results.Add( - "Security group rule allows ingress from public internet.", - block, - ) - } - } - if !failed { - results.AddPassed(&rule) - } - } - } - return - }, -) diff --git a/checks/cloud/aws/ec2/no_public_ingress_sgr.tf.go b/checks/cloud/aws/ec2/no_public_ingress_sgr.tf.go deleted file mode 100644 index e5d68d5d..00000000 --- a/checks/cloud/aws/ec2/no_public_ingress_sgr.tf.go +++ /dev/null @@ -1,38 +0,0 @@ -package ec2 - -var terraformNoPublicIngressSgrGoodExamples = []string{ - ` - resource "aws_security_group_rule" "good_example" { - type = "ingress" - cidr_blocks = ["10.0.0.0/16"] - } - `, - ` -resource "aws_security_group_rule" "allow_partner_rsync" { - type = "ingress" - security_group_id = aws_security_group.….id - from_port = 22 - to_port = 22 - protocol = "tcp" - cidr_blocks = [ - "1.2.3.4/32", - "4.5.6.7/32", - ] -} -`, -} - -var terraformNoPublicIngressSgrBadExamples = []string{ - ` - resource "aws_security_group_rule" "bad_example" { - type = "ingress" - cidr_blocks = ["0.0.0.0/0"] - } - `, -} - -var terraformNoPublicIngressSgrLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule#cidr_blocks`, -} - -var terraformNoPublicIngressSgrRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/no_public_ip.cf.go b/checks/cloud/aws/ec2/no_public_ip.cf.go deleted file mode 100644 index 8f5a0908..00000000 --- a/checks/cloud/aws/ec2/no_public_ip.cf.go +++ /dev/null @@ -1,28 +0,0 @@ -package ec2 - -var cloudFormationNoPublicIpGoodExamples = []string{ - `--- -Resources: - GoodExample: - Properties: - ImageId: ami-123456 - InstanceType: t2.small - Type: AWS::AutoScaling::LaunchConfiguration -`, -} - -var cloudFormationNoPublicIpBadExamples = []string{ - `--- -Resources: - BadExample: - Properties: - AssociatePublicIpAddress: true - ImageId: ami-123456 - InstanceType: t2.small - Type: AWS::AutoScaling::LaunchConfiguration -`, -} - -var cloudFormationNoPublicIpLinks = []string{} - -var cloudFormationNoPublicIpRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/no_public_ip.go b/checks/cloud/aws/ec2/no_public_ip.go deleted file mode 100755 index 66b771fe..00000000 --- a/checks/cloud/aws/ec2/no_public_ip.go +++ /dev/null @@ -1,53 +0,0 @@ -package ec2 - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicIp = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0009", - Aliases: []string{"aws-autoscaling-no-public-ip"}, - Provider: providers.AWSProvider, - Service: "ec2", - ShortCode: "no-public-ip", - Summary: "Launch configuration should not have a public IP address.", - Impact: "The instance or configuration is publicly accessible", - Resolution: "Set the instance to not be publicly accessible", - Explanation: `You should limit the provision of public IP addresses for resources. Resources should not be exposed on the public internet, but should have access limited to consumers required for the function of your application.`, - Links: []string{ - "https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicIpGoodExamples, - BadExamples: terraformNoPublicIpBadExamples, - Links: terraformNoPublicIpLinks, - RemediationMarkdown: terraformNoPublicIpRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationNoPublicIpGoodExamples, - BadExamples: cloudFormationNoPublicIpBadExamples, - Links: cloudFormationNoPublicIpLinks, - RemediationMarkdown: cloudFormationNoPublicIpRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, launchConfig := range s.AWS.EC2.LaunchConfigurations { - if launchConfig.AssociatePublicIP.IsTrue() { - results.Add( - "Launch configuration associates public IP address.", - launchConfig.AssociatePublicIP, - ) - } else { - results.AddPassed(&launchConfig) - } - } - return - }, -) diff --git a/checks/cloud/aws/ec2/no_public_ip.tf.go b/checks/cloud/aws/ec2/no_public_ip.tf.go deleted file mode 100644 index 712ac6d3..00000000 --- a/checks/cloud/aws/ec2/no_public_ip.tf.go +++ /dev/null @@ -1,23 +0,0 @@ -package ec2 - -var terraformNoPublicIpGoodExamples = []string{ - ` - resource "aws_launch_configuration" "good_example" { - associate_public_ip_address = false - } - `, -} - -var terraformNoPublicIpBadExamples = []string{ - ` - resource "aws_launch_configuration" "bad_example" { - associate_public_ip_address = true - } - `, -} - -var terraformNoPublicIpLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_configuration#associate_public_ip_address`, `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#associate_public_ip_address`, -} - -var terraformNoPublicIpRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/no_public_ip_subnet.cf.go b/checks/cloud/aws/ec2/no_public_ip_subnet.cf.go deleted file mode 100644 index bef77573..00000000 --- a/checks/cloud/aws/ec2/no_public_ip_subnet.cf.go +++ /dev/null @@ -1,26 +0,0 @@ -package ec2 - -var cloudFormationNoPublicIpSubnetGoodExamples = []string{ - `--- -Resources: - GoodExample: - Properties: - VpcId: vpc-123456 - Type: AWS::EC2::Subnet -`, -} - -var cloudFormationNoPublicIpSubnetBadExamples = []string{ - `--- -Resources: - BadExample: - Properties: - MapPublicIpOnLaunch: true - VpcId: vpc-123456 - Type: AWS::EC2::Subnet -`, -} - -var cloudFormationNoPublicIpSubnetLinks = []string{} - -var cloudFormationNoPublicIpSubnetRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/no_public_ip_subnet.go b/checks/cloud/aws/ec2/no_public_ip_subnet.go deleted file mode 100755 index 3663ce5c..00000000 --- a/checks/cloud/aws/ec2/no_public_ip_subnet.go +++ /dev/null @@ -1,53 +0,0 @@ -package ec2 - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicIpSubnet = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0164", - Aliases: []string{"aws-subnet-no-public-ip"}, - Provider: providers.AWSProvider, - Service: "ec2", - ShortCode: "no-public-ip-subnet", - Summary: "Instances in a subnet should not receive a public IP address by default.", - Impact: "The instance is publicly accessible", - Resolution: "Set the instance to not be publicly accessible", - Explanation: `You should limit the provision of public IP addresses for resources. Resources should not be exposed on the public internet, but should have access limited to consumers required for the function of your application.`, - Links: []string{ - "https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html#concepts-public-addresses", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicIpSubnetGoodExamples, - BadExamples: terraformNoPublicIpSubnetBadExamples, - Links: terraformNoPublicIpSubnetLinks, - RemediationMarkdown: terraformNoPublicIpSubnetRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationNoPublicIpSubnetGoodExamples, - BadExamples: cloudFormationNoPublicIpSubnetBadExamples, - Links: cloudFormationNoPublicIpSubnetLinks, - RemediationMarkdown: cloudFormationNoPublicIpSubnetRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, subnet := range s.AWS.EC2.Subnets { - if subnet.MapPublicIpOnLaunch.IsTrue() { - results.Add( - "Subnet associates public IP address.", - subnet.MapPublicIpOnLaunch, - ) - } else { - results.AddPassed(&subnet) - } - } - return - }, -) diff --git a/checks/cloud/aws/ec2/no_public_ip_subnet.tf.go b/checks/cloud/aws/ec2/no_public_ip_subnet.tf.go deleted file mode 100644 index 3e3bb8a2..00000000 --- a/checks/cloud/aws/ec2/no_public_ip_subnet.tf.go +++ /dev/null @@ -1,25 +0,0 @@ -package ec2 - -var terraformNoPublicIpSubnetGoodExamples = []string{ - ` - resource "aws_subnet" "good_example" { - vpc_id = "vpc-123456" - map_public_ip_on_launch = false - } - `, -} - -var terraformNoPublicIpSubnetBadExamples = []string{ - ` - resource "aws_subnet" "bad_example" { - vpc_id = "vpc-123456" - map_public_ip_on_launch = true - } - `, -} - -var terraformNoPublicIpSubnetLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet#map_public_ip_on_launch`, -} - -var terraformNoPublicIpSubnetRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/no_secrets_in_user_data.cf.go b/checks/cloud/aws/ec2/no_secrets_in_user_data.cf.go deleted file mode 100644 index 6daf1ffd..00000000 --- a/checks/cloud/aws/ec2/no_secrets_in_user_data.cf.go +++ /dev/null @@ -1,47 +0,0 @@ -package ec2 - -var cloudFormationNoSecretsInUserDataGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::EC2::Instance - Properties: - ImageId: "ami-79fd7eee" - KeyName: "testkey" - UserData: export SSM_PATH=/database/creds - BlockDeviceMappings: - - DeviceName: "/dev/sdm" - Ebs: - VolumeType: "io1" - Iops: "200" - DeleteOnTermination: "false" - VolumeSize: "20" - - DeviceName: "/dev/sdk" - -`, -} - -var cloudFormationNoSecretsInUserDataBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::EC2::Instance - Properties: - ImageId: "ami-79fd7eee" - KeyName: "testkey" - UserData: export DATABASE_PASSWORD=password1234 - BlockDeviceMappings: - - DeviceName: "/dev/sdm" - Ebs: - VolumeType: "io1" - Iops: "200" - DeleteOnTermination: "false" - VolumeSize: "20" - - DeviceName: "/dev/sdk" - -`, -} - -var cloudFormationNoSecretsInUserDataLinks = []string{} - -var cloudFormationNoSecretsInUserDataRemediationMarkdown = `` diff --git a/checks/cloud/aws/ec2/no_secrets_in_user_data.go b/checks/cloud/aws/ec2/no_secrets_in_user_data.go deleted file mode 100755 index c43d15c0..00000000 --- a/checks/cloud/aws/ec2/no_secrets_in_user_data.go +++ /dev/null @@ -1,61 +0,0 @@ -package ec2 - -import ( - "fmt" - - "github.com/aquasecurity/trivy/pkg/iac/severity" - - "github.com/aquasecurity/trivy/pkg/iac/state" - - "github.com/aquasecurity/trivy/pkg/iac/scan" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - - "github.com/aquasecurity/trivy/pkg/iac/providers" -) - -var CheckNoSecretsInUserData = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0029", - Provider: providers.AWSProvider, - Service: "ec2", - ShortCode: "no-secrets-in-user-data", - Summary: "User data for EC2 instances must not contain sensitive AWS keys", - Impact: "User data is visible through the AWS Management console", - Resolution: "Remove sensitive data from the EC2 instance user-data", - Explanation: `EC2 instance data is used to pass start up information into the EC2 instance. This userdata must not contain access key credentials. Instead use an IAM Instance Profile assigned to the instance to grant access to other AWS Services.`, - Links: []string{ - "https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-add-user-data.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoSecretsInUserDataGoodExamples, - BadExamples: terraformNoSecretsInUserDataBadExamples, - Links: terraformNoSecretsInUserDataLinks, - RemediationMarkdown: terraformNoSecretsInUserDataRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationNoSecretsInUserDataGoodExamples, - BadExamples: cloudFormationNoSecretsInUserDataBadExamples, - Links: cloudFormationNoSecretsInUserDataLinks, - RemediationMarkdown: cloudFormationNoSecretsInUserDataRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.AWS.EC2.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if result := scanner.Scan(instance.UserData.Value()); result.TransgressionFound { - results.Add( - fmt.Sprintf("Sensitive data found in instance user data: %s", result.Description), - instance.UserData, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/aws/ec2/no_secrets_in_user_data.tf.go b/checks/cloud/aws/ec2/no_secrets_in_user_data.tf.go deleted file mode 100644 index befb61c9..00000000 --- a/checks/cloud/aws/ec2/no_secrets_in_user_data.tf.go +++ /dev/null @@ -1,42 +0,0 @@ -package ec2 - -var terraformNoSecretsInUserDataGoodExamples = []string{ - ` - resource "aws_iam_instance_profile" "good_example" { - // ... - } - - resource "aws_instance" "good_example" { - ami = "ami-12345667" - instance_type = "t2.small" - - iam_instance_profile = aws_iam_instance_profile.good_profile.arn - - user_data = < 0 || len(sg.EgressRules) > 0 { - results.Add( - "Default security group for VPC has ingress or egress rules.", - &vpc, - ) - } - } else { - results.AddPassed(&vpc) - } - } - } - return - }, -) diff --git a/checks/cloud/aws/ecr/enable_image_scans.cf.go b/checks/cloud/aws/ecr/enable_image_scans.cf.go deleted file mode 100644 index 94f292f7..00000000 --- a/checks/cloud/aws/ecr/enable_image_scans.cf.go +++ /dev/null @@ -1,33 +0,0 @@ -package ecr - -var cloudFormationEnableImageScansGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::ECR::Repository - Properties: - RepositoryName: "test-repository" - ImageTagImmutability: IMMUTABLE - ImageScanningConfiguration: - ScanOnPush: True - EncryptionConfiguration: - EncryptionType: KMS - KmsKey: "alias/ecr-key" -`, -} - -var cloudFormationEnableImageScansBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::ECR::Repository - Properties: - RepositoryName: "test-repository" - ImageScanningConfiguration: - ScanOnPush: False -`, -} - -var cloudFormationEnableImageScansLinks = []string{} - -var cloudFormationEnableImageScansRemediationMarkdown = `` diff --git a/checks/cloud/aws/ecr/enable_image_scans.go b/checks/cloud/aws/ecr/enable_image_scans.go deleted file mode 100755 index 1eae943c..00000000 --- a/checks/cloud/aws/ecr/enable_image_scans.go +++ /dev/null @@ -1,52 +0,0 @@ -package ecr - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableImageScans = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0030", - Provider: providers.AWSProvider, - Service: "ecr", - ShortCode: "enable-image-scans", - Summary: "ECR repository has image scans disabled.", - Impact: "The ability to scan images is not being used and vulnerabilities will not be highlighted", - Resolution: "Enable ECR image scanning", - Explanation: `Repository image scans should be enabled to ensure vulnerable software can be discovered and remediated as soon as possible.`, - Links: []string{ - "https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-scanning.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableImageScansGoodExamples, - BadExamples: terraformEnableImageScansBadExamples, - Links: terraformEnableImageScansLinks, - RemediationMarkdown: terraformEnableImageScansRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnableImageScansGoodExamples, - BadExamples: cloudFormationEnableImageScansBadExamples, - Links: cloudFormationEnableImageScansLinks, - RemediationMarkdown: cloudFormationEnableImageScansRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, repo := range s.AWS.ECR.Repositories { - if repo.ImageScanning.ScanOnPush.IsFalse() { - results.Add( - "Image scanning is not enabled.", - repo.ImageScanning.ScanOnPush, - ) - } else { - results.AddPassed(&repo) - } - } - return - }, -) diff --git a/checks/cloud/aws/ecr/enable_image_scans.tf.go b/checks/cloud/aws/ecr/enable_image_scans.tf.go deleted file mode 100644 index cba9dd29..00000000 --- a/checks/cloud/aws/ecr/enable_image_scans.tf.go +++ /dev/null @@ -1,33 +0,0 @@ -package ecr - -var terraformEnableImageScansGoodExamples = []string{ - ` - resource "aws_ecr_repository" "good_example" { - name = "bar" - image_tag_mutability = "MUTABLE" - - image_scanning_configuration { - scan_on_push = true - } - } - `, -} - -var terraformEnableImageScansBadExamples = []string{ - ` - resource "aws_ecr_repository" "bad_example" { - name = "bar" - image_tag_mutability = "MUTABLE" - - image_scanning_configuration { - scan_on_push = false - } - } - `, -} - -var terraformEnableImageScansLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_repository#image_scanning_configuration`, -} - -var terraformEnableImageScansRemediationMarkdown = `` diff --git a/checks/cloud/aws/ecr/enforce_immutable_repository.cf.go b/checks/cloud/aws/ecr/enforce_immutable_repository.cf.go deleted file mode 100644 index bb9b8d08..00000000 --- a/checks/cloud/aws/ecr/enforce_immutable_repository.cf.go +++ /dev/null @@ -1,33 +0,0 @@ -package ecr - -var cloudFormationEnforceImmutableRepositoryGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::ECR::Repository - Properties: - RepositoryName: "test-repository" - ImageTagMutability: IMMUTABLE - ImageScanningConfiguration: - ScanOnPush: false - EncryptionConfiguration: - EncryptionType: KMS - KmsKey: "alias/ecr-key" -`, -} - -var cloudFormationEnforceImmutableRepositoryBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::ECR::Repository - Properties: - RepositoryName: "test-repository" - ImageScanningConfiguration: - ScanOnPush: false -`, -} - -var cloudFormationEnforceImmutableRepositoryLinks = []string{} - -var cloudFormationEnforceImmutableRepositoryRemediationMarkdown = `` diff --git a/checks/cloud/aws/ecr/enforce_immutable_repository.go b/checks/cloud/aws/ecr/enforce_immutable_repository.go deleted file mode 100755 index 6ceedf34..00000000 --- a/checks/cloud/aws/ecr/enforce_immutable_repository.go +++ /dev/null @@ -1,54 +0,0 @@ -package ecr - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnforceImmutableRepository = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0031", - Provider: providers.AWSProvider, - Service: "ecr", - ShortCode: "enforce-immutable-repository", - Summary: "ECR images tags shouldn't be mutable.", - Impact: "Image tags could be overwritten with compromised images", - Resolution: "Only use immutable images in ECR", - Explanation: `ECR images should be set to IMMUTABLE to prevent code injection through image mutation. - -This can be done by setting image_tag_mutability to IMMUTABLE`, - Links: []string{ - "https://sysdig.com/blog/toctou-tag-mutability/", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnforceImmutableRepositoryGoodExamples, - BadExamples: terraformEnforceImmutableRepositoryBadExamples, - Links: terraformEnforceImmutableRepositoryLinks, - RemediationMarkdown: terraformEnforceImmutableRepositoryRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnforceImmutableRepositoryGoodExamples, - BadExamples: cloudFormationEnforceImmutableRepositoryBadExamples, - Links: cloudFormationEnforceImmutableRepositoryLinks, - RemediationMarkdown: cloudFormationEnforceImmutableRepositoryRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, repo := range s.AWS.ECR.Repositories { - if repo.ImageTagsImmutable.IsFalse() { - results.Add( - "Repository tags are mutable.", - repo.ImageTagsImmutable, - ) - } else { - results.AddPassed(&repo) - } - } - return - }, -) diff --git a/checks/cloud/aws/ecr/enforce_immutable_repository.tf.go b/checks/cloud/aws/ecr/enforce_immutable_repository.tf.go deleted file mode 100644 index 8ef2935e..00000000 --- a/checks/cloud/aws/ecr/enforce_immutable_repository.tf.go +++ /dev/null @@ -1,33 +0,0 @@ -package ecr - -var terraformEnforceImmutableRepositoryGoodExamples = []string{ - ` - resource "aws_ecr_repository" "good_example" { - name = "bar" - image_tag_mutability = "IMMUTABLE" - - image_scanning_configuration { - scan_on_push = true - } - } - `, -} - -var terraformEnforceImmutableRepositoryBadExamples = []string{ - ` - resource "aws_ecr_repository" "bad_example" { - name = "bar" - image_tag_mutability = "MUTABLE" - - image_scanning_configuration { - scan_on_push = true - } - } - `, -} - -var terraformEnforceImmutableRepositoryLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecr_repository`, -} - -var terraformEnforceImmutableRepositoryRemediationMarkdown = `` diff --git a/checks/cloud/aws/ecr/no_public_access.cf.go b/checks/cloud/aws/ecr/no_public_access.cf.go deleted file mode 100644 index ac3f6ec8..00000000 --- a/checks/cloud/aws/ecr/no_public_access.cf.go +++ /dev/null @@ -1,67 +0,0 @@ -package ecr - -var cloudFormationNoPublicAccessGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::ECR::Repository - Properties: - RepositoryName: "test-repository" - ImageTagImmutability: IMMUTABLE - ImageScanningConfiguration: - ScanOnPush: false - EncryptionConfiguration: - EncryptionType: KMS - KmsKey: "alias/ecr-key" - RepositoryPolicyText: - Version: "2012-10-17" - Statement: - - - Sid: AllowPushPull - Effect: Allow - Principal: - AWS: - - "arn:aws:iam::123456789012:user/Alice" - Action: - - "ecr:GetDownloadUrlForLayer" - - "ecr:BatchGetImage" - - "ecr:BatchCheckLayerAvailability" - - "ecr:PutImage" - - "ecr:InitiateLayerUpload" - - "ecr:UploadLayerPart" - - "ecr:CompleteLayerUpload" -`, -} - -var cloudFormationNoPublicAccessBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::ECR::Repository - Properties: - RepositoryName: "test-repository" - ImageScanningConfiguration: - ScanOnPush: false - RepositoryPolicyText: - Version: "2012-10-17" - Statement: - - - Sid: AllowPushPull - Effect: Allow - Principal: - AWS: - - "*" - Action: - - "ecr:GetDownloadUrlForLayer" - - "ecr:BatchGetImage" - - "ecr:BatchCheckLayerAvailability" - - "ecr:PutImage" - - "ecr:InitiateLayerUpload" - - "ecr:UploadLayerPart" - - "ecr:CompleteLayerUpload" -`, -} - -var cloudFormationNoPublicAccessLinks = []string{} - -var cloudFormationNoPublicAccessRemediationMarkdown = `` diff --git a/checks/cloud/aws/ecr/no_public_access.go b/checks/cloud/aws/ecr/no_public_access.go deleted file mode 100755 index 06139428..00000000 --- a/checks/cloud/aws/ecr/no_public_access.go +++ /dev/null @@ -1,94 +0,0 @@ -package ecr - -import ( - "strings" - - "github.com/aquasecurity/trivy/pkg/iac/severity" - - "github.com/aquasecurity/trivy/pkg/iac/state" - - "github.com/aquasecurity/trivy/pkg/iac/scan" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - - "github.com/aquasecurity/trivy/pkg/iac/providers" -) - -var CheckNoPublicAccess = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0032", - Provider: providers.AWSProvider, - Service: "ecr", - ShortCode: "no-public-access", - Summary: "ECR repository policy must block public access", - Impact: "Risk of potential data leakage of sensitive artifacts", - Resolution: "Do not allow public access in the policy", - Explanation: `Allowing public access to the ECR repository risks leaking sensitive of abusable information`, - Links: []string{ - "https://docs.aws.amazon.com/AmazonECR/latest/public/public-repository-policies.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicAccessGoodExamples, - BadExamples: terraformNoPublicAccessBadExamples, - Links: terraformNoPublicAccessLinks, - RemediationMarkdown: terraformNoPublicAccessRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationNoPublicAccessGoodExamples, - BadExamples: cloudFormationNoPublicAccessBadExamples, - Links: cloudFormationNoPublicAccessLinks, - RemediationMarkdown: cloudFormationNoPublicAccessRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, repo := range s.AWS.ECR.Repositories { - if repo.Metadata.IsUnmanaged() { - continue - } - for _, policyDocument := range repo.Policies { - policy := policyDocument.Document.Parsed - statements, _ := policy.Statements() - for _, statement := range statements { - var hasECRAction bool - actions, _ := statement.Actions() - for _, action := range actions { - if strings.HasPrefix(action, "ecr:") { - hasECRAction = true - break - } - } - if !hasECRAction { - continue - } - var foundIssue bool - principals, _ := statement.Principals() - if all, r := principals.All(); all { - foundIssue = true - results.Add( - "Policy provides public access to the ECR repository.", - policyDocument.Document.MetadataFromIamGo(statement.Range(), r), - ) - } else { - accounts, r := principals.AWS() - for _, account := range accounts { - if account == "*" { - foundIssue = true - results.Add( - "Policy provides public access to the ECR repository.", - policyDocument.Document.MetadataFromIamGo(statement.Range(), r), - ) - } - continue - } - } - if foundIssue { - results.AddPassed(&repo) - } - } - } - } - return - }, -) diff --git a/checks/cloud/aws/ecr/no_public_access.tf.go b/checks/cloud/aws/ecr/no_public_access.tf.go deleted file mode 100644 index 27ddea04..00000000 --- a/checks/cloud/aws/ecr/no_public_access.tf.go +++ /dev/null @@ -1,89 +0,0 @@ -package ecr - -var terraformNoPublicAccessGoodExamples = []string{ - ` - resource "aws_ecr_repository" "foo" { - name = "bar" - } - - resource "aws_ecr_repository_policy" "foopolicy" { - repository = aws_ecr_repository.foo.name - - policy = <- - arn:aws:iam::012345678910:role/eks-service-role-good-example - EncryptionConfig: - Provider: - KeyArn: alias/eks-kms - Resources: - - secrets - ResourcesVpcConfig: - SecurityGroupIds: - - sg-6979fe18 - SubnetIds: - - subnet-6782e71e - - subnet-e7e761ac -`, -} - -var cloudFormationEncryptSecretsBadExamples = []string{ - `--- -Resources: - BadExample: - Type: 'AWS::EKS::Cluster' - Properties: - Name: badExample - Version: '1.14' - RoleArn: >- - arn:aws:iam::012345678910:role/eks-service-role-bad-example - ResourcesVpcConfig: - SecurityGroupIds: - - sg-6979fe18 - SubnetIds: - - subnet-6782e71e - - subnet-e7e761ac -`, -} - -var cloudFormationEncryptSecretsLinks = []string{} - -var cloudFormationEncryptSecretsRemediationMarkdown = `` diff --git a/checks/cloud/aws/eks/encrypt_secrets.go b/checks/cloud/aws/eks/encrypt_secrets.go deleted file mode 100755 index d70739ed..00000000 --- a/checks/cloud/aws/eks/encrypt_secrets.go +++ /dev/null @@ -1,57 +0,0 @@ -package eks - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEncryptSecrets = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0039", - Provider: providers.AWSProvider, - Service: "eks", - ShortCode: "encrypt-secrets", - Summary: "EKS should have the encryption of secrets enabled", - Impact: "EKS secrets could be read if compromised", - Resolution: "Enable encryption of EKS secrets", - Explanation: `EKS cluster resources should have the encryption_config block set with protection of the secrets resource.`, - Links: []string{ - "https://aws.amazon.com/about-aws/whats-new/2020/03/amazon-eks-adds-envelope-encryption-for-secrets-with-aws-kms/", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEncryptSecretsGoodExamples, - BadExamples: terraformEncryptSecretsBadExamples, - Links: terraformEncryptSecretsLinks, - RemediationMarkdown: terraformEncryptSecretsRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEncryptSecretsGoodExamples, - BadExamples: cloudFormationEncryptSecretsBadExamples, - Links: cloudFormationEncryptSecretsLinks, - RemediationMarkdown: cloudFormationEncryptSecretsRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.AWS.EKS.Clusters { - if cluster.Encryption.Secrets.IsFalse() { - results.Add( - "Cluster does not have secret encryption enabled.", - cluster.Encryption.Secrets, - ) - } else if cluster.Encryption.KMSKeyID.IsEmpty() { - results.Add( - "Cluster encryption requires a KMS key ID, which is missing", - cluster.Encryption.KMSKeyID, - ) - } else { - results.AddPassed(&cluster) - } - } - return - }, -) diff --git a/checks/cloud/aws/eks/encrypt_secrets.tf.go b/checks/cloud/aws/eks/encrypt_secrets.tf.go deleted file mode 100644 index 07a4867d..00000000 --- a/checks/cloud/aws/eks/encrypt_secrets.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package eks - -var terraformEncryptSecretsGoodExamples = []string{ - ` - resource "aws_eks_cluster" "good_example" { - encryption_config { - resources = [ "secrets" ] - provider { - key_arn = var.kms_arn - } - } - - name = "good_example_cluster" - role_arn = var.cluster_arn - vpc_config { - endpoint_public_access = false - } - } - `, -} - -var terraformEncryptSecretsBadExamples = []string{ - ` - resource "aws_eks_cluster" "bad_example" { - name = "bad_example_cluster" - - role_arn = var.cluster_arn - vpc_config { - endpoint_public_access = false - } - } - `, -} - -var terraformEncryptSecretsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_cluster#encryption_config`, -} - -var terraformEncryptSecretsRemediationMarkdown = `` diff --git a/checks/cloud/aws/eks/no_public_cluster_access.go b/checks/cloud/aws/eks/no_public_cluster_access.go deleted file mode 100755 index 8c79c344..00000000 --- a/checks/cloud/aws/eks/no_public_cluster_access.go +++ /dev/null @@ -1,46 +0,0 @@ -package eks - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicClusterAccess = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0040", - Provider: providers.AWSProvider, - Service: "eks", - ShortCode: "no-public-cluster-access", - Summary: "EKS Clusters should have the public access disabled", - Impact: "EKS can be access from the internet", - Resolution: "Don't enable public access to EKS Clusters", - Explanation: `EKS clusters are available publicly by default, this should be explicitly disabled in the vpc_config of the EKS cluster resource.`, - Links: []string{ - "https://docs.aws.amazon.com/eks/latest/userguide/cluster-endpoint.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicClusterAccessGoodExamples, - BadExamples: terraformNoPublicClusterAccessBadExamples, - Links: terraformNoPublicClusterAccessLinks, - RemediationMarkdown: terraformNoPublicClusterAccessRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.AWS.EKS.Clusters { - if cluster.PublicAccessEnabled.IsTrue() { - results.Add( - "Public cluster access is enabled.", - cluster.PublicAccessEnabled, - ) - } else { - results.AddPassed(&cluster) - } - } - return - }, -) diff --git a/checks/cloud/aws/eks/no_public_cluster_access.tf.go b/checks/cloud/aws/eks/no_public_cluster_access.tf.go deleted file mode 100644 index af4369e3..00000000 --- a/checks/cloud/aws/eks/no_public_cluster_access.tf.go +++ /dev/null @@ -1,36 +0,0 @@ -package eks - -var terraformNoPublicClusterAccessGoodExamples = []string{ - ` - resource "aws_eks_cluster" "good_example" { - // other config - - name = "good_example_cluster" - role_arn = var.cluster_arn - vpc_config { - endpoint_public_access = false - } - } - `, -} - -var terraformNoPublicClusterAccessBadExamples = []string{ - ` - resource "aws_eks_cluster" "bad_example" { - // other config - - name = "bad_example_cluster" - role_arn = var.cluster_arn - vpc_config { - endpoint_public_access = true - public_access_cidrs = ["0.0.0.0/0"] - } - } - `, -} - -var terraformNoPublicClusterAccessLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_cluster#endpoint_public_access`, -} - -var terraformNoPublicClusterAccessRemediationMarkdown = `` diff --git a/checks/cloud/aws/eks/no_public_cluster_access_to_cidr.go b/checks/cloud/aws/eks/no_public_cluster_access_to_cidr.go deleted file mode 100755 index 8e1f6a20..00000000 --- a/checks/cloud/aws/eks/no_public_cluster_access_to_cidr.go +++ /dev/null @@ -1,59 +0,0 @@ -package eks - -import ( - "fmt" - - "github.com/aquasecurity/trivy/pkg/iac/severity" - - "github.com/aquasecurity/trivy/pkg/iac/state" - - "github.com/aquasecurity/trivy/pkg/iac/scan" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - - "github.com/aquasecurity/trivy-checks/internal/cidr" - - "github.com/aquasecurity/trivy/pkg/iac/providers" -) - -var CheckNoPublicClusterAccessToCidr = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0041", - Provider: providers.AWSProvider, - Service: "eks", - ShortCode: "no-public-cluster-access-to-cidr", - Summary: "EKS cluster should not have open CIDR range for public access", - Impact: "EKS can be accessed from the internet", - Resolution: "Don't enable public access to EKS Clusters", - Explanation: `EKS Clusters have public access cidrs set to 0.0.0.0/0 by default which is wide open to the internet. This should be explicitly set to a more specific private CIDR range`, - Links: []string{ - "https://docs.aws.amazon.com/eks/latest/userguide/create-public-private-vpc.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicClusterAccessToCidrGoodExamples, - BadExamples: terraformNoPublicClusterAccessToCidrBadExamples, - Links: terraformNoPublicClusterAccessToCidrLinks, - RemediationMarkdown: terraformNoPublicClusterAccessToCidrRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.AWS.EKS.Clusters { - if cluster.PublicAccessEnabled.IsFalse() { - continue - } - for _, accessCidr := range cluster.PublicAccessCIDRs { - if cidr.IsPublic(accessCidr.Value()) { - results.Add( - fmt.Sprintf("Cluster allows access from a public CIDR: %s.", accessCidr.Value()), - accessCidr, - ) - } else { - results.AddPassed(&cluster) - } - } - } - return - }, -) diff --git a/checks/cloud/aws/eks/no_public_cluster_access_to_cidr.tf.go b/checks/cloud/aws/eks/no_public_cluster_access_to_cidr.tf.go deleted file mode 100644 index 095775a6..00000000 --- a/checks/cloud/aws/eks/no_public_cluster_access_to_cidr.tf.go +++ /dev/null @@ -1,36 +0,0 @@ -package eks - -var terraformNoPublicClusterAccessToCidrGoodExamples = []string{ - ` - resource "aws_eks_cluster" "good_example" { - // other config - - name = "good_example_cluster" - role_arn = var.cluster_arn - vpc_config { - endpoint_public_access = true - public_access_cidrs = ["10.2.0.0/8"] - } - } - `, -} - -var terraformNoPublicClusterAccessToCidrBadExamples = []string{ - ` - resource "aws_eks_cluster" "bad_example" { - // other config - - name = "bad_example_cluster" - role_arn = var.cluster_arn - vpc_config { - endpoint_public_access = true - } - } - `, -} - -var terraformNoPublicClusterAccessToCidrLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_cluster#vpc_config`, -} - -var terraformNoPublicClusterAccessToCidrRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticache/add_description_for_security_group.cf.go b/checks/cloud/aws/elasticache/add_description_for_security_group.cf.go deleted file mode 100644 index 4eb18124..00000000 --- a/checks/cloud/aws/elasticache/add_description_for_security_group.cf.go +++ /dev/null @@ -1,46 +0,0 @@ -package elasticache - -var cloudFormationAddDescriptionForSecurityGroupGoodExamples = []string{ - `--- -Resources: - GoodExampleCacheGroup: - Type: AWS::ElastiCache::SecurityGroup - Properties: - Description: Some description - GoodExampleEc2SecurityGroup: - Type: AWS::EC2::SecurityGroup - Properties: - GroupName: GoodExample - GroupDescription: Good Elasticache Security Group - GoodSecurityGroupIngress: - Type: AWS::ElastiCache::SecurityGroupIngress - Properties: - CacheSecurityGroupName: GoodExampleCacheGroup - EC2SecurityGroupName: GoodExampleEc2SecurityGroup -`, -} - -var cloudFormationAddDescriptionForSecurityGroupBadExamples = []string{ - `--- -Resources: - BadExampleCacheGroup: - Type: AWS::ElastiCache::SecurityGroup - Properties: - Tags: - - Name: BadExample - BadExampleEc2SecurityGroup: - Type: AWS::EC2::SecurityGroup - Properties: - GroupName: BadExample - GroupDescription: Bad Elasticache Security Group - BadSecurityGroupIngress: - Type: AWS::ElastiCache::SecurityGroupIngress - Properties: - CacheSecurityGroupName: BadExampleCacheGroup - EC2SecurityGroupName: BadExampleEc2SecurityGroup -`, -} - -var cloudFormationAddDescriptionForSecurityGroupLinks = []string{} - -var cloudFormationAddDescriptionForSecurityGroupRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticache/add_description_for_security_group.go b/checks/cloud/aws/elasticache/add_description_for_security_group.go deleted file mode 100755 index 1c791262..00000000 --- a/checks/cloud/aws/elasticache/add_description_for_security_group.go +++ /dev/null @@ -1,54 +0,0 @@ -package elasticache - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckAddDescriptionForSecurityGroup = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0049", - Provider: providers.AWSProvider, - Service: "elasticache", - ShortCode: "add-description-for-security-group", - Summary: "Missing description for security group/security group rule.", - Impact: "Descriptions provide context for the firewall rule reasons", - Resolution: "Add descriptions for all security groups and rules", - Explanation: `Security groups and security group rules should include a description for auditing purposes. - -Simplifies auditing, debugging, and managing security groups.`, - Links: []string{ - "https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/SecurityGroups.Creating.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformAddDescriptionForSecurityGroupGoodExamples, - BadExamples: terraformAddDescriptionForSecurityGroupBadExamples, - Links: terraformAddDescriptionForSecurityGroupLinks, - RemediationMarkdown: terraformAddDescriptionForSecurityGroupRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationAddDescriptionForSecurityGroupGoodExamples, - BadExamples: cloudFormationAddDescriptionForSecurityGroupBadExamples, - Links: cloudFormationAddDescriptionForSecurityGroupLinks, - RemediationMarkdown: cloudFormationAddDescriptionForSecurityGroupRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, sg := range s.AWS.ElastiCache.SecurityGroups { - if sg.Description.IsEmpty() { - results.Add( - "Security group does not have a description.", - sg.Description, - ) - } else { - results.AddPassed(&sg) - } - } - return - }, -) diff --git a/checks/cloud/aws/elasticache/add_description_for_security_group.tf.go b/checks/cloud/aws/elasticache/add_description_for_security_group.tf.go deleted file mode 100644 index e6a248d0..00000000 --- a/checks/cloud/aws/elasticache/add_description_for_security_group.tf.go +++ /dev/null @@ -1,35 +0,0 @@ -package elasticache - -var terraformAddDescriptionForSecurityGroupGoodExamples = []string{ - ` -resource "aws_security_group" "bar" { - name = "security-group" -} - -resource "aws_elasticache_security_group" "good_example" { - name = "elasticache-security-group" - security_group_names = [aws_security_group.bar.name] - description = "something" -} - `, -} - -var terraformAddDescriptionForSecurityGroupBadExamples = []string{ - ` -resource "aws_security_group" "bar" { - name = "security-group" -} - -resource "aws_elasticache_security_group" "bad_example" { - name = "elasticache-security-group" - security_group_names = [aws_security_group.bar.name] - description = "" -} - `, -} - -var terraformAddDescriptionForSecurityGroupLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_security_group#description`, -} - -var terraformAddDescriptionForSecurityGroupRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticache/enable_at_rest_encryption.go b/checks/cloud/aws/elasticache/enable_at_rest_encryption.go deleted file mode 100755 index 206efde1..00000000 --- a/checks/cloud/aws/elasticache/enable_at_rest_encryption.go +++ /dev/null @@ -1,46 +0,0 @@ -package elasticache - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableAtRestEncryption = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0045", - Provider: providers.AWSProvider, - Service: "elasticache", - ShortCode: "enable-at-rest-encryption", - Summary: "Elasticache Replication Group stores unencrypted data at-rest.", - Impact: "At-rest data in the Replication Group could be compromised if accessed.", - Resolution: "Enable at-rest encryption for replication group", - Explanation: `Data stored within an Elasticache replication node should be encrypted to ensure sensitive data is kept private.`, - Links: []string{ - "https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/at-rest-encryption.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableAtRestEncryptionGoodExamples, - BadExamples: terraformEnableAtRestEncryptionBadExamples, - Links: terraformEnableAtRestEncryptionLinks, - RemediationMarkdown: terraformEnableAtRestEncryptionRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.AWS.ElastiCache.ReplicationGroups { - if group.AtRestEncryptionEnabled.IsFalse() { - results.Add( - "Replication group does not have at-rest encryption enabled.", - group.AtRestEncryptionEnabled, - ) - } else { - results.AddPassed(&group) - } - } - return - }, -) diff --git a/checks/cloud/aws/elasticache/enable_at_rest_encryption.tf.go b/checks/cloud/aws/elasticache/enable_at_rest_encryption.tf.go deleted file mode 100644 index 6b9205e3..00000000 --- a/checks/cloud/aws/elasticache/enable_at_rest_encryption.tf.go +++ /dev/null @@ -1,29 +0,0 @@ -package elasticache - -var terraformEnableAtRestEncryptionGoodExamples = []string{ - ` - resource "aws_elasticache_replication_group" "good_example" { - replication_group_id = "foo" - replication_group_description = "my foo cluster" - - at_rest_encryption_enabled = true - } - `, -} - -var terraformEnableAtRestEncryptionBadExamples = []string{ - ` - resource "aws_elasticache_replication_group" "bad_example" { - replication_group_id = "foo" - replication_group_description = "my foo cluster" - - at_rest_encryption_enabled = false - } - `, -} - -var terraformEnableAtRestEncryptionLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_replication_group#at_rest_encryption_enabled`, -} - -var terraformEnableAtRestEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticache/enable_backup_retention.cf.go b/checks/cloud/aws/elasticache/enable_backup_retention.cf.go deleted file mode 100644 index aa18c7c1..00000000 --- a/checks/cloud/aws/elasticache/enable_backup_retention.cf.go +++ /dev/null @@ -1,40 +0,0 @@ -package elasticache - -var cloudFormationEnableBackupRetentionGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::ElastiCache::CacheCluster - Properties: - AZMode: cross-az - CacheNodeType: cache.m3.medium - Engine: redis - NumCacheNodes: '3' - SnapshotRetentionLimit: 7 - PreferredAvailabilityZones: - - us-west-2a - - us-west-2a - - us-west-2b -`, -} - -var cloudFormationEnableBackupRetentionBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::ElastiCache::CacheCluster - Properties: - AZMode: cross-az - CacheNodeType: cache.m3.medium - Engine: redis - NumCacheNodes: '3' - PreferredAvailabilityZones: - - us-west-2a - - us-west-2a - - us-west-2b -`, -} - -var cloudFormationEnableBackupRetentionLinks = []string{} - -var cloudFormationEnableBackupRetentionRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticache/enable_backup_retention.go b/checks/cloud/aws/elasticache/enable_backup_retention.go deleted file mode 100755 index af5711aa..00000000 --- a/checks/cloud/aws/elasticache/enable_backup_retention.go +++ /dev/null @@ -1,60 +0,0 @@ -package elasticache - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableBackupRetention = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0050", - Provider: providers.AWSProvider, - Service: "elasticache", - ShortCode: "enable-backup-retention", - Summary: "Redis cluster should have backup retention turned on", - Impact: "Without backups of the redis cluster recovery is made difficult", - Resolution: "Configure snapshot retention for redis cluster", - Explanation: `Redis clusters should have a snapshot retention time to ensure that they are backed up and can be restored if required.`, - Links: []string{ - "https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/backups-automatic.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableBackupRetentionGoodExamples, - BadExamples: terraformEnableBackupRetentionBadExamples, - Links: terraformEnableBackupRetentionLinks, - RemediationMarkdown: terraformEnableBackupRetentionRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnableBackupRetentionGoodExamples, - BadExamples: cloudFormationEnableBackupRetentionBadExamples, - Links: cloudFormationEnableBackupRetentionLinks, - RemediationMarkdown: cloudFormationEnableBackupRetentionRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.AWS.ElastiCache.Clusters { - if !cluster.Engine.EqualTo("redis") { - continue - } - - if cluster.NodeType.EqualTo("cache.t1.micro") { - continue - } - - if cluster.SnapshotRetentionLimit.EqualTo(0) { - results.Add( - "Cluster snapshot retention is not enabled.", - cluster.SnapshotRetentionLimit, - ) - } else { - results.AddPassed(&cluster) - } - } - return - }, -) diff --git a/checks/cloud/aws/elasticache/enable_backup_retention.tf.go b/checks/cloud/aws/elasticache/enable_backup_retention.tf.go deleted file mode 100644 index 026003c3..00000000 --- a/checks/cloud/aws/elasticache/enable_backup_retention.tf.go +++ /dev/null @@ -1,37 +0,0 @@ -package elasticache - -var terraformEnableBackupRetentionGoodExamples = []string{ - ` - resource "aws_elasticache_cluster" "good_example" { - cluster_id = "cluster-example" - engine = "redis" - node_type = "cache.m4.large" - num_cache_nodes = 1 - parameter_group_name = "default.redis3.2" - engine_version = "3.2.10" - port = 6379 - - snapshot_retention_limit = 5 - } - `, -} - -var terraformEnableBackupRetentionBadExamples = []string{ - ` - resource "aws_elasticache_cluster" "bad_example" { - cluster_id = "cluster-example" - engine = "redis" - node_type = "cache.m4.large" - num_cache_nodes = 1 - parameter_group_name = "default.redis3.2" - engine_version = "3.2.10" - port = 6379 - } - `, -} - -var terraformEnableBackupRetentionLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_cluster#snapshot_retention_limit`, -} - -var terraformEnableBackupRetentionRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticache/enable_in_transit_encryption.cf.go b/checks/cloud/aws/elasticache/enable_in_transit_encryption.cf.go deleted file mode 100644 index 2d2210b3..00000000 --- a/checks/cloud/aws/elasticache/enable_in_transit_encryption.cf.go +++ /dev/null @@ -1,52 +0,0 @@ -package elasticache - -var cloudFormationEnableInTransitEncryptionGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: 'AWS::ElastiCache::ReplicationGroup' - Properties: - AutomaticFailoverEnabled: true - CacheNodeType: cache.r3.large - CacheSubnetGroupName: !Ref CacheSubnetGroup - Engine: redis - EngineVersion: '3.2' - NumNodeGroups: '2' - ReplicasPerNodeGroup: '3' - Port: 6379 - PreferredMaintenanceWindow: 'sun:05:00-sun:09:00' - ReplicationGroupDescription: A sample replication group - SecurityGroupIds: - - !Ref ReplicationGroupSG - SnapshotRetentionLimit: 5 - SnapshotWindow: '10:00-12:00' - TransitEncryptionEnabled: true -`, -} - -var cloudFormationEnableInTransitEncryptionBadExamples = []string{ - `--- -Resources: - BadExample: - Type: 'AWS::ElastiCache::ReplicationGroup' - Properties: - AutomaticFailoverEnabled: true - CacheNodeType: cache.r3.large - CacheSubnetGroupName: !Ref CacheSubnetGroup - Engine: redis - EngineVersion: '3.2' - NumNodeGroups: '2' - ReplicasPerNodeGroup: '3' - Port: 6379 - PreferredMaintenanceWindow: 'sun:05:00-sun:09:00' - ReplicationGroupDescription: A sample replication group - SecurityGroupIds: - - !Ref ReplicationGroupSG - SnapshotRetentionLimit: 5 - SnapshotWindow: '10:00-12:00' -`, -} - -var cloudFormationEnableInTransitEncryptionLinks = []string{} - -var cloudFormationEnableInTransitEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticache/enable_in_transit_encryption.go b/checks/cloud/aws/elasticache/enable_in_transit_encryption.go deleted file mode 100755 index 08a1165a..00000000 --- a/checks/cloud/aws/elasticache/enable_in_transit_encryption.go +++ /dev/null @@ -1,52 +0,0 @@ -package elasticache - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableInTransitEncryption = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0051", - Provider: providers.AWSProvider, - Service: "elasticache", - ShortCode: "enable-in-transit-encryption", - Summary: "Elasticache Replication Group uses unencrypted traffic.", - Impact: "In transit data in the Replication Group could be read if intercepted", - Resolution: "Enable in transit encryption for replication group", - Explanation: `Traffic flowing between Elasticache replication nodes should be encrypted to ensure sensitive data is kept private.`, - Links: []string{ - "https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/in-transit-encryption.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableInTransitEncryptionGoodExamples, - BadExamples: terraformEnableInTransitEncryptionBadExamples, - Links: terraformEnableInTransitEncryptionLinks, - RemediationMarkdown: terraformEnableInTransitEncryptionRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnableInTransitEncryptionGoodExamples, - BadExamples: cloudFormationEnableInTransitEncryptionBadExamples, - Links: cloudFormationEnableInTransitEncryptionLinks, - RemediationMarkdown: cloudFormationEnableInTransitEncryptionRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.AWS.ElastiCache.ReplicationGroups { - if group.TransitEncryptionEnabled.IsFalse() { - results.Add( - "Replication group does not have transit encryption enabled.", - group.TransitEncryptionEnabled, - ) - } else { - results.AddPassed(&group) - } - } - return - }, -) diff --git a/checks/cloud/aws/elasticache/enable_in_transit_encryption.tf.go b/checks/cloud/aws/elasticache/enable_in_transit_encryption.tf.go deleted file mode 100644 index 7ad3794a..00000000 --- a/checks/cloud/aws/elasticache/enable_in_transit_encryption.tf.go +++ /dev/null @@ -1,27 +0,0 @@ -package elasticache - -var terraformEnableInTransitEncryptionGoodExamples = []string{ - ` - resource "aws_elasticache_replication_group" "good_example" { - replication_group_id = "foo" - replication_group_description = "my foo cluster" - transit_encryption_enabled = true - } - `, -} - -var terraformEnableInTransitEncryptionBadExamples = []string{ - ` - resource "aws_elasticache_replication_group" "bad_example" { - replication_group_id = "foo" - replication_group_description = "my foo cluster" - transit_encryption_enabled = false - } - `, -} - -var terraformEnableInTransitEncryptionLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_replication_group#transit_encryption_enabled`, -} - -var terraformEnableInTransitEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticsearch/enable_domain_encryption.cf.go b/checks/cloud/aws/elasticsearch/enable_domain_encryption.cf.go deleted file mode 100644 index b358b5cc..00000000 --- a/checks/cloud/aws/elasticsearch/enable_domain_encryption.cf.go +++ /dev/null @@ -1,54 +0,0 @@ -package elasticsearch - -var cloudFormationEnableDomainEncryptionGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::Elasticsearch::Domain - Properties: - DomainName: 'test' - ElasticsearchVersion: '7.10' - EncryptionAtRestOptions: - Enabled: true - KmsKeyId: alias/kmskey - ElasticsearchClusterConfig: - DedicatedMasterEnabled: true - InstanceCount: '2' - ZoneAwarenessEnabled: true - InstanceType: 'm3.medium.elasticsearch' - DedicatedMasterType: 'm3.medium.elasticsearch' - DedicatedMasterCount: '3' - EBSOptions: - EBSEnabled: true - Iops: '0' - VolumeSize: '20' - VolumeType: 'gp2' -`, -} - -var cloudFormationEnableDomainEncryptionBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::Elasticsearch::Domain - Properties: - DomainName: 'test' - ElasticsearchVersion: '7.10' - ElasticsearchClusterConfig: - DedicatedMasterEnabled: true - InstanceCount: '2' - ZoneAwarenessEnabled: true - InstanceType: 'm3.medium.elasticsearch' - DedicatedMasterType: 'm3.medium.elasticsearch' - DedicatedMasterCount: '3' - EBSOptions: - EBSEnabled: true - Iops: '0' - VolumeSize: '20' - VolumeType: 'gp2' -`, -} - -var cloudFormationEnableDomainEncryptionLinks = []string{} - -var cloudFormationEnableDomainEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticsearch/enable_domain_encryption.go b/checks/cloud/aws/elasticsearch/enable_domain_encryption.go deleted file mode 100755 index d5045922..00000000 --- a/checks/cloud/aws/elasticsearch/enable_domain_encryption.go +++ /dev/null @@ -1,52 +0,0 @@ -package elasticsearch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableDomainEncryption = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0048", - Provider: providers.AWSProvider, - Service: "elastic-search", - ShortCode: "enable-domain-encryption", - Summary: "Elasticsearch domain isn't encrypted at rest.", - Impact: "Data will be readable if compromised", - Resolution: "Enable ElasticSearch domain encryption", - Explanation: `You should ensure your Elasticsearch data is encrypted at rest to help prevent sensitive information from being read by unauthorised users.`, - Links: []string{ - "https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/encryption-at-rest.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableDomainEncryptionGoodExamples, - BadExamples: terraformEnableDomainEncryptionBadExamples, - Links: terraformEnableDomainEncryptionLinks, - RemediationMarkdown: terraformEnableDomainEncryptionRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnableDomainEncryptionGoodExamples, - BadExamples: cloudFormationEnableDomainEncryptionBadExamples, - Links: cloudFormationEnableDomainEncryptionLinks, - RemediationMarkdown: cloudFormationEnableDomainEncryptionRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, domain := range s.AWS.Elasticsearch.Domains { - if domain.AtRestEncryption.Enabled.IsFalse() { - results.Add( - "Domain does not have at-rest encryption enabled.", - domain.AtRestEncryption.Enabled, - ) - } else { - results.AddPassed(&domain) - } - } - return - }, -) diff --git a/checks/cloud/aws/elasticsearch/enable_domain_encryption.tf.go b/checks/cloud/aws/elasticsearch/enable_domain_encryption.tf.go deleted file mode 100644 index e94e10e5..00000000 --- a/checks/cloud/aws/elasticsearch/enable_domain_encryption.tf.go +++ /dev/null @@ -1,31 +0,0 @@ -package elasticsearch - -var terraformEnableDomainEncryptionGoodExamples = []string{ - ` - resource "aws_elasticsearch_domain" "good_example" { - domain_name = "domain-foo" - - encrypt_at_rest { - enabled = true - } - } - `, -} - -var terraformEnableDomainEncryptionBadExamples = []string{ - ` - resource "aws_elasticsearch_domain" "bad_example" { - domain_name = "domain-foo" - - encrypt_at_rest { - enabled = false - } - } - `, -} - -var terraformEnableDomainEncryptionLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticsearch_domain#encrypt_at_rest`, -} - -var terraformEnableDomainEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticsearch/enable_domain_logging.cf.go b/checks/cloud/aws/elasticsearch/enable_domain_logging.cf.go deleted file mode 100644 index 970d8fd3..00000000 --- a/checks/cloud/aws/elasticsearch/enable_domain_logging.cf.go +++ /dev/null @@ -1,57 +0,0 @@ -package elasticsearch - -var cloudFormationEnableDomainLoggingGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::Elasticsearch::Domain - Properties: - DomainName: 'test' - ElasticsearchVersion: '7.10' - EncryptionAtRestOptions: - Enabled: true - KmsKeyId: alias/kmskey - LogPublishingOptions: - AUDIT_LOGS: - Enabled: true - ElasticsearchClusterConfig: - DedicatedMasterEnabled: true - InstanceCount: '2' - ZoneAwarenessEnabled: true - InstanceType: 'm3.medium.elasticsearch' - DedicatedMasterType: 'm3.medium.elasticsearch' - DedicatedMasterCount: '3' - EBSOptions: - EBSEnabled: true - Iops: '0' - VolumeSize: '20' - VolumeType: 'gp2' -`, -} - -var cloudFormationEnableDomainLoggingBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::Elasticsearch::Domain - Properties: - DomainName: 'test' - ElasticsearchVersion: '7.10' - ElasticsearchClusterConfig: - DedicatedMasterEnabled: true - InstanceCount: '2' - ZoneAwarenessEnabled: true - InstanceType: 'm3.medium.elasticsearch' - DedicatedMasterType: 'm3.medium.elasticsearch' - DedicatedMasterCount: '3' - EBSOptions: - EBSEnabled: true - Iops: '0' - VolumeSize: '20' - VolumeType: 'gp2' -`, -} - -var cloudFormationEnableDomainLoggingLinks = []string{} - -var cloudFormationEnableDomainLoggingRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticsearch/enable_domain_logging.go b/checks/cloud/aws/elasticsearch/enable_domain_logging.go deleted file mode 100755 index 36840433..00000000 --- a/checks/cloud/aws/elasticsearch/enable_domain_logging.go +++ /dev/null @@ -1,58 +0,0 @@ -package elasticsearch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableDomainLogging = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0042", - Provider: providers.AWSProvider, - Service: "elastic-search", - ShortCode: "enable-domain-logging", - Summary: "Domain logging should be enabled for Elastic Search domains", - Impact: "Logging provides vital information about access and usage", - Resolution: "Enable logging for ElasticSearch domains", - Explanation: `Amazon ES exposes four Elasticsearch logs through Amazon CloudWatch Logs: error logs, search slow logs, index slow logs, and audit logs. - -Search slow logs, index slow logs, and error logs are useful for troubleshooting performance and stability issues. - -Audit logs track user activity for compliance purposes. - -All the logs are disabled by default.`, - Links: []string{ - "https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-createdomain-configure-slow-logs.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableDomainLoggingGoodExamples, - BadExamples: terraformEnableDomainLoggingBadExamples, - Links: terraformEnableDomainLoggingLinks, - RemediationMarkdown: terraformEnableDomainLoggingRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnableDomainLoggingGoodExamples, - BadExamples: cloudFormationEnableDomainLoggingBadExamples, - Links: cloudFormationEnableDomainLoggingLinks, - RemediationMarkdown: cloudFormationEnableDomainLoggingRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, domain := range s.AWS.Elasticsearch.Domains { - if domain.LogPublishing.AuditEnabled.IsFalse() { - results.Add( - "Domain audit logging is not enabled.", - domain.LogPublishing.AuditEnabled, - ) - } else { - results.AddPassed(&domain) - } - } - return - }, -) diff --git a/checks/cloud/aws/elasticsearch/enable_domain_logging.tf.go b/checks/cloud/aws/elasticsearch/enable_domain_logging.tf.go deleted file mode 100644 index 8df501d0..00000000 --- a/checks/cloud/aws/elasticsearch/enable_domain_logging.tf.go +++ /dev/null @@ -1,42 +0,0 @@ -package elasticsearch - -var terraformEnableDomainLoggingGoodExamples = []string{ - ` - resource "aws_elasticsearch_domain" "good_example" { - domain_name = "example" - elasticsearch_version = "1.5" - - log_publishing_options { - cloudwatch_log_group_arn = aws_cloudwatch_log_group.example.arn - log_type = "AUDIT_LOGS" - enabled = true - } - } - `, -} - -var terraformEnableDomainLoggingBadExamples = []string{ - ` - resource "aws_elasticsearch_domain" "bad_example" { - domain_name = "example" - elasticsearch_version = "1.5" - } - `, ` - resource "aws_elasticsearch_domain" "bad_example" { - domain_name = "example" - elasticsearch_version = "1.5" - - log_publishing_options { - cloudwatch_log_group_arn = aws_cloudwatch_log_group.example.arn - log_type = "AUDIT_LOGS" - enabled = false - } - } - `, -} - -var terraformEnableDomainLoggingLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticsearch_domain#log_type`, -} - -var terraformEnableDomainLoggingRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticsearch/enable_in_transit_encryption.cf.go b/checks/cloud/aws/elasticsearch/enable_in_transit_encryption.cf.go deleted file mode 100644 index da7f13a9..00000000 --- a/checks/cloud/aws/elasticsearch/enable_in_transit_encryption.cf.go +++ /dev/null @@ -1,56 +0,0 @@ -package elasticsearch - -var cloudFormationEnableInTransitEncryptionGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::Elasticsearch::Domain - Properties: - DomainName: 'test' - ElasticsearchVersion: '7.10' - EncryptionAtRestOptions: - Enabled: true - KmsKeyId: alias/kmskey - ElasticsearchClusterConfig: - DedicatedMasterEnabled: true - InstanceCount: '2' - ZoneAwarenessEnabled: true - InstanceType: 'm3.medium.elasticsearch' - DedicatedMasterType: 'm3.medium.elasticsearch' - DedicatedMasterCount: '3' - EBSOptions: - EBSEnabled: true - Iops: '0' - VolumeSize: '20' - VolumeType: 'gp2' - NodeToNodeEncryptionOptions: - Enabled: true -`, -} - -var cloudFormationEnableInTransitEncryptionBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::Elasticsearch::Domain - Properties: - DomainName: 'test' - ElasticsearchVersion: '7.10' - ElasticsearchClusterConfig: - DedicatedMasterEnabled: true - InstanceCount: '2' - ZoneAwarenessEnabled: true - InstanceType: 'm3.medium.elasticsearch' - DedicatedMasterType: 'm3.medium.elasticsearch' - DedicatedMasterCount: '3' - EBSOptions: - EBSEnabled: true - Iops: '0' - VolumeSize: '20' - VolumeType: 'gp2' -`, -} - -var cloudFormationEnableInTransitEncryptionLinks = []string{} - -var cloudFormationEnableInTransitEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticsearch/enable_in_transit_encryption.go b/checks/cloud/aws/elasticsearch/enable_in_transit_encryption.go deleted file mode 100755 index f4d2c1fa..00000000 --- a/checks/cloud/aws/elasticsearch/enable_in_transit_encryption.go +++ /dev/null @@ -1,52 +0,0 @@ -package elasticsearch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableInTransitEncryption = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0043", - Provider: providers.AWSProvider, - Service: "elastic-search", - ShortCode: "enable-in-transit-encryption", - Summary: "Elasticsearch domain uses plaintext traffic for node to node communication.", - Impact: "In transit data between nodes could be read if intercepted", - Resolution: "Enable encrypted node to node communication", - Explanation: `Traffic flowing between Elasticsearch nodes should be encrypted to ensure sensitive data is kept private.`, - Links: []string{ - "https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/ntn.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableInTransitEncryptionGoodExamples, - BadExamples: terraformEnableInTransitEncryptionBadExamples, - Links: terraformEnableInTransitEncryptionLinks, - RemediationMarkdown: terraformEnableInTransitEncryptionRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnableInTransitEncryptionGoodExamples, - BadExamples: cloudFormationEnableInTransitEncryptionBadExamples, - Links: cloudFormationEnableInTransitEncryptionLinks, - RemediationMarkdown: cloudFormationEnableInTransitEncryptionRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, domain := range s.AWS.Elasticsearch.Domains { - if domain.TransitEncryption.Enabled.IsFalse() { - results.Add( - "Domain does not have in-transit encryption enabled.", - domain.TransitEncryption.Enabled, - ) - } else { - results.AddPassed(&domain) - } - } - return - }, -) diff --git a/checks/cloud/aws/elasticsearch/enable_in_transit_encryption.tf.go b/checks/cloud/aws/elasticsearch/enable_in_transit_encryption.tf.go deleted file mode 100644 index b7d933dc..00000000 --- a/checks/cloud/aws/elasticsearch/enable_in_transit_encryption.tf.go +++ /dev/null @@ -1,31 +0,0 @@ -package elasticsearch - -var terraformEnableInTransitEncryptionGoodExamples = []string{ - ` - resource "aws_elasticsearch_domain" "good_example" { - domain_name = "domain-foo" - - node_to_node_encryption { - enabled = true - } - } - `, -} - -var terraformEnableInTransitEncryptionBadExamples = []string{ - ` - resource "aws_elasticsearch_domain" "bad_example" { - domain_name = "domain-foo" - - node_to_node_encryption { - enabled = false - } - } - `, -} - -var terraformEnableInTransitEncryptionLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticsearch_domain#encrypt_at_rest`, -} - -var terraformEnableInTransitEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticsearch/enforce_https.cf.go b/checks/cloud/aws/elasticsearch/enforce_https.cf.go deleted file mode 100644 index 0d963973..00000000 --- a/checks/cloud/aws/elasticsearch/enforce_https.cf.go +++ /dev/null @@ -1,57 +0,0 @@ -package elasticsearch - -var cloudFormationEnforceHttpsGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::Elasticsearch::Domain - Properties: - DomainName: 'test' - DomainEndpointOptions: - EnforceHTTPS: true - - ElasticsearchVersion: '7.10' - EncryptionAtRestOptions: - Enabled: true - KmsKeyId: alias/kmskey - ElasticsearchClusterConfig: - DedicatedMasterEnabled: true - InstanceCount: '2' - ZoneAwarenessEnabled: true - InstanceType: 'm3.medium.elasticsearch' - DedicatedMasterType: 'm3.medium.elasticsearch' - DedicatedMasterCount: '3' - EBSOptions: - EBSEnabled: true - Iops: '0' - VolumeSize: '20' - VolumeType: 'gp2' -`, -} - -var cloudFormationEnforceHttpsBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::Elasticsearch::Domain - Properties: - DomainName: 'test' - ElasticsearchVersion: '7.10' - ElasticsearchClusterConfig: - DedicatedMasterEnabled: true - InstanceCount: '2' - ZoneAwarenessEnabled: true - InstanceType: 'm3.medium.elasticsearch' - DedicatedMasterType: 'm3.medium.elasticsearch' - DedicatedMasterCount: '3' - EBSOptions: - EBSEnabled: true - Iops: '0' - VolumeSize: '20' - VolumeType: 'gp2' -`, -} - -var cloudFormationEnforceHttpsLinks = []string{} - -var cloudFormationEnforceHttpsRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticsearch/enforce_https.go b/checks/cloud/aws/elasticsearch/enforce_https.go deleted file mode 100755 index 4b6b8cca..00000000 --- a/checks/cloud/aws/elasticsearch/enforce_https.go +++ /dev/null @@ -1,54 +0,0 @@ -package elasticsearch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnforceHttps = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0046", - Provider: providers.AWSProvider, - Service: "elastic-search", - ShortCode: "enforce-https", - Summary: "Elasticsearch doesn't enforce HTTPS traffic.", - Impact: "HTTP traffic can be intercepted and the contents read", - Resolution: "Enforce the use of HTTPS for ElasticSearch", - Explanation: `Plain HTTP is unencrypted and human-readable. This means that if a malicious actor was to eavesdrop on your connection, they would be able to see all of your data flowing back and forth. - -You should use HTTPS, which is HTTP over an encrypted (TLS) connection, meaning eavesdroppers cannot read your traffic.`, - Links: []string{ - "https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-data-protection.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnforceHttpsGoodExamples, - BadExamples: terraformEnforceHttpsBadExamples, - Links: terraformEnforceHttpsLinks, - RemediationMarkdown: terraformEnforceHttpsRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationEnforceHttpsGoodExamples, - BadExamples: cloudFormationEnforceHttpsBadExamples, - Links: cloudFormationEnforceHttpsLinks, - RemediationMarkdown: cloudFormationEnforceHttpsRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, domain := range s.AWS.Elasticsearch.Domains { - if domain.Endpoint.EnforceHTTPS.IsFalse() { - results.Add( - "Domain does not enforce HTTPS.", - domain.Endpoint.EnforceHTTPS, - ) - } else { - results.AddPassed(&domain) - } - } - return - }, -) diff --git a/checks/cloud/aws/elasticsearch/enforce_https.tf.go b/checks/cloud/aws/elasticsearch/enforce_https.tf.go deleted file mode 100644 index 70642776..00000000 --- a/checks/cloud/aws/elasticsearch/enforce_https.tf.go +++ /dev/null @@ -1,31 +0,0 @@ -package elasticsearch - -var terraformEnforceHttpsGoodExamples = []string{ - ` - resource "aws_elasticsearch_domain" "good_example" { - domain_name = "domain-foo" - - domain_endpoint_options { - enforce_https = true - } - } - `, -} - -var terraformEnforceHttpsBadExamples = []string{ - ` - resource "aws_elasticsearch_domain" "bad_example" { - domain_name = "domain-foo" - - domain_endpoint_options { - enforce_https = false - } - } - `, -} - -var terraformEnforceHttpsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticsearch_domain#enforce_https`, -} - -var terraformEnforceHttpsRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticsearch/use_secure_tls_policy.cf.go b/checks/cloud/aws/elasticsearch/use_secure_tls_policy.cf.go deleted file mode 100644 index f711c010..00000000 --- a/checks/cloud/aws/elasticsearch/use_secure_tls_policy.cf.go +++ /dev/null @@ -1,56 +0,0 @@ -package elasticsearch - -var cloudFormationUseSecureTlsPolicyGoodExamples = []string{ - `--- -Resources: - GoodExample: - Type: AWS::Elasticsearch::Domain - Properties: - DomainName: 'test' - ElasticsearchVersion: '7.10' - DomainEndpointOptions: - TLSSecurityPolicy: Policy-Min-TLS-1-2-2019-07 - EncryptionAtRestOptions: - Enabled: true - KmsKeyId: alias/kmskey - ElasticsearchClusterConfig: - DedicatedMasterEnabled: true - InstanceCount: '2' - ZoneAwarenessEnabled: true - InstanceType: 'm3.medium.elasticsearch' - DedicatedMasterType: 'm3.medium.elasticsearch' - DedicatedMasterCount: '3' - EBSOptions: - EBSEnabled: true - Iops: '0' - VolumeSize: '20' - VolumeType: 'gp2' -`, -} - -var cloudFormationUseSecureTlsPolicyBadExamples = []string{ - `--- -Resources: - BadExample: - Type: AWS::Elasticsearch::Domain - Properties: - DomainName: 'test' - ElasticsearchVersion: '7.10' - ElasticsearchClusterConfig: - DedicatedMasterEnabled: true - InstanceCount: '2' - ZoneAwarenessEnabled: true - InstanceType: 'm3.medium.elasticsearch' - DedicatedMasterType: 'm3.medium.elasticsearch' - DedicatedMasterCount: '3' - EBSOptions: - EBSEnabled: true - Iops: '0' - VolumeSize: '20' - VolumeType: 'gp2' -`, -} - -var cloudFormationUseSecureTlsPolicyLinks = []string{} - -var cloudFormationUseSecureTlsPolicyRemediationMarkdown = `` diff --git a/checks/cloud/aws/elasticsearch/use_secure_tls_policy.go b/checks/cloud/aws/elasticsearch/use_secure_tls_policy.go deleted file mode 100755 index 533c2b1c..00000000 --- a/checks/cloud/aws/elasticsearch/use_secure_tls_policy.go +++ /dev/null @@ -1,52 +0,0 @@ -package elasticsearch - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckUseSecureTlsPolicy = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0126", - Provider: providers.AWSProvider, - Service: "elastic-search", - ShortCode: "use-secure-tls-policy", - Summary: "Elasticsearch domain endpoint is using outdated TLS policy.", - Impact: "Outdated SSL policies increase exposure to known vulnerabilities", - Resolution: "Use the most modern TLS/SSL policies available", - Explanation: `You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.`, - Links: []string{ - "https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-data-protection.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformUseSecureTlsPolicyGoodExamples, - BadExamples: terraformUseSecureTlsPolicyBadExamples, - Links: terraformUseSecureTlsPolicyLinks, - RemediationMarkdown: terraformUseSecureTlsPolicyRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationUseSecureTlsPolicyGoodExamples, - BadExamples: cloudFormationUseSecureTlsPolicyBadExamples, - Links: cloudFormationUseSecureTlsPolicyLinks, - RemediationMarkdown: cloudFormationUseSecureTlsPolicyRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, domain := range s.AWS.Elasticsearch.Domains { - if domain.Endpoint.TLSPolicy.NotEqualTo("Policy-Min-TLS-1-2-2019-07") { - results.Add( - "Domain does not have a secure TLS policy.", - domain.Endpoint.TLSPolicy, - ) - } else { - results.AddPassed(&domain) - } - } - return - }, -) diff --git a/checks/cloud/aws/elasticsearch/use_secure_tls_policy.tf.go b/checks/cloud/aws/elasticsearch/use_secure_tls_policy.tf.go deleted file mode 100644 index 99c630a0..00000000 --- a/checks/cloud/aws/elasticsearch/use_secure_tls_policy.tf.go +++ /dev/null @@ -1,33 +0,0 @@ -package elasticsearch - -var terraformUseSecureTlsPolicyGoodExamples = []string{ - ` - resource "aws_elasticsearch_domain" "good_example" { - domain_name = "domain-foo" - - domain_endpoint_options { - enforce_https = true - tls_security_policy = "Policy-Min-TLS-1-2-2019-07" - } - } - `, -} - -var terraformUseSecureTlsPolicyBadExamples = []string{ - ` - resource "aws_elasticsearch_domain" "bad_example" { - domain_name = "domain-foo" - - domain_endpoint_options { - enforce_https = true - tls_security_policy = "Policy-Min-TLS-1-0-2019-07" - } - } - `, -} - -var terraformUseSecureTlsPolicyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticsearch_domain#tls_security_policy`, -} - -var terraformUseSecureTlsPolicyRemediationMarkdown = `` diff --git a/checks/cloud/aws/elb/alb_not_public.go b/checks/cloud/aws/elb/alb_not_public.go deleted file mode 100755 index fa3dc15a..00000000 --- a/checks/cloud/aws/elb/alb_not_public.go +++ /dev/null @@ -1,48 +0,0 @@ -package elb - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/elb" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckAlbNotPublic = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0053", - Provider: providers.AWSProvider, - Service: "elb", - ShortCode: "alb-not-public", - Summary: "Load balancer is exposed to the internet.", - Impact: "The load balancer is exposed on the internet", - Resolution: "Switch to an internal load balancer or add a tfsec ignore", - Explanation: `There are many scenarios in which you would want to expose a load balancer to the wider internet, but this check exists as a warning to prevent accidental exposure of internal assets. You should ensure that this resource should be exposed publicly.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformAlbNotPublicGoodExamples, - BadExamples: terraformAlbNotPublicBadExamples, - Links: terraformAlbNotPublicLinks, - RemediationMarkdown: terraformAlbNotPublicRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, lb := range s.AWS.ELB.LoadBalancers { - if lb.Metadata.IsUnmanaged() || lb.Type.EqualTo(elb.TypeGateway) { - continue - } - if lb.Internal.IsFalse() { - results.Add( - "Load balancer is exposed publicly.", - lb.Internal, - ) - } else { - results.AddPassed(&lb) - } - } - return - }, -) diff --git a/checks/cloud/aws/elb/alb_not_public.tf.go b/checks/cloud/aws/elb/alb_not_public.tf.go deleted file mode 100644 index 6ef076df..00000000 --- a/checks/cloud/aws/elb/alb_not_public.tf.go +++ /dev/null @@ -1,23 +0,0 @@ -package elb - -var terraformAlbNotPublicGoodExamples = []string{ - ` - resource "aws_alb" "good_example" { - internal = true - } - `, -} - -var terraformAlbNotPublicBadExamples = []string{ - ` - resource "aws_alb" "bad_example" { - internal = false - } - `, -} - -var terraformAlbNotPublicLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb`, -} - -var terraformAlbNotPublicRemediationMarkdown = `` diff --git a/checks/cloud/aws/elb/drop_invalid_headers.go b/checks/cloud/aws/elb/drop_invalid_headers.go deleted file mode 100755 index 874ee839..00000000 --- a/checks/cloud/aws/elb/drop_invalid_headers.go +++ /dev/null @@ -1,52 +0,0 @@ -package elb - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/elb" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckDropInvalidHeaders = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0052", - Provider: providers.AWSProvider, - Service: "elb", - ShortCode: "drop-invalid-headers", - Summary: "Load balancers should drop invalid headers", - Impact: "Invalid headers being passed through to the target of the load balance may exploit vulnerabilities", - Resolution: "Set drop_invalid_header_fields to true", - Explanation: `Passing unknown or invalid headers through to the target poses a potential risk of compromise. - -By setting drop_invalid_header_fields to true, anything that does not conform to well known, defined headers will be removed by the load balancer.`, - Links: []string{ - "https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformDropInvalidHeadersGoodExamples, - BadExamples: terraformDropInvalidHeadersBadExamples, - Links: terraformDropInvalidHeadersLinks, - RemediationMarkdown: terraformDropInvalidHeadersRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, lb := range s.AWS.ELB.LoadBalancers { - if lb.Metadata.IsUnmanaged() || !lb.Type.EqualTo(elb.TypeApplication) || lb.Metadata.IsUnmanaged() { - continue - } - if lb.DropInvalidHeaderFields.IsFalse() { - results.Add( - "Application load balancer is not set to drop invalid headers.", - lb.DropInvalidHeaderFields, - ) - } else { - results.AddPassed(&lb) - } - } - return - }, -) diff --git a/checks/cloud/aws/elb/drop_invalid_headers.tf.go b/checks/cloud/aws/elb/drop_invalid_headers.tf.go deleted file mode 100644 index 7c72ee5a..00000000 --- a/checks/cloud/aws/elb/drop_invalid_headers.tf.go +++ /dev/null @@ -1,43 +0,0 @@ -package elb - -var terraformDropInvalidHeadersGoodExamples = []string{ - ` - resource "aws_alb" "good_example" { - name = "good_alb" - internal = false - load_balancer_type = "application" - - access_logs { - bucket = aws_s3_bucket.lb_logs.bucket - prefix = "test-lb" - enabled = true - } - - drop_invalid_header_fields = true - } - `, -} - -var terraformDropInvalidHeadersBadExamples = []string{ - ` - resource "aws_alb" "bad_example" { - name = "bad_alb" - internal = false - load_balancer_type = "application" - - access_logs { - bucket = aws_s3_bucket.lb_logs.bucket - prefix = "test-lb" - enabled = true - } - - drop_invalid_header_fields = false - } - `, -} - -var terraformDropInvalidHeadersLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb#drop_invalid_header_fields`, -} - -var terraformDropInvalidHeadersRemediationMarkdown = `` diff --git a/checks/cloud/aws/elb/http_not_used.go b/checks/cloud/aws/elb/http_not_used.go deleted file mode 100755 index 2c0a1278..00000000 --- a/checks/cloud/aws/elb/http_not_used.go +++ /dev/null @@ -1,67 +0,0 @@ -package elb - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/elb" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckHttpNotUsed = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0054", - Provider: providers.AWSProvider, - Service: "elb", - ShortCode: "http-not-used", - Summary: "Use of plain HTTP.", - Impact: "Your traffic is not protected", - Resolution: "Switch to HTTPS to benefit from TLS security features", - Explanation: `Plain HTTP is unencrypted and human-readable. This means that if a malicious actor was to eavesdrop on your connection, they would be able to see all of your data flowing back and forth. - -You should use HTTPS, which is HTTP over an encrypted (TLS) connection, meaning eavesdroppers cannot read your traffic.`, - Links: []string{ - "https://www.cloudflare.com/en-gb/learning/ssl/why-is-http-not-secure/", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformHttpNotUsedGoodExamples, - BadExamples: terraformHttpNotUsedBadExamples, - Links: terraformHttpNotUsedLinks, - RemediationMarkdown: terraformHttpNotUsedRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, lb := range s.AWS.ELB.LoadBalancers { - if !lb.Type.EqualTo(elb.TypeApplication) { - continue - } - for _, listener := range lb.Listeners { - if !listener.Protocol.EqualTo("HTTP") { - results.AddPassed(&listener) - continue - } - - var hasRedirect bool - for _, action := range listener.DefaultActions { - if action.Type.EqualTo("redirect") { - hasRedirect = true - break - } - } - if hasRedirect { - results.AddPassed(&listener) - break - } - - results.Add( - "Listener for application load balancer does not use HTTPS.", - listener.Protocol, - ) - } - } - return - }, -) diff --git a/checks/cloud/aws/elb/http_not_used.tf.go b/checks/cloud/aws/elb/http_not_used.tf.go deleted file mode 100644 index 3eec96b7..00000000 --- a/checks/cloud/aws/elb/http_not_used.tf.go +++ /dev/null @@ -1,23 +0,0 @@ -package elb - -var terraformHttpNotUsedGoodExamples = []string{ - ` - resource "aws_alb_listener" "good_example" { - protocol = "HTTPS" - } - `, -} - -var terraformHttpNotUsedBadExamples = []string{ - ` - resource "aws_alb_listener" "bad_example" { - protocol = "HTTP" - } - `, -} - -var terraformHttpNotUsedLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener`, -} - -var terraformHttpNotUsedRemediationMarkdown = `` diff --git a/checks/cloud/aws/elb/use_secure_tls_policy.go b/checks/cloud/aws/elb/use_secure_tls_policy.go deleted file mode 100755 index 9115e5d3..00000000 --- a/checks/cloud/aws/elb/use_secure_tls_policy.go +++ /dev/null @@ -1,61 +0,0 @@ -package elb - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var outdatedSSLPolicies = []string{ - "ELBSecurityPolicy-2015-05", - "ELBSecurityPolicy-2016-08", - "ELBSecurityPolicy-FS-2018-06", - "ELBSecurityPolicy-FS-1-1-2019-08", - "ELBSecurityPolicy-TLS-1-0-2015-04", - "ELBSecurityPolicy-TLS-1-1-2017-01", - "ELBSecurityPolicy-TLS13-1-0-2021-06", - "ELBSecurityPolicy-TLS13-1-1-2021-06", - "ELBSecurityPolicy-TLS13-1-2-Ext1-2021-06", - "ELBSecurityPolicy-TLS13-1-2-Ext2-2021-06", -} - -var CheckUseSecureTlsPolicy = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0047", - Provider: providers.AWSProvider, - Service: "elb", - ShortCode: "use-secure-tls-policy", - Summary: "An outdated SSL policy is in use by a load balancer.", - Impact: "The SSL policy is outdated and has known vulnerabilities", - Resolution: "Use a more recent TLS/SSL policy for the load balancer", - Explanation: `You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformUseSecureTlsPolicyGoodExamples, - BadExamples: terraformUseSecureTlsPolicyBadExamples, - Links: terraformUseSecureTlsPolicyLinks, - RemediationMarkdown: terraformUseSecureTlsPolicyRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, lb := range s.AWS.ELB.LoadBalancers { - for _, listener := range lb.Listeners { - for _, outdated := range outdatedSSLPolicies { - if listener.TLSPolicy.EqualTo(outdated) { - results.Add( - "Listener uses an outdated TLS policy.", - listener.TLSPolicy, - ) - } else { - results.AddPassed(&listener) - } - } - } - } - return - }, -) diff --git a/checks/cloud/aws/elb/use_secure_tls_policy.tf.go b/checks/cloud/aws/elb/use_secure_tls_policy.tf.go deleted file mode 100644 index 65daa699..00000000 --- a/checks/cloud/aws/elb/use_secure_tls_policy.tf.go +++ /dev/null @@ -1,25 +0,0 @@ -package elb - -var terraformUseSecureTlsPolicyGoodExamples = []string{ - ` - resource "aws_alb_listener" "good_example" { - ssl_policy = "ELBSecurityPolicy-TLS13-1-2-2021-06" - protocol = "HTTPS" - } - `, -} - -var terraformUseSecureTlsPolicyBadExamples = []string{ - ` - resource "aws_alb_listener" "bad_example" { - ssl_policy = "ELBSecurityPolicy-TLS-1-1-2017-01" - protocol = "HTTPS" - } - `, -} - -var terraformUseSecureTlsPolicyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener`, -} - -var terraformUseSecureTlsPolicyRemediationMarkdown = `` diff --git a/checks/cloud/aws/emr/enable_at_rest_encryption.go b/checks/cloud/aws/emr/enable_at_rest_encryption.go deleted file mode 100644 index 6f36b14d..00000000 --- a/checks/cloud/aws/emr/enable_at_rest_encryption.go +++ /dev/null @@ -1,79 +0,0 @@ -package emr - -import ( - "encoding/json" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableAtRestEncryption = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0137", - Provider: providers.AWSProvider, - Service: "emr", - ShortCode: "enable-at-rest-encryption", - Summary: "Enable at-rest encryption for EMR clusters.", - Impact: "At-rest data in the EMR cluster could be compromised if accessed.", - Resolution: "Enable at-rest encryption for EMR cluster", - Explanation: `Data stored within an EMR cluster should be encrypted to ensure sensitive data is kept private.`, - Links: []string{ - "https://docs.aws.amazon.com/config/latest/developerguide/operational-best-practices-for-nist_800-171.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableAtRestEncryptionGoodExamples, - BadExamples: terraformEnableAtRestEncryptionBadExamples, - Links: terraformEnableAtRestEncryptionLinks, - RemediationMarkdown: terraformEnableAtRestEncryptionRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, conf := range s.AWS.EMR.SecurityConfiguration { - vars, err := readVarsFromConfigurationAtRest(conf.Configuration.Value()) - if err != nil { - continue - } - - if !vars.EncryptionConfiguration.EnableAtRestEncryption { - results.Add( - "EMR cluster does not have at-rest encryption enabled.", - conf.Configuration, - ) - } else { - results.AddPassed(&conf) - } - - } - return - }, -) - -type conf struct { - EncryptionConfiguration struct { - AtRestEncryptionConfiguration struct { - S3EncryptionConfiguration struct { - EncryptionMode string `json:"EncryptionMode"` - } `json:"S3EncryptionConfiguration"` - LocalDiskEncryptionConfiguration struct { - EncryptionKeyProviderType string `json:"EncryptionKeyProviderType"` - AwsKmsKey string `json:"AwsKmsKey"` - } `json:"LocalDiskEncryptionConfiguration"` - } `json:"AtRestEncryptionConfiguration"` - EnableInTransitEncryption bool `json:"EnableInTransitEncryption"` - EnableAtRestEncryption bool `json:"EnableAtRestEncryption"` - } `json:"EncryptionConfiguration"` -} - -func readVarsFromConfigurationAtRest(raw string) (*conf, error) { - var testConf conf - if err := json.Unmarshal([]byte(raw), &testConf); err != nil { - return nil, err - } - - return &testConf, nil -} diff --git a/checks/cloud/aws/emr/enable_at_rest_encryption.tf.go b/checks/cloud/aws/emr/enable_at_rest_encryption.tf.go deleted file mode 100644 index 072ffbcd..00000000 --- a/checks/cloud/aws/emr/enable_at_rest_encryption.tf.go +++ /dev/null @@ -1,57 +0,0 @@ -package emr - -var terraformEnableAtRestEncryptionGoodExamples = []string{ - ` - resource "aws_emr_security_configuration" "good_example" { - name = "emrsc_other" - - configuration = <90 days", &user) - continue - } - var hasKey bool - for _, key := range user.AccessKeys { - if key.Active.IsFalse() || !key.LastAccess.GetMetadata().IsResolvable() || - key.LastAccess.After(time.Now().Add(-90*24*time.Hour)) { - continue - } - results.Add(fmt.Sprintf("User access key '%s' has not been used in >90 days", key.AccessKeyId.Value()), &user) - hasKey = true - } - if !hasKey { - results.AddPassed(&user) - } - } - - return - }, -) diff --git a/checks/cloud/aws/iam/disable_unused_credentials_45.go b/checks/cloud/aws/iam/disable_unused_credentials_45.go deleted file mode 100644 index abf88843..00000000 --- a/checks/cloud/aws/iam/disable_unused_credentials_45.go +++ /dev/null @@ -1,64 +0,0 @@ -package iam - -import ( - "fmt" - "time" - - "github.com/aquasecurity/trivy/pkg/iac/framework" - - "github.com/aquasecurity/trivy/pkg/iac/severity" - - "github.com/aquasecurity/trivy/pkg/iac/state" - - "github.com/aquasecurity/trivy/pkg/iac/scan" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - - "github.com/aquasecurity/trivy/pkg/iac/providers" -) - -var CheckUnusedCredentialsDisabled45Days = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0166", - Provider: providers.AWSProvider, - Frameworks: map[framework.Framework][]string{ - framework.CIS_AWS_1_4: {"1.12"}, - }, - Service: "iam", - ShortCode: "disable-unused-credentials-45-days", - Summary: "AWS IAM users can access AWS resources using different types of credentials, such as\npasswords or access keys. It is recommended that all credentials that have been unused in\n45 or greater days be deactivated or removed.", - Impact: "Leaving unused credentials active widens the scope for compromise.", - Resolution: "Disable credentials which are no longer used.", - Explanation: ` -Disabling or removing unnecessary credentials will reduce the window of opportunity for credentials associated with a compromised or abandoned account to be used. - `, - Links: []string{ - "https://console.aws.amazon.com/iam/", - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - for _, user := range s.AWS.IAM.Users { - if user.HasLoggedIn() && user.LastAccess.Before(time.Now().Add(-45*24*time.Hour)) { - results.Add("User has not logged in for >45 days", &user) - continue - } - var hasKey bool - for _, key := range user.AccessKeys { - if key.Active.IsFalse() || !key.LastAccess.GetMetadata().IsResolvable() || - key.LastAccess.After(time.Now().Add(-45*24*time.Hour)) { - continue - } - results.Add(fmt.Sprintf("User access key '%s' has not been used in >45 days", key.AccessKeyId.Value()), &user) - hasKey = true - } - if !hasKey { - results.AddPassed(&user) - } - } - - return - }, -) diff --git a/checks/cloud/aws/iam/enforce_group_mfa.go b/checks/cloud/aws/iam/enforce_group_mfa.go deleted file mode 100644 index 85376865..00000000 --- a/checks/cloud/aws/iam/enforce_group_mfa.go +++ /dev/null @@ -1,67 +0,0 @@ -package iam - -import ( - "strings" - - "github.com/aquasecurity/trivy/pkg/iac/severity" - - "github.com/aquasecurity/trivy/pkg/iac/state" - - "github.com/aquasecurity/trivy/pkg/iac/scan" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - - "github.com/aquasecurity/trivy/pkg/iac/providers" -) - -var CheckEnforceGroupMFA = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0123", - Aliases: []string{"aws-iam-enforce-mfa"}, - Provider: providers.AWSProvider, - Service: "iam", - ShortCode: "enforce-group-mfa", - Summary: "IAM groups should have MFA enforcement activated.", - Impact: "IAM groups are more vulnerable to compromise without multi factor authentication activated", - Resolution: "Use terraform-module/enforce-mfa/aws to ensure that MFA is enforced", - Explanation: ` -IAM groups should be protected with multi factor authentication to add safe guards to password compromise. - `, - Links: []string{ - "https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_passwords_account-policy.html#password-policy-details", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnforceMfaGoodExamples, - BadExamples: terraformEnforceMfaBadExamples, - Links: terraformEnforceMfaLinks, - RemediationMarkdown: terraformEnforceMfaRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - for _, group := range s.AWS.IAM.Groups { - var mfaEnforced bool - for _, policy := range group.Policies { - document := policy.Document.Parsed - statements, _ := document.Statements() - for _, statement := range statements { - conditions, _ := statement.Conditions() - for _, condition := range conditions { - key, _ := condition.Key() - if strings.EqualFold(key, "aws:MultiFactorAuthPresent") { - mfaEnforced = true - break - } - } - } - } - if !mfaEnforced { - results.Add("Multi-Factor authentication is not enforced for group", &group) - } - } - - return - }, -) diff --git a/checks/cloud/aws/iam/enforce_group_mfa.tf.go b/checks/cloud/aws/iam/enforce_group_mfa.tf.go deleted file mode 100644 index 8d74983a..00000000 --- a/checks/cloud/aws/iam/enforce_group_mfa.tf.go +++ /dev/null @@ -1,137 +0,0 @@ -package iam - -var terraformEnforceMfaGoodExamples = []string{ - ` -resource "aws_iam_group" "support" { - name = "support" -} -resource "aws_iam_group_policy" "mfa" { - - group = aws_iam_group.support.name - policy = < 1 { - results.Add("User has more than one active access key", &user) - } else { - results.AddPassed(&user) - } - } - return - }, -) diff --git a/checks/cloud/aws/iam/no_password_reuse.go b/checks/cloud/aws/iam/no_password_reuse.go deleted file mode 100755 index 0bd06ed8..00000000 --- a/checks/cloud/aws/iam/no_password_reuse.go +++ /dev/null @@ -1,58 +0,0 @@ -package iam - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPasswordReuse = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0056", - Provider: providers.AWSProvider, - Service: "iam", - ShortCode: "no-password-reuse", - Frameworks: map[framework.Framework][]string{ - framework.Default: nil, - framework.CIS_AWS_1_2: {"1.10"}, - framework.CIS_AWS_1_4: {"1.9"}, - }, - Summary: "IAM Password policy should prevent password reuse.", - Impact: "Password reuse increase the risk of compromised passwords being abused", - Resolution: "Prevent password reuse in the policy", - Explanation: `IAM account password policies should prevent the reuse of passwords. - -The account password policy should be set to prevent using any of the last five used passwords.`, - Links: []string{ - "https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_passwords_account-policy.html#password-policy-details", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPasswordReuseGoodExamples, - BadExamples: terraformNoPasswordReuseBadExamples, - Links: terraformNoPasswordReuseLinks, - RemediationMarkdown: terraformNoPasswordReuseRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - - policy := s.AWS.IAM.PasswordPolicy - if policy.Metadata.IsUnmanaged() { - return - } - - if policy.ReusePreventionCount.LessThan(5) { - results.Add( - "Password policy allows reuse of recent passwords.", - policy.ReusePreventionCount, - ) - } else { - results.AddPassed(&policy) - } - return - }, -) diff --git a/checks/cloud/aws/iam/no_password_reuse.tf.go b/checks/cloud/aws/iam/no_password_reuse.tf.go deleted file mode 100644 index df9a34a6..00000000 --- a/checks/cloud/aws/iam/no_password_reuse.tf.go +++ /dev/null @@ -1,27 +0,0 @@ -package iam - -var terraformNoPasswordReuseGoodExamples = []string{ - ` - resource "aws_iam_account_password_policy" "good_example" { - # ... - password_reuse_prevention = 5 - # ... - } - `, -} - -var terraformNoPasswordReuseBadExamples = []string{ - ` - resource "aws_iam_account_password_policy" "bad_example" { - # ... - password_reuse_prevention = 1 - # ... - } - `, -} - -var terraformNoPasswordReuseLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_account_password_policy`, -} - -var terraformNoPasswordReuseRemediationMarkdown = `` diff --git a/checks/cloud/aws/iam/no_policy_wildcards.cf.go b/checks/cloud/aws/iam/no_policy_wildcards.cf.go deleted file mode 100644 index dc509d23..00000000 --- a/checks/cloud/aws/iam/no_policy_wildcards.cf.go +++ /dev/null @@ -1,41 +0,0 @@ -package iam - -var cloudFormationNoPolicyWildcardsGoodExamples = []string{ - `--- -Resources: - GoodPolicy: - Type: 'AWS::IAM::Policy' - Properties: - PolicyName: CFNUsers - PolicyDocument: - Version: "2012-10-17" - Statement: - - Effect: Allow - Action: - - 's3:ListBuckets' - Resource: 'specific-bucket' -`, -} - -var cloudFormationNoPolicyWildcardsBadExamples = []string{ - `--- -Resources: - BadPolicy: - Type: 'AWS::IAM::Policy' - Properties: - PolicyName: CFNUsers - PolicyDocument: - Version: "2012-10-17" - Statement: - - Effect: Allow - Action: - - 'cloudformation:Describe*' - - 'cloudformation:List*' - - 'cloudformation:Get*' - Resource: '*' -`, -} - -var cloudFormationNoPolicyWildcardsLinks = []string{} - -var cloudFormationNoPolicyWildcardsRemediationMarkdown = `` diff --git a/checks/cloud/aws/iam/no_policy_wildcards.go b/checks/cloud/aws/iam/no_policy_wildcards.go deleted file mode 100755 index af9ee4dc..00000000 --- a/checks/cloud/aws/iam/no_policy_wildcards.go +++ /dev/null @@ -1,180 +0,0 @@ -package iam - -import ( - "fmt" - "regexp" - "strings" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/framework" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/aws/iam" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/liamg/iamgo" -) - -var ( - //arn:aws:logs:us-west-2:123456789012:log-group:SampleLogGroupName:* - cloudwatchLogStreamResourceRegex = regexp.MustCompile(`^arn:aws:logs:.*:.+:log-group:.+:\*`) -) - -var CheckNoPolicyWildcards = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0057", - Provider: providers.AWSProvider, - Service: "iam", - ShortCode: "no-policy-wildcards", - Frameworks: map[framework.Framework][]string{ - framework.Default: nil, - framework.CIS_AWS_1_4: {"1.16"}, - }, - Summary: "IAM policy should avoid use of wildcards and instead apply the principle of least privilege", - Impact: "Overly permissive policies may grant access to sensitive resources", - Resolution: "Specify the exact permissions required, and to which resources they should apply instead of using wildcards.", - Explanation: `You should use the principle of least privilege when defining your IAM policies. This means you should specify each exact permission required without using wildcards, as this could cause the granting of access to certain undesired actions, resources and principals.`, - Links: []string{ - "https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPolicyWildcardsGoodExamples, - BadExamples: terraformNoPolicyWildcardsBadExamples, - Links: terraformNoPolicyWildcardsLinks, - RemediationMarkdown: terraformNoPolicyWildcardsRemediationMarkdown, - }, - CloudFormation: &scan.EngineMetadata{ - GoodExamples: cloudFormationNoPolicyWildcardsGoodExamples, - BadExamples: cloudFormationNoPolicyWildcardsBadExamples, - Links: cloudFormationNoPolicyWildcardsLinks, - RemediationMarkdown: cloudFormationNoPolicyWildcardsRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, policy := range s.AWS.IAM.Policies { - if policy.Builtin.IsTrue() { - continue - } - results = checkPolicy(policy.Document, results) - } - for _, group := range s.AWS.IAM.Groups { - for _, policy := range group.Policies { - if policy.Builtin.IsTrue() { - continue - } - results = checkPolicy(policy.Document, results) - } - } - for _, user := range s.AWS.IAM.Users { - for _, policy := range user.Policies { - if policy.Builtin.IsTrue() { - continue - } - results = checkPolicy(policy.Document, results) - } - } - for _, role := range s.AWS.IAM.Roles { - for _, policy := range role.Policies { - if policy.Builtin.IsTrue() { - continue - } - results = checkPolicy(policy.Document, results) - } - } - return results - }, -) - -func checkPolicy(src iam.Document, results scan.Results) scan.Results { - statements, _ := src.Parsed.Statements() - for _, statement := range statements { - results = checkStatement(src, statement, results) - } - return results -} - -// nolint -func checkStatement(src iam.Document, statement iamgo.Statement, results scan.Results) scan.Results { - effect, _ := statement.Effect() - if effect != iamgo.EffectAllow { - return results - } - - actions, r := statement.Actions() - for _, action := range actions { - if strings.Contains(action, "*") { - results.Add( - fmt.Sprintf( - "IAM policy document uses wildcarded action '%s'", - actions[0], - ), - src.MetadataFromIamGo(statement.Range(), r), - ) - } else { - results.AddPassed(src) - } - } - - resources, r := statement.Resources() - for _, resource := range resources { - if strings.Contains(resource, "*") { - if allowed, action := iam.IsWildcardAllowed(actions...); !allowed { - if isObjectKeyContainsWildcard(resource) { - continue - } - if cloudwatchLogStreamResourceRegex.MatchString(resource) { - continue - } - - results.Add( - fmt.Sprintf("IAM policy document uses sensitive action '%s' on wildcarded resource '%s'", action, resources[0]), - src.MetadataFromIamGo(statement.Range(), r), - ) - } else { - results.AddPassed(src) - } - } else { - results.AddPassed(src) - } - } - principals, _ := statement.Principals() - if all, r := principals.All(); all { - results.Add( - "IAM policy document uses wildcarded principal.", - src.MetadataFromIamGo(statement.Range(), r), - ) - } - aws, r := principals.AWS() - for _, principal := range aws { - if strings.Contains(principal, "*") { - results.Add( - "IAM policy document uses wildcarded principal.", - src.MetadataFromIamGo(statement.Range(), r), - ) - } else { - results.AddPassed(src) - } - } - - return results -} - -func isObjectKeyContainsWildcard(arn string) bool { - // https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html - // arn:partition:service:region:account-id:resource-id - arnParts := strings.SplitN(arn, ":", 6) - - if len(arnParts) != 6 || arnParts[2] != "s3" { - return false - } - - resourceParts := strings.SplitN(arnParts[5], "/", 2) - if len(resourceParts) != 2 { - return false - } - - return !strings.ContainsRune(resourceParts[0], '*') && strings.ContainsRune(resourceParts[1], '*') - -} diff --git a/checks/cloud/aws/iam/no_policy_wildcards.tf.go b/checks/cloud/aws/iam/no_policy_wildcards.tf.go deleted file mode 100644 index 0f72fd19..00000000 --- a/checks/cloud/aws/iam/no_policy_wildcards.tf.go +++ /dev/null @@ -1,85 +0,0 @@ -package iam - -var terraformNoPolicyWildcardsGoodExamples = []string{ - ` - resource "aws_iam_role_policy" "test_policy" { - name = "test_policy" - role = aws_iam_role.test_role.id - - policy = data.aws_iam_policy_document.s3_policy.json - } - - resource "aws_iam_role" "test_role" { - name = "test_role" - assume_role_policy = jsonencode({ - Version = "2012-10-17" - Statement = [ - { - Action = "sts:AssumeRole" - Effect = "Allow" - Sid = "" - Principal = { - Service = "s3.amazonaws.com" - } - }, - ] - }) - } - - data "aws_iam_policy_document" "s3_policy" { - statement { - principals { - type = "AWS" - identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"] - } - actions = ["s3:GetObject"] - resources = [aws_s3_bucket.example.arn] - } - } - `, -} - -var terraformNoPolicyWildcardsBadExamples = []string{ - ` - resource "aws_iam_role_policy" "test_policy" { - name = "test_policy" - role = aws_iam_role.test_role.id - - policy = data.aws_iam_policy_document.s3_policy.json - } - - resource "aws_iam_role" "test_role" { - name = "test_role" - assume_role_policy = jsonencode({ - Version = "2012-10-17" - Statement = [ - { - Action = "sts:AssumeRole" - Effect = "Allow" - Sid = "" - Principal = { - Service = "s3.amazonaws.com" - } - }, - ] - }) - } - - data "aws_iam_policy_document" "s3_policy" { - statement { - principals { - type = "AWS" - identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"] - } - actions = ["s3:*"] - resources = ["*"] - } - } - `, -} - -var terraformNoPolicyWildcardsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document`, -} - -var terraformNoPolicyWildcardsRemediationMarkdown = `` diff --git a/checks/cloud/aws/iam/no_policy_wildcards.yaml b/checks/cloud/aws/iam/no_policy_wildcards.yaml deleted file mode 100644 index 7026ce4e..00000000 --- a/checks/cloud/aws/iam/no_policy_wildcards.yaml +++ /dev/null @@ -1,104 +0,0 @@ -terraform: - good: - - |- - resource "aws_iam_role_policy" "test_policy" { - name = "test_policy" - role = aws_iam_role.test_role.id - - policy = data.aws_iam_policy_document.s3_policy.json - } - - resource "aws_iam_role" "test_role" { - name = "test_role" - assume_role_policy = jsonencode({ - Version = "2012-10-17" - Statement = [ - { - Action = "sts:AssumeRole" - Effect = "Allow" - Sid = "" - Principal = { - Service = "s3.amazonaws.com" - } - }, - ] - }) - } - - data "aws_iam_policy_document" "s3_policy" { - statement { - principals { - type = "AWS" - identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"] - } - actions = ["s3:GetObject"] - resources = [aws_s3_bucket.example.arn] - } - } - bad: - - |- - resource "aws_iam_role_policy" "test_policy" { - name = "test_policy" - role = aws_iam_role.test_role.id - - policy = data.aws_iam_policy_document.s3_policy.json - } - - resource "aws_iam_role" "test_role" { - name = "test_role" - assume_role_policy = jsonencode({ - Version = "2012-10-17" - Statement = [ - { - Action = "sts:AssumeRole" - Effect = "Allow" - Sid = "" - Principal = { - Service = "s3.amazonaws.com" - } - }, - ] - }) - } - - data "aws_iam_policy_document" "s3_policy" { - statement { - principals { - type = "AWS" - identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"] - } - actions = ["s3:*"] - resources = ["*"] - } - } -cloudformation: - good: - - |- - Resources: - GoodPolicy: - Properties: - PolicyDocument: - Statement: - - Action: - - s3:ListBuckets - Effect: Allow - Resource: specific-bucket - Version: "2012-10-17" - PolicyName: CFNUsers - Type: AWS::IAM::Policy - bad: - - |- - Resources: - BadPolicy: - Properties: - PolicyDocument: - Statement: - - Action: - - cloudformation:Describe* - - cloudformation:List* - - cloudformation:Get* - Effect: Allow - Resource: '*' - Version: "2012-10-17" - PolicyName: CFNUsers - Type: AWS::IAM::Policy diff --git a/checks/cloud/aws/iam/no_root_access_keys.go b/checks/cloud/aws/iam/no_root_access_keys.go deleted file mode 100644 index 08a906ae..00000000 --- a/checks/cloud/aws/iam/no_root_access_keys.go +++ /dev/null @@ -1,63 +0,0 @@ -package iam - -import ( - "github.com/aquasecurity/trivy/pkg/iac/framework" - - "github.com/aquasecurity/trivy/pkg/iac/severity" - - "github.com/aquasecurity/trivy/pkg/iac/state" - - "github.com/aquasecurity/trivy/pkg/iac/scan" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - - "github.com/aquasecurity/trivy/pkg/iac/providers" -) - -var CheckNoRootAccessKeys = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0141", - Provider: providers.AWSProvider, - Service: "iam", - ShortCode: "no-root-access-keys", - Frameworks: map[framework.Framework][]string{ - framework.Default: nil, - framework.CIS_AWS_1_2: {"1.12"}, - framework.CIS_AWS_1_4: {"1.4"}, - }, - Summary: "The root user has complete access to all services and resources in an AWS account. AWS Access Keys provide programmatic access to a given account.", - Impact: "Compromise of the root account compromises the entire AWS account and all resources within it.", - Resolution: "Use lower privileged accounts instead, so only required privileges are available.", - Explanation: ` -CIS recommends that all access keys be associated with the root user be removed. Removing access keys associated with the root user limits vectors that the account can be compromised by. Removing the root user access keys also encourages the creation and use of role-based accounts that are least privileged. - `, - Links: []string{ - "https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoRootAccessKeysGoodExamples, - BadExamples: terraformNoRootAccessKeysBadExamples, - Links: terraformNoRootAccessKeysLinks, - RemediationMarkdown: terraformNoRootAccessKeysRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, user := range s.AWS.IAM.Users { - if user.Name.EqualTo("root") { - var hasActiveKey bool - for _, key := range user.AccessKeys { - if key.Active.IsTrue() { - results.Add("Access key exists for root user", &key) - hasActiveKey = true - } - } - if !hasActiveKey { - results.AddPassed(&user) - } - } - } - return - }, -) diff --git a/checks/cloud/aws/iam/no_root_access_keys.tf.go b/checks/cloud/aws/iam/no_root_access_keys.tf.go deleted file mode 100644 index fa4134fc..00000000 --- a/checks/cloud/aws/iam/no_root_access_keys.tf.go +++ /dev/null @@ -1,23 +0,0 @@ -package iam - -var terraformNoRootAccessKeysGoodExamples = []string{ - ` -resource "aws_iam_access_key" "good_example" { - user = "lowprivuser" -} - `, -} - -var terraformNoRootAccessKeysBadExamples = []string{ - ` -resource "aws_iam_access_key" "good_example" { - user = "root" -} - `, -} - -var terraformNoRootAccessKeysLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key`, -} - -var terraformNoRootAccessKeysRemediationMarkdown = `` diff --git a/checks/cloud/aws/iam/no_user_attached_policies.go b/checks/cloud/aws/iam/no_user_attached_policies.go deleted file mode 100644 index 9b2a995a..00000000 --- a/checks/cloud/aws/iam/no_user_attached_policies.go +++ /dev/null @@ -1,56 +0,0 @@ -package iam - -import ( - "github.com/aquasecurity/trivy/pkg/iac/framework" - - "github.com/aquasecurity/trivy/pkg/iac/severity" - - "github.com/aquasecurity/trivy/pkg/iac/state" - - "github.com/aquasecurity/trivy/pkg/iac/scan" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - - "github.com/aquasecurity/trivy/pkg/iac/providers" -) - -var CheckNoUserAttachedPolicies = rules.Register( - scan.Rule{ - AVDID: "AVD-AWS-0143", - Provider: providers.AWSProvider, - Service: "iam", - ShortCode: "no-user-attached-policies", - Frameworks: map[framework.Framework][]string{ - framework.Default: nil, - framework.CIS_AWS_1_2: {"1.16"}, - framework.CIS_AWS_1_4: {"1.15"}, - }, - Summary: "IAM policies should not be granted directly to users.", - Impact: "Complex access control is difficult to manage and maintain.", - Resolution: "Grant policies at the group level instead.", - Explanation: ` -CIS recommends that you apply IAM policies directly to groups and roles but not users. Assigning privileges at the group or role level reduces the complexity of access management as the number of users grow. Reducing access management complexity might in turn reduce opportunity for a principal to inadvertently receive or retain excessive privileges. - `, - Links: []string{ - "https://console.aws.amazon.com/iam/", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoUserAttachedPoliciesGoodExamples, - BadExamples: terraformNoUserAttachedPoliciesBadExamples, - Links: terraformNoUserAttachedPoliciesLinks, - RemediationMarkdown: terraformNoUserAttachedPoliciesRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, user := range s.AWS.IAM.Users { - if len(user.Policies) > 0 { - results.Add("One or more policies are attached directly to a user", &user) - } else { - results.AddPassed(&user) - } - } - return - }, -) diff --git a/checks/cloud/aws/iam/no_user_attached_policies.tf.go b/checks/cloud/aws/iam/no_user_attached_policies.tf.go deleted file mode 100644 index 825757a5..00000000 --- a/checks/cloud/aws/iam/no_user_attached_policies.tf.go +++ /dev/null @@ -1,78 +0,0 @@ -package iam - -var terraformNoUserAttachedPoliciesGoodExamples = []string{ - ` -resource "aws_iam_group" "developers" { - name = "developers" - path = "/users/" -} - -resource "aws_iam_user" "jim" { - name = "jim" -} - -resource "aws_iam_group_membership" "devteam" { - name = "developers-team" - - users = [ - aws_iam_user.jim.name, - ] - - group = aws_iam_group.developers.name -} - -resource "aws_iam_group_policy" "ec2policy" { - name = "test" - group = aws_iam_group.developers.name - - policy = <encryption_settings block, the enabled attribute should be set to true.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/virtual-machines/linux/disk-encryption", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableDiskEncryptionGoodExamples, - BadExamples: terraformEnableDiskEncryptionBadExamples, - Links: terraformEnableDiskEncryptionLinks, - RemediationMarkdown: terraformEnableDiskEncryptionRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, disk := range s.Azure.Compute.ManagedDisks { - if disk.Metadata.IsUnmanaged() { - continue - } - if disk.Encryption.Enabled.IsFalse() { - results.Add( - "Managed disk is not encrypted.", - disk.Encryption.Enabled, - ) - } else { - results.AddPassed(&disk) - } - } - return - }, -) diff --git a/checks/cloud/azure/compute/enable_disk_encryption.tf.go b/checks/cloud/azure/compute/enable_disk_encryption.tf.go deleted file mode 100644 index d727db7c..00000000 --- a/checks/cloud/azure/compute/enable_disk_encryption.tf.go +++ /dev/null @@ -1,25 +0,0 @@ -package compute - -var terraformEnableDiskEncryptionGoodExamples = []string{ - ` - resource "azurerm_managed_disk" "good_example" { - encryption_settings { - enabled = true - } - }`, -} - -var terraformEnableDiskEncryptionBadExamples = []string{ - ` - resource "azurerm_managed_disk" "bad_example" { - encryption_settings { - enabled = false - } - }`, -} - -var terraformEnableDiskEncryptionLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/managed_disk`, -} - -var terraformEnableDiskEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/azure/compute/no_secrets_in_custom_data.go b/checks/cloud/azure/compute/no_secrets_in_custom_data.go deleted file mode 100755 index f0580ffc..00000000 --- a/checks/cloud/azure/compute/no_secrets_in_custom_data.go +++ /dev/null @@ -1,63 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/owenrumney/squealer/pkg/squealer" -) - -var scanner = squealer.NewStringScanner() - -var CheckNoSecretsInCustomData = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0037", - Provider: providers.AzureProvider, - Service: "compute", - ShortCode: "no-secrets-in-custom-data", - Summary: "Ensure that no sensitive credentials are exposed in VM custom_data", - Impact: "Sensitive credentials in custom_data can be leaked", - Resolution: "Don't use sensitive credentials in the VM custom_data", - Explanation: `When creating Azure Virtual Machines, custom_data is used to pass start up information into the EC2 instance. This custom_dat must not contain access key credentials.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoSecretsInCustomDataGoodExamples, - BadExamples: terraformNoSecretsInCustomDataBadExamples, - Links: terraformNoSecretsInCustomDataLinks, - RemediationMarkdown: terraformNoSecretsInCustomDataRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, vm := range s.Azure.Compute.LinuxVirtualMachines { - if vm.Metadata.IsUnmanaged() { - continue - } - if result := scanner.Scan(vm.CustomData.Value()); result.TransgressionFound { - results.Add( - "Virtual machine includes secret(s) in custom data.", - vm.CustomData, - ) - } else { - results.AddPassed(&vm) - } - } - for _, vm := range s.Azure.Compute.WindowsVirtualMachines { - if vm.Metadata.IsUnmanaged() { - continue - } - if result := scanner.Scan(vm.CustomData.Value()); result.TransgressionFound { - results.Add( - "Virtual machine includes secret(s) in custom data.", - vm.CustomData, - ) - } else { - results.AddPassed(&vm) - } - } - return - }, -) diff --git a/checks/cloud/azure/compute/no_secrets_in_custom_data.tf.go b/checks/cloud/azure/compute/no_secrets_in_custom_data.tf.go deleted file mode 100644 index b4558068..00000000 --- a/checks/cloud/azure/compute/no_secrets_in_custom_data.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package compute - -var terraformNoSecretsInCustomDataGoodExamples = []string{ - ` - resource "azurerm_virtual_machine" "good_example" { - name = "good_example" - os_profile_linux_config { - disable_password_authentication = false - } - os_profile { - custom_data =<= 2.99.0 - role_based_access_control_enabled = true - } - `, ` -resource "azurerm_kubernetes_cluster" "aks_cluster" { - name = var.name - location = var.location - resource_group_name = var.resource_group_name - dns_prefix = var.name - kubernetes_version = var.cluster_version - api_server_authorized_ip_ranges = var.ip_whitelist - azure_policy_enabled = true - default_node_pool { - name = "default" - enable_auto_scaling = true - min_count = var.node_min_count - max_count = var.node_max_count - max_pods = var.pod_max_count # If you don't specify only allows 30 pods - vm_size = var.vm_size - os_disk_size_gb = 250 # default 30GB - vnet_subnet_id = var.vnet_subnet_id - } - - network_profile { - network_plugin = "azure" - network_policy = "azure" - } - - identity { - type = "SystemAssigned" - } - - azure_active_directory_role_based_access_control { - managed = true - azure_rbac_enabled = true - admin_group_object_ids = [data.azuread_group.aks_admins.object_id] - } - -} -`, -} - -var terraformUseRbacPermissionsBadExamples = []string{ - ` - resource "azurerm_kubernetes_cluster" "bad_example" { - // azurerm < 2.99.0 - role_based_access_control { - enabled = false - } - - // azurerm >= 2.99.0 - role_based_access_control_enabled = false - } - `, -} - -var terraformUseRbacPermissionsLinks = []string{ - `https://www.terraform.io/docs/providers/azurerm/r/kubernetes_cluster.html#role_based_access_control`, -} - -var terraformUseRbacPermissionsRemediationMarkdown = `` diff --git a/checks/cloud/azure/database/all_threat_alerts_enabled.go b/checks/cloud/azure/database/all_threat_alerts_enabled.go deleted file mode 100755 index 253cd3ce..00000000 --- a/checks/cloud/azure/database/all_threat_alerts_enabled.go +++ /dev/null @@ -1,46 +0,0 @@ -package database - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckAllThreatAlertsEnabled = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0028", - Provider: providers.AzureProvider, - Service: "database", - ShortCode: "all-threat-alerts-enabled", - Summary: "No threat detections are set", - Impact: "Disabling threat alerts means you are not getting the full benefit of server security protection", - Resolution: "Use all provided threat alerts", - Explanation: `SQL Server can alert for security issues including SQL Injection, vulnerabilities, access anomalies and data exfiltration. Ensure none of these are disabled to benefit from the best protection`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformAllThreatAlertsEnabledGoodExamples, - BadExamples: terraformAllThreatAlertsEnabledBadExamples, - Links: terraformAllThreatAlertsEnabledLinks, - RemediationMarkdown: terraformAllThreatAlertsEnabledRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, server := range s.Azure.Database.MSSQLServers { - for _, policy := range server.SecurityAlertPolicies { - if len(policy.DisabledAlerts) > 0 { - results.Add( - "Server has a security alert policy which disables alerts.", - policy.DisabledAlerts[0], - ) - } else { - results.AddPassed(&policy) - } - } - } - return - }, -) diff --git a/checks/cloud/azure/database/all_threat_alerts_enabled.tf.go b/checks/cloud/azure/database/all_threat_alerts_enabled.tf.go deleted file mode 100644 index d0f3ce58..00000000 --- a/checks/cloud/azure/database/all_threat_alerts_enabled.tf.go +++ /dev/null @@ -1,38 +0,0 @@ -package database - -var terraformAllThreatAlertsEnabledGoodExamples = []string{ - ` - resource "azurerm_mssql_server_security_alert_policy" "good_example" { - resource_group_name = azurerm_resource_group.example.name - server_name = azurerm_sql_server.example.name - state = "Enabled" - storage_endpoint = azurerm_storage_account.example.primary_blob_endpoint - storage_account_access_key = azurerm_storage_account.example.primary_access_key - disabled_alerts = [] - retention_days = 20 - } - `, -} - -var terraformAllThreatAlertsEnabledBadExamples = []string{ - ` - resource "azurerm_mssql_server_security_alert_policy" "bad_example" { - resource_group_name = azurerm_resource_group.example.name - server_name = azurerm_sql_server.example.name - state = "Enabled" - storage_endpoint = azurerm_storage_account.example.primary_blob_endpoint - storage_account_access_key = azurerm_storage_account.example.primary_access_key - disabled_alerts = [ - "Sql_Injection", - "Data_Exfiltration" - ] - retention_days = 20 - } - `, -} - -var terraformAllThreatAlertsEnabledLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_server_security_alert_policy#disabled_alerts`, -} - -var terraformAllThreatAlertsEnabledRemediationMarkdown = `` diff --git a/checks/cloud/azure/database/enable_audit.go b/checks/cloud/azure/database/enable_audit.go deleted file mode 100755 index 1afb5ddc..00000000 --- a/checks/cloud/azure/database/enable_audit.go +++ /dev/null @@ -1,46 +0,0 @@ -package database - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableAudit = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0027", - Provider: providers.AzureProvider, - Service: "database", - ShortCode: "enable-audit", - Summary: "Auditing should be enabled on Azure SQL Databases", - Impact: "Auditing provides valuable information about access and usage", - Resolution: "Enable auditing on Azure SQL databases", - Explanation: `Auditing helps you maintain regulatory compliance, understand database activity, and gain insight into discrepancies and anomalies that could indicate business concerns or suspected security violations.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/azure-sql/database/auditing-overview", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableAuditGoodExamples, - BadExamples: terraformEnableAuditBadExamples, - Links: terraformEnableAuditLinks, - RemediationMarkdown: terraformEnableAuditRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, server := range s.Azure.Database.MSSQLServers { - if len(server.ExtendedAuditingPolicies) == 0 && server.Metadata.IsManaged() { - results.Add( - "Server does not have an extended audit policy configured.", - &server, - ) - } else { - results.AddPassed(&server) - } - } - return - }, -) diff --git a/checks/cloud/azure/database/enable_audit.tf.go b/checks/cloud/azure/database/enable_audit.tf.go deleted file mode 100644 index e99f2a8f..00000000 --- a/checks/cloud/azure/database/enable_audit.tf.go +++ /dev/null @@ -1,41 +0,0 @@ -package database - -var terraformEnableAuditGoodExamples = []string{ - ` - resource "azurerm_sql_server" "good_example" { - name = "mssqlserver" - resource_group_name = azurerm_resource_group.example.name - location = azurerm_resource_group.example.location - version = "12.0" - administrator_login = "mradministrator" - administrator_login_password = "tfsecRocks" - } - - resource "azurerm_mssql_server_extended_auditing_policy" "example" { - server_id = azurerm_sql_server.good_example.id - storage_endpoint = azurerm_storage_account.example.primary_blob_endpoint - storage_account_access_key = azurerm_storage_account.example.primary_access_key - storage_account_access_key_is_secondary = true - retention_in_days = 6 - } - `, -} - -var terraformEnableAuditBadExamples = []string{ - ` - resource "azurerm_sql_server" "bad_example" { - name = "mssqlserver" - resource_group_name = azurerm_resource_group.example.name - location = azurerm_resource_group.example.location - version = "12.0" - administrator_login = "mradministrator" - administrator_login_password = "tfsecRocks" - } - `, -} - -var terraformEnableAuditLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_server_extended_auditing_policy`, -} - -var terraformEnableAuditRemediationMarkdown = `` diff --git a/checks/cloud/azure/database/enable_ssl_enforcement.go b/checks/cloud/azure/database/enable_ssl_enforcement.go deleted file mode 100755 index a7ddd1f2..00000000 --- a/checks/cloud/azure/database/enable_ssl_enforcement.go +++ /dev/null @@ -1,73 +0,0 @@ -package database - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableSslEnforcement = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0020", - Provider: providers.AzureProvider, - Service: "database", - ShortCode: "enable-ssl-enforcement", - Summary: "SSL should be enforced on database connections where applicable", - Impact: "Insecure connections could lead to data loss and other vulnerabilities", - Resolution: "Enable SSL enforcement", - Explanation: `SSL connections should be enforced were available to ensure secure transfer and reduce the risk of compromising data in flight.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableSslEnforcementGoodExamples, - BadExamples: terraformEnableSslEnforcementBadExamples, - Links: terraformEnableSslEnforcementLinks, - RemediationMarkdown: terraformEnableSslEnforcementRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, server := range s.Azure.Database.MariaDBServers { - if server.Metadata.IsUnmanaged() { - continue - } - if server.EnableSSLEnforcement.IsFalse() { - results.Add( - "Database server does not have enforce SSL.", - server.EnableSSLEnforcement, - ) - } else { - results.AddPassed(&server) - } - } - for _, server := range s.Azure.Database.MySQLServers { - if server.Metadata.IsUnmanaged() { - continue - } - if server.EnableSSLEnforcement.IsFalse() { - results.Add( - "Database server does not have enforce SSL.", - server.EnableSSLEnforcement, - ) - } else { - results.AddPassed(&server) - } - } - for _, server := range s.Azure.Database.PostgreSQLServers { - if server.Metadata.IsUnmanaged() { - continue - } - if server.EnableSSLEnforcement.IsFalse() { - results.Add( - "Database server does not have enforce SSL.", - server.EnableSSLEnforcement, - ) - } else { - results.AddPassed(&server) - } - } - return - }, -) diff --git a/checks/cloud/azure/database/enable_ssl_enforcement.tf.go b/checks/cloud/azure/database/enable_ssl_enforcement.tf.go deleted file mode 100644 index 3781dabd..00000000 --- a/checks/cloud/azure/database/enable_ssl_enforcement.tf.go +++ /dev/null @@ -1,31 +0,0 @@ -package database - -var terraformEnableSslEnforcementGoodExamples = []string{ - ` - resource "azurerm_postgresql_server" "good_example" { - name = "good_example" - - public_network_access_enabled = false - ssl_enforcement_enabled = true - ssl_minimal_tls_version_enforced = "TLS1_2" - } - `, -} - -var terraformEnableSslEnforcementBadExamples = []string{ - ` - resource "azurerm_postgresql_server" "bad_example" { - name = "bad_example" - - public_network_access_enabled = false - ssl_enforcement_enabled = false - ssl_minimal_tls_version_enforced = "TLS1_2" - } - `, -} - -var terraformEnableSslEnforcementLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/postgresql_server#ssl_enforcement_enabled`, `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mysql_server#ssl_enforcement_enabled`, `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mariadb_server#ssl_enforcement_enabled`, -} - -var terraformEnableSslEnforcementRemediationMarkdown = `` diff --git a/checks/cloud/azure/database/no_public_access.go b/checks/cloud/azure/database/no_public_access.go deleted file mode 100755 index 0e9b55cb..00000000 --- a/checks/cloud/azure/database/no_public_access.go +++ /dev/null @@ -1,86 +0,0 @@ -package database - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicAccess = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0022", - Provider: providers.AzureProvider, - Service: "database", - ShortCode: "no-public-access", - Summary: "Ensure databases are not publicly accessible", - Impact: "Publicly accessible database could lead to compromised data", - Resolution: "Disable public access to database when not required", - Explanation: `Database resources should not publicly available. You should limit all access to the minimum that is required for your application to function.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicAccessGoodExamples, - BadExamples: terraformNoPublicAccessBadExamples, - Links: terraformNoPublicAccessLinks, - RemediationMarkdown: terraformNoPublicAccessRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, server := range s.Azure.Database.MariaDBServers { - if server.Metadata.IsUnmanaged() { - continue - } - if server.EnablePublicNetworkAccess.IsTrue() { - results.Add( - "Database server has public network access enabled.", - server.EnablePublicNetworkAccess, - ) - } else { - results.AddPassed(&server) - } - } - for _, server := range s.Azure.Database.MSSQLServers { - if server.Metadata.IsUnmanaged() { - continue - } - if server.EnablePublicNetworkAccess.IsTrue() { - results.Add( - "Database server has public network access enabled.", - server.EnablePublicNetworkAccess, - ) - } else { - results.AddPassed(&server) - } - } - for _, server := range s.Azure.Database.MySQLServers { - if server.Metadata.IsUnmanaged() { - continue - } - if server.EnablePublicNetworkAccess.IsTrue() { - results.Add( - "Database server has public network access enabled.", - server.EnablePublicNetworkAccess, - ) - } else { - results.AddPassed(&server) - } - } - for _, server := range s.Azure.Database.PostgreSQLServers { - if server.Metadata.IsUnmanaged() { - continue - } - if server.EnablePublicNetworkAccess.IsTrue() { - results.Add( - "Database server has public network access enabled.", - server.EnablePublicNetworkAccess, - ) - } else { - results.AddPassed(&server) - } - } - return - }, -) diff --git a/checks/cloud/azure/database/no_public_access.tf.go b/checks/cloud/azure/database/no_public_access.tf.go deleted file mode 100644 index 3664d2d3..00000000 --- a/checks/cloud/azure/database/no_public_access.tf.go +++ /dev/null @@ -1,31 +0,0 @@ -package database - -var terraformNoPublicAccessGoodExamples = []string{ - ` - resource "azurerm_postgresql_server" "good_example" { - name = "bad_example" - - public_network_access_enabled = false - ssl_enforcement_enabled = false - ssl_minimal_tls_version_enforced = "TLS1_2" - } - `, -} - -var terraformNoPublicAccessBadExamples = []string{ - ` - resource "azurerm_postgresql_server" "bad_example" { - name = "bad_example" - - public_network_access_enabled = true - ssl_enforcement_enabled = false - ssl_minimal_tls_version_enforced = "TLS1_2" - } - `, -} - -var terraformNoPublicAccessLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/postgresql_server#public_network_access_enabled`, `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mysql_server#public_network_access_enabled`, `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mariadb_server#public_network_access_enabled`, -} - -var terraformNoPublicAccessRemediationMarkdown = `` diff --git a/checks/cloud/azure/database/no_public_firewall_access.go b/checks/cloud/azure/database/no_public_firewall_access.go deleted file mode 100755 index 7373be72..00000000 --- a/checks/cloud/azure/database/no_public_firewall_access.go +++ /dev/null @@ -1,102 +0,0 @@ -package database - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/azure/database" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicFirewallAccess = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0029", - Provider: providers.AzureProvider, - Service: "database", - ShortCode: "no-public-firewall-access", - Summary: "Ensure database firewalls do not permit public access", - Impact: "Publicly accessible databases could lead to compromised data", - Resolution: "Don't use wide ip ranges for the sql firewall", - Explanation: `Azure services can be allowed access through the firewall using a start and end IP address of 0.0.0.0. No other end ip address should be combined with a start of 0.0.0.0`, - Links: []string{ - "https://docs.microsoft.com/en-us/rest/api/sql/2021-02-01-preview/firewall-rules/create-or-update", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicFirewallAccessGoodExamples, - BadExamples: terraformNoPublicFirewallAccessBadExamples, - Links: terraformNoPublicFirewallAccessLinks, - RemediationMarkdown: terraformNoPublicFirewallAccessRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, server := range s.Azure.Database.MariaDBServers { - for _, rule := range server.FirewallRules { - if allowingAzureServices(rule) { - continue - } - if (cidr.IsPublic(rule.StartIP.Value()) || cidr.IsPublic(rule.EndIP.Value())) && rule.StartIP.NotEqualTo(rule.EndIP.Value()) { - results.Add( - "Firewall rule allows public internet access to a database server.", - rule.StartIP, - ) - } else { - results.AddPassed(&rule) - } - } - } - for _, server := range s.Azure.Database.MSSQLServers { - for _, rule := range server.FirewallRules { - if allowingAzureServices(rule) { - continue - } - if (cidr.IsPublic(rule.StartIP.Value()) || cidr.IsPublic(rule.EndIP.Value())) && rule.StartIP.NotEqualTo(rule.EndIP.Value()) { - results.Add( - "Firewall rule allows public internet access to a database server.", - rule.StartIP, - ) - } else { - results.AddPassed(&rule) - } - } - } - for _, server := range s.Azure.Database.MySQLServers { - for _, rule := range server.FirewallRules { - if allowingAzureServices(rule) { - continue - } - if (cidr.IsPublic(rule.StartIP.Value()) || cidr.IsPublic(rule.EndIP.Value())) && rule.StartIP.NotEqualTo(rule.EndIP.Value()) { - results.Add( - "Firewall rule allows public internet access to a database server.", - rule.StartIP, - ) - } else { - results.AddPassed(&rule) - } - } - } - for _, server := range s.Azure.Database.PostgreSQLServers { - for _, rule := range server.FirewallRules { - if allowingAzureServices(rule) { - continue - } - if (cidr.IsPublic(rule.StartIP.Value()) || cidr.IsPublic(rule.EndIP.Value())) && rule.StartIP.NotEqualTo(rule.EndIP.Value()) { - results.Add( - "Firewall rule allows public internet access to a database server.", - rule.StartIP, - ) - } else { - results.AddPassed(&rule) - } - } - } - return - }, -) - -func allowingAzureServices(rule database.FirewallRule) bool { - return rule.StartIP.EqualTo("0.0.0.0") && rule.EndIP.EqualTo("0.0.0.0") -} diff --git a/checks/cloud/azure/database/no_public_firewall_access.tf.go b/checks/cloud/azure/database/no_public_firewall_access.tf.go deleted file mode 100644 index e3bcdf78..00000000 --- a/checks/cloud/azure/database/no_public_firewall_access.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package database - -var terraformNoPublicFirewallAccessGoodExamples = []string{ - ` - resource "azurerm_sql_firewall_rule" "good_example" { - name = "good_rule" - resource_group_name = azurerm_resource_group.example.name - server_name = azurerm_sql_server.example.name - start_ip_address = "0.0.0.0" - end_ip_address = "0.0.0.0" - } - `, -} - -var terraformNoPublicFirewallAccessBadExamples = []string{ - ` - resource "azurerm_sql_firewall_rule" "bad_example" { - name = "bad_rule" - resource_group_name = azurerm_resource_group.example.name - server_name = azurerm_sql_server.example.name - start_ip_address = "0.0.0.0" - end_ip_address = "255.255.255.255" - } - - resource "azurerm_postgresql_firewall_rule" "bad_example" { - name = "bad_example" - resource_group_name = azurerm_resource_group.example.name - server_name = azurerm_postgresql_server.example.name - start_ip_address = "0.0.0.0" - end_ip_address = "255.255.255.255" - } - `, -} - -var terraformNoPublicFirewallAccessLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/sql_firewall_rule#end_ip_address`, -} - -var terraformNoPublicFirewallAccessRemediationMarkdown = `` diff --git a/checks/cloud/azure/database/postgres_configuration_connection_throttling.go b/checks/cloud/azure/database/postgres_configuration_connection_throttling.go deleted file mode 100755 index 77497231..00000000 --- a/checks/cloud/azure/database/postgres_configuration_connection_throttling.go +++ /dev/null @@ -1,49 +0,0 @@ -package database - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckPostgresConfigurationLogConnectionThrottling = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0021", - Provider: providers.AzureProvider, - Service: "database", - ShortCode: "postgres-configuration-connection-throttling", - Summary: "Ensure server parameter 'connection_throttling' is set to 'ON' for PostgreSQL Database Server", - Impact: "No log information to help diagnosing connection contention issues", - Resolution: "Enable connection throttling logging", - Explanation: `Postgresql can generate logs for connection throttling to improve visibility for audit and configuration issue resolution.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/postgresql/concepts-server-logs#configure-logging", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformPostgresConfigurationConnectionThrottlingGoodExamples, - BadExamples: terraformPostgresConfigurationConnectionThrottlingBadExamples, - Links: terraformPostgresConfigurationConnectionThrottlingLinks, - RemediationMarkdown: terraformPostgresConfigurationConnectionThrottlingRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, server := range s.Azure.Database.PostgreSQLServers { - if server.Metadata.IsUnmanaged() { - continue - } - if server.Config.ConnectionThrottling.IsFalse() { - results.Add( - "Database server is not configured to throttle connections.", - server.Config.ConnectionThrottling, - ) - } else { - results.AddPassed(&server.Config) - } - } - return - }, -) diff --git a/checks/cloud/azure/database/postgres_configuration_connection_throttling.tf.go b/checks/cloud/azure/database/postgres_configuration_connection_throttling.tf.go deleted file mode 100644 index 8c2aa078..00000000 --- a/checks/cloud/azure/database/postgres_configuration_connection_throttling.tf.go +++ /dev/null @@ -1,59 +0,0 @@ -package database - -var terraformPostgresConfigurationConnectionThrottlingGoodExamples = []string{ - ` - resource "azurerm_resource_group" "example" { - name = "example-resources" - location = "West Europe" - } - - resource "azurerm_postgresql_server" "example" { - name = "example-psqlserver" - location = azurerm_resource_group.example.location - resource_group_name = azurerm_resource_group.example.name - - administrator_login = "psqladminun" - administrator_login_password = "H@Sh1CoR3!" - - sku_name = "GP_Gen5_4" - version = "9.6" - storage_mb = 640000 - } - - resource "azurerm_postgresql_configuration" "example" { - name = "connection_throttling" - resource_group_name = azurerm_resource_group.example.name - server_name = azurerm_postgresql_server.example.name - value = "on" - } - - `, -} - -var terraformPostgresConfigurationConnectionThrottlingBadExamples = []string{ - ` - resource "azurerm_resource_group" "example" { - name = "example-resources" - location = "West Europe" - } - - resource "azurerm_postgresql_server" "example" { - name = "example-psqlserver" - location = azurerm_resource_group.example.location - resource_group_name = azurerm_resource_group.example.name - - administrator_login = "psqladminun" - administrator_login_password = "H@Sh1CoR3!" - - sku_name = "GP_Gen5_4" - version = "9.6" - storage_mb = 640000 - } - `, -} - -var terraformPostgresConfigurationConnectionThrottlingLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/postgresql_configuration`, -} - -var terraformPostgresConfigurationConnectionThrottlingRemediationMarkdown = `` diff --git a/checks/cloud/azure/database/postgres_configuration_log_checkpoints.go b/checks/cloud/azure/database/postgres_configuration_log_checkpoints.go deleted file mode 100755 index d85850b7..00000000 --- a/checks/cloud/azure/database/postgres_configuration_log_checkpoints.go +++ /dev/null @@ -1,49 +0,0 @@ -package database - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckPostgresConfigurationLogCheckpoints = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0024", - Provider: providers.AzureProvider, - Service: "database", - ShortCode: "postgres-configuration-log-checkpoints", - Summary: "Ensure server parameter 'log_checkpoints' is set to 'ON' for PostgreSQL Database Server", - Impact: "No error and query logs generated on checkpoint", - Resolution: "Enable checkpoint logging", - Explanation: `Postgresql can generate logs for checkpoints to improve visibility for audit and configuration issue resolution.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/postgresql/concepts-server-logs#configure-logging", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformPostgresConfigurationLogCheckpointsGoodExamples, - BadExamples: terraformPostgresConfigurationLogCheckpointsBadExamples, - Links: terraformPostgresConfigurationLogCheckpointsLinks, - RemediationMarkdown: terraformPostgresConfigurationLogCheckpointsRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, server := range s.Azure.Database.PostgreSQLServers { - if server.Metadata.IsUnmanaged() { - continue - } - if server.Config.LogCheckpoints.IsFalse() { - results.Add( - "Database server is not configured to log checkpoints.", - server.Config.LogCheckpoints, - ) - } else { - results.AddPassed(&server.Config) - } - } - return - }, -) diff --git a/checks/cloud/azure/database/postgres_configuration_log_checkpoints.tf.go b/checks/cloud/azure/database/postgres_configuration_log_checkpoints.tf.go deleted file mode 100644 index 027c20c1..00000000 --- a/checks/cloud/azure/database/postgres_configuration_log_checkpoints.tf.go +++ /dev/null @@ -1,59 +0,0 @@ -package database - -var terraformPostgresConfigurationLogCheckpointsGoodExamples = []string{ - ` - resource "azurerm_resource_group" "example" { - name = "example-resources" - location = "West Europe" - } - - resource "azurerm_postgresql_server" "example" { - name = "example-psqlserver" - location = azurerm_resource_group.example.location - resource_group_name = azurerm_resource_group.example.name - - administrator_login = "psqladminun" - administrator_login_password = "H@Sh1CoR3!" - - sku_name = "GP_Gen5_4" - version = "9.6" - storage_mb = 640000 - } - - resource "azurerm_postgresql_configuration" "example" { - name = "log_checkpoints" - resource_group_name = azurerm_resource_group.example.name - server_name = azurerm_postgresql_server.example.name - value = "on" - } - - `, -} - -var terraformPostgresConfigurationLogCheckpointsBadExamples = []string{ - ` - resource "azurerm_resource_group" "example" { - name = "example-resources" - location = "West Europe" - } - - resource "azurerm_postgresql_server" "example" { - name = "example-psqlserver" - location = azurerm_resource_group.example.location - resource_group_name = azurerm_resource_group.example.name - - administrator_login = "psqladminun" - administrator_login_password = "H@Sh1CoR3!" - - sku_name = "GP_Gen5_4" - version = "9.6" - storage_mb = 640000 - } - `, -} - -var terraformPostgresConfigurationLogCheckpointsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/postgresql_configuration`, -} - -var terraformPostgresConfigurationLogCheckpointsRemediationMarkdown = `` diff --git a/checks/cloud/azure/database/postgres_configuration_log_connections.go b/checks/cloud/azure/database/postgres_configuration_log_connections.go deleted file mode 100755 index b0b7bbe3..00000000 --- a/checks/cloud/azure/database/postgres_configuration_log_connections.go +++ /dev/null @@ -1,49 +0,0 @@ -package database - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckPostgresConfigurationLogConnections = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0019", - Provider: providers.AzureProvider, - Service: "database", - ShortCode: "postgres-configuration-log-connections", - Summary: "Ensure server parameter 'log_connections' is set to 'ON' for PostgreSQL Database Server", - Impact: "No visibility of successful connections", - Resolution: "Enable connection logging", - Explanation: `Postgresql can generate logs for successful connections to improve visibility for audit and configuration issue resolution.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/postgresql/concepts-server-logs#configure-logging", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformPostgresConfigurationLogConnectionsGoodExamples, - BadExamples: terraformPostgresConfigurationLogConnectionsBadExamples, - Links: terraformPostgresConfigurationLogConnectionsLinks, - RemediationMarkdown: terraformPostgresConfigurationLogConnectionsRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, server := range s.Azure.Database.PostgreSQLServers { - if server.Metadata.IsUnmanaged() { - continue - } - if server.Config.LogConnections.IsFalse() { - results.Add( - "Database server is not configured to log connections.", - server.Config.LogConnections, - ) - } else { - results.AddPassed(&server.Config) - } - } - return - }, -) diff --git a/checks/cloud/azure/database/postgres_configuration_log_connections.tf.go b/checks/cloud/azure/database/postgres_configuration_log_connections.tf.go deleted file mode 100644 index 842b1b53..00000000 --- a/checks/cloud/azure/database/postgres_configuration_log_connections.tf.go +++ /dev/null @@ -1,59 +0,0 @@ -package database - -var terraformPostgresConfigurationLogConnectionsGoodExamples = []string{ - ` - resource "azurerm_resource_group" "example" { - name = "example-resources" - location = "West Europe" - } - - resource "azurerm_postgresql_server" "example" { - name = "example-psqlserver" - location = azurerm_resource_group.example.location - resource_group_name = azurerm_resource_group.example.name - - administrator_login = "psqladminun" - administrator_login_password = "H@Sh1CoR3!" - - sku_name = "GP_Gen5_4" - version = "9.6" - storage_mb = 640000 - } - - resource "azurerm_postgresql_configuration" "example" { - name = "log_connections" - resource_group_name = azurerm_resource_group.example.name - server_name = azurerm_postgresql_server.example.name - value = "on" - } - - `, -} - -var terraformPostgresConfigurationLogConnectionsBadExamples = []string{ - ` - resource "azurerm_resource_group" "example" { - name = "example-resources" - location = "West Europe" - } - - resource "azurerm_postgresql_server" "example" { - name = "example-psqlserver" - location = azurerm_resource_group.example.location - resource_group_name = azurerm_resource_group.example.name - - administrator_login = "psqladminun" - administrator_login_password = "H@Sh1CoR3!" - - sku_name = "GP_Gen5_4" - version = "9.6" - storage_mb = 640000 - } - `, -} - -var terraformPostgresConfigurationLogConnectionsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/postgresql_configuration`, `https://docs.microsoft.com/en-us/azure/postgresql/concepts-server-logs#configure-logging`, -} - -var terraformPostgresConfigurationLogConnectionsRemediationMarkdown = `` diff --git a/checks/cloud/azure/database/retention_period_set.go b/checks/cloud/azure/database/retention_period_set.go deleted file mode 100755 index 1556e05f..00000000 --- a/checks/cloud/azure/database/retention_period_set.go +++ /dev/null @@ -1,50 +0,0 @@ -package database - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckRetentionPeriodSet = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0025", - Provider: providers.AzureProvider, - Service: "database", - ShortCode: "retention-period-set", - Summary: "Database auditing rentention period should be longer than 90 days", - Impact: "Short logging retention could result in missing valuable historical information", - Resolution: "Set retention periods of database auditing to greater than 90 days", - Explanation: `When Auditing is configured for a SQL database, if the retention period is not set, the retention will be unlimited. - -If the retention period is to be explicitly set, it should be set for no less than 90 days.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/azure-sql/database/auditing-overview", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformRetentionPeriodSetGoodExamples, - BadExamples: terraformRetentionPeriodSetBadExamples, - Links: terraformRetentionPeriodSetLinks, - RemediationMarkdown: terraformRetentionPeriodSetRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, server := range s.Azure.Database.MSSQLServers { - for _, policy := range server.ExtendedAuditingPolicies { - if policy.RetentionInDays.LessThan(90) && policy.RetentionInDays.NotEqualTo(0) { - results.Add( - "Server has a retention period of less than 90 days.", - policy.RetentionInDays, - ) - } else { - results.AddPassed(&policy) - } - } - } - return - }, -) diff --git a/checks/cloud/azure/database/retention_period_set.tf.go b/checks/cloud/azure/database/retention_period_set.tf.go deleted file mode 100644 index cff5ab03..00000000 --- a/checks/cloud/azure/database/retention_period_set.tf.go +++ /dev/null @@ -1,38 +0,0 @@ -package database - -var terraformRetentionPeriodSetGoodExamples = []string{ - ` - resource "azurerm_mssql_database_extended_auditing_policy" "good_example" { - database_id = azurerm_mssql_database.example.id - storage_endpoint = azurerm_storage_account.example.primary_blob_endpoint - storage_account_access_key = azurerm_storage_account.example.primary_access_key - storage_account_access_key_is_secondary = false - } - - resource "azurerm_mssql_database_extended_auditing_policy" "good_example" { - database_id = azurerm_mssql_database.example.id - storage_endpoint = azurerm_storage_account.example.primary_blob_endpoint - storage_account_access_key = azurerm_storage_account.example.primary_access_key - storage_account_access_key_is_secondary = false - retention_in_days = 90 - } - `, -} - -var terraformRetentionPeriodSetBadExamples = []string{ - ` - resource "azurerm_mssql_database_extended_auditing_policy" "bad_example" { - database_id = azurerm_mssql_database.example.id - storage_endpoint = azurerm_storage_account.example.primary_blob_endpoint - storage_account_access_key = azurerm_storage_account.example.primary_access_key - storage_account_access_key_is_secondary = false - retention_in_days = 6 - } - `, -} - -var terraformRetentionPeriodSetLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_database_extended_auditing_policy`, `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_server#retention_in_days`, -} - -var terraformRetentionPeriodSetRemediationMarkdown = `` diff --git a/checks/cloud/azure/database/secure_tls_policy.go b/checks/cloud/azure/database/secure_tls_policy.go deleted file mode 100755 index 7fedbddf..00000000 --- a/checks/cloud/azure/database/secure_tls_policy.go +++ /dev/null @@ -1,73 +0,0 @@ -package database - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckSecureTlsPolicy = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0026", - Provider: providers.AzureProvider, - Service: "database", - ShortCode: "secure-tls-policy", - Summary: "Databases should have the minimum TLS set for connections", - Impact: "Outdated TLS policies increase exposure to known issues", - Resolution: "Use the most modern TLS policies available", - Explanation: `You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformSecureTlsPolicyGoodExamples, - BadExamples: terraformSecureTlsPolicyBadExamples, - Links: terraformSecureTlsPolicyLinks, - RemediationMarkdown: terraformSecureTlsPolicyRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, server := range s.Azure.Database.MSSQLServers { - if server.Metadata.IsUnmanaged() { - continue - } - if server.MinimumTLSVersion.NotEqualTo("1.2") { - results.Add( - "Database server does not require a secure TLS version.", - server.MinimumTLSVersion, - ) - } else { - results.AddPassed(&server) - } - } - for _, server := range s.Azure.Database.MySQLServers { - if server.Metadata.IsUnmanaged() { - continue - } - if server.MinimumTLSVersion.NotEqualTo("TLS1_2") { - results.Add( - "Database server does not require a secure TLS version.", - server.MinimumTLSVersion, - ) - } else { - results.AddPassed(&server) - } - } - for _, server := range s.Azure.Database.PostgreSQLServers { - if server.Metadata.IsUnmanaged() { - continue - } - if server.MinimumTLSVersion.NotEqualTo("TLS1_2") { - results.Add( - "Database server does not require a secure TLS version.", - server.MinimumTLSVersion, - ) - } else { - results.AddPassed(&server) - } - } - return - }, -) diff --git a/checks/cloud/azure/database/secure_tls_policy.tf.go b/checks/cloud/azure/database/secure_tls_policy.tf.go deleted file mode 100644 index 94b37b4d..00000000 --- a/checks/cloud/azure/database/secure_tls_policy.tf.go +++ /dev/null @@ -1,51 +0,0 @@ -package database - -var terraformSecureTlsPolicyGoodExamples = []string{ - ` - resource "azurerm_mssql_server" "good_example" { - name = "mssqlserver" - resource_group_name = azurerm_resource_group.example.name - location = azurerm_resource_group.example.location - version = "12.0" - administrator_login = "missadministrator" - administrator_login_password = "thisIsKat11" - minimum_tls_version = "1.2" - } - - resource "azurerm_postgresql_server" "good_example" { - name = "bad_example" - - public_network_access_enabled = true - ssl_enforcement_enabled = false - ssl_minimal_tls_version_enforced = "TLS1_2" - } - `, -} - -var terraformSecureTlsPolicyBadExamples = []string{ - ` - resource "azurerm_mssql_server" "bad_example" { - name = "mssqlserver" - resource_group_name = azurerm_resource_group.example.name - location = azurerm_resource_group.example.location - version = "12.0" - administrator_login = "missadministrator" - administrator_login_password = "thisIsKat11" - minimum_tls_version = "1.1" - } - - resource "azurerm_postgresql_server" "bad_example" { - name = "bad_example" - - public_network_access_enabled = true - ssl_enforcement_enabled = false - ssl_minimal_tls_version_enforced = "TLS1_1" - } - `, -} - -var terraformSecureTlsPolicyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_server#minimum_tls_version`, `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mysql_server#ssl_minimal_tls_version_enforced`, `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/postgresql_server#ssl_minimal_tls_version_enforced`, -} - -var terraformSecureTlsPolicyRemediationMarkdown = `` diff --git a/checks/cloud/azure/database/threat_alert_email_set.go b/checks/cloud/azure/database/threat_alert_email_set.go deleted file mode 100755 index cbf953f5..00000000 --- a/checks/cloud/azure/database/threat_alert_email_set.go +++ /dev/null @@ -1,46 +0,0 @@ -package database - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckThreatAlertEmailSet = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0018", - Provider: providers.AzureProvider, - Service: "database", - ShortCode: "threat-alert-email-set", - Summary: "At least one email address is set for threat alerts", - Impact: "Nobody will be promptly alerted in the case of a threat being detected", - Resolution: "Provide at least one email address for threat alerts", - Explanation: `SQL Server sends alerts for threat detection via email, if there are no email addresses set then mitigation will be delayed.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformThreatAlertEmailSetGoodExamples, - BadExamples: terraformThreatAlertEmailSetBadExamples, - Links: terraformThreatAlertEmailSetLinks, - RemediationMarkdown: terraformThreatAlertEmailSetRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, server := range s.Azure.Database.MSSQLServers { - for _, policy := range server.SecurityAlertPolicies { - if len(policy.EmailAddresses) == 0 { - results.Add( - "Security alert policy does not include any email addresses for notification.", - &policy, - ) - } else { - results.AddPassed(&policy) - } - } - } - return - }, -) diff --git a/checks/cloud/azure/database/threat_alert_email_set.tf.go b/checks/cloud/azure/database/threat_alert_email_set.tf.go deleted file mode 100644 index f2bc6bba..00000000 --- a/checks/cloud/azure/database/threat_alert_email_set.tf.go +++ /dev/null @@ -1,41 +0,0 @@ -package database - -var terraformThreatAlertEmailSetGoodExamples = []string{ - ` - resource "azurerm_mssql_server_security_alert_policy" "good_example" { - resource_group_name = azurerm_resource_group.example.name - server_name = azurerm_sql_server.example.name - state = "Enabled" - storage_endpoint = azurerm_storage_account.example.primary_blob_endpoint - storage_account_access_key = azurerm_storage_account.example.primary_access_key - disabled_alerts = [ - "Sql_Injection", - "Data_Exfiltration" - ] - email_addresses = ["db-security@acme.org"] - } - `, -} - -var terraformThreatAlertEmailSetBadExamples = []string{ - ` - resource "azurerm_mssql_server_security_alert_policy" "bad_example" { - resource_group_name = azurerm_resource_group.example.name - server_name = azurerm_sql_server.example.name - state = "Enabled" - storage_endpoint = azurerm_storage_account.example.primary_blob_endpoint - storage_account_access_key = azurerm_storage_account.example.primary_access_key - disabled_alerts = [ - "Sql_Injection", - "Data_Exfiltration" - ] - email_addresses = [] - } - `, -} - -var terraformThreatAlertEmailSetLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_server_security_alert_policy#email_addresses`, -} - -var terraformThreatAlertEmailSetRemediationMarkdown = `` diff --git a/checks/cloud/azure/database/threat_alert_email_to_owner.go b/checks/cloud/azure/database/threat_alert_email_to_owner.go deleted file mode 100755 index f517e85d..00000000 --- a/checks/cloud/azure/database/threat_alert_email_to_owner.go +++ /dev/null @@ -1,46 +0,0 @@ -package database - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckThreatAlertEmailToOwner = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0023", - Provider: providers.AzureProvider, - Service: "database", - ShortCode: "threat-alert-email-to-owner", - Summary: "Security threat alerts go to subcription owners and co-administrators", - Impact: "Administrators and subscription owners may have a delayed response", - Resolution: "Enable email to subscription owners", - Explanation: `Subscription owners should be notified when there are security alerts. By ensuring the administrators of the account have been notified they can quickly assist in any required remediation`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformThreatAlertEmailToOwnerGoodExamples, - BadExamples: terraformThreatAlertEmailToOwnerBadExamples, - Links: terraformThreatAlertEmailToOwnerLinks, - RemediationMarkdown: terraformThreatAlertEmailToOwnerRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, server := range s.Azure.Database.MSSQLServers { - for _, policy := range server.SecurityAlertPolicies { - if policy.EmailAccountAdmins.IsFalse() { - results.Add( - "Security alert policy does not alert account admins.", - policy.EmailAccountAdmins, - ) - } else { - results.AddPassed(&policy) - } - } - } - return - }, -) diff --git a/checks/cloud/azure/database/threat_alert_email_to_owner.tf.go b/checks/cloud/azure/database/threat_alert_email_to_owner.tf.go deleted file mode 100644 index 75d460ea..00000000 --- a/checks/cloud/azure/database/threat_alert_email_to_owner.tf.go +++ /dev/null @@ -1,37 +0,0 @@ -package database - -var terraformThreatAlertEmailToOwnerGoodExamples = []string{ - ` - resource "azurerm_mssql_server_security_alert_policy" "good_example" { - resource_group_name = azurerm_resource_group.example.name - server_name = azurerm_sql_server.example.name - state = "Enabled" - storage_endpoint = azurerm_storage_account.example.primary_blob_endpoint - storage_account_access_key = azurerm_storage_account.example.primary_access_key - disabled_alerts = [] - - email_account_admins = true - } - `, -} - -var terraformThreatAlertEmailToOwnerBadExamples = []string{ - ` - resource "azurerm_mssql_server_security_alert_policy" "bad_example" { - resource_group_name = azurerm_resource_group.example.name - server_name = azurerm_sql_server.example.name - state = "Enabled" - storage_endpoint = azurerm_storage_account.example.primary_blob_endpoint - storage_account_access_key = azurerm_storage_account.example.primary_access_key - disabled_alerts = [ - ] - email_account_admins = false - } - `, -} - -var terraformThreatAlertEmailToOwnerLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_server_security_alert_policy#email_account_admins`, -} - -var terraformThreatAlertEmailToOwnerRemediationMarkdown = `` diff --git a/checks/cloud/azure/datafactory/no_public_access.go b/checks/cloud/azure/datafactory/no_public_access.go deleted file mode 100755 index 73a7bb72..00000000 --- a/checks/cloud/azure/datafactory/no_public_access.go +++ /dev/null @@ -1,48 +0,0 @@ -package datafactory - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicAccess = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0035", - Provider: providers.AzureProvider, - Service: "datafactory", - ShortCode: "no-public-access", - Summary: "Data Factory should have public access disabled, the default is enabled.", - Impact: "Data factory is publicly accessible", - Resolution: "Set public access to disabled for Data Factory", - Explanation: `Data Factory has public access set to true by default. - -Disabling public network access is applicable only to the self-hosted integration runtime, not to Azure Integration Runtime and SQL Server Integration Services (SSIS) Integration Runtime.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/data-factory/data-movement-security-considerations#hybrid-scenarios", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicAccessGoodExamples, - BadExamples: terraformNoPublicAccessBadExamples, - Links: terraformNoPublicAccessLinks, - RemediationMarkdown: terraformNoPublicAccessRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, factory := range s.Azure.DataFactory.DataFactories { - if factory.EnablePublicNetwork.IsTrue() { - results.Add( - "Data factory allows public network access.", - factory.EnablePublicNetwork, - ) - } else { - results.AddPassed(&factory) - } - } - return - }, -) diff --git a/checks/cloud/azure/datafactory/no_public_access.tf.go b/checks/cloud/azure/datafactory/no_public_access.tf.go deleted file mode 100644 index 3d1773f4..00000000 --- a/checks/cloud/azure/datafactory/no_public_access.tf.go +++ /dev/null @@ -1,28 +0,0 @@ -package datafactory - -var terraformNoPublicAccessGoodExamples = []string{ - ` - resource "azurerm_data_factory" "good_example" { - name = "example" - location = azurerm_resource_group.example.location - resource_group_name = azurerm_resource_group.example.name - public_network_enabled = false - } - `, -} - -var terraformNoPublicAccessBadExamples = []string{ - ` - resource "azurerm_data_factory" "bad_example" { - name = "example" - location = azurerm_resource_group.example.location - resource_group_name = azurerm_resource_group.example.name - } - `, -} - -var terraformNoPublicAccessLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/data_factory#public_network_enabled`, -} - -var terraformNoPublicAccessRemediationMarkdown = `` diff --git a/checks/cloud/azure/datalake/enable_at_rest_encryption.go b/checks/cloud/azure/datalake/enable_at_rest_encryption.go deleted file mode 100755 index 60206898..00000000 --- a/checks/cloud/azure/datalake/enable_at_rest_encryption.go +++ /dev/null @@ -1,46 +0,0 @@ -package datalake - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableAtRestEncryption = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0036", - Provider: providers.AzureProvider, - Service: "datalake", - ShortCode: "enable-at-rest-encryption", - Summary: "Unencrypted data lake storage.", - Impact: "Data could be read if compromised", - Resolution: "Enable encryption of data lake storage", - Explanation: `Datalake storage encryption defaults to Enabled, it shouldn't be overridden to Disabled.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/data-lake-store/data-lake-store-security-overview", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableAtRestEncryptionGoodExamples, - BadExamples: terraformEnableAtRestEncryptionBadExamples, - Links: terraformEnableAtRestEncryptionLinks, - RemediationMarkdown: terraformEnableAtRestEncryptionRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, store := range s.Azure.DataLake.Stores { - if store.EnableEncryption.IsFalse() { - results.Add( - "Data lake store is not encrypted.", - store.EnableEncryption, - ) - } else { - results.AddPassed(&store) - } - } - return - }, -) diff --git a/checks/cloud/azure/datalake/enable_at_rest_encryption.tf.go b/checks/cloud/azure/datalake/enable_at_rest_encryption.tf.go deleted file mode 100644 index 82a77644..00000000 --- a/checks/cloud/azure/datalake/enable_at_rest_encryption.tf.go +++ /dev/null @@ -1,21 +0,0 @@ -package datalake - -var terraformEnableAtRestEncryptionGoodExamples = []string{ - ` - resource "azurerm_data_lake_store" "good_example" { - encryption_state = "Enabled" - }`, -} - -var terraformEnableAtRestEncryptionBadExamples = []string{ - ` - resource "azurerm_data_lake_store" "bad_example" { - encryption_state = "Disabled" - }`, -} - -var terraformEnableAtRestEncryptionLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/data_lake_store`, -} - -var terraformEnableAtRestEncryptionRemediationMarkdown = `` diff --git a/checks/cloud/azure/keyvault/content_type_for_secret.go b/checks/cloud/azure/keyvault/content_type_for_secret.go deleted file mode 100755 index da7de8fb..00000000 --- a/checks/cloud/azure/keyvault/content_type_for_secret.go +++ /dev/null @@ -1,50 +0,0 @@ -package keyvault - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckContentTypeForSecret = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0015", - Provider: providers.AzureProvider, - Service: "keyvault", - ShortCode: "content-type-for-secret", - Summary: "Key vault Secret should have a content type set", - Impact: "The secret's type is unclear without a content type", - Resolution: "Provide content type for secrets to aid interpretation on retrieval", - Explanation: `Content Type is an optional Key Vault Secret behavior and is not enabled by default. - -Clients may specify the content type of a secret to assist in interpreting the secret data when it's retrieved. The maximum length of this field is 255 characters. There are no pre-defined values. The suggested usage is as a hint for interpreting the secret data.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/key-vault/secrets/about-secrets", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformContentTypeForSecretGoodExamples, - BadExamples: terraformContentTypeForSecretBadExamples, - Links: terraformContentTypeForSecretLinks, - RemediationMarkdown: terraformContentTypeForSecretRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, vault := range s.Azure.KeyVault.Vaults { - for _, secret := range vault.Secrets { - if secret.ContentType.IsEmpty() { - results.Add( - "Secret does not have a content-type specified.", - secret.ContentType, - ) - } else { - results.AddPassed(&secret) - } - } - } - return - }, -) diff --git a/checks/cloud/azure/keyvault/content_type_for_secret.tf.go b/checks/cloud/azure/keyvault/content_type_for_secret.tf.go deleted file mode 100644 index d790b650..00000000 --- a/checks/cloud/azure/keyvault/content_type_for_secret.tf.go +++ /dev/null @@ -1,28 +0,0 @@ -package keyvault - -var terraformContentTypeForSecretGoodExamples = []string{ - ` - resource "azurerm_key_vault_secret" "good_example" { - name = "secret-sauce" - value = "szechuan" - key_vault_id = azurerm_key_vault.example.id - content_type = "password" - } - `, -} - -var terraformContentTypeForSecretBadExamples = []string{ - ` - resource "azurerm_key_vault_secret" "bad_example" { - name = "secret-sauce" - value = "szechuan" - key_vault_id = azurerm_key_vault.example.id - } - `, -} - -var terraformContentTypeForSecretLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret#content_type`, -} - -var terraformContentTypeForSecretRemediationMarkdown = `` diff --git a/checks/cloud/azure/keyvault/ensure_key_expiry.go b/checks/cloud/azure/keyvault/ensure_key_expiry.go deleted file mode 100755 index 7b0d71e0..00000000 --- a/checks/cloud/azure/keyvault/ensure_key_expiry.go +++ /dev/null @@ -1,50 +0,0 @@ -package keyvault - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnsureKeyExpiry = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0014", - Provider: providers.AzureProvider, - Service: "keyvault", - ShortCode: "ensure-key-expiry", - Summary: "Ensure that the expiration date is set on all keys", - Impact: "Long life keys increase the attack surface when compromised", - Resolution: "Set an expiration date on the vault key", - Explanation: `Expiration Date is an optional Key Vault Key behavior and is not set by default. - -Set when the resource will be become inactive.`, - Links: []string{ - "https://docs.microsoft.com/en-us/powershell/module/az.keyvault/update-azkeyvaultkey?view=azps-5.8.0#example-1--modify-a-key-to-enable-it--and-set-the-expiration-date-and-tags", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnsureKeyExpiryGoodExamples, - BadExamples: terraformEnsureKeyExpiryBadExamples, - Links: terraformEnsureKeyExpiryLinks, - RemediationMarkdown: terraformEnsureKeyExpiryRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, vault := range s.Azure.KeyVault.Vaults { - for _, key := range vault.Keys { - if key.ExpiryDate.IsNever() { - results.Add( - "Key should have an expiry date specified.", - key.ExpiryDate, - ) - } else { - results.AddPassed(&key) - } - } - } - return - }, -) diff --git a/checks/cloud/azure/keyvault/ensure_key_expiry.tf.go b/checks/cloud/azure/keyvault/ensure_key_expiry.tf.go deleted file mode 100644 index af23cd37..00000000 --- a/checks/cloud/azure/keyvault/ensure_key_expiry.tf.go +++ /dev/null @@ -1,48 +0,0 @@ -package keyvault - -var terraformEnsureKeyExpiryGoodExamples = []string{ - ` - resource "azurerm_key_vault_key" "good_example" { - name = "generated-certificate" - key_vault_id = azurerm_key_vault.example.id - key_type = "RSA" - key_size = 2048 - expiration_date = "1982-12-31T00:00:00Z" - - key_opts = [ - "decrypt", - "encrypt", - "sign", - "unwrapKey", - "verify", - "wrapKey", - ] - } - `, -} - -var terraformEnsureKeyExpiryBadExamples = []string{ - ` - resource "azurerm_key_vault_key" "bad_example" { - name = "generated-certificate" - key_vault_id = azurerm_key_vault.example.id - key_type = "RSA" - key_size = 2048 - - key_opts = [ - "decrypt", - "encrypt", - "sign", - "unwrapKey", - "verify", - "wrapKey", - ] - } - `, -} - -var terraformEnsureKeyExpiryLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_key#expiration_date`, -} - -var terraformEnsureKeyExpiryRemediationMarkdown = `` diff --git a/checks/cloud/azure/keyvault/ensure_secret_expiry.go b/checks/cloud/azure/keyvault/ensure_secret_expiry.go deleted file mode 100755 index bb31c440..00000000 --- a/checks/cloud/azure/keyvault/ensure_secret_expiry.go +++ /dev/null @@ -1,50 +0,0 @@ -package keyvault - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnsureSecretExpiry = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0017", - Provider: providers.AzureProvider, - Service: "keyvault", - ShortCode: "ensure-secret-expiry", - Summary: "Key Vault Secret should have an expiration date set", - Impact: "Long life secrets increase the opportunity for compromise", - Resolution: "Set an expiry for secrets", - Explanation: `Expiration Date is an optional Key Vault Secret behavior and is not set by default. - -Set when the resource will be become inactive.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/key-vault/secrets/about-secrets", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnsureSecretExpiryGoodExamples, - BadExamples: terraformEnsureSecretExpiryBadExamples, - Links: terraformEnsureSecretExpiryLinks, - RemediationMarkdown: terraformEnsureSecretExpiryRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, vault := range s.Azure.KeyVault.Vaults { - for _, secret := range vault.Secrets { - if secret.ExpiryDate.IsNever() { - results.Add( - "Secret should have an expiry date specified.", - secret.ExpiryDate, - ) - } else { - results.AddPassed(&secret) - } - } - } - return - }, -) diff --git a/checks/cloud/azure/keyvault/ensure_secret_expiry.tf.go b/checks/cloud/azure/keyvault/ensure_secret_expiry.tf.go deleted file mode 100644 index c45f15f8..00000000 --- a/checks/cloud/azure/keyvault/ensure_secret_expiry.tf.go +++ /dev/null @@ -1,49 +0,0 @@ -package keyvault - -var terraformEnsureSecretExpiryGoodExamples = []string{ - ` - resource "azurerm_key_vault_secret" "good_example" { - name = "secret-sauce" - value = "szechuan" - key_vault_id = azurerm_key_vault.example.id - expiration_date = "1982-12-31T00:00:00Z" - } - `, - ` -resource "azuread_application" "myapp" { - display_name = "MyAzureAD App" - - group_membership_claims = ["ApplicationGroup"] - prevent_duplicate_names = true - -} - -resource "azuread_application_password" "myapp" { - application_object_id = azuread_application.myapp.object_id -} - -resource "azurerm_key_vault_secret" "myapp_pass" { - name = "myapp-oauth" - value = azuread_application_password.myapp.value - key_vault_id = azurerm_key_vault.cluster_key_vault.id - expiration_date = azuread_application_password.myapp.end_date - content_type = "Password" -} -`, -} - -var terraformEnsureSecretExpiryBadExamples = []string{ - ` - resource "azurerm_key_vault_secret" "bad_example" { - name = "secret-sauce" - value = "szechuan" - key_vault_id = azurerm_key_vault.example.id - } - `, -} - -var terraformEnsureSecretExpiryLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret#expiration_date`, -} - -var terraformEnsureSecretExpiryRemediationMarkdown = `` diff --git a/checks/cloud/azure/keyvault/no_purge.go b/checks/cloud/azure/keyvault/no_purge.go deleted file mode 100755 index ed0ad8bd..00000000 --- a/checks/cloud/azure/keyvault/no_purge.go +++ /dev/null @@ -1,56 +0,0 @@ -package keyvault - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPurge = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0016", - Provider: providers.AzureProvider, - Service: "keyvault", - ShortCode: "no-purge", - Summary: "Key vault should have purge protection enabled", - Impact: "Keys could be purged from the vault without protection", - Resolution: "Enable purge protection for key vaults", - Explanation: `Purge protection is an optional Key Vault behavior and is not enabled by default. - -Purge protection can only be enabled once soft-delete is enabled. It can be turned on via CLI or PowerShell.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/key-vault/general/soft-delete-overview#purge-protection", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPurgeGoodExamples, - BadExamples: terraformNoPurgeBadExamples, - Links: terraformNoPurgeLinks, - RemediationMarkdown: terraformNoPurgeRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, vault := range s.Azure.KeyVault.Vaults { - if vault.Metadata.IsUnmanaged() { - continue - } - if vault.EnablePurgeProtection.IsFalse() { - results.Add( - "Vault does not have purge protection enabled.", - vault.EnablePurgeProtection, - ) - } else if vault.EnablePurgeProtection.IsTrue() && (vault.SoftDeleteRetentionDays.LessThan(7) || vault.SoftDeleteRetentionDays.GreaterThan(90)) { - results.Add( - "Resource should have soft_delete_retention_days set between 7 and 90 days in order to enable purge protection.", - vault.SoftDeleteRetentionDays, - ) - } else { - results.AddPassed(&vault) - } - } - return - }, -) diff --git a/checks/cloud/azure/keyvault/no_purge.tf.go b/checks/cloud/azure/keyvault/no_purge.tf.go deleted file mode 100644 index 449ca628..00000000 --- a/checks/cloud/azure/keyvault/no_purge.tf.go +++ /dev/null @@ -1,30 +0,0 @@ -package keyvault - -var terraformNoPurgeGoodExamples = []string{ - ` - resource "azurerm_key_vault" "good_example" { - name = "examplekeyvault" - location = azurerm_resource_group.good_example.location - enabled_for_disk_encryption = true - soft_delete_retention_days = 7 - purge_protection_enabled = true - } - `, -} - -var terraformNoPurgeBadExamples = []string{ - ` - resource "azurerm_key_vault" "bad_example" { - name = "examplekeyvault" - location = azurerm_resource_group.bad_example.location - enabled_for_disk_encryption = true - purge_protection_enabled = false - } - `, -} - -var terraformNoPurgeLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault#purge_protection_enabled`, -} - -var terraformNoPurgeRemediationMarkdown = `` diff --git a/checks/cloud/azure/keyvault/specify_network_acl.go b/checks/cloud/azure/keyvault/specify_network_acl.go deleted file mode 100755 index 2997171d..00000000 --- a/checks/cloud/azure/keyvault/specify_network_acl.go +++ /dev/null @@ -1,51 +0,0 @@ -package keyvault - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckSpecifyNetworkAcl = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0013", - Provider: providers.AzureProvider, - Service: "keyvault", - ShortCode: "specify-network-acl", - Summary: "Key vault should have the network acl block specified", - Impact: "Without a network ACL the key vault is freely accessible", - Resolution: "Set a network ACL for the key vault", - Explanation: `Network ACLs allow you to reduce your exposure to risk by limiting what can access your key vault. - -The default action of the Network ACL should be set to deny for when IPs are not matched. Azure services can be allowed to bypass.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/key-vault/general/network-security", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformSpecifyNetworkAclGoodExamples, - BadExamples: terraformSpecifyNetworkAclBadExamples, - Links: terraformSpecifyNetworkAclLinks, - RemediationMarkdown: terraformSpecifyNetworkAclRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, vault := range s.Azure.KeyVault.Vaults { - if vault.Metadata.IsUnmanaged() { - continue - } - if vault.NetworkACLs.DefaultAction.NotEqualTo("Deny") { - results.Add( - "Vault network ACL does not block access by default.", - vault.NetworkACLs.DefaultAction, - ) - } else { - results.AddPassed(&vault) - } - } - return - }, -) diff --git a/checks/cloud/azure/keyvault/specify_network_acl.tf.go b/checks/cloud/azure/keyvault/specify_network_acl.tf.go deleted file mode 100644 index b351d30e..00000000 --- a/checks/cloud/azure/keyvault/specify_network_acl.tf.go +++ /dev/null @@ -1,36 +0,0 @@ -package keyvault - -var terraformSpecifyNetworkAclGoodExamples = []string{ - ` - resource "azurerm_key_vault" "good_example" { - name = "examplekeyvault" - location = azurerm_resource_group.good_example.location - enabled_for_disk_encryption = true - soft_delete_retention_days = 7 - purge_protection_enabled = false - - network_acls { - bypass = "AzureServices" - default_action = "Deny" - } - } - `, -} - -var terraformSpecifyNetworkAclBadExamples = []string{ - ` - resource "azurerm_key_vault" "bad_example" { - name = "examplekeyvault" - location = azurerm_resource_group.bad_example.location - enabled_for_disk_encryption = true - soft_delete_retention_days = 7 - purge_protection_enabled = false - } - `, -} - -var terraformSpecifyNetworkAclLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault#network_acls`, -} - -var terraformSpecifyNetworkAclRemediationMarkdown = `` diff --git a/checks/cloud/azure/monitor/activity_log_retention_set.go b/checks/cloud/azure/monitor/activity_log_retention_set.go deleted file mode 100755 index 8df1de96..00000000 --- a/checks/cloud/azure/monitor/activity_log_retention_set.go +++ /dev/null @@ -1,54 +0,0 @@ -package monitor - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckActivityLogRetentionSet = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0031", - Provider: providers.AzureProvider, - Service: "monitor", - ShortCode: "activity-log-retention-set", - Summary: "Ensure the activity retention log is set to at least a year", - Impact: "Short life activity logs can lead to missing records when investigating a breach", - Resolution: "Set a retention period that will allow for delayed investigation", - Explanation: `The average time to detect a breach is up to 210 days, to ensure that all the information required for an effective investigation is available, the retention period should allow for delayed starts to investigating.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/azure-monitor/essentials/platform-logs-overview", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformActivityLogRetentionSetGoodExamples, - BadExamples: terraformActivityLogRetentionSetBadExamples, - Links: terraformActivityLogRetentionSetLinks, - RemediationMarkdown: terraformActivityLogRetentionSetRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, profile := range s.Azure.Monitor.LogProfiles { - if profile.Metadata.IsUnmanaged() { - continue - } - if profile.RetentionPolicy.Enabled.IsFalse() { - results.Add( - "Profile does not enable the log retention policy.", - profile.RetentionPolicy.Enabled, - ) - } else if profile.RetentionPolicy.Days.LessThan(365) { - results.Add( - "Profile has a log retention policy of less than 1 year.", - profile.RetentionPolicy.Days, - ) - } else { - results.AddPassed(&profile) - } - } - return - }, -) diff --git a/checks/cloud/azure/monitor/activity_log_retention_set.tf.go b/checks/cloud/azure/monitor/activity_log_retention_set.tf.go deleted file mode 100644 index 7ada4568..00000000 --- a/checks/cloud/azure/monitor/activity_log_retention_set.tf.go +++ /dev/null @@ -1,33 +0,0 @@ -package monitor - -var terraformActivityLogRetentionSetGoodExamples = []string{ - ` - resource "azurerm_monitor_log_profile" "good_example" { - name = "good_example" - - retention_policy { - enabled = true - days = 365 - } - } - `, -} - -var terraformActivityLogRetentionSetBadExamples = []string{ - ` - resource "azurerm_monitor_log_profile" "bad_example" { - name = "bad_example" - - retention_policy { - enabled = true - days = 7 - } - } - `, -} - -var terraformActivityLogRetentionSetLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_log_profile#retention_policy`, -} - -var terraformActivityLogRetentionSetRemediationMarkdown = `` diff --git a/checks/cloud/azure/monitor/capture_all_activities.go b/checks/cloud/azure/monitor/capture_all_activities.go deleted file mode 100755 index 28eb4616..00000000 --- a/checks/cloud/azure/monitor/capture_all_activities.go +++ /dev/null @@ -1,75 +0,0 @@ -package monitor - -import ( - "fmt" - - "github.com/aquasecurity/trivy/pkg/iac/severity" - - "github.com/aquasecurity/trivy/pkg/iac/state" - - "github.com/aquasecurity/trivy/pkg/iac/scan" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/azure/monitor" -) - -var CheckCaptureAllActivities = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0033", - Provider: providers.AzureProvider, - Service: "monitor", - ShortCode: "capture-all-activities", - Summary: "Ensure log profile captures all activities", - Impact: "Log profile must capture all activity to be able to ensure that all relevant information possible is available for an investigation", - Resolution: "Configure log profile to capture all activities", - Explanation: `Log profiles should capture all categories to ensure that all events are logged`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/azure-monitor/essentials/activity-log", - "https://docs.microsoft.com/en-us/cli/azure/monitor/log-profiles?view=azure-cli-latest#az_monitor_log_profiles_create-required-parameters", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformCaptureAllActivitiesGoodExamples, - BadExamples: terraformCaptureAllActivitiesBadExamples, - Links: terraformCaptureAllActivitiesLinks, - RemediationMarkdown: terraformCaptureAllActivitiesRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - required := []string{ - "Action", "Write", "Delete", - } - for _, profile := range s.Azure.Monitor.LogProfiles { - if profile.Metadata.IsUnmanaged() { - continue - } - var failed bool - for _, cat := range required { - if !hasCategory(profile, cat) { - failed = true - results.Add( - fmt.Sprintf("Log profile does not require the '%s' category.", cat), - &profile, - ) - } - } - - if !failed { - results.AddPassed(&profile) - } - } - return - }, -) - -func hasCategory(profile monitor.LogProfile, cgry string) bool { - for _, category := range profile.Categories { - if category.EqualTo(cgry) { - return true - } - } - return false -} diff --git a/checks/cloud/azure/monitor/capture_all_activities.tf.go b/checks/cloud/azure/monitor/capture_all_activities.tf.go deleted file mode 100644 index b28eed26..00000000 --- a/checks/cloud/azure/monitor/capture_all_activities.tf.go +++ /dev/null @@ -1,41 +0,0 @@ -package monitor - -var terraformCaptureAllActivitiesGoodExamples = []string{ - ` - resource "azurerm_monitor_log_profile" "good_example" { - name = "good_example" - - categories = [ - "Action", - "Delete", - "Write", - ] - - retention_policy { - enabled = true - days = 365 - } - } - `, -} - -var terraformCaptureAllActivitiesBadExamples = []string{ - ` - resource "azurerm_monitor_log_profile" "bad_example" { - name = "bad_example" - - categories = [] - - retention_policy { - enabled = true - days = 7 - } - } - `, -} - -var terraformCaptureAllActivitiesLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_log_profile#categories`, -} - -var terraformCaptureAllActivitiesRemediationMarkdown = `` diff --git a/checks/cloud/azure/monitor/capture_all_regions.go b/checks/cloud/azure/monitor/capture_all_regions.go deleted file mode 100755 index 6208c55c..00000000 --- a/checks/cloud/azure/monitor/capture_all_regions.go +++ /dev/null @@ -1,146 +0,0 @@ -package monitor - -import ( - "fmt" - "strings" - - "github.com/aquasecurity/trivy/pkg/iac/severity" - - "github.com/aquasecurity/trivy/pkg/iac/state" - - "github.com/aquasecurity/trivy/pkg/iac/scan" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/azure/monitor" -) - -var CheckCaptureAllRegions = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0032", - Provider: providers.AzureProvider, - Service: "monitor", - ShortCode: "capture-all-regions", - Summary: "Ensure activitys are captured for all locations", - Impact: "Activity may be occurring in locations that aren't being monitored", - Resolution: "Enable capture for all locations", - Explanation: `Log profiles should capture all regions to ensure that all events are logged`, - Links: []string{ - "https://docs.microsoft.com/en-us/cli/azure/monitor/log-profiles?view=azure-cli-latest#az_monitor_log_profiles_create-required-parameters", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformCaptureAllRegionsGoodExamples, - BadExamples: terraformCaptureAllRegionsBadExamples, - Links: terraformCaptureAllRegionsLinks, - RemediationMarkdown: terraformCaptureAllRegionsRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, profile := range s.Azure.Monitor.LogProfiles { - if missing := findMissingRegions(profile); len(missing) > 0 { - details := fmt.Sprintf("%d regions missing", len(missing)) - if len(missing) < 10 { - details = fmt.Sprintf("missing: %s", strings.Join(missing, ", ")) - } - results.Add( - fmt.Sprintf("Log profile does not log to all regions (%s).", details), - &profile, - ) - } else { - results.AddPassed(&profile) - } - } - return - }, -) - -func findMissingRegions(profile monitor.LogProfile) []string { - var missing []string - for _, location := range locations { - var found bool - for _, loc := range profile.Locations { - if loc.EqualTo(location) { - found = true - break - } - } - if !found { - missing = append(missing, location) - } - } - return missing -} - -var locations = []string{ - "eastus", - "eastus2", - "southcentralus", - "westus2", - "westus3", - "australiaeast", - "southeastasia", - "northeurope", - "swedencentral", - "uksouth", - "westeurope", - "centralus", - "northcentralus", - "westus", - "southafricanorth", - "centralindia", - "eastasia", - "japaneast", - "jioindiawest", - "koreacentral", - "canadacentral", - "francecentral", - "germanywestcentral", - "norwayeast", - "switzerlandnorth", - "uaenorth", - "brazilsouth", - "centralusstage", - "eastusstage", - "eastus2stage", - "northcentralusstage", - "southcentralusstage", - "westusstage", - "westus2stage", - "asia", - "asiapacific", - "australia", - "brazil", - "canada", - "europe", - "global", - "india", - "japan", - "uk", - "unitedstates", - "eastasiastage", - "southeastasiastage", - "centraluseuap", - "eastus2euap", - "westcentralus", - "southafricawest", - "australiacentral", - "australiacentral2", - "australiasoutheast", - "japanwest", - "jioindiacentral", - "koreasouth", - "southindia", - "westindia", - "canadaeast", - "francesouth", - "germanynorth", - "norwaywest", - "swedensouth", - "switzerlandwest", - "ukwest", - "uaecentral", - "brazilsoutheast", -} diff --git a/checks/cloud/azure/monitor/capture_all_regions.tf.go b/checks/cloud/azure/monitor/capture_all_regions.tf.go deleted file mode 100644 index 42c2a886..00000000 --- a/checks/cloud/azure/monitor/capture_all_regions.tf.go +++ /dev/null @@ -1,115 +0,0 @@ -package monitor - -var terraformCaptureAllRegionsGoodExamples = []string{ - ` - resource "azurerm_monitor_log_profile" "good_example" { - name = "bad_example" - - categories = [] - - locations = [ - "eastus", - "eastus2", - "southcentralus", - "westus2", - "westus3", - "australiaeast", - "southeastasia", - "northeurope", - "swedencentral", - "uksouth", - "westeurope", - "centralus", - "northcentralus", - "westus", - "southafricanorth", - "centralindia", - "eastasia", - "japaneast", - "jioindiawest", - "koreacentral", - "canadacentral", - "francecentral", - "germanywestcentral", - "norwayeast", - "switzerlandnorth", - "uaenorth", - "brazilsouth", - "centralusstage", - "eastusstage", - "eastus2stage", - "northcentralusstage", - "southcentralusstage", - "westusstage", - "westus2stage", - "asia", - "asiapacific", - "australia", - "brazil", - "canada", - "europe", - "global", - "india", - "japan", - "uk", - "unitedstates", - "eastasiastage", - "southeastasiastage", - "centraluseuap", - "eastus2euap", - "westcentralus", - "southafricawest", - "australiacentral", - "australiacentral2", - "australiasoutheast", - "japanwest", - "jioindiacentral", - "koreasouth", - "southindia", - "westindia", - "canadaeast", - "francesouth", - "germanynorth", - "norwaywest", - "swedensouth", - "switzerlandwest", - "ukwest", - "uaecentral", - "brazilsoutheast", - ] - - retention_policy { - enabled = true - days = 7 - } - } - - `, -} - -var terraformCaptureAllRegionsBadExamples = []string{ - ` - - resource "azurerm_monitor_log_profile" "bad_example" { - name = "bad_example" - - categories = [] - - locations = [ - "westus", - "global", - ] - - retention_policy { - enabled = true - days = 7 - } - } - `, -} - -var terraformCaptureAllRegionsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_log_profile#locations`, -} - -var terraformCaptureAllRegionsRemediationMarkdown = `` diff --git a/checks/cloud/azure/network/disable_rdp_from_internet.go b/checks/cloud/azure/network/disable_rdp_from_internet.go deleted file mode 100755 index 6ac26642..00000000 --- a/checks/cloud/azure/network/disable_rdp_from_internet.go +++ /dev/null @@ -1,67 +0,0 @@ -package network - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var CheckDisableRdpFromInternet = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0048", - Provider: providers.AzureProvider, - Service: "network", - ShortCode: "disable-rdp-from-internet", - Summary: "RDP access should not be accessible from the Internet, should be blocked on port 3389", - Impact: "Anyone from the internet can potentially RDP onto an instance", - Resolution: "Block RDP port from internet", - Explanation: `RDP access can be configured on either the network security group or in the network security group rule. - -RDP access should not be permitted from the internet (*, 0.0.0.0, /0, internet, any). Consider using the Azure Bastion Service.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/bastion/tutorial-create-host-portal", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformDisableRdpFromInternetGoodExamples, - BadExamples: terraformDisableRdpFromInternetBadExamples, - Links: terraformDisableRdpFromInternetLinks, - RemediationMarkdown: terraformDisableRdpFromInternetRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.Azure.Network.SecurityGroups { - var failed bool - for _, rule := range group.Rules { - if rule.Allow.IsFalse() || rule.Outbound.IsTrue() { - continue - } - if rule.Protocol.EqualTo("Icmp", types.IgnoreCase) { - continue - } - for _, ports := range rule.DestinationPorts { - if ports.Includes(3389) { - for _, ip := range rule.SourceAddresses { - if cidr.IsPublic(ip.Value()) && cidr.CountAddresses(ip.Value()) > 1 { - failed = true - results.Add( - "Security group rule allows ingress to RDP port from multiple public internet addresses.", - ip, - ) - } - } - } - } - if !failed { - results.AddPassed(&group) - } - } - } - return - }, -) diff --git a/checks/cloud/azure/network/disable_rdp_from_internet.tf.go b/checks/cloud/azure/network/disable_rdp_from_internet.tf.go deleted file mode 100644 index f7341800..00000000 --- a/checks/cloud/azure/network/disable_rdp_from_internet.tf.go +++ /dev/null @@ -1,63 +0,0 @@ -package network - -var terraformDisableRdpFromInternetGoodExamples = []string{ - ` - resource "azurerm_network_security_rule" "good_example" { - name = "good_example_security_rule" - direction = "Inbound" - access = "Allow" - protocol = "TCP" - source_port_range = "*" - destination_port_ranges = ["3389"] - source_address_prefix = "4.53.160.75" - destination_address_prefix = "*" - } - - resource "azurerm_network_security_group" "example" { - name = "tf-appsecuritygroup" - location = azurerm_resource_group.example.location - resource_group_name = azurerm_resource_group.example.name - - security_rule { - source_port_range = "any" - destination_port_ranges = ["3389"] - source_address_prefix = "4.53.160.75" - destination_address_prefix = "*" - } - } - `, -} - -var terraformDisableRdpFromInternetBadExamples = []string{ - ` - resource "azurerm_network_security_rule" "bad_example" { - name = "bad_example_security_rule" - direction = "Inbound" - access = "Allow" - protocol = "TCP" - source_port_range = "*" - destination_port_ranges = ["3389"] - source_address_prefix = "*" - destination_address_prefix = "*" - } - - resource "azurerm_network_security_group" "example" { - name = "tf-appsecuritygroup" - location = azurerm_resource_group.example.location - resource_group_name = azurerm_resource_group.example.name - - security_rule { - source_port_range = "any" - destination_port_ranges = ["3389"] - source_address_prefix = "*" - destination_address_prefix = "*" - } - } - `, -} - -var terraformDisableRdpFromInternetLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/network_security_group#security_rule`, `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_security_rule#source_port_ranges`, -} - -var terraformDisableRdpFromInternetRemediationMarkdown = `` diff --git a/checks/cloud/azure/network/no_public_egress.go b/checks/cloud/azure/network/no_public_egress.go deleted file mode 100755 index d526138e..00000000 --- a/checks/cloud/azure/network/no_public_egress.go +++ /dev/null @@ -1,59 +0,0 @@ -package network - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicEgress = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0051", - Provider: providers.AzureProvider, - Service: "network", - ShortCode: "no-public-egress", - Summary: "An outbound network security rule allows traffic to /0.", - Impact: "The port is exposed for egress to the internet", - Resolution: "Set a more restrictive cidr range", - Explanation: `Network security rules should not use very broad subnets. - -Where possible, segments should be broken into smaller subnets.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/security/fundamentals/network-best-practices", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicEgressGoodExamples, - BadExamples: terraformNoPublicEgressBadExamples, - Links: terraformNoPublicEgressLinks, - RemediationMarkdown: terraformNoPublicEgressRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.Azure.Network.SecurityGroups { - var failed bool - for _, rule := range group.Rules { - if rule.Outbound.IsFalse() || rule.Allow.IsFalse() { - continue - } - for _, ip := range rule.DestinationAddresses { - if cidr.IsPublic(ip.Value()) { - failed = true - results.Add( - "Security group rule allows egress to public internet.", - ip, - ) - } - } - } - if !failed { - results.AddPassed(&group) - } - } - return - }, -) diff --git a/checks/cloud/azure/network/no_public_egress.tf.go b/checks/cloud/azure/network/no_public_egress.tf.go deleted file mode 100644 index 8ab85d72..00000000 --- a/checks/cloud/azure/network/no_public_egress.tf.go +++ /dev/null @@ -1,25 +0,0 @@ -package network - -var terraformNoPublicEgressGoodExamples = []string{ - ` - resource "azurerm_network_security_rule" "good_example" { - direction = "Outbound" - destination_address_prefix = "10.0.0.0/16" - access = "Allow" - }`, -} - -var terraformNoPublicEgressBadExamples = []string{ - ` - resource "azurerm_network_security_rule" "bad_example" { - direction = "Outbound" - destination_address_prefix = "0.0.0.0/0" - access = "Allow" - }`, -} - -var terraformNoPublicEgressLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_security_rule`, -} - -var terraformNoPublicEgressRemediationMarkdown = `` diff --git a/checks/cloud/azure/network/no_public_ingress.go b/checks/cloud/azure/network/no_public_ingress.go deleted file mode 100755 index c99a0a43..00000000 --- a/checks/cloud/azure/network/no_public_ingress.go +++ /dev/null @@ -1,60 +0,0 @@ -package network - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicIngress = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0047", - Provider: providers.AzureProvider, - Service: "network", - ShortCode: "no-public-ingress", - Summary: "An inbound network security rule allows traffic from /0.", - Impact: "The port is exposed for ingress from the internet", - Resolution: "Set a more restrictive cidr range", - Explanation: `Network security rules should not use very broad subnets. - -Where possible, segments should be broken into smaller subnets.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/security/fundamentals/network-best-practices", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicIngressGoodExamples, - BadExamples: terraformNoPublicIngressBadExamples, - Links: terraformNoPublicIngressLinks, - RemediationMarkdown: terraformNoPublicIngressRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.Azure.Network.SecurityGroups { - var failed bool - for _, rule := range group.Rules { - if rule.Outbound.IsTrue() || rule.Allow.IsFalse() { - continue - } - for _, ip := range rule.SourceAddresses { - // single public IPs acceptable to allow for well known IP addresses to be used - if cidr.IsPublic(ip.Value()) && cidr.CountAddresses(ip.Value()) > 1 { - failed = true - results.Add( - "Security group rule allows ingress from public internet.", - ip, - ) - } - } - } - if !failed { - results.AddPassed(&group) - } - } - return - }, -) diff --git a/checks/cloud/azure/network/no_public_ingress.tf.go b/checks/cloud/azure/network/no_public_ingress.tf.go deleted file mode 100644 index 6ef84dd8..00000000 --- a/checks/cloud/azure/network/no_public_ingress.tf.go +++ /dev/null @@ -1,33 +0,0 @@ -package network - -var terraformNoPublicIngressGoodExamples = []string{ - ` - resource "azurerm_network_security_rule" "good_example" { - direction = "Inbound" - destination_address_prefix = "10.0.0.0/16" - access = "Allow" - }`, ` -resource "azurerm_network_security_rule" "allow_lb_prober" { - direction = "Inbound" - access = "Allow" - protocol = "Tcp" # Probes are always TCP - source_port_range = "*" - destination_port_ranges = "443" - source_address_prefix = "168.63.129.16" // single public IP (Azure well known) -}`, -} - -var terraformNoPublicIngressBadExamples = []string{ - ` - resource "azurerm_network_security_rule" "bad_example" { - direction = "Inbound" - source_address_prefix = "0.0.0.0/0" - access = "Allow" - }`, -} - -var terraformNoPublicIngressLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_security_rule`, -} - -var terraformNoPublicIngressRemediationMarkdown = `` diff --git a/checks/cloud/azure/network/retention_policy_set.go b/checks/cloud/azure/network/retention_policy_set.go deleted file mode 100755 index 7b7b088a..00000000 --- a/checks/cloud/azure/network/retention_policy_set.go +++ /dev/null @@ -1,57 +0,0 @@ -package network - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckRetentionPolicySet = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0049", - Provider: providers.AzureProvider, - Service: "network", - ShortCode: "retention-policy-set", - Summary: "Retention policy for flow logs should be enabled and set to greater than 90 days", - Impact: "Not enabling retention or having short expiry on flow logs could lead to compromise being undetected limiting time for analysis", - Resolution: "Ensure flow log retention is turned on with an expiry of >90 days", - Explanation: `Flow logs are the source of truth for all network activity in your cloud environment. -To enable analysis in security event that was detected late, you need to have the logs available. - -Setting an retention policy will help ensure as much information is available for review.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/network-watcher/network-watcher-monitoring-overview", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformRetentionPolicySetGoodExamples, - BadExamples: terraformRetentionPolicySetBadExamples, - Links: terraformRetentionPolicySetLinks, - RemediationMarkdown: terraformRetentionPolicySetRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, flowLog := range s.Azure.Network.NetworkWatcherFlowLogs { - if flowLog.Metadata.IsUnmanaged() { - continue - } - if flowLog.RetentionPolicy.Enabled.IsFalse() { - results.Add( - "Flow log does not enable the log retention policy.", - flowLog.RetentionPolicy.Enabled, - ) - } else if flowLog.RetentionPolicy.Days.LessThan(90) { - results.Add( - "Flow log has a log retention policy of less than 90 days.", - flowLog.RetentionPolicy.Days, - ) - } else { - results.AddPassed(&flowLog) - } - } - return - }, -) diff --git a/checks/cloud/azure/network/retention_policy_set.tf.go b/checks/cloud/azure/network/retention_policy_set.tf.go deleted file mode 100644 index d7f5af81..00000000 --- a/checks/cloud/azure/network/retention_policy_set.tf.go +++ /dev/null @@ -1,43 +0,0 @@ -package network - -var terraformRetentionPolicySetGoodExamples = []string{ - ` -resource "azurerm_network_watcher_flow_log" "good_watcher" { - network_watcher_name = "good_watcher" - resource_group_name = "resource-group" - - network_security_group_id = azurerm_network_security_group.test.id - storage_account_id = azurerm_storage_account.test.id - enabled = true - - retention_policy { - enabled = true - days = 90 - } -} - `, -} - -var terraformRetentionPolicySetBadExamples = []string{ - ` -resource "azurerm_network_watcher_flow_log" "bad_watcher" { - network_watcher_name = "bad_watcher" - resource_group_name = "resource-group" - - network_security_group_id = azurerm_network_security_group.test.id - storage_account_id = azurerm_storage_account.test.id - enabled = true - - retention_policy { - enabled = true - days = 7 - } -} - `, -} - -var terraformRetentionPolicySetLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_watcher_flow_log#retention_policy`, -} - -var terraformRetentionPolicySetRemediationMarkdown = `` diff --git a/checks/cloud/azure/network/ssh_blocked_from_internet.go b/checks/cloud/azure/network/ssh_blocked_from_internet.go deleted file mode 100755 index 377d9b29..00000000 --- a/checks/cloud/azure/network/ssh_blocked_from_internet.go +++ /dev/null @@ -1,65 +0,0 @@ -package network - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var CheckSshBlockedFromInternet = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0050", - Provider: providers.AzureProvider, - Service: "network", - ShortCode: "ssh-blocked-from-internet", - Summary: "SSH access should not be accessible from the Internet, should be blocked on port 22", - Impact: "Its dangerous to allow SSH access from the internet", - Resolution: "Block port 22 access from the internet", - Explanation: `SSH access can be configured on either the network security group or in the network security group rule. - -SSH access should not be permitted from the internet (*, 0.0.0.0, /0, internet, any)`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformSshBlockedFromInternetGoodExamples, - BadExamples: terraformSshBlockedFromInternetBadExamples, - Links: terraformSshBlockedFromInternetLinks, - RemediationMarkdown: terraformSshBlockedFromInternetRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.Azure.Network.SecurityGroups { - var failed bool - for _, rule := range group.Rules { - if rule.Allow.IsFalse() || rule.Outbound.IsTrue() { - continue - } - if rule.Protocol.EqualTo("Icmp", types.IgnoreCase) { - continue - } - for _, ports := range rule.DestinationPorts { - if ports.Includes(22) { - for _, ip := range rule.SourceAddresses { - if cidr.IsPublic(ip.Value()) && cidr.CountAddresses(ip.Value()) > 1 { - failed = true - results.Add( - "Security group rule allows ingress to SSH port from multiple public internet addresses.", - ip, - ) - } - } - } - } - if !failed { - results.AddPassed(&group) - } - } - } - return - }, -) diff --git a/checks/cloud/azure/network/ssh_blocked_from_internet.tf.go b/checks/cloud/azure/network/ssh_blocked_from_internet.tf.go deleted file mode 100644 index 9662cfbe..00000000 --- a/checks/cloud/azure/network/ssh_blocked_from_internet.tf.go +++ /dev/null @@ -1,37 +0,0 @@ -package network - -var terraformSshBlockedFromInternetGoodExamples = []string{ - ` - resource "azurerm_network_security_rule" "good_example" { - name = "good_example_security_rule" - direction = "Inbound" - access = "Allow" - protocol = "TCP" - source_port_range = "*" - destination_port_range = "22" - source_address_prefix = "82.102.23.23" - destination_address_prefix = "*" - } - `, -} - -var terraformSshBlockedFromInternetBadExamples = []string{ - ` - resource "azurerm_network_security_rule" "bad_example" { - name = "bad_example_security_rule" - direction = "Inbound" - access = "Allow" - protocol = "TCP" - source_port_range = "*" - destination_port_range = "22" - source_address_prefix = "*" - destination_address_prefix = "*" - } - `, -} - -var terraformSshBlockedFromInternetLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/network_security_group#security_rule`, `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_security_rule#source_port_ranges`, -} - -var terraformSshBlockedFromInternetRemediationMarkdown = `` diff --git a/checks/cloud/azure/securitycenter/alert_on_severe_notifications.go b/checks/cloud/azure/securitycenter/alert_on_severe_notifications.go deleted file mode 100755 index 84dbabca..00000000 --- a/checks/cloud/azure/securitycenter/alert_on_severe_notifications.go +++ /dev/null @@ -1,50 +0,0 @@ -package securitycenter - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckAlertOnSevereNotifications = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0044", - Provider: providers.AzureProvider, - Service: "security-center", - ShortCode: "alert-on-severe-notifications", - Summary: "Send notification emails for high severity alerts", - Impact: "The ability to react to high severity notifications could be delayed", - Resolution: " Set alert notifications to be on", - Explanation: `It is recommended that at least one valid contact is configured for the security center. -Microsoft will notify the security contact directly in the event of a security incident using email and require alerting to be turned on.`, - Links: []string{ - "https://azure.microsoft.com/en-us/services/security-center/", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformAlertOnSevereNotificationsGoodExamples, - BadExamples: terraformAlertOnSevereNotificationsBadExamples, - Links: terraformAlertOnSevereNotificationsLinks, - RemediationMarkdown: terraformAlertOnSevereNotificationsRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, contact := range s.Azure.SecurityCenter.Contacts { - if contact.Metadata.IsUnmanaged() { - continue - } - if contact.EnableAlertNotifications.IsFalse() { - results.Add( - "Security contact has alert notifications disabled.", - contact.EnableAlertNotifications, - ) - } else { - results.AddPassed(&contact) - } - } - return - }, -) diff --git a/checks/cloud/azure/securitycenter/alert_on_severe_notifications.tf.go b/checks/cloud/azure/securitycenter/alert_on_severe_notifications.tf.go deleted file mode 100644 index 3dd661f0..00000000 --- a/checks/cloud/azure/securitycenter/alert_on_severe_notifications.tf.go +++ /dev/null @@ -1,31 +0,0 @@ -package securitycenter - -var terraformAlertOnSevereNotificationsGoodExamples = []string{ - ` - resource "azurerm_security_center_contact" "good_example" { - email = "good_example@example.com" - phone = "+1-555-555-5555" - - alert_notifications = true - alerts_to_admins = true - } - `, -} - -var terraformAlertOnSevereNotificationsBadExamples = []string{ - ` - resource "azurerm_security_center_contact" "bad_example" { - email = "bad_example@example.com" - phone = "+1-555-555-5555" - - alert_notifications = false - alerts_to_admins = false - } - `, -} - -var terraformAlertOnSevereNotificationsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/security_center_contact#alert_notifications`, -} - -var terraformAlertOnSevereNotificationsRemediationMarkdown = `` diff --git a/checks/cloud/azure/securitycenter/enable_standard_subscription.go b/checks/cloud/azure/securitycenter/enable_standard_subscription.go deleted file mode 100755 index 147f5940..00000000 --- a/checks/cloud/azure/securitycenter/enable_standard_subscription.go +++ /dev/null @@ -1,52 +0,0 @@ -package securitycenter - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/azure/securitycenter" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableStandardSubscription = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0045", - Provider: providers.AzureProvider, - Service: "security-center", - ShortCode: "enable-standard-subscription", - Summary: "Enable the standard security center subscription tier", - Impact: "Using free subscription does not enable Azure Defender for the resource type", - Resolution: "Enable standard subscription tier to benefit from Azure Defender", - Explanation: `To benefit from Azure Defender you should use the Standard subscription tier. - - Enabling Azure Defender extends the capabilities of the free mode to workloads running in private and other public clouds, providing unified security management and threat protection across your hybrid cloud workloads.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/security-center/security-center-pricing", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableStandardSubscriptionGoodExamples, - BadExamples: terraformEnableStandardSubscriptionBadExamples, - Links: terraformEnableStandardSubscriptionLinks, - RemediationMarkdown: terraformEnableStandardSubscriptionRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, sub := range s.Azure.SecurityCenter.Subscriptions { - if sub.Metadata.IsUnmanaged() { - continue - } - if sub.Tier.EqualTo(securitycenter.TierFree) { - results.Add( - "Security center subscription uses the free tier.", - sub.Tier, - ) - } else { - results.AddPassed(&sub) - } - } - return - }, -) diff --git a/checks/cloud/azure/securitycenter/enable_standard_subscription.tf.go b/checks/cloud/azure/securitycenter/enable_standard_subscription.tf.go deleted file mode 100644 index 4d780b03..00000000 --- a/checks/cloud/azure/securitycenter/enable_standard_subscription.tf.go +++ /dev/null @@ -1,25 +0,0 @@ -package securitycenter - -var terraformEnableStandardSubscriptionGoodExamples = []string{ - ` - resource "azurerm_security_center_subscription_pricing" "good_example" { - tier = "Standard" - resource_type = "VirtualMachines" - } - `, -} - -var terraformEnableStandardSubscriptionBadExamples = []string{ - ` - resource "azurerm_security_center_subscription_pricing" "bad_example" { - tier = "Free" - resource_type = "VirtualMachines" - } - `, -} - -var terraformEnableStandardSubscriptionLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/security_center_subscription_pricing#tier`, -} - -var terraformEnableStandardSubscriptionRemediationMarkdown = `` diff --git a/checks/cloud/azure/securitycenter/set_required_contact_details.go b/checks/cloud/azure/securitycenter/set_required_contact_details.go deleted file mode 100755 index a605a3cd..00000000 --- a/checks/cloud/azure/securitycenter/set_required_contact_details.go +++ /dev/null @@ -1,50 +0,0 @@ -package securitycenter - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckSetRequiredContactDetails = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0046", - Provider: providers.AzureProvider, - Service: "security-center", - ShortCode: "set-required-contact-details", - Summary: "The required contact details should be set for security center", - Impact: "Without a telephone number set, Azure support can't contact", - Resolution: "Set a telephone number for security center contact", - Explanation: `It is recommended that at least one valid contact is configured for the security center. -Microsoft will notify the security contact directly in the event of a security incident and will look to use a telephone number in cases where a prompt response is required.`, - Links: []string{ - "https://azure.microsoft.com/en-us/services/security-center/", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformSetRequiredContactDetailsGoodExamples, - BadExamples: terraformSetRequiredContactDetailsBadExamples, - Links: terraformSetRequiredContactDetailsLinks, - RemediationMarkdown: terraformSetRequiredContactDetailsRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, contact := range s.Azure.SecurityCenter.Contacts { - if contact.Metadata.IsUnmanaged() { - continue - } - if contact.Phone.IsEmpty() { - results.Add( - "Security contact does not have a phone number listed.", - contact.Phone, - ) - } else { - results.AddPassed(&contact) - } - } - return - }, -) diff --git a/checks/cloud/azure/securitycenter/set_required_contact_details.tf.go b/checks/cloud/azure/securitycenter/set_required_contact_details.tf.go deleted file mode 100644 index dc6bbaab..00000000 --- a/checks/cloud/azure/securitycenter/set_required_contact_details.tf.go +++ /dev/null @@ -1,31 +0,0 @@ -package securitycenter - -var terraformSetRequiredContactDetailsGoodExamples = []string{ - ` - resource "azurerm_security_center_contact" "good_example" { - email = "good_contact@example.com" - phone = "+1-555-555-5555" - - alert_notifications = true - alerts_to_admins = true - } - `, -} - -var terraformSetRequiredContactDetailsBadExamples = []string{ - ` - resource "azurerm_security_center_contact" "bad_example" { - email = "bad_contact@example.com" - phone = "" - - alert_notifications = true - alerts_to_admins = true - } - `, -} - -var terraformSetRequiredContactDetailsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/security_center_contact#phone`, -} - -var terraformSetRequiredContactDetailsRemediationMarkdown = `` diff --git a/checks/cloud/azure/storage/allow_microsoft_service_bypass.go b/checks/cloud/azure/storage/allow_microsoft_service_bypass.go deleted file mode 100755 index 83a67626..00000000 --- a/checks/cloud/azure/storage/allow_microsoft_service_bypass.go +++ /dev/null @@ -1,57 +0,0 @@ -package storage - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckAllowMicrosoftServiceBypass = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0010", - Provider: providers.AzureProvider, - Service: "storage", - ShortCode: "allow-microsoft-service-bypass", - Summary: "Trusted Microsoft Services should have bypass access to Storage accounts", - Impact: "Trusted Microsoft Services won't be able to access storage account unless rules set to allow", - Resolution: "Allow Trusted Microsoft Services to bypass", - Explanation: `Some Microsoft services that interact with storage accounts operate from networks that can't be granted access through network rules. - -To help this type of service work as intended, allow the set of trusted Microsoft services to bypass the network rules`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/storage/common/storage-network-security#trusted-microsoft-services", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformAllowMicrosoftServiceBypassGoodExamples, - BadExamples: terraformAllowMicrosoftServiceBypassBadExamples, - Links: terraformAllowMicrosoftServiceBypassLinks, - RemediationMarkdown: terraformAllowMicrosoftServiceBypassRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, account := range s.Azure.Storage.Accounts { - for _, rule := range account.NetworkRules { - var found bool - for _, bypass := range rule.Bypass { - if bypass.EqualTo("AzureServices") { - found = true - } - } - if !found { - results.Add( - "Network rules do not allow bypass for Microsoft Services.", - &rule, - ) - } else { - results.AddPassed(&rule) - } - - } - } - return - }, -) diff --git a/checks/cloud/azure/storage/allow_microsoft_service_bypass.tf.go b/checks/cloud/azure/storage/allow_microsoft_service_bypass.tf.go deleted file mode 100644 index 262efa3f..00000000 --- a/checks/cloud/azure/storage/allow_microsoft_service_bypass.tf.go +++ /dev/null @@ -1,75 +0,0 @@ -package storage - -var terraformAllowMicrosoftServiceBypassGoodExamples = []string{ - ` - resource "azurerm_storage_account" "good_example" { - name = "storageaccountname" - resource_group_name = azurerm_resource_group.example.name - - location = azurerm_resource_group.example.location - account_tier = "Standard" - account_replication_type = "LRS" - - network_rules { - default_action = "Deny" - ip_rules = ["100.0.0.1"] - virtual_network_subnet_ids = [azurerm_subnet.example.id] - bypass = ["Metrics", "AzureServices"] - } - - tags = { - environment = "staging" - } - } - - resource "azurerm_storage_account_network_rules" "test" { - resource_group_name = azurerm_resource_group.test.name - storage_account_name = azurerm_storage_account.test.name - - default_action = "Allow" - ip_rules = ["127.0.0.1"] - virtual_network_subnet_ids = [azurerm_subnet.test.id] - bypass = ["Metrics", "AzureServices"] - } - `, -} - -var terraformAllowMicrosoftServiceBypassBadExamples = []string{ - ` - resource "azurerm_storage_account" "bad_example" { - name = "storageaccountname" - resource_group_name = azurerm_resource_group.example.name - - location = azurerm_resource_group.example.location - account_tier = "Standard" - account_replication_type = "LRS" - - network_rules { - default_action = "Deny" - ip_rules = ["100.0.0.1"] - virtual_network_subnet_ids = [azurerm_subnet.example.id] - bypass = ["Metrics"] - } - - tags = { - environment = "staging" - } - } - - resource "azurerm_storage_account_network_rules" "test" { - resource_group_name = azurerm_resource_group.test.name - storage_account_name = azurerm_storage_account.test.name - - default_action = "Allow" - ip_rules = ["127.0.0.1"] - virtual_network_subnet_ids = [azurerm_subnet.test.id] - bypass = ["Metrics"] - } - `, -} - -var terraformAllowMicrosoftServiceBypassLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account#bypass`, `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account_network_rules#bypass`, -} - -var terraformAllowMicrosoftServiceBypassRemediationMarkdown = `` diff --git a/checks/cloud/azure/storage/default_action_deny.go b/checks/cloud/azure/storage/default_action_deny.go deleted file mode 100755 index c6f24c6f..00000000 --- a/checks/cloud/azure/storage/default_action_deny.go +++ /dev/null @@ -1,50 +0,0 @@ -package storage - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckDefaultActionDeny = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0012", - Provider: providers.AzureProvider, - Service: "storage", - ShortCode: "default-action-deny", - Summary: "The default action on Storage account network rules should be set to deny", - Impact: "Network rules that allow could cause data to be exposed publicly", - Resolution: "Set network rules to deny", - Explanation: `The default_action for network rules should come into effect when no other rules are matched. - -The default action should be set to Deny.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/firewall/rule-processing", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformDefaultActionDenyGoodExamples, - BadExamples: terraformDefaultActionDenyBadExamples, - Links: terraformDefaultActionDenyLinks, - RemediationMarkdown: terraformDefaultActionDenyRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, account := range s.Azure.Storage.Accounts { - for _, rule := range account.NetworkRules { - if rule.AllowByDefault.IsTrue() { - results.Add( - "Network rules allow access by default.", - rule.AllowByDefault, - ) - } else { - results.AddPassed(&rule) - } - } - } - return - }, -) diff --git a/checks/cloud/azure/storage/default_action_deny.tf.go b/checks/cloud/azure/storage/default_action_deny.tf.go deleted file mode 100644 index f130d670..00000000 --- a/checks/cloud/azure/storage/default_action_deny.tf.go +++ /dev/null @@ -1,31 +0,0 @@ -package storage - -var terraformDefaultActionDenyGoodExamples = []string{ - ` - resource "azurerm_storage_account_network_rules" "good_example" { - - default_action = "Deny" - ip_rules = ["127.0.0.1"] - virtual_network_subnet_ids = [azurerm_subnet.test.id] - bypass = ["Metrics"] - } - `, -} - -var terraformDefaultActionDenyBadExamples = []string{ - ` - resource "azurerm_storage_account_network_rules" "bad_example" { - - default_action = "Allow" - ip_rules = ["127.0.0.1"] - virtual_network_subnet_ids = [azurerm_subnet.test.id] - bypass = ["Metrics"] - } - `, -} - -var terraformDefaultActionDenyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account_network_rules#default_action`, -} - -var terraformDefaultActionDenyRemediationMarkdown = `` diff --git a/checks/cloud/azure/storage/enforce_https.go b/checks/cloud/azure/storage/enforce_https.go deleted file mode 100755 index e17ea3be..00000000 --- a/checks/cloud/azure/storage/enforce_https.go +++ /dev/null @@ -1,53 +0,0 @@ -package storage - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnforceHttps = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0008", - Provider: providers.AzureProvider, - Service: "storage", - ShortCode: "enforce-https", - Summary: "Storage accounts should be configured to only accept transfers that are over secure connections", - Impact: "Insecure transfer of data into secure accounts could be read if intercepted", - Resolution: "Only allow secure connection for transferring data into storage accounts", - Explanation: `You can configure your storage account to accept requests from secure connections only by setting the Secure transfer required property for the storage account. - -When you require secure transfer, any requests originating from an insecure connection are rejected. - -Microsoft recommends that you always require secure transfer for all of your storage accounts.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/storage/common/storage-require-secure-transfer", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnforceHttpsGoodExamples, - BadExamples: terraformEnforceHttpsBadExamples, - Links: terraformEnforceHttpsLinks, - RemediationMarkdown: terraformEnforceHttpsRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, account := range s.Azure.Storage.Accounts { - if account.Metadata.IsUnmanaged() { - continue - } - if account.EnforceHTTPS.IsFalse() { - results.Add( - "Account does not enforce HTTPS.", - account.EnforceHTTPS, - ) - } else { - results.AddPassed(&account) - } - } - return - }, -) diff --git a/checks/cloud/azure/storage/enforce_https.tf.go b/checks/cloud/azure/storage/enforce_https.tf.go deleted file mode 100644 index 29c2f5bf..00000000 --- a/checks/cloud/azure/storage/enforce_https.tf.go +++ /dev/null @@ -1,33 +0,0 @@ -package storage - -var terraformEnforceHttpsGoodExamples = []string{ - ` - resource "azurerm_storage_account" "good_example" { - name = "storageaccountname" - resource_group_name = azurerm_resource_group.example.name - location = azurerm_resource_group.example.location - account_tier = "Standard" - account_replication_type = "GRS" - enable_https_traffic_only = true - } - `, -} - -var terraformEnforceHttpsBadExamples = []string{ - ` - resource "azurerm_storage_account" "bad_example" { - name = "storageaccountname" - resource_group_name = azurerm_resource_group.example.name - location = azurerm_resource_group.example.location - account_tier = "Standard" - account_replication_type = "GRS" - enable_https_traffic_only = false - } - `, -} - -var terraformEnforceHttpsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account#enable_https_traffic_only`, -} - -var terraformEnforceHttpsRemediationMarkdown = `` diff --git a/checks/cloud/azure/storage/no_public_access.go b/checks/cloud/azure/storage/no_public_access.go deleted file mode 100755 index 008d2620..00000000 --- a/checks/cloud/azure/storage/no_public_access.go +++ /dev/null @@ -1,51 +0,0 @@ -package storage - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/azure/storage" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicAccess = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0007", - Provider: providers.AzureProvider, - Service: "storage", - ShortCode: "no-public-access", - Summary: "Storage containers in blob storage mode should not have public access", - Impact: "Data in the storage container could be exposed publicly", - Resolution: "Disable public access to storage containers", - Explanation: `Storage container public access should be off. It can be configured for blobs only, containers and blobs or off entirely. The default is off, with no public access. - -Explicitly overriding publicAccess to anything other than off should be avoided.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/storage/blobs/anonymous-read-access-configure?tabs=portal#set-the-public-access-level-for-a-container", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicAccessGoodExamples, - BadExamples: terraformNoPublicAccessBadExamples, - Links: terraformNoPublicAccessLinks, - RemediationMarkdown: terraformNoPublicAccessRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, account := range s.Azure.Storage.Accounts { - for _, container := range account.Containers { - if container.PublicAccess.NotEqualTo(storage.PublicAccessOff) { - results.Add( - "Container allows public access.", - container.PublicAccess, - ) - } else { - results.AddPassed(&container) - } - } - } - return - }, -) diff --git a/checks/cloud/azure/storage/no_public_access.tf.go b/checks/cloud/azure/storage/no_public_access.tf.go deleted file mode 100644 index 28d50f6b..00000000 --- a/checks/cloud/azure/storage/no_public_access.tf.go +++ /dev/null @@ -1,29 +0,0 @@ -package storage - -var terraformNoPublicAccessGoodExamples = []string{ - ` - resource "azurerm_storage_container" "good_example" { - name = "terraform-container-storage" - container_access_type = "private" - } - `, -} - -var terraformNoPublicAccessBadExamples = []string{ - ` - resource "azurerm_storage_container" "bad_example" { - name = "terraform-container-storage" - container_access_type = "blob" - - properties = { - "publicAccess" = "blob" - } - } - `, -} - -var terraformNoPublicAccessLinks = []string{ - `https://www.terraform.io/docs/providers/azure/r/storage_container.html#properties`, -} - -var terraformNoPublicAccessRemediationMarkdown = `` diff --git a/checks/cloud/azure/storage/queue_services_logging_enabled.go b/checks/cloud/azure/storage/queue_services_logging_enabled.go deleted file mode 100755 index ed1d5fca..00000000 --- a/checks/cloud/azure/storage/queue_services_logging_enabled.go +++ /dev/null @@ -1,53 +0,0 @@ -package storage - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckQueueServicesLoggingEnabled = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0009", - Provider: providers.AzureProvider, - Service: "storage", - ShortCode: "queue-services-logging-enabled", - Summary: "When using Queue Services for a storage account, logging should be enabled.", - Impact: "Logging provides valuable information about access and usage", - Resolution: "Enable logging for Queue Services", - Explanation: `Storage Analytics logs detailed information about successful and failed requests to a storage service. - -This information can be used to monitor individual requests and to diagnose issues with a storage service. - -Requests are logged on a best-effort basis.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/storage/common/storage-analytics-logging?tabs=dotnet", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformQueueServicesLoggingEnabledGoodExamples, - BadExamples: terraformQueueServicesLoggingEnabledBadExamples, - Links: terraformQueueServicesLoggingEnabledLinks, - RemediationMarkdown: terraformQueueServicesLoggingEnabledRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, account := range s.Azure.Storage.Accounts { - if account.Metadata.IsUnmanaged() || len(account.Queues) == 0 { - continue - } - if account.QueueProperties.EnableLogging.IsFalse() { - results.Add( - "Queue services storage account does not have logging enabled.", - account.QueueProperties.EnableLogging, - ) - } else { - results.AddPassed(&account) - } - } - return - }, -) diff --git a/checks/cloud/azure/storage/queue_services_logging_enabled.tf.go b/checks/cloud/azure/storage/queue_services_logging_enabled.tf.go deleted file mode 100644 index b2189c02..00000000 --- a/checks/cloud/azure/storage/queue_services_logging_enabled.tf.go +++ /dev/null @@ -1,47 +0,0 @@ -package storage - -var terraformQueueServicesLoggingEnabledGoodExamples = []string{ - ` - resource "azurerm_storage_account" "good_example" { - name = "example" - resource_group_name = data.azurerm_resource_group.example.name - location = data.azurerm_resource_group.example.location - account_tier = "Standard" - account_replication_type = "GRS" - queue_properties { - logging { - delete = true - read = true - write = true - version = "1.0" - retention_policy_days = 10 - } - } - } - `, -} - -var terraformQueueServicesLoggingEnabledBadExamples = []string{ - ` - resource "azurerm_storage_account" "bad_example" { - name = "example" - resource_group_name = data.azurerm_resource_group.example.name - location = data.azurerm_resource_group.example.location - account_tier = "Standard" - account_replication_type = "GRS" - queue_properties { - } - } - - resource "azurerm_storage_queue" "bad_example" { - name = "my-queue" - storage_account_name = azurerm_storage_account.bad_example.name - } - `, -} - -var terraformQueueServicesLoggingEnabledLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account#logging`, -} - -var terraformQueueServicesLoggingEnabledRemediationMarkdown = `` diff --git a/checks/cloud/azure/storage/use_secure_tls_policy.go b/checks/cloud/azure/storage/use_secure_tls_policy.go deleted file mode 100755 index c82a1c48..00000000 --- a/checks/cloud/azure/storage/use_secure_tls_policy.go +++ /dev/null @@ -1,53 +0,0 @@ -package storage - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckUseSecureTlsPolicy = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0011", - Provider: providers.AzureProvider, - Service: "storage", - ShortCode: "use-secure-tls-policy", - Summary: "The minimum TLS version for Storage Accounts should be TLS1_2", - Impact: "The TLS version being outdated and has known vulnerabilities", - Resolution: "Use a more recent TLS/SSL policy for the load balancer", - Explanation: `Azure Storage currently supports three versions of the TLS protocol: 1.0, 1.1, and 1.2. - -Azure Storage uses TLS 1.2 on public HTTPS endpoints, but TLS 1.0 and TLS 1.1 are still supported for backward compatibility. - -This check will warn if the minimum TLS is not set to TLS1_2.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/storage/common/transport-layer-security-configure-minimum-version", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformUseSecureTlsPolicyGoodExamples, - BadExamples: terraformUseSecureTlsPolicyBadExamples, - Links: terraformUseSecureTlsPolicyLinks, - RemediationMarkdown: terraformUseSecureTlsPolicyRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, account := range s.Azure.Storage.Accounts { - if account.Metadata.IsUnmanaged() { - continue - } - if account.MinimumTLSVersion.NotEqualTo("TLS1_2") { - results.Add( - "Storage account uses an insecure TLS version.", - account.MinimumTLSVersion, - ) - } else { - results.AddPassed(&account) - } - } - return - }, -) diff --git a/checks/cloud/azure/storage/use_secure_tls_policy.tf.go b/checks/cloud/azure/storage/use_secure_tls_policy.tf.go deleted file mode 100644 index f9bddab7..00000000 --- a/checks/cloud/azure/storage/use_secure_tls_policy.tf.go +++ /dev/null @@ -1,29 +0,0 @@ -package storage - -var terraformUseSecureTlsPolicyGoodExamples = []string{ - ` - resource "azurerm_storage_account" "good_example" { - name = "storageaccountname" - resource_group_name = azurerm_resource_group.example.name - location = azurerm_resource_group.example.location - min_tls_version = "TLS1_2" - } - `, -} - -var terraformUseSecureTlsPolicyBadExamples = []string{ - ` - resource "azurerm_storage_account" "bad_example" { - name = "storageaccountname" - resource_group_name = azurerm_resource_group.example.name - location = azurerm_resource_group.example.location - min_tls_version = "TLS1_0" - } - `, -} - -var terraformUseSecureTlsPolicyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account#min_tls_version`, -} - -var terraformUseSecureTlsPolicyRemediationMarkdown = `` diff --git a/checks/cloud/azure/synapse/virtual_network_enabled.go b/checks/cloud/azure/synapse/virtual_network_enabled.go deleted file mode 100755 index 40e917cf..00000000 --- a/checks/cloud/azure/synapse/virtual_network_enabled.go +++ /dev/null @@ -1,53 +0,0 @@ -package synapse - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckVirtualNetworkEnabled = rules.Register( - scan.Rule{ - AVDID: "AVD-AZU-0034", - Provider: providers.AzureProvider, - Service: "synapse", - ShortCode: "virtual-network-enabled", - Summary: "Synapse Workspace should have managed virtual network enabled, the default is disabled.", - Impact: "Your Synapse workspace is not using the private endpoints", - Resolution: "Set manage virtual network to enabled", - Explanation: `Synapse Workspace does not have managed virtual network enabled by default. - -When you create your Azure Synapse workspace, you can choose to associate it to a Microsoft Azure Virtual Network. The Virtual Network associated with your workspace is managed by Azure Synapse. This Virtual Network is called a Managed workspace Virtual Network. -Managed private endpoints are private endpoints created in a Managed Virtual Network associated with your Azure Synapse workspace. Managed private endpoints establish a private link to Azure resources. You can only use private links in a workspace that has a Managed workspace Virtual Network.`, - Links: []string{ - "https://docs.microsoft.com/en-us/azure/synapse-analytics/security/synapse-workspace-managed-private-endpoints", - "https://docs.microsoft.com/en-us/azure/synapse-analytics/security/synapse-workspace-managed-vnet", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformVirtualNetworkEnabledGoodExamples, - BadExamples: terraformVirtualNetworkEnabledBadExamples, - Links: terraformVirtualNetworkEnabledLinks, - RemediationMarkdown: terraformVirtualNetworkEnabledRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, workspace := range s.Azure.Synapse.Workspaces { - if workspace.Metadata.IsUnmanaged() { - continue - } - if workspace.EnableManagedVirtualNetwork.IsFalse() { - results.Add( - "Workspace does not have a managed virtual network enabled.", - workspace.EnableManagedVirtualNetwork, - ) - } else { - results.AddPassed(&workspace) - } - } - return - }, -) diff --git a/checks/cloud/azure/synapse/virtual_network_enabled.tf.go b/checks/cloud/azure/synapse/virtual_network_enabled.tf.go deleted file mode 100644 index 4fe6c581..00000000 --- a/checks/cloud/azure/synapse/virtual_network_enabled.tf.go +++ /dev/null @@ -1,53 +0,0 @@ -package synapse - -var terraformVirtualNetworkEnabledGoodExamples = []string{ - ` - resource "azurerm_synapse_workspace" "good_example" { - name = "example" - resource_group_name = azurerm_resource_group.example.name - location = azurerm_resource_group.example.location - storage_data_lake_gen2_filesystem_id = azurerm_storage_data_lake_gen2_filesystem.example.id - sql_administrator_login = "sqladminuser" - sql_administrator_login_password = "H@Sh1CoR3!" - managed_virtual_network_enabled = true - aad_admin { - login = "AzureAD Admin" - object_id = "00000000-0000-0000-0000-000000000000" - tenant_id = "00000000-0000-0000-0000-000000000000" - } - - tags = { - Env = "production" - } - } - `, -} - -var terraformVirtualNetworkEnabledBadExamples = []string{ - ` - resource "azurerm_synapse_workspace" "bad_example" { - name = "example" - resource_group_name = azurerm_resource_group.example.name - location = azurerm_resource_group.example.location - storage_data_lake_gen2_filesystem_id = azurerm_storage_data_lake_gen2_filesystem.example.id - sql_administrator_login = "sqladminuser" - sql_administrator_login_password = "H@Sh1CoR3!" - - aad_admin { - login = "AzureAD Admin" - object_id = "00000000-0000-0000-0000-000000000000" - tenant_id = "00000000-0000-0000-0000-000000000000" - } - - tags = { - Env = "production" - } - } - `, -} - -var terraformVirtualNetworkEnabledLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/synapse_workspace#managed_virtual_network_enabled`, -} - -var terraformVirtualNetworkEnabledRemediationMarkdown = `` diff --git a/checks/cloud/cloudstack/compute/no_sensitive_info.go b/checks/cloud/cloudstack/compute/no_sensitive_info.go deleted file mode 100755 index abae467c..00000000 --- a/checks/cloud/cloudstack/compute/no_sensitive_info.go +++ /dev/null @@ -1,50 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/owenrumney/squealer/pkg/squealer" -) - -var scanner = squealer.NewStringScanner() - -var CheckNoSensitiveInfo = rules.Register( - scan.Rule{ - AVDID: "AVD-CLDSTK-0001", - Provider: providers.CloudStackProvider, - Service: "compute", - ShortCode: "no-sensitive-info", - Summary: "No sensitive data stored in user_data", - Impact: "Sensitive credentials in the user data can be leaked", - Resolution: "Don't use sensitive data in the user data section", - Explanation: `When creating instances, user data can be used during the initial configuration. User data must not contain sensitive information`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoSensitiveInfoGoodExamples, - BadExamples: terraformNoSensitiveInfoBadExamples, - Links: terraformNoSensitiveInfoLinks, - RemediationMarkdown: terraformNoSensitiveInfoRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.CloudStack.Compute.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if scanner.Scan(instance.UserData.Value()).TransgressionFound { - results.Add( - "Instance user data contains secret(s).", - instance.UserData, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/cloudstack/compute/no_sensitive_info.tf.go b/checks/cloud/cloudstack/compute/no_sensitive_info.tf.go deleted file mode 100644 index 4cd93cd7..00000000 --- a/checks/cloud/cloudstack/compute/no_sensitive_info.tf.go +++ /dev/null @@ -1,55 +0,0 @@ -package compute - -var terraformNoSensitiveInfoGoodExamples = []string{ - ` - resource "cloudstack_instance" "web" { - name = "server-1" - service_offering = "small" - network_id = "6eb22f91-7454-4107-89f4-36afcdf33021" - template = "CentOS 6.5" - zone = "zone-1" - user_data = < 1 { - failed = true - results.Add( - "Egress rule allows access to multiple public addresses.", - address, - ) - } - } - } - if !failed { - results.AddPassed(&firewall) - } - } - return - }, -) diff --git a/checks/cloud/digitalocean/compute/no_public_egress.tf.go b/checks/cloud/digitalocean/compute/no_public_egress.tf.go deleted file mode 100644 index 23fdc089..00000000 --- a/checks/cloud/digitalocean/compute/no_public_egress.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package compute - -var terraformNoPublicEgressGoodExamples = []string{ - ` - resource "digitalocean_firewall" "good_example" { - name = "only-22-80-and-443" - - droplet_ids = [digitalocean_droplet.web.id] - - outbound_rule { - protocol = "tcp" - port_range = "22" - destination_addresses = ["192.168.1.0/24", "fc00::/7"] - } - } - `, -} - -var terraformNoPublicEgressBadExamples = []string{ - ` - resource "digitalocean_firewall" "bad_example" { - name = "only-22-80-and-443" - - droplet_ids = [digitalocean_droplet.web.id] - - outbound_rule { - protocol = "tcp" - port_range = "22" - destination_addresses = ["0.0.0.0/0", "::/0"] - } - } - `, -} - -var terraformNoPublicEgressLinks = []string{ - `https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs/resources/firewall`, -} - -var terraformNoPublicEgressRemediationMarkdown = `` diff --git a/checks/cloud/digitalocean/compute/no_public_ingress.go b/checks/cloud/digitalocean/compute/no_public_ingress.go deleted file mode 100755 index 11132691..00000000 --- a/checks/cloud/digitalocean/compute/no_public_ingress.go +++ /dev/null @@ -1,54 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicIngress = rules.Register( - scan.Rule{ - AVDID: "AVD-DIG-0001", - Provider: providers.DigitalOceanProvider, - Service: "compute", - ShortCode: "no-public-ingress", - Summary: "The firewall has an inbound rule with open access", - Impact: "Your port is exposed to the internet", - Resolution: "Set a more restrictive CIRDR range", - Explanation: `Opening up ports to connect out to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that are explicitly required where possible.`, - Links: []string{ - "https://docs.digitalocean.com/products/networking/firewalls/how-to/configure-rules/", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicIngressGoodExamples, - BadExamples: terraformNoPublicIngressBadExamples, - Links: terraformNoPublicIngressLinks, - RemediationMarkdown: terraformNoPublicIngressRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, firewall := range s.DigitalOcean.Compute.Firewalls { - var failed bool - for _, rule := range firewall.InboundRules { - for _, address := range rule.SourceAddresses { - if cidr.IsPublic(address.Value()) && cidr.CountAddresses(address.Value()) > 1 { - failed = true - results.Add( - "Ingress rule allows access from multiple public addresses.", - address, - ) - } - } - } - if !failed { - results.AddPassed(&firewall) - } - } - return - }, -) diff --git a/checks/cloud/digitalocean/compute/no_public_ingress.tf.go b/checks/cloud/digitalocean/compute/no_public_ingress.tf.go deleted file mode 100644 index 8a6ea9a4..00000000 --- a/checks/cloud/digitalocean/compute/no_public_ingress.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package compute - -var terraformNoPublicIngressGoodExamples = []string{ - ` - resource "digitalocean_firewall" "good_example" { - name = "only-22-80-and-443" - - droplet_ids = [digitalocean_droplet.web.id] - - inbound_rule { - protocol = "tcp" - port_range = "22" - source_addresses = ["192.168.1.0/24", "fc00::/7"] - } - } - `, -} - -var terraformNoPublicIngressBadExamples = []string{ - ` - resource "digitalocean_firewall" "bad_example" { - name = "only-22-80-and-443" - - droplet_ids = [digitalocean_droplet.web.id] - - inbound_rule { - protocol = "tcp" - port_range = "22" - source_addresses = ["0.0.0.0/0", "::/0"] - } - } - `, -} - -var terraformNoPublicIngressLinks = []string{ - `https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs/resources/firewall`, -} - -var terraformNoPublicIngressRemediationMarkdown = `` diff --git a/checks/cloud/digitalocean/compute/use_ssh_keys.go b/checks/cloud/digitalocean/compute/use_ssh_keys.go deleted file mode 100755 index 3fe335e3..00000000 --- a/checks/cloud/digitalocean/compute/use_ssh_keys.go +++ /dev/null @@ -1,49 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckUseSshKeys = rules.Register( - scan.Rule{ - AVDID: "AVD-DIG-0004", - Provider: providers.DigitalOceanProvider, - Service: "compute", - ShortCode: "use-ssh-keys", - Summary: "SSH Keys are the preferred way to connect to your droplet, no keys are supplied", - Impact: "Logging in with username and password is easier to compromise", - Resolution: "Use ssh keys for login", - Explanation: `When working with a server, you’ll likely spend most of your time in a terminal session connected to your server through SSH. A more secure alternative to password-based logins, SSH keys use encryption to provide a secure way of logging into your server and are recommended for all users.`, - Links: []string{ - "https://www.digitalocean.com/community/tutorials/understanding-the-ssh-encryption-and-connection-process", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformUseSshKeysGoodExamples, - BadExamples: terraformUseSshKeysBadExamples, - Links: terraformUseSshKeysLinks, - RemediationMarkdown: terraformUseSshKeysRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, droplet := range s.DigitalOcean.Compute.Droplets { - if droplet.Metadata.IsUnmanaged() { - continue - } - if len(droplet.SSHKeys) == 0 { - results.Add( - "Droplet does not have an SSH key specified.", - &droplet, - ) - } else { - results.AddPassed(&droplet) - } - } - return - }, -) diff --git a/checks/cloud/digitalocean/compute/use_ssh_keys.tf.go b/checks/cloud/digitalocean/compute/use_ssh_keys.tf.go deleted file mode 100644 index 9a01e552..00000000 --- a/checks/cloud/digitalocean/compute/use_ssh_keys.tf.go +++ /dev/null @@ -1,34 +0,0 @@ -package compute - -var terraformUseSshKeysGoodExamples = []string{ - ` - data "digitalocean_ssh_key" "terraform" { - name = "myKey" - } - - resource "digitalocean_droplet" "good_example" { - image = "ubuntu-18-04-x64" - name = "web-1" - region = "nyc2" - size = "s-1vcpu-1gb" - ssh_keys = [ data.digitalocean_ssh_key.myKey.id ] - } - `, -} - -var terraformUseSshKeysBadExamples = []string{ - ` - resource "digitalocean_droplet" "good_example" { - image = "ubuntu-18-04-x64" - name = "web-1" - region = "nyc2" - size = "s-1vcpu-1gb" - } - `, -} - -var terraformUseSshKeysLinks = []string{ - `https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs/resources/droplet#ssh_keys`, -} - -var terraformUseSshKeysRemediationMarkdown = `` diff --git a/checks/cloud/digitalocean/spaces/acl_no_public_read.go b/checks/cloud/digitalocean/spaces/acl_no_public_read.go deleted file mode 100755 index 31b7f744..00000000 --- a/checks/cloud/digitalocean/spaces/acl_no_public_read.go +++ /dev/null @@ -1,60 +0,0 @@ -package spaces - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckAclNoPublicRead = rules.Register( - scan.Rule{ - AVDID: "AVD-DIG-0006", - Provider: providers.DigitalOceanProvider, - Service: "spaces", - ShortCode: "acl-no-public-read", - Summary: "Spaces bucket or bucket object has public read acl set", - Impact: "The contents of the space can be accessed publicly", - Resolution: "Apply a more restrictive ACL", - Explanation: `Space bucket and bucket object permissions should be set to deny public access unless explicitly required.`, - Links: []string{ - "https://docs.digitalocean.com/reference/api/spaces-api/#access-control-lists-acls", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformAclNoPublicReadGoodExamples, - BadExamples: terraformAclNoPublicReadBadExamples, - Links: terraformAclNoPublicReadLinks, - RemediationMarkdown: terraformAclNoPublicReadRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, bucket := range s.DigitalOcean.Spaces.Buckets { - if bucket.Metadata.IsUnmanaged() { - continue - } - if bucket.ACL.EqualTo("public-read") { - results.Add( - "Bucket is publicly exposed.", - bucket.ACL, - ) - } else { - results.AddPassed(&bucket) - } - - for _, object := range bucket.Objects { - if object.ACL.EqualTo("public-read") { - results.Add( - "Object is publicly exposed.", - object.ACL, - ) - } else { - results.AddPassed(&object) - } - } - } - return - }, -) diff --git a/checks/cloud/digitalocean/spaces/acl_no_public_read.tf.go b/checks/cloud/digitalocean/spaces/acl_no_public_read.tf.go deleted file mode 100644 index 7a570bcc..00000000 --- a/checks/cloud/digitalocean/spaces/acl_no_public_read.tf.go +++ /dev/null @@ -1,44 +0,0 @@ -package spaces - -var terraformAclNoPublicReadGoodExamples = []string{ - ` - resource "digitalocean_spaces_bucket" "good_example" { - name = "private_space" - region = "nyc3" - acl = "private" - } - - resource "digitalocean_spaces_bucket_object" "index" { - region = digitalocean_spaces_bucket.good_example.region - bucket = digitalocean_spaces_bucket.good_example.name - key = "index.html" - content = "

This page is empty.

" - content_type = "text/html" - } - `, -} - -var terraformAclNoPublicReadBadExamples = []string{ - ` - resource "digitalocean_spaces_bucket" "bad_example" { - name = "public_space" - region = "nyc3" - acl = "public-read" - } - - resource "digitalocean_spaces_bucket_object" "index" { - region = digitalocean_spaces_bucket.bad_example.region - bucket = digitalocean_spaces_bucket.bad_example.name - key = "index.html" - content = "

This page is empty.

" - content_type = "text/html" - acl = "public-read" - } - `, -} - -var terraformAclNoPublicReadLinks = []string{ - `https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs/resources/spaces_bucket#acl`, `https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs/resources/spaces_bucket_object#acl`, -} - -var terraformAclNoPublicReadRemediationMarkdown = `` diff --git a/checks/cloud/digitalocean/spaces/disable_force_destroy.go b/checks/cloud/digitalocean/spaces/disable_force_destroy.go deleted file mode 100755 index c948c113..00000000 --- a/checks/cloud/digitalocean/spaces/disable_force_destroy.go +++ /dev/null @@ -1,47 +0,0 @@ -package spaces - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckDisableForceDestroy = rules.Register( - scan.Rule{ - AVDID: "AVD-DIG-0009", - Provider: providers.DigitalOceanProvider, - Service: "spaces", - ShortCode: "disable-force-destroy", - Summary: "Force destroy is enabled on Spaces bucket which is dangerous", - Impact: "Accidental deletion of bucket objects", - Resolution: "Don't use force destroy on bucket configuration", - Explanation: `Enabling force destroy on a Spaces bucket means that the bucket can be deleted without the additional check that it is empty. This risks important data being accidentally deleted by a bucket removal process.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformDisableForceDestroyGoodExamples, - BadExamples: terraformDisableForceDestroyBadExamples, - Links: terraformDisableForceDestroyLinks, - RemediationMarkdown: terraformDisableForceDestroyRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, bucket := range s.DigitalOcean.Spaces.Buckets { - if bucket.Metadata.IsUnmanaged() { - continue - } - if bucket.ForceDestroy.IsTrue() { - results.Add( - "Bucket has force-destroy enabled.", - bucket.ForceDestroy, - ) - } else { - results.AddPassed(&bucket) - } - } - return - }, -) diff --git a/checks/cloud/digitalocean/spaces/disable_force_destroy.tf.go b/checks/cloud/digitalocean/spaces/disable_force_destroy.tf.go deleted file mode 100644 index 253db7b2..00000000 --- a/checks/cloud/digitalocean/spaces/disable_force_destroy.tf.go +++ /dev/null @@ -1,26 +0,0 @@ -package spaces - -var terraformDisableForceDestroyGoodExamples = []string{ - ` - resource "digitalocean_spaces_bucket" "good_example" { - name = "foobar" - region = "nyc3" - } - `, -} - -var terraformDisableForceDestroyBadExamples = []string{ - ` - resource "digitalocean_spaces_bucket" "bad_example" { - name = "foobar" - region = "nyc3" - force_destroy = true - } - `, -} - -var terraformDisableForceDestroyLinks = []string{ - `https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs/resources/spaces_bucket#force_destroy`, -} - -var terraformDisableForceDestroyRemediationMarkdown = `` diff --git a/checks/cloud/digitalocean/spaces/versioning_enabled.go b/checks/cloud/digitalocean/spaces/versioning_enabled.go deleted file mode 100755 index 63d4e14e..00000000 --- a/checks/cloud/digitalocean/spaces/versioning_enabled.go +++ /dev/null @@ -1,49 +0,0 @@ -package spaces - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckVersioningEnabled = rules.Register( - scan.Rule{ - AVDID: "AVD-DIG-0007", - Provider: providers.DigitalOceanProvider, - Service: "spaces", - ShortCode: "versioning-enabled", - Summary: "Spaces buckets should have versioning enabled", - Impact: "Deleted or modified data would not be recoverable", - Resolution: "Enable versioning to protect against accidental or malicious removal or modification", - Explanation: `Versioning is a means of keeping multiple variants of an object in the same bucket. You can use the Spaces (S3) Versioning feature to preserve, retrieve, and restore every version of every object stored in your buckets. With versioning you can recover more easily from both unintended user actions and application failures.`, - Links: []string{ - "https://docs.aws.amazon.com/AmazonS3/latest/userguide/Versioning.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformVersioningEnabledGoodExamples, - BadExamples: terraformVersioningEnabledBadExamples, - Links: terraformVersioningEnabledLinks, - RemediationMarkdown: terraformVersioningEnabledRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, bucket := range s.DigitalOcean.Spaces.Buckets { - if bucket.Metadata.IsUnmanaged() { - continue - } - if bucket.Versioning.Enabled.IsFalse() { - results.Add( - "Bucket does not have versioning enabled.", - bucket.Versioning.Enabled, - ) - } else { - results.AddPassed(&bucket) - } - } - return - }, -) diff --git a/checks/cloud/digitalocean/spaces/versioning_enabled.tf.go b/checks/cloud/digitalocean/spaces/versioning_enabled.tf.go deleted file mode 100644 index 53a8716f..00000000 --- a/checks/cloud/digitalocean/spaces/versioning_enabled.tf.go +++ /dev/null @@ -1,38 +0,0 @@ -package spaces - -var terraformVersioningEnabledGoodExamples = []string{ - ` - resource "digitalocean_spaces_bucket" "good_example" { - name = "foobar" - region = "nyc3" - - versioning { - enabled = true - } - } - `, -} - -var terraformVersioningEnabledBadExamples = []string{ - ` - resource "digitalocean_spaces_bucket" "bad_example" { - name = "foobar" - region = "nyc3" - } - - resource "digitalocean_spaces_bucket" "bad_example" { - name = "foobar" - region = "nyc3" - - versioning { - enabled = false - } - } - `, -} - -var terraformVersioningEnabledLinks = []string{ - `https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs/resources/spaces_bucket#versioning`, -} - -var terraformVersioningEnabledRemediationMarkdown = `` diff --git a/checks/cloud/github/actions/no_plain_text_action_secrets.go b/checks/cloud/github/actions/no_plain_text_action_secrets.go deleted file mode 100644 index 7ae8871c..00000000 --- a/checks/cloud/github/actions/no_plain_text_action_secrets.go +++ /dev/null @@ -1,48 +0,0 @@ -package actions - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPlainTextActionEnvironmentSecrets = rules.Register( - scan.Rule{ - AVDID: "AVD-GIT-0002", - Provider: providers.GitHubProvider, - Service: "actions", - ShortCode: "no-plain-text-action-secrets", - Summary: "Ensure plaintext value is not used for GitHub Action Environment Secret.", - Impact: "Unencrypted sensitive plaintext value can be easily accessible in code.", - Resolution: "Do not store plaintext values in your code but rather populate the encrypted_value using fields from a resource, data source or variable.", Explanation: `For the purposes of security, the contents of the plaintext_value field have been marked as sensitive to Terraform, but this does not hide it from state files. State should be treated as sensitive always.`, - - Links: []string{ - "https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_environment_secret", - "https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPlainTextActionSecretsGoodExamples, - BadExamples: terraformNoPlainTextActionSecretsBadExamples, - Links: terraformNoPlainTextActionSecretsLinks, - RemediationMarkdown: terraformNoPlainTextActionSecretsRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, environmentSecret := range s.GitHub.EnvironmentSecrets { - if environmentSecret.Metadata.IsUnmanaged() { - continue - } - if environmentSecret.PlainTextValue.IsNotEmpty() { - results.Add("Secret has plain text value", - environmentSecret.PlainTextValue) - } else { - results.AddPassed(&environmentSecret) - } - } - return results - }, -) diff --git a/checks/cloud/github/actions/no_plain_text_action_secrets.tf.go b/checks/cloud/github/actions/no_plain_text_action_secrets.tf.go deleted file mode 100644 index 27e4685d..00000000 --- a/checks/cloud/github/actions/no_plain_text_action_secrets.tf.go +++ /dev/null @@ -1,29 +0,0 @@ -package actions - -var terraformNoPlainTextActionSecretsGoodExamples = []string{ - ` -resource "github_actions_environment_secret" "good_example" { - repository = "my repository name" - environment = "my environment" - secret_name = "my secret name" - encrypted_value = var.some_encrypted_secret_string -} -`, -} - -var terraformNoPlainTextActionSecretsBadExamples = []string{ - ` -resource "github_actions_environment_secret" "bad_example" { - repository = "my repository name" - environment = "my environment" - secret_name = "my secret name" - plaintext_value = "sensitive secret string" -} -`, -} - -var terraformNoPlainTextActionSecretsLinks = []string{ - `https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_environment_secret`, `https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions`, -} - -var terraformNoPlainTextActionSecretsRemediationMarkdown = `` diff --git a/checks/cloud/github/branch_protections/require_signed_commits.go b/checks/cloud/github/branch_protections/require_signed_commits.go deleted file mode 100755 index ee3771fb..00000000 --- a/checks/cloud/github/branch_protections/require_signed_commits.go +++ /dev/null @@ -1,50 +0,0 @@ -package branch_protections - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckRequireSignedCommits = rules.Register( - scan.Rule{ - AVDID: "AVD-GIT-0004", - Provider: providers.GitHubProvider, - Service: "branch_protections", - ShortCode: "require_signed_commits", - Summary: "GitHub branch protection does not require signed commits.", - Impact: "Commits may not be verified and signed as coming from a trusted developer", - Resolution: "Require signed commits", - Explanation: `GitHub branch protection should be set to require signed commits. - -You can do this by setting the require_signed_commits attribute to 'true'.`, - Links: []string{ - "https://registry.terraform.io/providers/integrations/github/latest/docs/resources/branch_protection#require_signed_commits", - "https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification", - "https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches#require-signed-commits", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformRequireSignedCommitsGoodExamples, - BadExamples: terraformRequireSignedCommitsBadExamples, - Links: terraformRequireSignedCommitsLinks, - RemediationMarkdown: terraformRequireSignedCommitsRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, branchProtection := range s.GitHub.BranchProtections { - if branchProtection.RequireSignedCommits.IsFalse() { - results.Add( - "Branch protection does not require signed commits,", - branchProtection.RequireSignedCommits, - ) - } else { - results.AddPassed(branchProtection) - } - } - return - }, -) diff --git a/checks/cloud/github/branch_protections/require_signed_commits.tf.go b/checks/cloud/github/branch_protections/require_signed_commits.tf.go deleted file mode 100644 index 51aa2736..00000000 --- a/checks/cloud/github/branch_protections/require_signed_commits.tf.go +++ /dev/null @@ -1,29 +0,0 @@ -package branch_protections - -var terraformRequireSignedCommitsGoodExamples = []string{ - ` - resource "github_branch_protection" "good_example" { - repository_id = "example" - pattern = "main" - - require_signed_commits = true - } - `, -} - -var terraformRequireSignedCommitsBadExamples = []string{ - ` - resource "github_branch_protection" "good_example" { - repository_id = "example" - pattern = "main" - - require_signed_commits = false - } - `, -} - -var terraformRequireSignedCommitsLinks = []string{ - `https://registry.terraform.io/providers/integrations/github/latest/docs/resources/branch_protection`, -} - -var terraformRequireSignedCommitsRemediationMarkdown = `` diff --git a/checks/cloud/github/repositories/enable_vulnerability_alerts.go b/checks/cloud/github/repositories/enable_vulnerability_alerts.go deleted file mode 100755 index c2039d8e..00000000 --- a/checks/cloud/github/repositories/enable_vulnerability_alerts.go +++ /dev/null @@ -1,54 +0,0 @@ -package repositories - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableVulnerabilityAlerts = rules.Register( - scan.Rule{ - AVDID: "AVD-GIT-0003", - Provider: providers.GitHubProvider, - Service: "repositories", - ShortCode: "enable_vulnerability_alerts", - Summary: "GitHub repository has vulnerability alerts disabled.", - Impact: "Known vulnerabilities may not be discovered", - Resolution: "Enable vulnerability alerts", - Explanation: `GitHub repository should be set to use vulnerability alerts. - -You can do this by setting the vulnerability_alerts attribute to 'true'.`, - Links: []string{ - "https://docs.github.com/en/code-security/supply-chain-security/managing-vulnerabilities-in-your-projects-dependencies/about-alerts-for-vulnerable-dependencies", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableVulnerabilityAlertsGoodExamples, - BadExamples: terraformEnableVulnerabilityAlertsBadExamples, - Links: terraformEnableVulnerabilityAlertsLinks, - RemediationMarkdown: terraformEnableVulnerabilityAlertsRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, repo := range s.GitHub.Repositories { - if repo.Metadata.IsUnmanaged() { - continue - } - if repo.IsArchived() { - continue - } - if repo.VulnerabilityAlerts.IsFalse() { - results.Add( - "Repository does not have vulnerability alerts enabled,", - repo.VulnerabilityAlerts, - ) - } else { - results.AddPassed(repo) - } - } - return - }, -) diff --git a/checks/cloud/github/repositories/enable_vulnerability_alerts.tf.go b/checks/cloud/github/repositories/enable_vulnerability_alerts.tf.go deleted file mode 100644 index 7e8808d7..00000000 --- a/checks/cloud/github/repositories/enable_vulnerability_alerts.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package repositories - -var terraformEnableVulnerabilityAlertsGoodExamples = []string{ - ` - resource "github_repository" "good_example" { - name = "example" - description = "My awesome codebase" - - vulnerability_alerts = true - - template { - owner = "github" - repository = "terraform-module-template" - } - } - `, -} - -var terraformEnableVulnerabilityAlertsBadExamples = []string{ - ` - resource "github_repository" "bad_example" { - name = "example" - description = "My awesome codebase" - - vulnerability_alerts = false - - template { - owner = "github" - repository = "terraform-module-template" - } - } - `, -} - -var terraformEnableVulnerabilityAlertsLinks = []string{ - `https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository`, -} - -var terraformEnableVulnerabilityAlertsRemediationMarkdown = `` diff --git a/checks/cloud/github/repositories/private.tf.go b/checks/cloud/github/repositories/private.tf.go deleted file mode 100644 index a5c650a7..00000000 --- a/checks/cloud/github/repositories/private.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package repositories - -var terraformPrivateGoodExamples = []string{ - ` - resource "github_repository" "good_example" { - name = "example" - description = "My awesome codebase" - - visibility = "private" - - template { - owner = "github" - repository = "terraform-module-template" - } - } - `, -} - -var terraformPrivateBadExamples = []string{ - ` - resource "github_repository" "bad_example" { - name = "example" - description = "My awesome codebase" - - visibility = "public" - - template { - owner = "github" - repository = "terraform-module-template" - } - } - `, -} - -var terraformPrivateLinks = []string{ - `https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository`, -} - -var terraformPrivateRemediationMarkdown = `` diff --git a/checks/cloud/github/repositories/private_repository.go b/checks/cloud/github/repositories/private_repository.go deleted file mode 100755 index dd9a0a95..00000000 --- a/checks/cloud/github/repositories/private_repository.go +++ /dev/null @@ -1,52 +0,0 @@ -package repositories - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckPrivate = rules.Register( - scan.Rule{ - AVDID: "AVD-GIT-0001", - Provider: providers.GitHubProvider, - Service: "repositories", - ShortCode: "private", - Summary: "GitHub repository shouldn't be public.", - Impact: "Anyone can read the contents of the GitHub repository and leak IP", - Resolution: "Make sensitive or commercially important repositories private", - Explanation: `GitHub repository should be set to be private. - -You can do this by either setting private attribute to 'true' or visibility attribute to 'internal' or 'private'.`, - Links: []string{ - "https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-repository-visibility", - "https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-repository-visibility#about-internal-repositories", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformPrivateGoodExamples, - BadExamples: terraformPrivateBadExamples, - Links: terraformPrivateLinks, - RemediationMarkdown: terraformPrivateRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, repo := range s.GitHub.Repositories { - if repo.Metadata.IsUnmanaged() { - continue - } - if repo.Public.IsTrue() { - results.Add( - "Repository is public,", - repo.Public, - ) - } else { - results.AddPassed(repo) - } - } - return - }, -) diff --git a/checks/cloud/google/bigquery/no_public_access.go b/checks/cloud/google/bigquery/no_public_access.go deleted file mode 100755 index 5af6e854..00000000 --- a/checks/cloud/google/bigquery/no_public_access.go +++ /dev/null @@ -1,47 +0,0 @@ -package bigquery - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/google/bigquery" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicAccess = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0046", - Provider: providers.GoogleProvider, - Service: "bigquery", - ShortCode: "no-public-access", - Summary: "BigQuery datasets should only be accessible within the organisation", - Impact: "Exposure of sensitive data to the public iniernet", - Resolution: "Configure access permissions with higher granularity", - Explanation: `Using 'allAuthenticatedUsers' provides any GCP user - even those outside of your organisation - access to your BigQuery dataset.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicAccessGoodExamples, - BadExamples: terraformNoPublicAccessBadExamples, - Links: terraformNoPublicAccessLinks, - RemediationMarkdown: terraformNoPublicAccessRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, dataset := range s.Google.BigQuery.Datasets { - for _, grant := range dataset.AccessGrants { - if grant.SpecialGroup.EqualTo(bigquery.SpecialGroupAllAuthenticatedUsers) { - results.Add( - "Dataset grants access to all authenticated GCP users.", - grant.SpecialGroup, - ) - } else { - results.AddPassed(&grant) - } - } - } - return - }, -) diff --git a/checks/cloud/google/bigquery/no_public_access.tf.go b/checks/cloud/google/bigquery/no_public_access.tf.go deleted file mode 100644 index c83db651..00000000 --- a/checks/cloud/google/bigquery/no_public_access.tf.go +++ /dev/null @@ -1,64 +0,0 @@ -package bigquery - -var terraformNoPublicAccessGoodExamples = []string{ - ` - resource "google_bigquery_dataset" "good_example" { - dataset_id = "example_dataset" - friendly_name = "test" - description = "This is a test description" - location = "EU" - default_table_expiration_ms = 3600000 - - labels = { - env = "default" - } - - access { - role = "OWNER" - user_by_email = google_service_account.bqowner.email - } - - access { - role = "READER" - domain = "hashicorp.com" - } - } - - resource "google_service_account" "bqowner" { - account_id = "bqowner" - } - `, -} - -var terraformNoPublicAccessBadExamples = []string{ - ` - resource "google_bigquery_dataset" "bad_example" { - dataset_id = "example_dataset" - friendly_name = "test" - description = "This is a test description" - location = "EU" - default_table_expiration_ms = 3600000 - - labels = { - env = "default" - } - - access { - role = "OWNER" - special_group = "allAuthenticatedUsers" - } - - access { - role = "READER" - domain = "hashicorp.com" - } - } - - `, -} - -var terraformNoPublicAccessLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/bigquery_dataset#special_group`, -} - -var terraformNoPublicAccessRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/disk_encryption_customer_key.go b/checks/cloud/google/compute/disk_encryption_customer_key.go deleted file mode 100755 index cd84f570..00000000 --- a/checks/cloud/google/compute/disk_encryption_customer_key.go +++ /dev/null @@ -1,47 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckDiskEncryptionCustomerKey = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0034", - Provider: providers.GoogleProvider, - Service: "compute", - ShortCode: "disk-encryption-customer-key", - Summary: "Disks should be encrypted with customer managed encryption keys", - Impact: "Using unmanaged keys does not allow for proper key management.", - Resolution: "Use managed keys to encrypt disks.", - Explanation: `Using unmanaged keys makes rotation and general management difficult.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformDiskEncryptionCustomerKeyGoodExamples, - BadExamples: terraformDiskEncryptionCustomerKeyBadExamples, - Links: terraformDiskEncryptionCustomerKeyLinks, - RemediationMarkdown: terraformDiskEncryptionCustomerKeyRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, disk := range s.Google.Compute.Disks { - if disk.Metadata.IsUnmanaged() { - continue - } - if disk.Encryption.KMSKeyLink.IsEmpty() { - results.Add( - "Disk is not encrypted with a customer managed key.", - disk.Encryption.KMSKeyLink, - ) - } else { - results.AddPassed(&disk) - } - } - return - }, -) diff --git a/checks/cloud/google/compute/disk_encryption_customer_key.tf.go b/checks/cloud/google/compute/disk_encryption_customer_key.tf.go deleted file mode 100644 index 17a5f99f..00000000 --- a/checks/cloud/google/compute/disk_encryption_customer_key.tf.go +++ /dev/null @@ -1,40 +0,0 @@ -package compute - -var terraformDiskEncryptionCustomerKeyGoodExamples = []string{ - ` - resource "google_compute_disk" "good_example" { - name = "test-disk" - type = "pd-ssd" - zone = "us-central1-a" - image = "debian-9-stretch-v20200805" - labels = { - environment = "dev" - } - physical_block_size_bytes = 4096 - disk_encryption_key { - kms_key_self_link = "something" - } - } - `, -} - -var terraformDiskEncryptionCustomerKeyBadExamples = []string{ - ` - resource "google_compute_disk" "bad_example" { - name = "test-disk" - type = "pd-ssd" - zone = "us-central1-a" - image = "debian-9-stretch-v20200805" - labels = { - environment = "dev" - } - physical_block_size_bytes = 4096 - } - `, -} - -var terraformDiskEncryptionCustomerKeyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_disk#kms_key_self_link`, -} - -var terraformDiskEncryptionCustomerKeyRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/disk_encryption_no_plaintext_key.go b/checks/cloud/google/compute/disk_encryption_no_plaintext_key.go deleted file mode 100755 index 695656d6..00000000 --- a/checks/cloud/google/compute/disk_encryption_no_plaintext_key.go +++ /dev/null @@ -1,58 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckDiskEncryptionRequired = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0037", - Provider: providers.GoogleProvider, - Service: "compute", - ShortCode: "disk-encryption-no-plaintext-key", - Summary: "The encryption key used to encrypt a compute disk has been specified in plaintext.", - Impact: "The encryption key should be considered compromised as it is not stored securely.", - Resolution: "Reference a managed key rather than include the key in raw format.", - Explanation: `Sensitive values such as raw encryption keys should not be included in your Terraform code, and should be stored securely by a secrets manager.`, - Links: []string{ - "https://cloud.google.com/compute/docs/disks/customer-supplied-encryption", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformDiskEncryptionNoPlaintextKeyGoodExamples, - BadExamples: terraformDiskEncryptionNoPlaintextKeyBadExamples, - Links: terraformDiskEncryptionNoPlaintextKeyLinks, - RemediationMarkdown: terraformDiskEncryptionNoPlaintextKeyRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.Compute.Instances { - for _, disk := range append(instance.BootDisks, instance.AttachedDisks...) { - if disk.Encryption.RawKey.Len() > 0 { - results.Add( - "Instance disk has encryption key provided in plaintext.", - disk.Encryption.RawKey, - ) - } else { - results.AddPassed(&disk) - } - } - } - for _, disk := range s.Google.Compute.Disks { - if disk.Encryption.RawKey.Len() > 0 { - results.Add( - "Disk encryption key is supplied in plaintext.", - disk.Encryption.RawKey, - ) - } else { - results.AddPassed(&disk) - } - } - return - }, -) diff --git a/checks/cloud/google/compute/disk_encryption_no_plaintext_key.tf.go b/checks/cloud/google/compute/disk_encryption_no_plaintext_key.tf.go deleted file mode 100644 index 633d50ce..00000000 --- a/checks/cloud/google/compute/disk_encryption_no_plaintext_key.tf.go +++ /dev/null @@ -1,27 +0,0 @@ -package compute - -var terraformDiskEncryptionNoPlaintextKeyGoodExamples = []string{ - ` - resource "google_compute_disk" "good_example" { - disk_encryption_key { - kms_key_self_link = google_kms_crypto_key.my_crypto_key.id - } - } - `, -} - -var terraformDiskEncryptionNoPlaintextKeyBadExamples = []string{ - ` - resource "google_compute_disk" "bad_example" { - disk_encryption_key { - raw_key="b2ggbm8gdGhpcyBpcyBiYWQ=" - } - } - `, -} - -var terraformDiskEncryptionNoPlaintextKeyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_disk#kms_key_self_link`, -} - -var terraformDiskEncryptionNoPlaintextKeyRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/enable_shielded_vm_im.go b/checks/cloud/google/compute/enable_shielded_vm_im.go deleted file mode 100755 index cf0ff0b1..00000000 --- a/checks/cloud/google/compute/enable_shielded_vm_im.go +++ /dev/null @@ -1,49 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableShieldedVMIntegrityMonitoring = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0045", - Provider: providers.GoogleProvider, - Service: "compute", - ShortCode: "enable-shielded-vm-im", - Summary: "Instances should have Shielded VM integrity monitoring enabled", - Impact: "No visibility of VM instance boot state.", - Resolution: "Enable Shielded VM Integrity Monitoring", - Explanation: `Integrity monitoring helps you understand and make decisions about the state of your VM instances.`, - Links: []string{ - "https://cloud.google.com/security/shielded-cloud/shielded-vm#integrity-monitoring", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableShieldedVmImGoodExamples, - BadExamples: terraformEnableShieldedVmImBadExamples, - Links: terraformEnableShieldedVmImLinks, - RemediationMarkdown: terraformEnableShieldedVmImRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.Compute.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.ShieldedVM.IntegrityMonitoringEnabled.IsFalse() { - results.Add( - "Instance does not have shielded VM integrity monitoring enabled.", - instance.ShieldedVM.IntegrityMonitoringEnabled, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/google/compute/enable_shielded_vm_im.tf.go b/checks/cloud/google/compute/enable_shielded_vm_im.tf.go deleted file mode 100644 index e91d7e9d..00000000 --- a/checks/cloud/google/compute/enable_shielded_vm_im.tf.go +++ /dev/null @@ -1,61 +0,0 @@ -package compute - -var terraformEnableShieldedVmImGoodExamples = []string{ - ` - resource "google_compute_instance" "good_example" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - tags = ["foo", "bar"] - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - shielded_instance_config { - enable_integrity_monitoring = true - } - } - `, -} - -var terraformEnableShieldedVmImBadExamples = []string{ - ` - resource "google_compute_instance" "bad_example" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - tags = ["foo", "bar"] - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - shielded_instance_config { - enable_integrity_monitoring = false - } - } - `, -} - -var terraformEnableShieldedVmImLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#enable_vtpm`, -} - -var terraformEnableShieldedVmImRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/enable_shielded_vm_sb.go b/checks/cloud/google/compute/enable_shielded_vm_sb.go deleted file mode 100644 index 16f7747b..00000000 --- a/checks/cloud/google/compute/enable_shielded_vm_sb.go +++ /dev/null @@ -1,49 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableShieldedVMSecureBoot = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0067", - Provider: providers.GoogleProvider, - Service: "compute", - ShortCode: "enable-shielded-vm-sb", - Summary: "Instances should have Shielded VM secure boot enabled", - Impact: "Unable to verify digital signature of boot components, and unable to stop the boot process if verification fails.", - Resolution: "Enable Shielded VM secure boot", - Explanation: `Secure boot helps ensure that the system only runs authentic software.`, - Links: []string{ - "https://cloud.google.com/security/shielded-cloud/shielded-vm#secure-boot", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableShieldedVmSbGoodExamples, - BadExamples: terraformEnableShieldedVmSbBadExamples, - Links: terraformEnableShieldedVmSbLinks, - RemediationMarkdown: terraformEnableShieldedVmSbRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.Compute.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.ShieldedVM.SecureBootEnabled.IsFalse() { - results.Add( - "Instance does not have shielded VM secure boot enabled.", - instance.ShieldedVM.SecureBootEnabled, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/google/compute/enable_shielded_vm_sb.tf.go b/checks/cloud/google/compute/enable_shielded_vm_sb.tf.go deleted file mode 100644 index 47dce3dd..00000000 --- a/checks/cloud/google/compute/enable_shielded_vm_sb.tf.go +++ /dev/null @@ -1,61 +0,0 @@ -package compute - -var terraformEnableShieldedVmSbGoodExamples = []string{ - ` - resource "google_compute_instance" "good_example" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - tags = ["foo", "bar"] - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - shielded_instance_config { - enable_secure_boot = true - } - } - `, -} - -var terraformEnableShieldedVmSbBadExamples = []string{ - ` - resource "google_compute_instance" "bad_example" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - tags = ["foo", "bar"] - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - shielded_instance_config { - enable_secure_boot = false - } - } - `, -} - -var terraformEnableShieldedVmSbLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#enable_secure_boot`, -} - -var terraformEnableShieldedVmSbRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/enable_shielded_vm_vtpm.go b/checks/cloud/google/compute/enable_shielded_vm_vtpm.go deleted file mode 100755 index 650a7fe5..00000000 --- a/checks/cloud/google/compute/enable_shielded_vm_vtpm.go +++ /dev/null @@ -1,49 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableShieldedVMVTPM = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0041", - Provider: providers.GoogleProvider, - Service: "compute", - ShortCode: "enable-shielded-vm-vtpm", - Summary: "Instances should have Shielded VM VTPM enabled", - Impact: "Unable to prevent unwanted system state modification", - Resolution: "Enable Shielded VM VTPM", - Explanation: `The virtual TPM provides numerous security measures to your VM.`, - Links: []string{ - "https://cloud.google.com/blog/products/identity-security/virtual-trusted-platform-module-for-shielded-vms-security-in-plaintext", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableShieldedVmVtpmGoodExamples, - BadExamples: terraformEnableShieldedVmVtpmBadExamples, - Links: terraformEnableShieldedVmVtpmLinks, - RemediationMarkdown: terraformEnableShieldedVmVtpmRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.Compute.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.ShieldedVM.VTPMEnabled.IsFalse() { - results.Add( - "Instance does not have VTPM for shielded VMs enabled.", - instance.ShieldedVM.VTPMEnabled, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/google/compute/enable_shielded_vm_vtpm.tf.go b/checks/cloud/google/compute/enable_shielded_vm_vtpm.tf.go deleted file mode 100644 index 3e2efa98..00000000 --- a/checks/cloud/google/compute/enable_shielded_vm_vtpm.tf.go +++ /dev/null @@ -1,61 +0,0 @@ -package compute - -var terraformEnableShieldedVmVtpmGoodExamples = []string{ - ` - resource "google_compute_instance" "good_example" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - tags = ["foo", "bar"] - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - shielded_instance_config { - enable_vtpm = true - } - } - `, -} - -var terraformEnableShieldedVmVtpmBadExamples = []string{ - ` - resource "google_compute_instance" "bad_example" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - tags = ["foo", "bar"] - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - shielded_instance_config { - enable_vtpm = false - } - } - `, -} - -var terraformEnableShieldedVmVtpmLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#enable_vtpm`, -} - -var terraformEnableShieldedVmVtpmRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/enable_vpc_flow_logs.go b/checks/cloud/google/compute/enable_vpc_flow_logs.go deleted file mode 100755 index ef88b095..00000000 --- a/checks/cloud/google/compute/enable_vpc_flow_logs.go +++ /dev/null @@ -1,49 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableVPCFlowLogs = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0029", - Provider: providers.GoogleProvider, - Service: "compute", - ShortCode: "enable-vpc-flow-logs", - Summary: "VPC flow logs should be enabled for all subnetworks", - Impact: "Limited auditing capability and awareness", - Resolution: "Enable VPC flow logs", - Explanation: `VPC flow logs record information about all traffic, which is a vital tool in reviewing anomalous traffic.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableVpcFlowLogsGoodExamples, - BadExamples: terraformEnableVpcFlowLogsBadExamples, - Links: terraformEnableVpcFlowLogsLinks, - RemediationMarkdown: terraformEnableVpcFlowLogsRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, network := range s.Google.Compute.Networks { - for _, subnetwork := range network.Subnetworks { - if subnetwork.EnableFlowLogs.IsFalse() && - // Proxy-only subnets don't support VPC Flow Logs. - // https://cloud.google.com/vpc/docs/using-flow-logs#flow_logs_appear_to_be_disabled_even_though_you_enabled_them - !subnetwork.Purpose.IsOneOf("REGIONAL_MANAGED_PROXY", "GLOBAL_MANAGED_PROXY") { - results.Add( - "Subnetwork does not have VPC flow logs enabled.", - subnetwork.EnableFlowLogs, - ) - } else { - results.AddPassed(&subnetwork) - } - } - } - return - }, -) diff --git a/checks/cloud/google/compute/enable_vpc_flow_logs.tf.go b/checks/cloud/google/compute/enable_vpc_flow_logs.tf.go deleted file mode 100644 index fe22e0fc..00000000 --- a/checks/cloud/google/compute/enable_vpc_flow_logs.tf.go +++ /dev/null @@ -1,50 +0,0 @@ -package compute - -var terraformEnableVpcFlowLogsGoodExamples = []string{ - ` -resource "google_compute_subnetwork" "good_example" { - name = "test-subnetwork" - ip_cidr_range = "10.2.0.0/16" - region = "us-central1" - network = google_compute_network.custom-test.id - secondary_ip_range { - range_name = "tf-test-secondary-range-update1" - ip_cidr_range = "192.168.10.0/24" - } - log_config { - aggregation_interval = "INTERVAL_10_MIN" - flow_sampling = 0.5 - metadata = "INCLUDE_ALL_METADATA" - } -} -resource "google_compute_network" "custom-test" { - name = "test-network" - auto_create_subnetworks = false -} -`, -} - -var terraformEnableVpcFlowLogsBadExamples = []string{ - ` -resource "google_compute_subnetwork" "bad_example" { - name = "test-subnetwork" - ip_cidr_range = "10.2.0.0/16" - region = "us-central1" - network = google_compute_network.custom-test.id - secondary_ip_range { - range_name = "tf-test-secondary-range-update1" - ip_cidr_range = "192.168.10.0/24" - } -} -resource "google_compute_network" "custom-test" { - name = "test-network" - auto_create_subnetworks = false -} -`, -} - -var terraformEnableVpcFlowLogsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_subnetwork#enable_flow_logs`, -} - -var terraformEnableVpcFlowLogsRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/no_default_service_account.go b/checks/cloud/google/compute/no_default_service_account.go deleted file mode 100755 index 9d7b3752..00000000 --- a/checks/cloud/google/compute/no_default_service_account.go +++ /dev/null @@ -1,47 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoDefaultServiceAccount = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0044", - Provider: providers.GoogleProvider, - Service: "compute", - ShortCode: "no-default-service-account", - Summary: "Instances should not use the default service account", - Impact: "Instance has full access to the project", - Resolution: "Remove use of default service account", - Explanation: `The default service account has full project access. Instances should instead be assigned the minimal access they need.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoDefaultServiceAccountGoodExamples, - BadExamples: terraformNoDefaultServiceAccountBadExamples, - Links: terraformNoDefaultServiceAccountLinks, - RemediationMarkdown: terraformNoDefaultServiceAccountRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.Compute.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.ServiceAccount.IsDefault.IsTrue() { - results.Add( - "Instance uses the default service account.", - instance.ServiceAccount.Email, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/google/compute/no_default_service_account.tf.go b/checks/cloud/google/compute/no_default_service_account.tf.go deleted file mode 100644 index 41594fed..00000000 --- a/checks/cloud/google/compute/no_default_service_account.tf.go +++ /dev/null @@ -1,84 +0,0 @@ -package compute - -var terraformNoDefaultServiceAccountGoodExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service_account_id" - display_name = "Service Account" - } - - resource "google_compute_instance" "default" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - tags = ["foo", "bar"] - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - network_interface { - network = "default" - - access_config { - // Ephemeral IP - } - } - - metadata = { - foo = "bar" - } - - metadata_startup_script = "echo hi > /test.txt" - - service_account { - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - email = google_service_account.default.email - scopes = ["cloud-platform"] - } - } - `, -} - -var terraformNoDefaultServiceAccountBadExamples = []string{ - ` - resource "google_compute_instance" "default" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - tags = ["foo", "bar"] - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - service_account { - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - email = "1234567890-compute@developer.gserviceaccount.com" - scopes = ["cloud-platform"] - } - } - `, -} - -var terraformNoDefaultServiceAccountLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#`, -} - -var terraformNoDefaultServiceAccountRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/no_ip_forwarding.go b/checks/cloud/google/compute/no_ip_forwarding.go deleted file mode 100755 index 2f61be03..00000000 --- a/checks/cloud/google/compute/no_ip_forwarding.go +++ /dev/null @@ -1,47 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoIpForwarding = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0043", - Provider: providers.GoogleProvider, - Service: "compute", - ShortCode: "no-ip-forwarding", - Summary: "Instances should not have IP forwarding enabled", - Impact: "Instance can send/receive packets without the explicit instance address", - Resolution: "Disable IP forwarding", - Explanation: `Disabling IP forwarding ensures the instance can only receive packets addressed to the instance and can only send packets with a source address of the instance.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoIpForwardingGoodExamples, - BadExamples: terraformNoIpForwardingBadExamples, - Links: terraformNoIpForwardingLinks, - RemediationMarkdown: terraformNoIpForwardingRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.Compute.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.CanIPForward.IsTrue() { - results.Add( - "Instance has IP forwarding allowed.", - instance.CanIPForward, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/google/compute/no_ip_forwarding.tf.go b/checks/cloud/google/compute/no_ip_forwarding.tf.go deleted file mode 100644 index 620cf42f..00000000 --- a/checks/cloud/google/compute/no_ip_forwarding.tf.go +++ /dev/null @@ -1,53 +0,0 @@ -package compute - -var terraformNoIpForwardingGoodExamples = []string{ - ` - resource "google_compute_instance" "good_example" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - can_ip_forward = false - } - `, -} - -var terraformNoIpForwardingBadExamples = []string{ - ` - resource "google_compute_instance" "bad_example" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - can_ip_forward = true - } - `, -} - -var terraformNoIpForwardingLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#can_ip_forward`, -} - -var terraformNoIpForwardingRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/no_oslogin_override.go b/checks/cloud/google/compute/no_oslogin_override.go deleted file mode 100755 index 73520307..00000000 --- a/checks/cloud/google/compute/no_oslogin_override.go +++ /dev/null @@ -1,47 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoOsloginOverride = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0036", - Provider: providers.GoogleProvider, - Service: "compute", - ShortCode: "no-oslogin-override", - Summary: "Instances should not override the project setting for OS Login", - Impact: "Access via SSH key cannot be revoked automatically when an IAM user is removed.", - Resolution: "Enable OS Login at project level and remove instance-level overrides", - Explanation: `OS Login automatically revokes the relevant SSH keys when an IAM user has their access revoked.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoOsloginOverrideGoodExamples, - BadExamples: terraformNoOsloginOverrideBadExamples, - Links: terraformNoOsloginOverrideLinks, - RemediationMarkdown: terraformNoOsloginOverrideRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.Compute.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.OSLoginEnabled.IsFalse() { - results.Add( - "Instance has OS Login disabled.", - instance.OSLoginEnabled, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/google/compute/no_oslogin_override.tf.go b/checks/cloud/google/compute/no_oslogin_override.tf.go deleted file mode 100644 index e6343882..00000000 --- a/checks/cloud/google/compute/no_oslogin_override.tf.go +++ /dev/null @@ -1,56 +0,0 @@ -package compute - -var terraformNoOsloginOverrideGoodExamples = []string{ - ` - resource "google_compute_instance" "default" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - metadata = { - } - } - `, -} - -var terraformNoOsloginOverrideBadExamples = []string{ - ` - resource "google_compute_instance" "default" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - metadata = { - enable-oslogin = false - } - } - `, -} - -var terraformNoOsloginOverrideLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#`, -} - -var terraformNoOsloginOverrideRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/no_project_wide_ssh_keys.go b/checks/cloud/google/compute/no_project_wide_ssh_keys.go deleted file mode 100755 index b9d43557..00000000 --- a/checks/cloud/google/compute/no_project_wide_ssh_keys.go +++ /dev/null @@ -1,47 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoProjectWideSshKeys = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0030", - Provider: providers.GoogleProvider, - Service: "compute", - ShortCode: "no-project-wide-ssh-keys", - Summary: "Disable project-wide SSH keys for all instances", - Impact: "Compromise of a single key pair compromises all instances", - Resolution: "Disable project-wide SSH keys", - Explanation: `Use of project-wide SSH keys means that a compromise of any one of these key pairs can result in all instances being compromised. It is recommended to use instance-level keys.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoProjectWideSshKeysGoodExamples, - BadExamples: terraformNoProjectWideSshKeysBadExamples, - Links: terraformNoProjectWideSshKeysLinks, - RemediationMarkdown: terraformNoProjectWideSshKeysRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.Compute.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.EnableProjectSSHKeyBlocking.IsFalse() { - results.Add( - "Instance allows use of project-level SSH keys.", - instance.EnableProjectSSHKeyBlocking, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/google/compute/no_project_wide_ssh_keys.tf.go b/checks/cloud/google/compute/no_project_wide_ssh_keys.tf.go deleted file mode 100644 index e23a7816..00000000 --- a/checks/cloud/google/compute/no_project_wide_ssh_keys.tf.go +++ /dev/null @@ -1,103 +0,0 @@ -package compute - -var terraformNoProjectWideSshKeysGoodExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service_account_id" - display_name = "Service Account" - } - - resource "google_compute_instance" "default" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - tags = ["foo", "bar"] - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - network_interface { - network = "default" - - access_config { - // Ephemeral IP - } - } - - metadata = { - block-project-ssh-keys = true - } - - metadata_startup_script = "echo hi > /test.txt" - - service_account { - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - email = google_service_account.default.email - scopes = ["cloud-platform"] - } - } - `, -} - -var terraformNoProjectWideSshKeysBadExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service_account_id" - display_name = "Service Account" - } - - resource "google_compute_instance" "default" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - tags = ["foo", "bar"] - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - network_interface { - network = "default" - - access_config { - // Ephemeral IP - } - } - - metadata = { - block-project-ssh-keys = false - } - - metadata_startup_script = "echo hi > /test.txt" - - service_account { - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - email = google_service_account.default.email - scopes = ["cloud-platform"] - } - } - `, -} - -var terraformNoProjectWideSshKeysLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#`, -} - -var terraformNoProjectWideSshKeysRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/no_public_egress.go b/checks/cloud/google/compute/no_public_egress.go deleted file mode 100755 index c05858fb..00000000 --- a/checks/cloud/google/compute/no_public_egress.go +++ /dev/null @@ -1,62 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicEgress = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0035", - Provider: providers.GoogleProvider, - Service: "compute", - ShortCode: "no-public-egress", - Summary: "An outbound firewall rule allows traffic to /0.", - Impact: "The port is exposed for egress to the internet", - Resolution: "Set a more restrictive cidr range", - Explanation: `Network security rules should not use very broad subnets. - -Where possible, segments should be broken into smaller subnets and avoid using the /0 subnet.`, - Links: []string{ - "https://cloud.google.com/vpc/docs/using-firewalls", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicEgressGoodExamples, - BadExamples: terraformNoPublicEgressBadExamples, - Links: terraformNoPublicEgressLinks, - RemediationMarkdown: terraformNoPublicEgressRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, network := range s.Google.Compute.Networks { - if network.Firewall == nil { - continue - } - for _, rule := range network.Firewall.EgressRules { - if !rule.IsAllow.IsTrue() { - continue - } - if rule.Enforced.IsFalse() { - continue - } - for _, destination := range rule.DestinationRanges { - if cidr.IsPublic(destination.Value()) && cidr.CountAddresses(destination.Value()) > 1 { - results.Add( - "Firewall rule allows egress traffic to multiple addresses on the public internet.", - destination, - ) - } else { - results.AddPassed(destination) - } - } - } - } - return - }, -) diff --git a/checks/cloud/google/compute/no_public_egress.tf.go b/checks/cloud/google/compute/no_public_egress.tf.go deleted file mode 100644 index fa5b14ce..00000000 --- a/checks/cloud/google/compute/no_public_egress.tf.go +++ /dev/null @@ -1,29 +0,0 @@ -package compute - -var terraformNoPublicEgressGoodExamples = []string{ - ` - resource "google_compute_firewall" "good_example" { - direction = "EGRESS" - allow { - protocol = "icmp" - } - destination_ranges = ["1.2.3.4/32"] -}`, -} - -var terraformNoPublicEgressBadExamples = []string{ - ` -resource "google_compute_firewall" "bad_example" { - direction = "EGRESS" - allow { - protocol = "icmp" - } - destination_ranges = ["0.0.0.0/0"] -}`, -} - -var terraformNoPublicEgressLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_firewall`, -} - -var terraformNoPublicEgressRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/no_public_ingress.go b/checks/cloud/google/compute/no_public_ingress.go deleted file mode 100755 index 835e0d68..00000000 --- a/checks/cloud/google/compute/no_public_ingress.go +++ /dev/null @@ -1,67 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicIngress = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0027", - Provider: providers.GoogleProvider, - Service: "compute", - ShortCode: "no-public-ingress", - Summary: "An inbound firewall rule allows traffic from /0.", - Impact: "The port is exposed for ingress from the internet", - Resolution: "Set a more restrictive cidr range", - Explanation: `Network security rules should not use very broad subnets. - -Where possible, segments should be broken into smaller subnets and avoid using the /0 subnet.`, - Links: []string{ - "https://cloud.google.com/vpc/docs/using-firewalls", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicIngressGoodExamples, - BadExamples: terraformNoPublicIngressBadExamples, - Links: terraformNoPublicIngressLinks, - RemediationMarkdown: terraformNoPublicIngressRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, network := range s.Google.Compute.Networks { - if network.Firewall == nil { - continue - } - - if len(network.Firewall.SourceTags) > 0 && len(network.Firewall.TargetTags) > 0 { - continue - } - - for _, rule := range network.Firewall.IngressRules { - if !rule.IsAllow.IsTrue() { - continue - } - if rule.Enforced.IsFalse() { - continue - } - for _, source := range rule.SourceRanges { - if cidr.IsPublic(source.Value()) && cidr.CountAddresses(source.Value()) > 1 { - results.Add( - "Firewall rule allows ingress traffic from multiple addresses on the public internet.", - source, - ) - } else { - results.AddPassed(source) - } - } - } - } - return - }, -) diff --git a/checks/cloud/google/compute/no_public_ingress.tf.go b/checks/cloud/google/compute/no_public_ingress.tf.go deleted file mode 100644 index a2dd2f0b..00000000 --- a/checks/cloud/google/compute/no_public_ingress.tf.go +++ /dev/null @@ -1,55 +0,0 @@ -package compute - -var terraformNoPublicIngressGoodExamples = []string{ - ` -resource "google_compute_firewall" "good_example" { - source_ranges = ["1.2.3.4/32"] - allow { - protocol = "icmp" - } -}`, - ` -resource "google_compute_firewall" "allow-vms-to-some-machine" { - name = "allow-vms-to-some-machine" - network = local.network - priority = 1300 - direction = "INGRESS" - allow { - protocol = "tcp" - ports = ["8081"] - } - source_tags = ["vms"] - target_tags = ["some-machine"] -}`, - ` -resource "google_compute_firewall" "test" { - name = "gmp-validating-webhook-fw" - network = google_compute_network.my_vpc_name.self_link - - allow { - protocol = "tcp" - ports = ["8443"] - } - - target_tags = [ "k8s-node-pool" ] - source_ranges = [google_container_cluster.my_cluster_name.private_cluster_config[0].master_ipv4_cidr_block] -} -`, -} - -var terraformNoPublicIngressBadExamples = []string{ - ` -resource "google_compute_firewall" "bad_example" { - source_ranges = ["0.0.0.0/0"] - allow { - protocol = "icmp" - } -}`, -} - -var terraformNoPublicIngressLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_firewall#source_ranges`, - `https://www.terraform.io/docs/providers/google/r/compute_firewall.html`, -} - -var terraformNoPublicIngressRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/no_public_ip.go b/checks/cloud/google/compute/no_public_ip.go deleted file mode 100755 index 469323f8..00000000 --- a/checks/cloud/google/compute/no_public_ip.go +++ /dev/null @@ -1,49 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckInstancesDoNotHavePublicIPs = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0031", - Provider: providers.GoogleProvider, - Service: service, - ShortCode: "no-public-ip", - Summary: "Instances should not have public IP addresses", - Impact: "Direct exposure of an instance to the public internet", - Resolution: "Remove public IP", - Explanation: `Instances should not be publicly exposed to the internet`, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicIpGoodExamples, - BadExamples: terraformNoPublicIpBadExamples, - Links: terraformNoPublicIpLinks, - RemediationMarkdown: terraformNoPublicIpRemediationMarkdown, - }, - Severity: severity.High, - Links: []string{ - "https://cloud.google.com/compute/docs/ip-addresses#externaladdresses", - }, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.Compute.Instances { - for _, networkInterface := range instance.NetworkInterfaces { - if networkInterface.HasPublicIP.IsTrue() { - results.Add( - "Instance has a public IP allocated.", - networkInterface.HasPublicIP, - ) - } else { - results.AddPassed(&networkInterface) - } - } - - } - return results - }, -) diff --git a/checks/cloud/google/compute/no_public_ip.tf.go b/checks/cloud/google/compute/no_public_ip.tf.go deleted file mode 100644 index fe2de7bd..00000000 --- a/checks/cloud/google/compute/no_public_ip.tf.go +++ /dev/null @@ -1,65 +0,0 @@ -package compute - -var terraformNoPublicIpGoodExamples = []string{ - ` - resource "google_compute_instance" "good_example" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - tags = ["foo", "bar"] - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - network_interface { - network = "default" - } - } - `, -} - -var terraformNoPublicIpBadExamples = []string{ - ` - resource "google_compute_instance" "bad_example" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - tags = ["foo", "bar"] - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - network_interface { - network = "default" - - access_config { - // Ephemeral IP - } - } - } - `, -} - -var terraformNoPublicIpLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#access_config`, -} - -var terraformNoPublicIpRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/no_serial_port.go b/checks/cloud/google/compute/no_serial_port.go deleted file mode 100755 index ebdb1049..00000000 --- a/checks/cloud/google/compute/no_serial_port.go +++ /dev/null @@ -1,47 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoSerialPort = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0032", - Provider: providers.GoogleProvider, - Service: "compute", - ShortCode: "no-serial-port", - Summary: "Disable serial port connectivity for all instances", - Impact: "Unrestricted network access to the serial console of the instance", - Resolution: "Disable serial port access", - Explanation: `When serial port access is enabled, the access is not governed by network security rules meaning the port can be exposed publicly.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoSerialPortGoodExamples, - BadExamples: terraformNoSerialPortBadExamples, - Links: terraformNoSerialPortLinks, - RemediationMarkdown: terraformNoSerialPortRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.Compute.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.EnableSerialPort.IsTrue() { - results.Add( - "Instance has serial port enabled.", - instance.EnableSerialPort, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/google/compute/no_serial_port.tf.go b/checks/cloud/google/compute/no_serial_port.tf.go deleted file mode 100644 index 5e107934..00000000 --- a/checks/cloud/google/compute/no_serial_port.tf.go +++ /dev/null @@ -1,103 +0,0 @@ -package compute - -var terraformNoSerialPortGoodExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service_account_id" - display_name = "Service Account" - } - - resource "google_compute_instance" "default" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - tags = ["foo", "bar"] - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - network_interface { - network = "default" - - access_config { - // Ephemeral IP - } - } - - metadata = { - serial-port-enable = false - } - - metadata_startup_script = "echo hi > /test.txt" - - service_account { - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - email = google_service_account.default.email - scopes = ["cloud-platform"] - } - } - `, -} - -var terraformNoSerialPortBadExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service_account_id" - display_name = "Service Account" - } - - resource "google_compute_instance" "default" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - tags = ["foo", "bar"] - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - network_interface { - network = "default" - - access_config { - // Ephemeral IP - } - } - - metadata = { - serial-port-enable = true - } - - metadata_startup_script = "echo hi > /test.txt" - - service_account { - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - email = google_service_account.default.email - scopes = ["cloud-platform"] - } - } - `, -} - -var terraformNoSerialPortLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#`, -} - -var terraformNoSerialPortRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/project_level_oslogin.go b/checks/cloud/google/compute/project_level_oslogin.go deleted file mode 100755 index 87f65e10..00000000 --- a/checks/cloud/google/compute/project_level_oslogin.go +++ /dev/null @@ -1,44 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckProjectLevelOslogin = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0042", - Provider: providers.GoogleProvider, - Service: "compute", - ShortCode: "project-level-oslogin", - Summary: "OS Login should be enabled at project level", - Impact: "Access via SSH key cannot be revoked automatically when an IAM user is removed.", - Resolution: "Enable OS Login at project level", - Explanation: `OS Login automatically revokes the relevant SSH keys when an IAM user has their access revoked.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformProjectLevelOsloginGoodExamples, - BadExamples: terraformProjectLevelOsloginBadExamples, - Links: terraformProjectLevelOsloginLinks, - RemediationMarkdown: terraformProjectLevelOsloginRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - if s.Google.Compute.ProjectMetadata.Metadata.IsManaged() { - if s.Google.Compute.ProjectMetadata.EnableOSLogin.IsFalse() { - results.Add( - "OS Login is disabled at project level.", - s.Google.Compute.ProjectMetadata.EnableOSLogin, - ) - } else { - results.AddPassed(&s.Google.Compute.ProjectMetadata) - } - } - return - }, -) diff --git a/checks/cloud/google/compute/project_level_oslogin.tf.go b/checks/cloud/google/compute/project_level_oslogin.tf.go deleted file mode 100644 index 5484d919..00000000 --- a/checks/cloud/google/compute/project_level_oslogin.tf.go +++ /dev/null @@ -1,27 +0,0 @@ -package compute - -var terraformProjectLevelOsloginGoodExamples = []string{ - ` - resource "google_compute_project_metadata" "default" { - metadata = { - enable-oslogin = true - } - } - `, -} - -var terraformProjectLevelOsloginBadExamples = []string{ - ` - resource "google_compute_project_metadata" "default" { - metadata = { - enable-oslogin = false - } - } - `, -} - -var terraformProjectLevelOsloginLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_project_metadata#`, -} - -var terraformProjectLevelOsloginRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/service.go b/checks/cloud/google/compute/service.go deleted file mode 100755 index af136198..00000000 --- a/checks/cloud/google/compute/service.go +++ /dev/null @@ -1,3 +0,0 @@ -package compute - -const service = "compute" diff --git a/checks/cloud/google/compute/use_secure_tls_policy.go b/checks/cloud/google/compute/use_secure_tls_policy.go deleted file mode 100755 index 71592f6f..00000000 --- a/checks/cloud/google/compute/use_secure_tls_policy.go +++ /dev/null @@ -1,47 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckUseSecureTlsPolicy = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0039", - Provider: providers.GoogleProvider, - Service: "compute", - ShortCode: "use-secure-tls-policy", - Summary: "SSL policies should enforce secure versions of TLS", - Impact: "Data in transit is not sufficiently secured", - Resolution: "Enforce a minimum TLS version of 1.2", - Explanation: `TLS versions prior to 1.2 are outdated and insecure. You should use 1.2 as aminimum version.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformUseSecureTlsPolicyGoodExamples, - BadExamples: terraformUseSecureTlsPolicyBadExamples, - Links: terraformUseSecureTlsPolicyLinks, - RemediationMarkdown: terraformUseSecureTlsPolicyRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, policy := range s.Google.Compute.SSLPolicies { - if policy.Metadata.IsUnmanaged() { - continue - } - if policy.MinimumTLSVersion.NotEqualTo("TLS_1_2") { - results.Add( - "TLS policy does not specify a minimum of TLS 1.2", - policy.MinimumTLSVersion, - ) - } else { - results.AddPassed(&policy) - } - } - return - }, -) diff --git a/checks/cloud/google/compute/use_secure_tls_policy.tf.go b/checks/cloud/google/compute/use_secure_tls_policy.tf.go deleted file mode 100644 index fdedb0ab..00000000 --- a/checks/cloud/google/compute/use_secure_tls_policy.tf.go +++ /dev/null @@ -1,28 +0,0 @@ -package compute - -var terraformUseSecureTlsPolicyGoodExamples = []string{ - ` - resource "google_compute_ssl_policy" "good_example" { - name = "production-ssl-policy" - profile = "MODERN" - min_tls_version = "TLS_1_2" - } - `, -} - -var terraformUseSecureTlsPolicyBadExamples = []string{ - ` - resource "google_compute_ssl_policy" "bad_example" { - name = "production-ssl-policy" - profile = "MODERN" - min_tls_version = "TLS_1_1" - } - - `, -} - -var terraformUseSecureTlsPolicyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_ssl_policy#min_tls_version`, -} - -var terraformUseSecureTlsPolicyRemediationMarkdown = `` diff --git a/checks/cloud/google/compute/vm_disk_encryption_customer_key.go b/checks/cloud/google/compute/vm_disk_encryption_customer_key.go deleted file mode 100755 index 63ba66ad..00000000 --- a/checks/cloud/google/compute/vm_disk_encryption_customer_key.go +++ /dev/null @@ -1,46 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckVmDiskEncryptionCustomerKey = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0033", - Provider: providers.GoogleProvider, - Service: "compute", - ShortCode: "vm-disk-encryption-customer-key", - Summary: "VM disks should be encrypted with Customer Supplied Encryption Keys", - Impact: "Using unmanaged keys does not allow for proper management", - Resolution: "Use managed keys ", - Explanation: `Using unmanaged keys makes rotation and general management difficult.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformVmDiskEncryptionCustomerKeyGoodExamples, - BadExamples: terraformVmDiskEncryptionCustomerKeyBadExamples, - Links: terraformVmDiskEncryptionCustomerKeyLinks, - RemediationMarkdown: terraformVmDiskEncryptionCustomerKeyRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.Compute.Instances { - for _, disk := range append(instance.BootDisks, instance.AttachedDisks...) { - if disk.Encryption.KMSKeyLink.IsEmpty() { - results.Add( - "Instance disk encryption does not use a customer managed key.", - disk.Encryption.KMSKeyLink, - ) - } else { - results.AddPassed(&disk) - } - } - } - return - }, -) diff --git a/checks/cloud/google/compute/vm_disk_encryption_customer_key.tf.go b/checks/cloud/google/compute/vm_disk_encryption_customer_key.tf.go deleted file mode 100644 index eb2cfb81..00000000 --- a/checks/cloud/google/compute/vm_disk_encryption_customer_key.tf.go +++ /dev/null @@ -1,104 +0,0 @@ -package compute - -var terraformVmDiskEncryptionCustomerKeyGoodExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service_account_id" - display_name = "Service Account" - } - - resource "google_compute_instance" "good_example" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - tags = ["foo", "bar"] - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - kms_key_self_link = "something" - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - network_interface { - network = "default" - - access_config { - // Ephemeral IP - } - } - - metadata = { - foo = "bar" - } - - metadata_startup_script = "echo hi > /test.txt" - - service_account { - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - email = google_service_account.default.email - scopes = ["cloud-platform"] - } - } - `, -} - -var terraformVmDiskEncryptionCustomerKeyBadExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service_account_id" - display_name = "Service Account" - } - - resource "google_compute_instance" "bad_example" { - name = "test" - machine_type = "e2-medium" - zone = "us-central1-a" - - tags = ["foo", "bar"] - - boot_disk { - initialize_params { - image = "debian-cloud/debian-9" - } - } - - // Local SSD disk - scratch_disk { - interface = "SCSI" - } - - network_interface { - network = "default" - - access_config { - // Ephemeral IP - } - } - - metadata = { - foo = "bar" - } - - metadata_startup_script = "echo hi > /test.txt" - - service_account { - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - email = google_service_account.default.email - scopes = ["cloud-platform"] - } - } - `, -} - -var terraformVmDiskEncryptionCustomerKeyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#kms_key_self_link`, -} - -var terraformVmDiskEncryptionCustomerKeyRemediationMarkdown = `` diff --git a/checks/cloud/google/dns/enable_dnssec.go b/checks/cloud/google/dns/enable_dnssec.go deleted file mode 100755 index 92766d25..00000000 --- a/checks/cloud/google/dns/enable_dnssec.go +++ /dev/null @@ -1,47 +0,0 @@ -package dns - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableDnssec = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0013", - Provider: providers.GoogleProvider, - Service: "dns", - ShortCode: "enable-dnssec", - Summary: "Cloud DNS should use DNSSEC", - Impact: "Unverified DNS responses could lead to man-in-the-middle attacks", - Resolution: "Enable DNSSEC", - Explanation: `DNSSEC authenticates DNS responses, preventing MITM attacks and impersonation.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableDnssecGoodExamples, - BadExamples: terraformEnableDnssecBadExamples, - Links: terraformEnableDnssecLinks, - RemediationMarkdown: terraformEnableDnssecRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, zone := range s.Google.DNS.ManagedZones { - if zone.Metadata.IsUnmanaged() || zone.IsPrivate() { - continue - } - if zone.DNSSec.Enabled.IsFalse() { - results.Add( - "Managed zone does not have DNSSEC enabled.", - zone.DNSSec.Enabled, - ) - } else { - results.AddPassed(&zone) - } - } - return - }, -) diff --git a/checks/cloud/google/dns/enable_dnssec.tf.go b/checks/cloud/google/dns/enable_dnssec.tf.go deleted file mode 100644 index 19fe0b41..00000000 --- a/checks/cloud/google/dns/enable_dnssec.tf.go +++ /dev/null @@ -1,47 +0,0 @@ -package dns - -var terraformEnableDnssecGoodExamples = []string{ - ` - resource "google_dns_managed_zone" "good_example" { - name = "example-zone" - dns_name = "example-${random_id.rnd.hex}.com." - description = "Example DNS zone" - labels = { - foo = "bar" - } - dnssec_config { - state = "on" - } - } - - resource "random_id" "rnd" { - byte_length = 4 - } - `, -} - -var terraformEnableDnssecBadExamples = []string{ - ` - resource "google_dns_managed_zone" "bad_example" { - name = "example-zone" - dns_name = "example-${random_id.rnd.hex}.com." - description = "Example DNS zone" - labels = { - foo = "bar" - } - dnssec_config { - state = "off" - } - } - - resource "random_id" "rnd" { - byte_length = 4 - } - `, -} - -var terraformEnableDnssecLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/dns_managed_zone#state`, -} - -var terraformEnableDnssecRemediationMarkdown = `` diff --git a/checks/cloud/google/dns/no_rsa_sha1.go b/checks/cloud/google/dns/no_rsa_sha1.go deleted file mode 100755 index 813124e8..00000000 --- a/checks/cloud/google/dns/no_rsa_sha1.go +++ /dev/null @@ -1,50 +0,0 @@ -package dns - -import ( - "fmt" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoRsaSha1 = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0012", - Provider: providers.GoogleProvider, - Service: "dns", - ShortCode: "no-rsa-sha1", - Summary: "Zone signing should not use RSA SHA1", - Impact: "Less secure encryption algorithm than others available", - Resolution: "Use RSA SHA512", - Explanation: `RSA SHA1 is a weaker algorithm than SHA2-based algorithms such as RSA SHA256/512`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoRsaSha1GoodExamples, - BadExamples: terraformNoRsaSha1BadExamples, - Links: terraformNoRsaSha1Links, - RemediationMarkdown: terraformNoRsaSha1RemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, zone := range s.Google.DNS.ManagedZones { - if zone.Metadata.IsUnmanaged() { - continue - } - for _, keySpec := range zone.DNSSec.DefaultKeySpecs { - - if keySpec.Algorithm.EqualTo("rsasha1") { - results.Add( - fmt.Sprintf("Zone uses %q key type with RSA SHA1 algorithm for signing.", keySpec.KeyType.Value()), - keySpec.Algorithm, - ) - } - } - } - return - }, -) diff --git a/checks/cloud/google/dns/no_rsa_sha1.tf.go b/checks/cloud/google/dns/no_rsa_sha1.tf.go deleted file mode 100644 index 4a2fc4db..00000000 --- a/checks/cloud/google/dns/no_rsa_sha1.tf.go +++ /dev/null @@ -1,49 +0,0 @@ -package dns - -var terraformNoRsaSha1GoodExamples = []string{ - ` -resource "google_dns_managed_zone" "example-zone" { - name = "example-zone" - dns_name = "example-${random_id.rnd.hex}.com." - - dnssec_config { - state = "on" - default_key_specs { - algorithm = "rsasha512" - key_type = "keySigning" - } - default_key_specs { - algorithm = "rsasha512" - key_type = "zoneSigning" - } - } -} - `, -} - -var terraformNoRsaSha1BadExamples = []string{ - ` -resource "google_dns_managed_zone" "example-zone" { - name = "example-zone" - dns_name = "example-${random_id.rnd.hex}.com." - - dnssec_config { - state = "on" - default_key_specs { - algorithm = "rsasha1" - key_type = "keySigning" - } - default_key_specs { - algorithm = "rsasha1" - key_type = "zoneSigning" - } - } -} - `, -} - -var terraformNoRsaSha1Links = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/dns_managed_zone#algorithm`, -} - -var terraformNoRsaSha1RemediationMarkdown = `` diff --git a/checks/cloud/google/gke/enable_auto_repair.go b/checks/cloud/google/gke/enable_auto_repair.go deleted file mode 100755 index 8d0710f3..00000000 --- a/checks/cloud/google/gke/enable_auto_repair.go +++ /dev/null @@ -1,46 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableAutoRepair = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0063", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "enable-auto-repair", - Summary: "Kubernetes should have 'Automatic repair' enabled", - Impact: "Failing nodes will require manual repair.", - Resolution: "Enable automatic repair", - Explanation: `Automatic repair will monitor nodes and attempt repair when a node fails multiple subsequent health checks`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableAutoRepairGoodExamples, - BadExamples: terraformEnableAutoRepairBadExamples, - Links: terraformEnableAutoRepairLinks, - RemediationMarkdown: terraformEnableAutoRepairRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - for _, nodePool := range cluster.NodePools { - if nodePool.Management.EnableAutoRepair.IsFalse() { - results.Add( - "Node pool does not have auto-repair enabled.", - nodePool.Management.EnableAutoRepair, - ) - } else { - results.AddPassed(&nodePool) - } - } - } - return - }, -) diff --git a/checks/cloud/google/gke/enable_auto_repair.tf.go b/checks/cloud/google/gke/enable_auto_repair.tf.go deleted file mode 100644 index 47eeb661..00000000 --- a/checks/cloud/google/gke/enable_auto_repair.tf.go +++ /dev/null @@ -1,87 +0,0 @@ -package gke - -var terraformEnableAutoRepairGoodExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "primary" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - } - - resource "google_container_node_pool" "good_example" { - name = "my-node-pool" - cluster = google_container_cluster.primary.id - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - management { - auto_repair = true - } - } - `, -} - -var terraformEnableAutoRepairBadExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "primary" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - } - - resource "google_container_node_pool" "bad_example" { - name = "my-node-pool" - cluster = google_container_cluster.primary.id - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - management { - auto_repair = false - } - } - `, -} - -var terraformEnableAutoRepairLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool#auto_repair`, -} - -var terraformEnableAutoRepairRemediationMarkdown = `` diff --git a/checks/cloud/google/gke/enable_auto_upgrade.go b/checks/cloud/google/gke/enable_auto_upgrade.go deleted file mode 100755 index 89ff1fd6..00000000 --- a/checks/cloud/google/gke/enable_auto_upgrade.go +++ /dev/null @@ -1,47 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableAutoUpgrade = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0058", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "enable-auto-upgrade", - Summary: "Kubernetes should have 'Automatic upgrade' enabled", - Impact: "Nodes will need the cluster master version manually updating", - Resolution: "Enable automatic upgrades", - Explanation: `Automatic updates keep nodes updated with the latest cluster master version.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableAutoUpgradeGoodExamples, - BadExamples: terraformEnableAutoUpgradeBadExamples, - Links: terraformEnableAutoUpgradeLinks, - RemediationMarkdown: terraformEnableAutoUpgradeRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - for _, nodePool := range cluster.NodePools { - if nodePool.Management.EnableAutoUpgrade.IsFalse() { - results.Add( - "Node pool does not have auto-upgraade enabled.", - nodePool.Management.EnableAutoUpgrade, - ) - } else { - results.AddPassed(&nodePool) - } - - } - } - return - }, -) diff --git a/checks/cloud/google/gke/enable_auto_upgrade.tf.go b/checks/cloud/google/gke/enable_auto_upgrade.tf.go deleted file mode 100644 index d2a61d7a..00000000 --- a/checks/cloud/google/gke/enable_auto_upgrade.tf.go +++ /dev/null @@ -1,87 +0,0 @@ -package gke - -var terraformEnableAutoUpgradeGoodExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "primary" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - } - - resource "google_container_node_pool" "good_example" { - name = "my-node-pool" - cluster = google_container_cluster.primary.id - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - management { - auto_upgrade = true - } - } - `, -} - -var terraformEnableAutoUpgradeBadExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "primary" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - } - - resource "google_container_node_pool" "bad_example" { - name = "my-node-pool" - cluster = google_container_cluster.primary.id - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - management { - auto_upgrade = false - } - } - `, -} - -var terraformEnableAutoUpgradeLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool#auto_upgrade`, -} - -var terraformEnableAutoUpgradeRemediationMarkdown = `` diff --git a/checks/cloud/google/gke/enable_ip_aliasing.go b/checks/cloud/google/gke/enable_ip_aliasing.go deleted file mode 100755 index 3f6b0441..00000000 --- a/checks/cloud/google/gke/enable_ip_aliasing.go +++ /dev/null @@ -1,48 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableIpAliasing = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0049", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "enable-ip-aliasing", - Summary: "Clusters should have IP aliasing enabled", - Impact: "Nodes need a NAT gateway to access local services", - Resolution: "Enable IP aliasing", - Explanation: `IP aliasing allows the reuse of public IPs internally, removing the need for a NAT gateway.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableIpAliasingGoodExamples, - BadExamples: terraformEnableIpAliasingBadExamples, - Links: terraformEnableIpAliasingLinks, - RemediationMarkdown: terraformEnableIpAliasingRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - if cluster.Metadata.IsUnmanaged() { - continue - } - if cluster.IPAllocationPolicy.Enabled.IsFalse() { - results.Add( - "Cluster has IP aliasing disabled.", - cluster.IPAllocationPolicy.Enabled, - ) - } else { - results.AddPassed(&cluster) - } - - } - return - }, -) diff --git a/checks/cloud/google/gke/enable_ip_aliasing.tf.go b/checks/cloud/google/gke/enable_ip_aliasing.tf.go deleted file mode 100644 index fbdc2e47..00000000 --- a/checks/cloud/google/gke/enable_ip_aliasing.tf.go +++ /dev/null @@ -1,84 +0,0 @@ -package gke - -var terraformEnableIpAliasingGoodExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "good_example" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - ip_allocation_policy {} - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformEnableIpAliasingBadExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "bad_example" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformEnableIpAliasingLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#ip_allocation_policy`, -} - -var terraformEnableIpAliasingRemediationMarkdown = `` diff --git a/checks/cloud/google/gke/enable_master_networks.go b/checks/cloud/google/gke/enable_master_networks.go deleted file mode 100755 index 80ae2958..00000000 --- a/checks/cloud/google/gke/enable_master_networks.go +++ /dev/null @@ -1,48 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableMasterNetworks = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0061", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "enable-master-networks", - Summary: "Master authorized networks should be configured on GKE clusters", - Impact: "Unrestricted network access to the master", - Resolution: "Enable master authorized networks", - Explanation: `Enabling authorized networks means you can restrict master access to a fixed set of CIDR ranges`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableMasterNetworksGoodExamples, - BadExamples: terraformEnableMasterNetworksBadExamples, - Links: terraformEnableMasterNetworksLinks, - RemediationMarkdown: terraformEnableMasterNetworksRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - if cluster.Metadata.IsUnmanaged() { - continue - } - if cluster.MasterAuthorizedNetworks.Enabled.IsFalse() { - results.Add( - "Cluster does not have master authorized networks enabled.", - cluster.MasterAuthorizedNetworks.Enabled, - ) - } else { - results.AddPassed(&cluster) - } - - } - return - }, -) diff --git a/checks/cloud/google/gke/enable_master_networks.tf.go b/checks/cloud/google/gke/enable_master_networks.tf.go deleted file mode 100644 index 34760b4c..00000000 --- a/checks/cloud/google/gke/enable_master_networks.tf.go +++ /dev/null @@ -1,89 +0,0 @@ -package gke - -var terraformEnableMasterNetworksGoodExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "primary" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - master_authorized_networks_config { - cidr_blocks { - cidr_block = "10.10.128.0/24" - display_name = "internal" - } - } - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformEnableMasterNetworksBadExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "primary" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformEnableMasterNetworksLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#`, -} - -var terraformEnableMasterNetworksRemediationMarkdown = `` diff --git a/checks/cloud/google/gke/enable_network_policy.go b/checks/cloud/google/gke/enable_network_policy.go deleted file mode 100755 index 04400315..00000000 --- a/checks/cloud/google/gke/enable_network_policy.go +++ /dev/null @@ -1,50 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableNetworkPolicy = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0056", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "enable-network-policy", - Summary: "Network Policy should be enabled on GKE clusters", - Impact: "Unrestricted inter-cluster communication", - Resolution: "Enable network policy", - Explanation: `Enabling a network policy allows the segregation of network traffic by namespace`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableNetworkPolicyGoodExamples, - BadExamples: terraformEnableNetworkPolicyBadExamples, - Links: terraformEnableNetworkPolicyLinks, - RemediationMarkdown: terraformEnableNetworkPolicyRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - if cluster.Metadata.IsUnmanaged() { - continue - } - if cluster.NetworkPolicy.Enabled.IsFalse() && - !cluster.EnableAutpilot.IsTrue() && - !cluster.DatapathProvider.EqualTo("ADVANCED_DATAPATH") { - results.Add( - "Cluster does not have a network policy enabled.", - cluster.NetworkPolicy.Enabled, - ) - } else { - results.AddPassed(&cluster) - } - - } - return - }, -) diff --git a/checks/cloud/google/gke/enable_network_policy.tf.go b/checks/cloud/google/gke/enable_network_policy.tf.go deleted file mode 100644 index d49c8d59..00000000 --- a/checks/cloud/google/gke/enable_network_policy.tf.go +++ /dev/null @@ -1,89 +0,0 @@ -package gke - -var terraformEnableNetworkPolicyGoodExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "good_example" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - network_policy { - enabled = true - } - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformEnableNetworkPolicyBadExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "bad_example" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - network_policy { - enabled = false - } - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformEnableNetworkPolicyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#enabled`, -} - -var terraformEnableNetworkPolicyRemediationMarkdown = `` diff --git a/checks/cloud/google/gke/enable_private_cluster.go b/checks/cloud/google/gke/enable_private_cluster.go deleted file mode 100755 index f5c3f0d2..00000000 --- a/checks/cloud/google/gke/enable_private_cluster.go +++ /dev/null @@ -1,48 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnablePrivateCluster = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0059", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "enable-private-cluster", - Summary: "Clusters should be set to private", - Impact: "Nodes may be exposed to the public internet", - Resolution: "Enable private cluster", - Explanation: `Enabling private nodes on a cluster ensures the nodes are only available internally as they will only be assigned internal addresses.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnablePrivateClusterGoodExamples, - BadExamples: terraformEnablePrivateClusterBadExamples, - Links: terraformEnablePrivateClusterLinks, - RemediationMarkdown: terraformEnablePrivateClusterRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - if cluster.Metadata.IsUnmanaged() { - continue - } - if cluster.PrivateCluster.EnablePrivateNodes.IsFalse() { - results.Add( - "Cluster does not have private nodes.", - cluster.PrivateCluster.EnablePrivateNodes, - ) - } else { - results.AddPassed(&cluster) - } - - } - return - }, -) diff --git a/checks/cloud/google/gke/enable_private_cluster.tf.go b/checks/cloud/google/gke/enable_private_cluster.tf.go deleted file mode 100644 index 270cc0a5..00000000 --- a/checks/cloud/google/gke/enable_private_cluster.tf.go +++ /dev/null @@ -1,89 +0,0 @@ -package gke - -var terraformEnablePrivateClusterGoodExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "good_example" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - private_cluster_config { - enable_private_nodes = true - } - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformEnablePrivateClusterBadExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "bad_example" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - private_cluster_config { - enable_private_nodes = false - } - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformEnablePrivateClusterLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#enable_private_nodes`, -} - -var terraformEnablePrivateClusterRemediationMarkdown = `` diff --git a/checks/cloud/google/gke/enable_stackdriver_logging.go b/checks/cloud/google/gke/enable_stackdriver_logging.go deleted file mode 100755 index 8ac7e0ba..00000000 --- a/checks/cloud/google/gke/enable_stackdriver_logging.go +++ /dev/null @@ -1,48 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableStackdriverLogging = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0060", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "enable-stackdriver-logging", - Summary: "Stackdriver Logging should be enabled", - Impact: "Visibility will be reduced", - Resolution: "Enable StackDriver logging", - Explanation: `StackDriver logging provides a useful interface to all of stdout/stderr for each container and should be enabled for moitoring, debugging, etc.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableStackdriverLoggingGoodExamples, - BadExamples: terraformEnableStackdriverLoggingBadExamples, - Links: terraformEnableStackdriverLoggingLinks, - RemediationMarkdown: terraformEnableStackdriverLoggingRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - if cluster.Metadata.IsUnmanaged() { - continue - } - if cluster.LoggingService.NotEqualTo("logging.googleapis.com/kubernetes") { - results.Add( - "Cluster does not use the logging.googleapis.com/kubernetes StackDriver logging service.", - cluster.LoggingService, - ) - } else { - results.AddPassed(&cluster) - } - - } - return - }, -) diff --git a/checks/cloud/google/gke/enable_stackdriver_logging.tf.go b/checks/cloud/google/gke/enable_stackdriver_logging.tf.go deleted file mode 100644 index c7fad3ea..00000000 --- a/checks/cloud/google/gke/enable_stackdriver_logging.tf.go +++ /dev/null @@ -1,85 +0,0 @@ -package gke - -var terraformEnableStackdriverLoggingGoodExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "good_example" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - logging_service = "logging.googleapis.com/kubernetes" - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformEnableStackdriverLoggingBadExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "bad_example" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - logging_service = "logging.googleapis.com" - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformEnableStackdriverLoggingLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#logging_service`, -} - -var terraformEnableStackdriverLoggingRemediationMarkdown = `` diff --git a/checks/cloud/google/gke/enable_stackdriver_monitoring.go b/checks/cloud/google/gke/enable_stackdriver_monitoring.go deleted file mode 100755 index 5eda3b10..00000000 --- a/checks/cloud/google/gke/enable_stackdriver_monitoring.go +++ /dev/null @@ -1,48 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableStackdriverMonitoring = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0052", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "enable-stackdriver-monitoring", - Summary: "Stackdriver Monitoring should be enabled", - Impact: "Visibility will be reduced", - Resolution: "Enable StackDriver monitoring", - Explanation: `StackDriver monitoring aggregates logs, events, and metrics from your Kubernetes environment on GKE to help you understand your application's behavior in production.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableStackdriverMonitoringGoodExamples, - BadExamples: terraformEnableStackdriverMonitoringBadExamples, - Links: terraformEnableStackdriverMonitoringLinks, - RemediationMarkdown: terraformEnableStackdriverMonitoringRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - if cluster.Metadata.IsUnmanaged() { - continue - } - if cluster.MonitoringService.NotEqualTo("monitoring.googleapis.com/kubernetes") { - results.Add( - "Cluster does not use the monitoring.googleapis.com/kubernetes StackDriver monitoring service.", - cluster.MonitoringService, - ) - } else { - results.AddPassed(&cluster) - } - - } - return - }, -) diff --git a/checks/cloud/google/gke/enable_stackdriver_monitoring.tf.go b/checks/cloud/google/gke/enable_stackdriver_monitoring.tf.go deleted file mode 100644 index c7541d30..00000000 --- a/checks/cloud/google/gke/enable_stackdriver_monitoring.tf.go +++ /dev/null @@ -1,85 +0,0 @@ -package gke - -var terraformEnableStackdriverMonitoringGoodExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "good_example" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - monitoring_service = "monitoring.googleapis.com/kubernetes" - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformEnableStackdriverMonitoringBadExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "bad_example" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - monitoring_service = "monitoring.googleapis.com" - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformEnableStackdriverMonitoringLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#monitoring_service`, -} - -var terraformEnableStackdriverMonitoringRemediationMarkdown = `` diff --git a/checks/cloud/google/gke/metadata_endpoints_disabled.go b/checks/cloud/google/gke/metadata_endpoints_disabled.go deleted file mode 100755 index b3490d96..00000000 --- a/checks/cloud/google/gke/metadata_endpoints_disabled.go +++ /dev/null @@ -1,65 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckMetadataEndpointsDisabled = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0048", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "metadata-endpoints-disabled", - Summary: "Legacy metadata endpoints enabled.", - Impact: "Legacy metadata endpoints don't require metadata headers", - Resolution: "Disable legacy metadata endpoints", - Explanation: `The Compute Engine instance metadata server exposes legacy v0.1 and v1beta1 endpoints, which do not enforce metadata query headers. - -This is a feature in the v1 APIs that makes it more difficult for a potential attacker to retrieve instance metadata. - -Unless specifically required, we recommend you disable these legacy APIs. - -When setting the metadata block, the default value for disable-legacy-endpoints is set to true, they should not be explicitly enabled.`, - Links: []string{ - "https://cloud.google.com/kubernetes-engine/docs/how-to/hardening-your-cluster#protect_node_metadata_default_for_112", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformMetadataEndpointsDisabledGoodExamples, - BadExamples: terraformMetadataEndpointsDisabledBadExamples, - Links: terraformMetadataEndpointsDisabledLinks, - RemediationMarkdown: terraformMetadataEndpointsDisabledRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - if cluster.Metadata.IsUnmanaged() { - continue - } - if cluster.RemoveDefaultNodePool.IsTrue() { - for _, pool := range cluster.NodePools { - if pool.NodeConfig.EnableLegacyEndpoints.IsTrue() { - results.Add( - "Cluster has legacy metadata endpoints enabled.", - pool.NodeConfig.EnableLegacyEndpoints, - ) - } - } - } else if cluster.NodeConfig.EnableLegacyEndpoints.IsTrue() { - results.Add( - "Cluster has legacy metadata endpoints enabled.", - cluster.NodeConfig.EnableLegacyEndpoints, - ) - } else { - results.AddPassed(&cluster) - } - - } - return - }, -) diff --git a/checks/cloud/google/gke/metadata_endpoints_disabled.tf.go b/checks/cloud/google/gke/metadata_endpoints_disabled.tf.go deleted file mode 100644 index 0ec8185c..00000000 --- a/checks/cloud/google/gke/metadata_endpoints_disabled.tf.go +++ /dev/null @@ -1,29 +0,0 @@ -package gke - -var terraformMetadataEndpointsDisabledGoodExamples = []string{ - ` - resource "google_container_cluster" "good_example" { - node_config { - metadata = { - disable-legacy-endpoints = true - } - } - }`, -} - -var terraformMetadataEndpointsDisabledBadExamples = []string{ - ` - resource "google_container_cluster" "bad_example" { - node_config { - metadata = { - disable-legacy-endpoints = false - } - } - }`, -} - -var terraformMetadataEndpointsDisabledLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#metadata`, -} - -var terraformMetadataEndpointsDisabledRemediationMarkdown = `` diff --git a/checks/cloud/google/gke/no_legacy_authentication.go b/checks/cloud/google/gke/no_legacy_authentication.go deleted file mode 100755 index b04b7c4d..00000000 --- a/checks/cloud/google/gke/no_legacy_authentication.go +++ /dev/null @@ -1,57 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoLegacyAuthentication = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0064", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "no-legacy-authentication", - Summary: "Legacy client authentication methods utilized.", - Impact: "Username/password or certificate authentication methods are less secure", - Resolution: "Use service account or OAuth for authentication", - Explanation: `It is recommended to use Service Accounts and OAuth as authentication methods for accessing the master in the container cluster. - -Basic authentication should be disabled by explicitly unsetting the username and password on the master_auth block.`, - Links: []string{ - "https://cloud.google.com/kubernetes-engine/docs/how-to/hardening-your-cluster#restrict_authn_methods", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoLegacyAuthenticationGoodExamples, - BadExamples: terraformNoLegacyAuthenticationBadExamples, - Links: terraformNoLegacyAuthenticationLinks, - RemediationMarkdown: terraformNoLegacyAuthenticationRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - if cluster.Metadata.IsUnmanaged() { - continue - } - if cluster.MasterAuth.ClientCertificate.IssueCertificate.IsTrue() { - results.Add( - "Cluster allows the use of certificates for master authentication.", - cluster.MasterAuth.ClientCertificate.IssueCertificate, - ) - } else if cluster.MasterAuth.Username.NotEqualTo("") { - results.Add( - "Cluster allows the use of basic auth for master authentication.", - cluster.MasterAuth.Username, - ) - } else { - results.AddPassed(&cluster) - } - - } - return - }, -) diff --git a/checks/cloud/google/gke/no_legacy_authentication.tf.go b/checks/cloud/google/gke/no_legacy_authentication.tf.go deleted file mode 100644 index 953d6ab3..00000000 --- a/checks/cloud/google/gke/no_legacy_authentication.tf.go +++ /dev/null @@ -1,88 +0,0 @@ -package gke - -var terraformNoLegacyAuthenticationGoodExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "good_example" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformNoLegacyAuthenticationBadExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "good_example" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - master_auth { - client_certificate_config { - issue_client_certificate = true - } - } - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformNoLegacyAuthenticationLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#master_auth`, -} - -var terraformNoLegacyAuthenticationRemediationMarkdown = `` diff --git a/checks/cloud/google/gke/no_public_control_plane.go b/checks/cloud/google/gke/no_public_control_plane.go deleted file mode 100755 index fc45d54f..00000000 --- a/checks/cloud/google/gke/no_public_control_plane.go +++ /dev/null @@ -1,51 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicControlPlane = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0053", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "no-public-control-plane", - Summary: "GKE Control Plane should not be publicly accessible", - Impact: "GKE control plane exposed to public internet", - Resolution: "Use private nodes and master authorised networks to prevent exposure", - Explanation: `The GKE control plane is exposed to the public internet by default.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicControlPlaneGoodExamples, - BadExamples: terraformNoPublicControlPlaneBadExamples, - Links: terraformNoPublicControlPlaneLinks, - RemediationMarkdown: terraformNoPublicControlPlaneRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - if cluster.Metadata.IsUnmanaged() { - continue - } - for _, block := range cluster.MasterAuthorizedNetworks.CIDRs { - if cidr.IsPublic(block.Value()) { - results.Add( - "Cluster exposes control plane to the public internet.", - block, - ) - } else { - results.AddPassed(&cluster) - } - - } - } - return - }, -) diff --git a/checks/cloud/google/gke/no_public_control_plane.tf.go b/checks/cloud/google/gke/no_public_control_plane.tf.go deleted file mode 100644 index d7f075d7..00000000 --- a/checks/cloud/google/gke/no_public_control_plane.tf.go +++ /dev/null @@ -1,95 +0,0 @@ -package gke - -var terraformNoPublicControlPlaneGoodExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "primary" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - master_authorized_networks_config { - cidr_blocks { - cidr_block = "10.10.128.0/24" - display_name = "internal" - } - } - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformNoPublicControlPlaneBadExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "primary" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - master_authorized_networks_config { - cidr_blocks { - cidr_block = "0.0.0.0/0" - display_name = "external" - } - } - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformNoPublicControlPlaneLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#`, -} - -var terraformNoPublicControlPlaneRemediationMarkdown = `` diff --git a/checks/cloud/google/gke/node_metadata_security.go b/checks/cloud/google/gke/node_metadata_security.go deleted file mode 100755 index 8c4523bb..00000000 --- a/checks/cloud/google/gke/node_metadata_security.go +++ /dev/null @@ -1,64 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNodeMetadataSecurity = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0057", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "node-metadata-security", - Summary: "Node metadata value disables metadata concealment.", - Impact: "Metadata that isn't concealed potentially risks leakage of sensitive data", - Resolution: "Set node metadata to SECURE or GKE_METADATA_SERVER", - Explanation: `If the workload_metadata_config block within node_config is included, the node_metadata attribute should be configured securely. - -The attribute should be set to SECURE to use metadata concealment, or GKE_METADATA_SERVER if workload identity is enabled. This ensures that the VM metadata is not unnecessarily exposed to pods.`, - Links: []string{ - "https://cloud.google.com/kubernetes-engine/docs/how-to/protecting-cluster-metadata#create-concealed", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNodeMetadataSecurityGoodExamples, - BadExamples: terraformNodeMetadataSecurityBadExamples, - Links: terraformNodeMetadataSecurityLinks, - RemediationMarkdown: terraformNodeMetadataSecurityRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - if cluster.Metadata.IsManaged() { - metadata := cluster.NodeConfig.WorkloadMetadataConfig.NodeMetadata - if metadata.EqualTo("UNSPECIFIED") || metadata.EqualTo("EXPOSE") { - results.Add( - "Cluster exposes node metadata of pools by default.", - metadata, - ) - } else { - results.AddPassed(&cluster) - } - - } - for _, pool := range cluster.NodePools { - metadata := pool.NodeConfig.WorkloadMetadataConfig.NodeMetadata - if metadata.EqualTo("UNSPECIFIED") || metadata.EqualTo("EXPOSE") { - results.Add( - "Node pool exposes node metadata.", - metadata, - ) - } else { - results.AddPassed(&pool) - } - - } - } - return - }, -) diff --git a/checks/cloud/google/gke/node_metadata_security.tf.go b/checks/cloud/google/gke/node_metadata_security.tf.go deleted file mode 100644 index 2f21b2b4..00000000 --- a/checks/cloud/google/gke/node_metadata_security.tf.go +++ /dev/null @@ -1,29 +0,0 @@ -package gke - -var terraformNodeMetadataSecurityGoodExamples = []string{ - ` - resource "google_container_node_pool" "good_example" { - node_config { - workload_metadata_config { - node_metadata = "SECURE" - } - } - }`, -} - -var terraformNodeMetadataSecurityBadExamples = []string{ - ` - resource "google_container_node_pool" "bad_example" { - node_config { - workload_metadata_config { - node_metadata = "EXPOSE" - } - } - }`, -} - -var terraformNodeMetadataSecurityLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#node_metadata`, -} - -var terraformNodeMetadataSecurityRemediationMarkdown = `` diff --git a/checks/cloud/google/gke/node_pool_uses_cos.go b/checks/cloud/google/gke/node_pool_uses_cos.go deleted file mode 100755 index 5a9db079..00000000 --- a/checks/cloud/google/gke/node_pool_uses_cos.go +++ /dev/null @@ -1,58 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" - "github.com/aquasecurity/trivy/pkg/iac/types" -) - -var CheckNodePoolUsesCos = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0054", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "node-pool-uses-cos", - Summary: "Ensure Container-Optimized OS (cos) is used for Kubernetes Engine Clusters Node image", - Impact: "COS is the recommended OS image to use on cluster nodes", - Resolution: "Use the COS image type", - Explanation: `GKE supports several OS image types but COS is the recommended OS image to use on cluster nodes for enhanced security`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNodePoolUsesCosGoodExamples, - BadExamples: terraformNodePoolUsesCosBadExamples, - Links: terraformNodePoolUsesCosLinks, - RemediationMarkdown: terraformNodePoolUsesCosRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - if cluster.Metadata.IsManaged() { - if cluster.NodeConfig.ImageType.NotEqualTo("") && cluster.NodeConfig.ImageType.NotEqualTo("COS_CONTAINERD", types.IgnoreCase) && cluster.NodeConfig.ImageType.NotEqualTo("COS", types.IgnoreCase) { - results.Add( - "Cluster is not configuring node pools to use the COS containerd image type by default.", - cluster.NodeConfig.ImageType, - ) - } else { - results.AddPassed(&cluster) - } - } - for _, pool := range cluster.NodePools { - if pool.NodeConfig.ImageType.NotEqualTo("COS_CONTAINERD", types.IgnoreCase) && pool.NodeConfig.ImageType.NotEqualTo("COS", types.IgnoreCase) { - results.Add( - "Node pool is not using the COS containerd image type.", - pool.NodeConfig.ImageType, - ) - } else { - results.AddPassed(&pool) - } - - } - } - return - }, -) diff --git a/checks/cloud/google/gke/node_pool_uses_cos.tf.go b/checks/cloud/google/gke/node_pool_uses_cos.tf.go deleted file mode 100644 index f4e41a50..00000000 --- a/checks/cloud/google/gke/node_pool_uses_cos.tf.go +++ /dev/null @@ -1,83 +0,0 @@ -package gke - -var terraformNodePoolUsesCosGoodExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "primary" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - } - - resource "google_container_node_pool" "good_example" { - name = "my-node-pool" - cluster = google_container_cluster.primary.id - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - image_type = "COS" - } - } - `, -} - -var terraformNodePoolUsesCosBadExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "primary" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - } - - resource "google_container_node_pool" "bad_example" { - name = "my-node-pool" - cluster = google_container_cluster.primary.id - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - image_type = "something" - } - } - `, -} - -var terraformNodePoolUsesCosLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool#image_type`, -} - -var terraformNodePoolUsesCosRemediationMarkdown = `` diff --git a/checks/cloud/google/gke/node_shielding_enabled.go b/checks/cloud/google/gke/node_shielding_enabled.go deleted file mode 100755 index 33600b86..00000000 --- a/checks/cloud/google/gke/node_shielding_enabled.go +++ /dev/null @@ -1,52 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNodeShieldingEnabled = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0055", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "node-shielding-enabled", - Summary: "Shielded GKE nodes not enabled.", - Impact: "Node identity and integrity can't be verified without shielded GKE nodes", - Resolution: "Enable node shielding", - Explanation: `CIS GKE Benchmark Recommendation: 6.5.5. Ensure Shielded GKE Nodes are Enabled - -Shielded GKE Nodes provide strong, verifiable node identity and integrity to increase the security of GKE nodes and should be enabled on all GKE clusters.`, - Links: []string{ - "https://cloud.google.com/kubernetes-engine/docs/how-to/hardening-your-cluster#shielded_nodes", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNodeShieldingEnabledGoodExamples, - BadExamples: terraformNodeShieldingEnabledBadExamples, - Links: terraformNodeShieldingEnabledLinks, - RemediationMarkdown: terraformNodeShieldingEnabledRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - if cluster.Metadata.IsUnmanaged() { - continue - } - if cluster.EnableShieldedNodes.IsFalse() { - results.Add( - "Cluster has shielded nodes disabled.", - cluster.EnableShieldedNodes, - ) - } else { - results.AddPassed(&cluster) - } - - } - return - }, -) diff --git a/checks/cloud/google/gke/node_shielding_enabled.tf.go b/checks/cloud/google/gke/node_shielding_enabled.tf.go deleted file mode 100644 index bb41fd12..00000000 --- a/checks/cloud/google/gke/node_shielding_enabled.tf.go +++ /dev/null @@ -1,21 +0,0 @@ -package gke - -var terraformNodeShieldingEnabledGoodExamples = []string{ - ` - resource "google_container_cluster" "good_example" { - enable_shielded_nodes = "true" - }`, -} - -var terraformNodeShieldingEnabledBadExamples = []string{ - ` - resource "google_container_cluster" "bad_example" { - enable_shielded_nodes = "false" - }`, -} - -var terraformNodeShieldingEnabledLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#enable_shielded_nodes`, -} - -var terraformNodeShieldingEnabledRemediationMarkdown = `` diff --git a/checks/cloud/google/gke/use_cluster_labels.go b/checks/cloud/google/gke/use_cluster_labels.go deleted file mode 100755 index d4274a6f..00000000 --- a/checks/cloud/google/gke/use_cluster_labels.go +++ /dev/null @@ -1,47 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckUseClusterLabels = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0051", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "use-cluster-labels", - Summary: "Clusters should be configured with Labels", - Impact: "Asset management can be limited/more difficult", - Resolution: "Set cluster resource labels", - Explanation: `Labels make it easier to manage assets and differentiate between clusters and environments, allowing the mapping of computational resources to the wider organisational structure.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformUseClusterLabelsGoodExamples, - BadExamples: terraformUseClusterLabelsBadExamples, - Links: terraformUseClusterLabelsLinks, - RemediationMarkdown: terraformUseClusterLabelsRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - if cluster.Metadata.IsUnmanaged() { - continue - } - if cluster.ResourceLabels.Len() == 0 { - results.Add( - "Cluster does not use GCE resource labels.", - cluster.ResourceLabels, - ) - } else { - results.AddPassed(&cluster) - } - } - return - }, -) diff --git a/checks/cloud/google/gke/use_cluster_labels.tf.go b/checks/cloud/google/gke/use_cluster_labels.tf.go deleted file mode 100644 index 8bd1d6d0..00000000 --- a/checks/cloud/google/gke/use_cluster_labels.tf.go +++ /dev/null @@ -1,86 +0,0 @@ -package gke - -var terraformUseClusterLabelsGoodExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "good_example" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - resource_labels = { - "env" = "staging" - } - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformUseClusterLabelsBadExamples = []string{ - ` - resource "google_service_account" "default" { - account_id = "service-account-id" - display_name = "Service Account" - } - - resource "google_container_cluster" "bad_example" { - name = "my-gke-cluster" - location = "us-central1" - - # We can't create a cluster with no node pool defined, but we want to only use - # separately managed node pools. So we create the smallest possible default - # node pool and immediately delete it. - remove_default_node_pool = true - initial_node_count = 1 - } - - resource "google_container_node_pool" "primary_preemptible_nodes" { - name = "my-node-pool" - location = "us-central1" - cluster = google_container_cluster.primary.name - node_count = 1 - - node_config { - preemptible = true - machine_type = "e2-medium" - - # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. - service_account = google_service_account.default.email - oauth_scopes = [ - "https://www.googleapis.com/auth/cloud-platform" - ] - } - } - `, -} - -var terraformUseClusterLabelsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#resource_labels`, -} - -var terraformUseClusterLabelsRemediationMarkdown = `` diff --git a/checks/cloud/google/gke/use_rbac_permissions.go b/checks/cloud/google/gke/use_rbac_permissions.go deleted file mode 100755 index 39f22887..00000000 --- a/checks/cloud/google/gke/use_rbac_permissions.go +++ /dev/null @@ -1,51 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckUseRbacPermissions = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0062", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "use-rbac-permissions", - Summary: "Legacy ABAC permissions are enabled.", - Impact: "ABAC permissions are less secure than RBAC permissions", - Resolution: "Switch to using RBAC permissions", - Explanation: `You should disable Attribute-Based Access Control (ABAC), and instead use Role-Based Access Control (RBAC) in GKE. - -RBAC has significant security advantages and is now stable in Kubernetes, so it’s time to disable ABAC.`, - Links: []string{ - "https://cloud.google.com/kubernetes-engine/docs/how-to/hardening-your-cluster#leave_abac_disabled_default_for_110", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformUseRbacPermissionsGoodExamples, - BadExamples: terraformUseRbacPermissionsBadExamples, - Links: terraformUseRbacPermissionsLinks, - RemediationMarkdown: terraformUseRbacPermissionsRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - if cluster.Metadata.IsUnmanaged() { - continue - } - if cluster.EnableLegacyABAC.IsTrue() { - results.Add( - "Cluster has legacy ABAC enabled.", - cluster.EnableLegacyABAC, - ) - } else { - results.AddPassed(&cluster) - } - } - return - }, -) diff --git a/checks/cloud/google/gke/use_rbac_permissions.tf.go b/checks/cloud/google/gke/use_rbac_permissions.tf.go deleted file mode 100644 index a4dae05d..00000000 --- a/checks/cloud/google/gke/use_rbac_permissions.tf.go +++ /dev/null @@ -1,25 +0,0 @@ -package gke - -var terraformUseRbacPermissionsGoodExamples = []string{ - ` - resource "google_container_cluster" "good_example" { - # ... - # enable_legacy_abac not set - # ... - } - `, -} - -var terraformUseRbacPermissionsBadExamples = []string{ - ` - resource "google_container_cluster" "bad_example" { - enable_legacy_abac = "true" - } - `, -} - -var terraformUseRbacPermissionsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#enable_legacy_abac`, -} - -var terraformUseRbacPermissionsRemediationMarkdown = `` diff --git a/checks/cloud/google/gke/use_service_account.go b/checks/cloud/google/gke/use_service_account.go deleted file mode 100755 index bfd0532a..00000000 --- a/checks/cloud/google/gke/use_service_account.go +++ /dev/null @@ -1,60 +0,0 @@ -package gke - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckUseServiceAccount = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0050", - Provider: providers.GoogleProvider, - Service: "gke", - ShortCode: "use-service-account", - Summary: "Checks for service account defined for GKE nodes", - Impact: "Service accounts with wide permissions can increase the risk of compromise", - Resolution: "Use limited permissions for service accounts to be effective", - Explanation: `You should create and use a minimally privileged service account to run your GKE cluster instead of using the Compute Engine default service account.`, - Links: []string{ - "https://cloud.google.com/kubernetes-engine/docs/how-to/hardening-your-cluster#use_least_privilege_sa", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformUseServiceAccountGoodExamples, - BadExamples: terraformUseServiceAccountBadExamples, - Links: terraformUseServiceAccountLinks, - RemediationMarkdown: terraformUseServiceAccountRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, cluster := range s.Google.GKE.Clusters { - if cluster.Metadata.IsManaged() { - if cluster.RemoveDefaultNodePool.IsFalse() { - if cluster.NodeConfig.ServiceAccount.IsEmpty() { - results.Add( - "Cluster does not override the default service account.", - cluster.NodeConfig.ServiceAccount, - ) - } - } else { - results.AddPassed(&cluster) - } - } - for _, pool := range cluster.NodePools { - if pool.NodeConfig.ServiceAccount.IsEmpty() { - results.Add( - "Node pool does not override the default service account.", - pool.NodeConfig.ServiceAccount, - ) - } else { - results.AddPassed(&pool) - } - } - } - return - }, -) diff --git a/checks/cloud/google/gke/use_service_account.tf.go b/checks/cloud/google/gke/use_service_account.tf.go deleted file mode 100644 index 10a0d939..00000000 --- a/checks/cloud/google/gke/use_service_account.tf.go +++ /dev/null @@ -1,26 +0,0 @@ -package gke - -var terraformUseServiceAccountGoodExamples = []string{ - ` - resource "google_container_cluster" "good_example" { - node_config { - service_account = "cool-service-account@example.com" - } - } - `, -} - -var terraformUseServiceAccountBadExamples = []string{ - ` - resource "google_container_cluster" "bad_example" { - node_config { - } - } - `, -} - -var terraformUseServiceAccountLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#service_account`, -} - -var terraformUseServiceAccountRemediationMarkdown = `` diff --git a/checks/cloud/google/iam/no_conditions_on_workload_identity_pool_provider.go b/checks/cloud/google/iam/no_conditions_on_workload_identity_pool_provider.go deleted file mode 100644 index 9cba887b..00000000 --- a/checks/cloud/google/iam/no_conditions_on_workload_identity_pool_provider.go +++ /dev/null @@ -1,46 +0,0 @@ -package iam - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoConditionOnWorkloadIdentityPoolProvider = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0068", - Provider: providers.GoogleProvider, - Service: "iam", - ShortCode: "no-conditions-workload-identity-pool-provider", - Summary: "A configuration for an external workload identity pool provider should have conditions set", - Impact: "Allows an external attacker to authenticate as the attached service account and act with its permissions", - Resolution: "Set conditions on this provider, for example by restricting it to only be allowed from repositories in your GitHub organization", - Explanation: `In GitHub Actions, one can authenticate to Google Cloud by setting values for workload_identity_provider and service_account and requesting a short-lived OIDC token which is then used to execute commands as that Service Account. If you don't specify a condition in the workload identity provider pool configuration, then any GitHub Action can assume this role and act as that Service Account.`, - Links: []string{ - "https://www.revblock.dev/exploiting-misconfigured-google-cloud-service-accounts-from-github-actions/", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoConditionOnWorkloadIdentityPoolProviderGoodExamples, - BadExamples: terraformNoConditionOnWorkloadIdentityPoolProviderBadExamples, - Links: terraformNoConditionOnWorkloadIdentityPoolProviderLinks, - RemediationMarkdown: terraformNoConditionOnWorkloadIdentityPoolProviderMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, provider := range s.Google.IAM.WorkloadIdentityPoolProviders { - if provider.AttributeCondition.IsEmpty() { - results.Add( - "This workload identity pool provider configuration has no conditions set.", - provider.AttributeCondition, - ) - } else { - results.AddPassed(provider) - } - } - return - }, -) diff --git a/checks/cloud/google/iam/no_conditions_on_workload_identity_pool_provider.tf.go b/checks/cloud/google/iam/no_conditions_on_workload_identity_pool_provider.tf.go deleted file mode 100644 index 4eb8dbfd..00000000 --- a/checks/cloud/google/iam/no_conditions_on_workload_identity_pool_provider.tf.go +++ /dev/null @@ -1,65 +0,0 @@ -package iam - -var terraformNoConditionOnWorkloadIdentityPoolProviderGoodExamples = []string{ - ` - resource "google_iam_workload_identity_pool" "github" { - provider = google - project = data.google_project.project.project_id - workload_identity_pool_id = "github" - } - - resource "google_iam_workload_identity_pool_provider" "github" { - provider = google - project = data.google_project.project.project_id - workload_identity_pool_id = google_iam_workload_identity_pool.github-actions[0].workload_identity_pool_id - workload_identity_pool_provider_id = "github" - - attribute_condition = "assertion.repository_owner=='your-github-organization'" - - attribute_mapping = { - "google.subject" = "assertion.sub" - "attribute.actor" = "assertion.actor" - "attribute.aud" = "assertion.aud" - "attribute.repository" = "assertion.repository" - } - - oidc { - issuer_uri = "https://token.actions.githubusercontent.com" - } - } - `, -} - -var terraformNoConditionOnWorkloadIdentityPoolProviderBadExamples = []string{ - ` - resource "google_iam_workload_identity_pool" "github" { - provider = google - project = data.google_project.project.project_id - workload_identity_pool_id = "github" - } - - resource "google_iam_workload_identity_pool_provider" "github" { - provider = google - project = data.google_project.project.project_id - workload_identity_pool_id = google_iam_workload_identity_pool.github-actions[0].workload_identity_pool_id - workload_identity_pool_provider_id = "github" - - attribute_mapping = { - "google.subject" = "assertion.sub" - "attribute.actor" = "assertion.actor" - "attribute.aud" = "assertion.aud" - "attribute.repository" = "assertion.repository" - } - - oidc { - issuer_uri = "https://token.actions.githubusercontent.com" - } - } - `, -} - -var terraformNoConditionOnWorkloadIdentityPoolProviderLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/iam_workload_identity_pool_provider#attribute_condition`, -} - -var terraformNoConditionOnWorkloadIdentityPoolProviderMarkdown = `` diff --git a/checks/cloud/google/iam/no_default_network.go b/checks/cloud/google/iam/no_default_network.go deleted file mode 100755 index e4765325..00000000 --- a/checks/cloud/google/iam/no_default_network.go +++ /dev/null @@ -1,48 +0,0 @@ -package iam - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoDefaultNetwork = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0010", - Provider: providers.GoogleProvider, - Service: "iam", - ShortCode: "no-default-network", - Summary: "Default network should not be created at project level", - Impact: "Exposure of internal infrastructure/services to public internet", - Resolution: "Disable automatic default network creation", - Explanation: `The default network which is provided for a project contains multiple insecure firewall rules which allow ingress to the project's infrastructure. Creation of this network should therefore be disabled.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoDefaultNetworkGoodExamples, - BadExamples: terraformNoDefaultNetworkBadExamples, - Links: terraformNoDefaultNetworkLinks, - RemediationMarkdown: terraformNoDefaultNetworkRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - // TODO: check constraints before auto_create_network - for _, project := range s.Google.IAM.AllProjects() { - if project.Metadata.IsUnmanaged() { - continue - } - if project.AutoCreateNetwork.IsTrue() { - results.Add( - "Project has automatic network creation enabled.", - project.AutoCreateNetwork, - ) - } else { - results.AddPassed(project) - } - } - return - }, -) diff --git a/checks/cloud/google/iam/no_default_network.tf.go b/checks/cloud/google/iam/no_default_network.tf.go deleted file mode 100644 index a7e48269..00000000 --- a/checks/cloud/google/iam/no_default_network.tf.go +++ /dev/null @@ -1,29 +0,0 @@ -package iam - -var terraformNoDefaultNetworkGoodExamples = []string{ - ` - resource "google_project" "good_example" { - name = "My Project" - project_id = "your-project-id" - org_id = "1234567" - auto_create_network = false - } - `, -} - -var terraformNoDefaultNetworkBadExamples = []string{ - ` - resource "google_project" "bad_example" { - name = "My Project" - project_id = "your-project-id" - org_id = "1234567" - auto_create_network = true - } - `, -} - -var terraformNoDefaultNetworkLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_project#auto_create_network`, -} - -var terraformNoDefaultNetworkRemediationMarkdown = `` diff --git a/checks/cloud/google/iam/no_folder_level_default_service_account_assignment.go b/checks/cloud/google/iam/no_folder_level_default_service_account_assignment.go deleted file mode 100755 index 4316cb4e..00000000 --- a/checks/cloud/google/iam/no_folder_level_default_service_account_assignment.go +++ /dev/null @@ -1,90 +0,0 @@ -package iam - -import ( - "strings" - - "github.com/aquasecurity/trivy/pkg/iac/severity" - - "github.com/aquasecurity/trivy/pkg/iac/state" - - "github.com/aquasecurity/trivy/pkg/iac/scan" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - - "github.com/aquasecurity/trivy/pkg/iac/providers" -) - -var CheckNoFolderLevelDefaultServiceAccountAssignment = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0004", - Provider: providers.GoogleProvider, - Service: "iam", - ShortCode: "no-folder-level-default-service-account-assignment", - Summary: "Roles should not be assigned to default service accounts", - Impact: "Violation of principal of least privilege", - Resolution: "Use specialised service accounts for specific purposes.", - Explanation: `Default service accounts should not be used - consider creating specialised service accounts for individual purposes.`, - Links: []string{ - "", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoFolderLevelDefaultServiceAccountAssignmentGoodExamples, - BadExamples: terraformNoFolderLevelDefaultServiceAccountAssignmentBadExamples, - Links: terraformNoFolderLevelDefaultServiceAccountAssignmentLinks, - RemediationMarkdown: terraformNoFolderLevelDefaultServiceAccountAssignmentRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, folder := range s.Google.IAM.AllFolders() { - for _, member := range folder.Members { - if member.Metadata.IsUnmanaged() { - continue - } - if member.DefaultServiceAccount.IsTrue() { - results.Add( - "Role is assigned to a default service account at folder level.", - member.DefaultServiceAccount, - ) - } else if isMemberDefaultServiceAccount(member.Member.Value()) { - results.Add( - "Role is assigned to a default service account at folder level.", - member.Member, - ) - } else { - results.AddPassed(&member) - } - - } - for _, binding := range folder.Bindings { - if binding.Metadata.IsUnmanaged() { - continue - } - if binding.IncludesDefaultServiceAccount.IsTrue() { - results.Add( - "Role is assigned to a default service account at folder level.", - binding.IncludesDefaultServiceAccount, - ) - continue - } - for _, member := range binding.Members { - if isMemberDefaultServiceAccount(member.Value()) { - results.Add( - "Role is assigned to a default service account at folder level.", - member, - ) - } else { - results.AddPassed(member) - } - } - } - - } - return - }, -) - -func isMemberDefaultServiceAccount(member string) bool { - return strings.HasSuffix(member, "-compute@developer.gserviceaccount.com") || strings.HasSuffix(member, "@appspot.gserviceaccount.com") -} diff --git a/checks/cloud/google/iam/no_folder_level_default_service_account_assignment.tf.go b/checks/cloud/google/iam/no_folder_level_default_service_account_assignment.tf.go deleted file mode 100644 index cea419dc..00000000 --- a/checks/cloud/google/iam/no_folder_level_default_service_account_assignment.tf.go +++ /dev/null @@ -1,47 +0,0 @@ -package iam - -var terraformNoFolderLevelDefaultServiceAccountAssignmentGoodExamples = []string{ - ` - resource "google_service_account" "test" { - account_id = "account123" - display_name = "account123" - } - - resource "google_folder_iam_member" "folder-123" { - folder = "folder-123" - role = "roles/whatever" - member = "serviceAccount:${google_service_account.test.email}" - } - `, -} - -var terraformNoFolderLevelDefaultServiceAccountAssignmentBadExamples = []string{ - ` - resource "google_folder_iam_member" "folder-123" { - folder = "folder-123" - role = "roles/whatever" - member = "123-compute@developer.gserviceaccount.com" - } - `, ` - resource "google_folder_iam_member" "folder-123" { - folder = "folder-123" - role = "roles/whatever" - member = "123@appspot.gserviceaccount.com" - } - `, ` - data "google_compute_default_service_account" "default" { - } - - resource "google_folder_iam_member" "folder-123" { - folder = "folder-123" - role = "roles/whatever" - member = data.google_compute_default_service_account.default.id - } - `, -} - -var terraformNoFolderLevelDefaultServiceAccountAssignmentLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_folder_iam`, ``, -} - -var terraformNoFolderLevelDefaultServiceAccountAssignmentRemediationMarkdown = `` diff --git a/checks/cloud/google/iam/no_folder_level_service_account_impersonation.go b/checks/cloud/google/iam/no_folder_level_service_account_impersonation.go deleted file mode 100755 index a104e4a2..00000000 --- a/checks/cloud/google/iam/no_folder_level_service_account_impersonation.go +++ /dev/null @@ -1,66 +0,0 @@ -package iam - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoFolderLevelServiceAccountImpersonation = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0005", - Provider: providers.GoogleProvider, - Service: "IAM", - ShortCode: "no-folder-level-service-account-impersonation", - Summary: "Users should not be granted service account access at the folder level", - Impact: "Privilege escalation, impersonation of any/all services", - Resolution: "Provide access at the service-level instead of folder-level, if required", - Explanation: `Users with service account access at folder level can impersonate any service account. Instead, they should be given access to particular service accounts as required.`, - Links: []string{ - "https://cloud.google.com/iam/docs/impersonating-service-accounts", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoFolderLevelServiceAccountImpersonationGoodExamples, - BadExamples: terraformNoFolderLevelServiceAccountImpersonationBadExamples, - Links: terraformNoFolderLevelServiceAccountImpersonationLinks, - RemediationMarkdown: terraformNoFolderLevelServiceAccountImpersonationRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, folder := range s.Google.IAM.AllFolders() { - for _, member := range folder.Members { - if member.Metadata.IsUnmanaged() { - continue - } - if member.Role.IsOneOf("roles/iam.serviceAccountUser", "roles/iam.serviceAccountTokenCreator") { - results.Add( - "Service account access is granted to a user at folder level.", - member.Role, - ) - } else { - results.AddPassed(&member) - } - - } - for _, binding := range folder.Bindings { - if binding.Metadata.IsUnmanaged() { - continue - } - if binding.Role.IsOneOf("roles/iam.serviceAccountUser", "roles/iam.serviceAccountTokenCreator") { - results.Add( - "Service account access is granted to a user at folder level.", - binding.Role, - ) - } else { - results.AddPassed(&binding) - } - - } - } - return - }, -) diff --git a/checks/cloud/google/iam/no_folder_level_service_account_impersonation.tf.go b/checks/cloud/google/iam/no_folder_level_service_account_impersonation.tf.go deleted file mode 100644 index dd7eecb5..00000000 --- a/checks/cloud/google/iam/no_folder_level_service_account_impersonation.tf.go +++ /dev/null @@ -1,30 +0,0 @@ -package iam - -var terraformNoFolderLevelServiceAccountImpersonationGoodExamples = []string{ - ` - resource "google_folder_iam_binding" "folder-123" { - folder = "folder-123" - role = "roles/nothingInParticular" - } - `, -} - -var terraformNoFolderLevelServiceAccountImpersonationBadExamples = []string{ - ` - resource "google_folder_iam_binding" "folder-123" { - folder = "folder-123" - role = "roles/iam.serviceAccountUser" - } - `, ` - resource "google_folder_iam_binding" "folder-123" { - folder = "folder-123" - role = "roles/iam.serviceAccountTokenCreator" - } - `, -} - -var terraformNoFolderLevelServiceAccountImpersonationLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_folder_iam`, -} - -var terraformNoFolderLevelServiceAccountImpersonationRemediationMarkdown = `` diff --git a/checks/cloud/google/iam/no_org_level_default_service_account_assignment.go b/checks/cloud/google/iam/no_org_level_default_service_account_assignment.go deleted file mode 100755 index afc9a506..00000000 --- a/checks/cloud/google/iam/no_org_level_default_service_account_assignment.go +++ /dev/null @@ -1,77 +0,0 @@ -package iam - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoOrgLevelDefaultServiceAccountAssignment = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0008", - Provider: providers.GoogleProvider, - Service: "iam", - ShortCode: "no-org-level-default-service-account-assignment", - Summary: "Roles should not be assigned to default service accounts", - Impact: "Violation of principal of least privilege", - Resolution: "Use specialised service accounts for specific purposes.", - Explanation: `Default service accounts should not be used - consider creating specialised service accounts for individual purposes.`, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoOrgLevelDefaultServiceAccountAssignmentGoodExamples, - BadExamples: terraformNoOrgLevelDefaultServiceAccountAssignmentBadExamples, - Links: terraformNoOrgLevelDefaultServiceAccountAssignmentLinks, - RemediationMarkdown: terraformNoOrgLevelDefaultServiceAccountAssignmentRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, org := range s.Google.IAM.Organizations { - for _, binding := range org.Bindings { - if binding.Metadata.IsUnmanaged() { - continue - } - if binding.IncludesDefaultServiceAccount.IsTrue() { - results.Add( - "Role is assigned to a default service account at organisation level.", - binding.IncludesDefaultServiceAccount, - ) - } else { - for _, member := range binding.Members { - if isMemberDefaultServiceAccount(member.Value()) { - results.Add( - "Role is assigned to a default service account at organisation level.", - member, - ) - } else { - results.AddPassed(member) - } - - } - } - } - for _, member := range org.Members { - if member.Metadata.IsUnmanaged() { - continue - } - if isMemberDefaultServiceAccount(member.Member.Value()) { - results.Add( - "Role is assigned to a default service account at organisation level.", - member.Member, - ) - } else if member.DefaultServiceAccount.IsTrue() { - results.Add( - "Role is assigned to a default service account at organisation level.", - member.DefaultServiceAccount, - ) - } else { - results.AddPassed(&member) - } - - } - } - return - }, -) diff --git a/checks/cloud/google/iam/no_org_level_default_service_account_assignment.tf.go b/checks/cloud/google/iam/no_org_level_default_service_account_assignment.tf.go deleted file mode 100644 index 7b562722..00000000 --- a/checks/cloud/google/iam/no_org_level_default_service_account_assignment.tf.go +++ /dev/null @@ -1,47 +0,0 @@ -package iam - -var terraformNoOrgLevelDefaultServiceAccountAssignmentGoodExamples = []string{ - ` - resource "google_service_account" "test" { - account_id = "account123" - display_name = "account123" - } - - resource "google_organization_iam_member" "org-123" { - org_id = "org-123" - role = "roles/whatever" - member = "serviceAccount:${google_service_account.test.email}" - } - `, -} - -var terraformNoOrgLevelDefaultServiceAccountAssignmentBadExamples = []string{ - ` - resource "google_organization_iam_member" "org-123" { - org_id = "organization-123" - role = "roles/whatever" - member = "123-compute@developer.gserviceaccount.com" - } - `, ` - resource "google_organization_iam_member" "org-123" { - org_id = "org-123" - role = "roles/whatever" - member = "123@appspot.gserviceaccount.com" - } - `, ` - data "google_compute_default_service_account" "default" { - } - - resource "google_organization_iam_member" "org-123" { - org_id = "org-123" - role = "roles/whatever" - member = data.google_compute_default_service_account.default.id - } - `, -} - -var terraformNoOrgLevelDefaultServiceAccountAssignmentLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_organization_iam`, ``, -} - -var terraformNoOrgLevelDefaultServiceAccountAssignmentRemediationMarkdown = `` diff --git a/checks/cloud/google/iam/no_org_level_service_account_impersonation.go b/checks/cloud/google/iam/no_org_level_service_account_impersonation.go deleted file mode 100755 index 57599266..00000000 --- a/checks/cloud/google/iam/no_org_level_service_account_impersonation.go +++ /dev/null @@ -1,66 +0,0 @@ -package iam - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoOrgLevelServiceAccountImpersonation = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0009", - Provider: providers.GoogleProvider, - Service: "iam", - ShortCode: "no-org-level-service-account-impersonation", - Summary: "Users should not be granted service account access at the organization level", - Impact: "Privilege escalation, impersonation of any/all services", - Resolution: "Provide access at the service-level instead of organization-level, if required", - Explanation: `Users with service account access at organization level can impersonate any service account. Instead, they should be given access to particular service accounts as required.`, - Links: []string{ - "https://cloud.google.com/iam/docs/impersonating-service-accounts", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoOrgLevelServiceAccountImpersonationGoodExamples, - BadExamples: terraformNoOrgLevelServiceAccountImpersonationBadExamples, - Links: terraformNoOrgLevelServiceAccountImpersonationLinks, - RemediationMarkdown: terraformNoOrgLevelServiceAccountImpersonationRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, org := range s.Google.IAM.Organizations { - for _, member := range org.Members { - if member.Metadata.IsUnmanaged() { - continue - } - if member.Role.IsOneOf("roles/iam.serviceAccountUser", "roles/iam.serviceAccountTokenCreator") { - results.Add( - "Service account access is granted to a user at organization level.", - member.Role, - ) - } else { - results.AddPassed(&member) - } - - } - for _, binding := range org.Bindings { - if binding.Metadata.IsUnmanaged() { - continue - } - if binding.Role.IsOneOf("roles/iam.serviceAccountUser", "roles/iam.serviceAccountTokenCreator") { - results.Add( - "Service account access is granted to a user at organization level.", - binding.Role, - ) - } else { - results.AddPassed(&binding) - } - - } - } - return - }, -) diff --git a/checks/cloud/google/iam/no_org_level_service_account_impersonation.tf.go b/checks/cloud/google/iam/no_org_level_service_account_impersonation.tf.go deleted file mode 100644 index 602cb773..00000000 --- a/checks/cloud/google/iam/no_org_level_service_account_impersonation.tf.go +++ /dev/null @@ -1,30 +0,0 @@ -package iam - -var terraformNoOrgLevelServiceAccountImpersonationGoodExamples = []string{ - ` - resource "google_organization_iam_binding" "organization-123" { - org_id = "org-123" - role = "roles/nothingInParticular" - } - `, -} - -var terraformNoOrgLevelServiceAccountImpersonationBadExamples = []string{ - ` - resource "google_organization_iam_binding" "organization-123" { - org_id = "org-123" - role = "roles/iam.serviceAccountUser" - } - `, ` - resource "google_organization_iam_binding" "organization-123" { - org_id = "org-123" - role = "roles/iam.serviceAccountTokenCreator" - } - `, -} - -var terraformNoOrgLevelServiceAccountImpersonationLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_organization_iam`, -} - -var terraformNoOrgLevelServiceAccountImpersonationRemediationMarkdown = `` diff --git a/checks/cloud/google/iam/no_privileged_service_accounts.go b/checks/cloud/google/iam/no_privileged_service_accounts.go deleted file mode 100755 index a591d156..00000000 --- a/checks/cloud/google/iam/no_privileged_service_accounts.go +++ /dev/null @@ -1,166 +0,0 @@ -package iam - -import ( - "strings" - - "github.com/aquasecurity/trivy/pkg/iac/severity" - - "github.com/aquasecurity/trivy/pkg/iac/state" - - "github.com/aquasecurity/trivy/pkg/iac/scan" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - - "github.com/aquasecurity/trivy/pkg/iac/providers" -) - -var CheckNoPrivilegedServiceAccounts = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0007", - Provider: providers.GoogleProvider, - Service: "iam", - ShortCode: "no-privileged-service-accounts", - Summary: "Service accounts should not have roles assigned with excessive privileges", - Impact: "Cloud account takeover if a resource using a service account is compromised", - Resolution: "Limit service account access to minimal required set", - Explanation: `Service accounts should have a minimal set of permissions assigned in order to do their job. They should never have excessive access as if compromised, an attacker can escalate privileges and take over the entire account.`, - Links: []string{ - "https://cloud.google.com/iam/docs/understanding-roles", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPrivilegedServiceAccountsGoodExamples, - BadExamples: terraformNoPrivilegedServiceAccountsBadExamples, - Links: terraformNoPrivilegedServiceAccountsLinks, - RemediationMarkdown: terraformNoPrivilegedServiceAccountsRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, project := range s.Google.IAM.AllProjects() { - for _, member := range project.Members { - if member.Metadata.IsUnmanaged() { - continue - } - if member.Member.StartsWith("serviceAccount:") { - if isRolePrivileged(member.Role.Value()) { - results.Add( - "Service account is granted a privileged role.", - member.Role, - ) - } else { - results.AddPassed(&member) - } - - } - } - for _, binding := range project.Bindings { - if binding.Metadata.IsUnmanaged() { - continue - } - if isRolePrivileged(binding.Role.Value()) { - for _, member := range binding.Members { - if member.StartsWith("serviceAccount:") { - results.Add( - "Service account is granted a privileged role.", - binding.Role, - ) - } else { - results.AddPassed(&binding) - } - - } - } - } - } - for _, folder := range s.Google.IAM.AllFolders() { - for _, member := range folder.Members { - if member.Metadata.IsUnmanaged() { - continue - } - if member.Member.StartsWith("serviceAccount:") { - if isRolePrivileged(member.Role.Value()) { - results.Add( - "Service account is granted a privileged role.", - member.Role, - ) - } else { - results.AddPassed(&member) - } - - } - } - for _, binding := range folder.Bindings { - if binding.Metadata.IsUnmanaged() { - continue - } - if isRolePrivileged(binding.Role.Value()) { - for _, member := range binding.Members { - if member.StartsWith("serviceAccount:") { - results.Add( - "Service account is granted a privileged role.", - binding.Role, - ) - } else { - results.AddPassed(member) - } - - } - } - } - - } - - for _, org := range s.Google.IAM.Organizations { - for _, member := range org.Members { - if member.Metadata.IsUnmanaged() { - continue - } - if member.Member.StartsWith("serviceAccount:") { - if isRolePrivileged(member.Role.Value()) { - results.Add( - "Service account is granted a privileged role.", - member.Role, - ) - } else { - results.AddPassed(&member) - } - - } - } - for _, binding := range org.Bindings { - if binding.Metadata.IsUnmanaged() { - continue - } - if isRolePrivileged(binding.Role.Value()) { - for _, member := range binding.Members { - if member.StartsWith("serviceAccount:") { - results.Add( - "Service account is granted a privileged role.", - binding.Role, - ) - } else { - results.AddPassed(member) - } - - } - } - } - - } - - return - }, -) - -func isRolePrivileged(role string) bool { - switch { - case role == "roles/owner": - return true - case role == "roles/editor": - return true - case strings.HasSuffix(strings.ToLower(role), "admin"): - return true - } - return false -} diff --git a/checks/cloud/google/iam/no_privileged_service_accounts.tf.go b/checks/cloud/google/iam/no_privileged_service_accounts.tf.go deleted file mode 100644 index f7912d66..00000000 --- a/checks/cloud/google/iam/no_privileged_service_accounts.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package iam - -var terraformNoPrivilegedServiceAccountsGoodExamples = []string{ - ` - resource "google_service_account" "test" { - account_id = "account123" - display_name = "account123" - email = "jim@tfsec.dev" - } - - resource "google_project_iam_member" "project" { - project = "your-project-id" - role = "roles/logging.logWriter" - member = "serviceAccount:${google_service_account.test.email}" - } - `, -} - -var terraformNoPrivilegedServiceAccountsBadExamples = []string{ - ` - resource "google_service_account" "test" { - account_id = "account123" - display_name = "account123" - email = "jim@tfsec.dev" - } - - resource "google_project_iam_member" "project" { - project = "your-project-id" - role = "roles/owner" - member = "serviceAccount:${google_service_account.test.email}" - } - `, -} - -var terraformNoPrivilegedServiceAccountsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_project_iam`, -} - -var terraformNoPrivilegedServiceAccountsRemediationMarkdown = `` diff --git a/checks/cloud/google/iam/no_project_level_default_service_account_assignment.go b/checks/cloud/google/iam/no_project_level_default_service_account_assignment.go deleted file mode 100755 index d95b8857..00000000 --- a/checks/cloud/google/iam/no_project_level_default_service_account_assignment.go +++ /dev/null @@ -1,80 +0,0 @@ -package iam - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoProjectLevelDefaultServiceAccountAssignment = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0006", - Provider: providers.GoogleProvider, - Service: "iam", - ShortCode: "no-project-level-default-service-account-assignment", - Summary: "Roles should not be assigned to default service accounts", - Impact: "Violation of principal of least privilege", - Resolution: "Use specialised service accounts for specific purposes.", - Explanation: `Default service accounts should not be used - consider creating specialised service accounts for individual purposes.`, - Links: []string{ - "", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoProjectLevelDefaultServiceAccountAssignmentGoodExamples, - BadExamples: terraformNoProjectLevelDefaultServiceAccountAssignmentBadExamples, - Links: terraformNoProjectLevelDefaultServiceAccountAssignmentLinks, - RemediationMarkdown: terraformNoProjectLevelDefaultServiceAccountAssignmentRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, project := range s.Google.IAM.AllProjects() { - for _, binding := range project.Bindings { - if binding.Metadata.IsUnmanaged() { - continue - } - if binding.IncludesDefaultServiceAccount.IsTrue() { - results.Add( - "Role is assigned to a default service account at project level.", - binding.IncludesDefaultServiceAccount, - ) - } else { - for _, member := range binding.Members { - if isMemberDefaultServiceAccount(member.Value()) { - results.Add( - "Role is assigned to a default service account at project level.", - member, - ) - } else { - results.AddPassed(member) - } - - } - } - } - for _, member := range project.Members { - if member.Metadata.IsUnmanaged() { - continue - } - if member.DefaultServiceAccount.IsTrue() { - results.Add( - "Role is assigned to a default service account at project level.", - member.DefaultServiceAccount, - ) - } else if isMemberDefaultServiceAccount(member.Member.Value()) { - results.Add( - "Role is assigned to a default service account at project level.", - member.Member, - ) - } else { - results.AddPassed(&member) - } - - } - } - return - }, -) diff --git a/checks/cloud/google/iam/no_project_level_default_service_account_assignment.tf.go b/checks/cloud/google/iam/no_project_level_default_service_account_assignment.tf.go deleted file mode 100644 index 6e98dd6e..00000000 --- a/checks/cloud/google/iam/no_project_level_default_service_account_assignment.tf.go +++ /dev/null @@ -1,47 +0,0 @@ -package iam - -var terraformNoProjectLevelDefaultServiceAccountAssignmentGoodExamples = []string{ - ` - resource "google_service_account" "test" { - account_id = "account123" - display_name = "account123" - } - - resource "google_project_iam_member" "project-123" { - project = "project-123" - role = "roles/whatever" - member = "serviceAccount:${google_service_account.test.email}" - } - `, -} - -var terraformNoProjectLevelDefaultServiceAccountAssignmentBadExamples = []string{ - ` - resource "google_project_iam_member" "project-123" { - project = "project-123" - role = "roles/whatever" - member = "123-compute@developer.gserviceaccount.com" - } - `, ` - resource "google_project_iam_member" "project-123" { - project = "project-123" - role = "roles/whatever" - member = "123@appspot.gserviceaccount.com" - } - `, ` - data "google_compute_default_service_account" "default" { - } - - resource "google_project_iam_member" "project-123" { - project = "project-123" - role = "roles/whatever" - member = data.google_compute_default_service_account.default.id - } - `, -} - -var terraformNoProjectLevelDefaultServiceAccountAssignmentLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_project_iam`, ``, -} - -var terraformNoProjectLevelDefaultServiceAccountAssignmentRemediationMarkdown = `` diff --git a/checks/cloud/google/iam/no_project_level_service_account_impersonation.go b/checks/cloud/google/iam/no_project_level_service_account_impersonation.go deleted file mode 100755 index 919b5d7a..00000000 --- a/checks/cloud/google/iam/no_project_level_service_account_impersonation.go +++ /dev/null @@ -1,65 +0,0 @@ -package iam - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoProjectLevelServiceAccountImpersonation = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0011", - Provider: providers.GoogleProvider, - Service: "iam", - ShortCode: "no-project-level-service-account-impersonation", - Summary: "Users should not be granted service account access at the project level", - Impact: "Privilege escalation, impersonation of any/all services", - Resolution: "Provide access at the service-level instead of project-level, if required", - Explanation: `Users with service account access at project level can impersonate any service account. Instead, they should be given access to particular service accounts as required.`, - Links: []string{ - "https://cloud.google.com/iam/docs/impersonating-service-accounts", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoProjectLevelServiceAccountImpersonationGoodExamples, - BadExamples: terraformNoProjectLevelServiceAccountImpersonationBadExamples, - Links: terraformNoProjectLevelServiceAccountImpersonationLinks, - RemediationMarkdown: terraformNoProjectLevelServiceAccountImpersonationRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, project := range s.Google.IAM.AllProjects() { - for _, member := range project.Members { - if member.Metadata.IsUnmanaged() { - continue - } - if member.Role.IsOneOf("roles/iam.serviceAccountUser", "roles/iam.serviceAccountTokenCreator") { - results.Add( - "Service account access is granted to a user at project level.", - member.Role, - ) - } else { - results.AddPassed(&member) - } - } - for _, binding := range project.Bindings { - if binding.Metadata.IsUnmanaged() { - continue - } - if binding.Role.IsOneOf("roles/iam.serviceAccountUser", "roles/iam.serviceAccountTokenCreator") { - results.Add( - "Service account access is granted to a user at project level.", - binding.Role, - ) - } else { - results.AddPassed(&binding) - } - - } - } - return - }, -) diff --git a/checks/cloud/google/iam/no_project_level_service_account_impersonation.tf.go b/checks/cloud/google/iam/no_project_level_service_account_impersonation.tf.go deleted file mode 100644 index 8ecccb69..00000000 --- a/checks/cloud/google/iam/no_project_level_service_account_impersonation.tf.go +++ /dev/null @@ -1,30 +0,0 @@ -package iam - -var terraformNoProjectLevelServiceAccountImpersonationGoodExamples = []string{ - ` - resource "google_project_iam_binding" "project-123" { - project = "project-123" - role = "roles/nothingInParticular" - } - `, -} - -var terraformNoProjectLevelServiceAccountImpersonationBadExamples = []string{ - ` - resource "google_project_iam_binding" "project-123" { - project = "project-123" - role = "roles/iam.serviceAccountUser" - } - `, ` - resource "google_project_iam_binding" "project-123" { - project = "project-123" - role = "roles/iam.serviceAccountTokenCreator" - } - `, -} - -var terraformNoProjectLevelServiceAccountImpersonationLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_project_iam`, -} - -var terraformNoProjectLevelServiceAccountImpersonationRemediationMarkdown = `` diff --git a/checks/cloud/google/iam/no_user_granted_permissions.go b/checks/cloud/google/iam/no_user_granted_permissions.go deleted file mode 100755 index dbe69357..00000000 --- a/checks/cloud/google/iam/no_user_granted_permissions.go +++ /dev/null @@ -1,131 +0,0 @@ -package iam - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoUserGrantedPermissions = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0003", - Provider: providers.GoogleProvider, - Service: "iam", - ShortCode: "no-user-granted-permissions", - Summary: "IAM granted directly to user.", - Impact: "Users shouldn't have permissions granted to them directly", - Resolution: "Roles should be granted permissions and assigned to users", - Explanation: `Permissions should not be directly granted to users, you identify roles that contain the appropriate permissions, and then grant those roles to the user. - -Granting permissions to users quickly become unwieldy and complex to make large scale changes to remove access to a particular resource. - -Permissions should be granted on roles, groups, services accounts instead.`, - Links: []string{ - "https://cloud.google.com/iam/docs/overview#permissions", - "https://cloud.google.com/resource-manager/reference/rest/v1/projects/setIamPolicy", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoUserGrantedPermissionsGoodExamples, - BadExamples: terraformNoUserGrantedPermissionsBadExamples, - Links: terraformNoUserGrantedPermissionsLinks, - RemediationMarkdown: terraformNoUserGrantedPermissionsRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, project := range s.Google.IAM.AllProjects() { - for _, member := range project.Members { - if member.Metadata.IsUnmanaged() { - continue - } - if member.Member.StartsWith("user:") { - results.Add( - "Permissions are granted directly to a user.", - member.Role, - ) - } else { - results.AddPassed(&member) - } - - } - for _, binding := range project.Bindings { - for _, member := range binding.Members { - if member.StartsWith("user:") { - results.Add( - "Permissions are granted directly to a user.", - binding.Role, - ) - } else { - results.AddPassed(member) - } - - } - } - } - - for _, folder := range s.Google.IAM.AllFolders() { - for _, member := range folder.Members { - if member.Metadata.IsUnmanaged() { - continue - } - if member.Member.StartsWith("user:") { - results.Add( - "Permissions are granted directly to a user.", - member.Role, - ) - } else { - results.AddPassed(&member) - } - - } - for _, binding := range folder.Bindings { - for _, member := range binding.Members { - if member.StartsWith("user:") { - results.Add( - "Permissions are granted directly to a user.", - binding.Role, - ) - } else { - results.AddPassed(member) - } - - } - } - } - - for _, org := range s.Google.IAM.Organizations { - for _, member := range org.Members { - if member.Metadata.IsUnmanaged() { - continue - } - if member.Member.StartsWith("user:") { - results.Add( - "Permissions are granted directly to a user.", - member.Role, - ) - } else { - results.AddPassed(&member) - } - - } - for _, binding := range org.Bindings { - for _, member := range binding.Members { - if member.StartsWith("user:") { - results.Add( - "Permissions are granted directly to a user.", - binding.Role, - ) - } else { - results.AddPassed(member) - } - - } - } - } - - return - }, -) diff --git a/checks/cloud/google/iam/no_user_granted_permissions.tf.go b/checks/cloud/google/iam/no_user_granted_permissions.tf.go deleted file mode 100644 index c0a0194f..00000000 --- a/checks/cloud/google/iam/no_user_granted_permissions.tf.go +++ /dev/null @@ -1,34 +0,0 @@ -package iam - -var terraformNoUserGrantedPermissionsGoodExamples = []string{ - ` - resource "google_project_iam_binding" "good_example" { - members = [ - "group:test@example.com", - ] - } - - resource "google_storage_bucket_iam_member" "good_example" { - member = "serviceAccount:test@example.com" - }`, -} - -var terraformNoUserGrantedPermissionsBadExamples = []string{ - ` - resource "google_project_iam_binding" "bad_example" { - members = [ - "user:test@example.com", - ] - } - - resource "google_project_iam_member" "bad_example" { - member = "user:test@example.com" - } - `, -} - -var terraformNoUserGrantedPermissionsLinks = []string{ - `https://www.terraform.io/docs/providers/google/d/iam_policy.html#members`, -} - -var terraformNoUserGrantedPermissionsRemediationMarkdown = `` diff --git a/checks/cloud/google/kms/rotate_kms_keys.go b/checks/cloud/google/kms/rotate_kms_keys.go deleted file mode 100755 index 71c51b93..00000000 --- a/checks/cloud/google/kms/rotate_kms_keys.go +++ /dev/null @@ -1,46 +0,0 @@ -package kms - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckRotateKmsKeys = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0065", - Provider: providers.GoogleProvider, - Service: "kms", - ShortCode: "rotate-kms-keys", - Summary: "KMS keys should be rotated at least every 90 days", - Impact: "Exposure is greater if the same keys are used over a long period", - Resolution: "Set key rotation period to 90 days", - Explanation: `Keys should be rotated on a regular basis to limit exposure if a given key should become compromised.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformRotateKmsKeysGoodExamples, - BadExamples: terraformRotateKmsKeysBadExamples, - Links: terraformRotateKmsKeysLinks, - RemediationMarkdown: terraformRotateKmsKeysRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, keyring := range s.Google.KMS.KeyRings { - for _, key := range keyring.Keys { - if key.RotationPeriodSeconds.GreaterThan(7776000) { - results.Add( - "Key has a rotation period of more than 90 days.", - key.RotationPeriodSeconds, - ) - } else { - results.AddPassed(&key) - } - } - } - return - }, -) diff --git a/checks/cloud/google/kms/rotate_kms_keys.tf.go b/checks/cloud/google/kms/rotate_kms_keys.tf.go deleted file mode 100644 index fb3cff01..00000000 --- a/checks/cloud/google/kms/rotate_kms_keys.tf.go +++ /dev/null @@ -1,45 +0,0 @@ -package kms - -var terraformRotateKmsKeysGoodExamples = []string{ - ` - resource "google_kms_key_ring" "keyring" { - name = "keyring-example" - location = "global" - } - - resource "google_kms_crypto_key" "example-key" { - name = "crypto-key-example" - key_ring = google_kms_key_ring.keyring.id - rotation_period = "7776000s" - - lifecycle { - prevent_destroy = true - } - } - `, -} - -var terraformRotateKmsKeysBadExamples = []string{ - ` - resource "google_kms_key_ring" "keyring" { - name = "keyring-example" - location = "global" - } - - resource "google_kms_crypto_key" "example-key" { - name = "crypto-key-example" - key_ring = google_kms_key_ring.keyring.id - rotation_period = "15552000s" - - lifecycle { - prevent_destroy = true - } - } - `, -} - -var terraformRotateKmsKeysLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/kms_crypto_key#rotation_period`, -} - -var terraformRotateKmsKeysRemediationMarkdown = `` diff --git a/checks/cloud/google/sql/enable_backup.go b/checks/cloud/google/sql/enable_backup.go deleted file mode 100755 index 663fca00..00000000 --- a/checks/cloud/google/sql/enable_backup.go +++ /dev/null @@ -1,50 +0,0 @@ -package sql - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableBackup = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0024", - Provider: providers.GoogleProvider, - Service: "sql", - ShortCode: "enable-backup", - Summary: "Enable automated backups to recover from data-loss", - Impact: "No recovery of lost or corrupted data", - Resolution: "Enable automated backups", - Explanation: `Automated backups are not enabled by default. Backups are an easy way to restore data in a corruption or data-loss scenario.`, - Links: []string{ - "https://cloud.google.com/sql/docs/mysql/backup-recovery/backups", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableBackupGoodExamples, - BadExamples: terraformEnableBackupBadExamples, - Links: terraformEnableBackupLinks, - RemediationMarkdown: terraformEnableBackupRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.SQL.Instances { - if instance.Metadata.IsUnmanaged() || instance.IsReplica.IsTrue() { - continue - } - if instance.Settings.Backups.Enabled.IsFalse() { - results.Add( - "Database instance does not have backups enabled.", - instance.Settings.Backups.Enabled, - ) - } else { - results.AddPassed(&instance) - } - - } - return - }, -) diff --git a/checks/cloud/google/sql/enable_backup.tf.go b/checks/cloud/google/sql/enable_backup.tf.go deleted file mode 100644 index 867648a1..00000000 --- a/checks/cloud/google/sql/enable_backup.tf.go +++ /dev/null @@ -1,52 +0,0 @@ -package sql - -var terraformEnableBackupGoodExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "POSTGRES_12" - region = "us-central1" - settings { - backup_configuration { - enabled = true - } - } - } - `, - ` -resource "google_sql_database_instance" "new_instance_sql_replica" { - name = "replica" - region = "europe-west3" - database_version = "POSTGRES_14" - master_instance_name = google_sql_database_instance.instance[0].name - deletion_protection = terraform.workspace == "prod" ? true : false - - replica_configuration { - connect_retry_interval = 0 - failover_target = false - master_heartbeat_period = 0 - } -} -`, -} - -var terraformEnableBackupBadExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "POSTGRES_12" - region = "us-central1" - settings { - backup_configuration { - enabled = false - } - } - } - `, -} - -var terraformEnableBackupLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance#settings.backup_configuration.enabled=true`, -} - -var terraformEnableBackupRemediationMarkdown = `` diff --git a/checks/cloud/google/sql/enable_pg_temp_file_logging.go b/checks/cloud/google/sql/enable_pg_temp_file_logging.go deleted file mode 100755 index a8bafa4d..00000000 --- a/checks/cloud/google/sql/enable_pg_temp_file_logging.go +++ /dev/null @@ -1,58 +0,0 @@ -package sql - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/google/sql" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnablePgTempFileLogging = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0014", - Provider: providers.GoogleProvider, - Service: "sql", - ShortCode: "enable-pg-temp-file-logging", - Summary: "Temporary file logging should be enabled for all temporary files.", - Impact: "Use of temporary files will not be logged", - Resolution: "Enable temporary file logging for all files", - Explanation: `Temporary files are not logged by default. To log all temporary files, a value of ` + "`" + `0` + "`" + ` should set in the ` + "`" + `log_temp_files` + "`" + ` flag - as all files greater in size than the number of bytes set in this flag will be logged.`, - Links: []string{ - "https://postgresqlco.nf/doc/en/param/log_temp_files/", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnablePgTempFileLoggingGoodExamples, - BadExamples: terraformEnablePgTempFileLoggingBadExamples, - Links: terraformEnablePgTempFileLoggingLinks, - RemediationMarkdown: terraformEnablePgTempFileLoggingRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.SQL.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.DatabaseFamily() != sql.DatabaseFamilyPostgres { - continue - } - if instance.Settings.Flags.LogTempFileSize.LessThan(0) { - results.Add( - "Database instance has temporary file logging disabled.", - instance.Settings.Flags.LogTempFileSize, - ) - } else if instance.Settings.Flags.LogTempFileSize.GreaterThan(0) { - results.Add( - "Database instance has temporary file logging disabled for files of certain sizes.", - instance.Settings.Flags.LogTempFileSize, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/google/sql/enable_pg_temp_file_logging.tf.go b/checks/cloud/google/sql/enable_pg_temp_file_logging.tf.go deleted file mode 100644 index dc17b1bf..00000000 --- a/checks/cloud/google/sql/enable_pg_temp_file_logging.tf.go +++ /dev/null @@ -1,33 +0,0 @@ -package sql - -var terraformEnablePgTempFileLoggingGoodExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "POSTGRES_12" - region = "us-central1" - settings { - database_flags { - name = "log_temp_files" - value = "0" - } - } - } - `, -} - -var terraformEnablePgTempFileLoggingBadExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "POSTGRES_12" - region = "us-central1" - } - `, -} - -var terraformEnablePgTempFileLoggingLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance`, -} - -var terraformEnablePgTempFileLoggingRemediationMarkdown = `` diff --git a/checks/cloud/google/sql/encrypt_in_transit_data.go b/checks/cloud/google/sql/encrypt_in_transit_data.go deleted file mode 100755 index 690554cc..00000000 --- a/checks/cloud/google/sql/encrypt_in_transit_data.go +++ /dev/null @@ -1,49 +0,0 @@ -package sql - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEncryptInTransitData = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0015", - Provider: providers.GoogleProvider, - Service: "sql", - ShortCode: "encrypt-in-transit-data", - Summary: "SSL connections to a SQL database instance should be enforced.", - Impact: "Intercepted data can be read in transit", - Resolution: "Enforce SSL for all connections", - Explanation: `In-transit data should be encrypted so that if traffic is intercepted data will not be exposed in plaintext to attackers.`, - Links: []string{ - "https://cloud.google.com/sql/docs/mysql/configure-ssl-instance", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEncryptInTransitDataGoodExamples, - BadExamples: terraformEncryptInTransitDataBadExamples, - Links: terraformEncryptInTransitDataLinks, - RemediationMarkdown: terraformEncryptInTransitDataRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.SQL.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.Settings.IPConfiguration.RequireTLS.IsFalse() { - results.Add( - "Database instance does not require TLS for all connections.", - instance.Settings.IPConfiguration.RequireTLS, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/google/sql/encrypt_in_transit_data.tf.go b/checks/cloud/google/sql/encrypt_in_transit_data.tf.go deleted file mode 100644 index 63878789..00000000 --- a/checks/cloud/google/sql/encrypt_in_transit_data.tf.go +++ /dev/null @@ -1,91 +0,0 @@ -package sql - -var terraformEncryptInTransitDataGoodExamples = []string{ - ` - # For terraform-provider-google < 6.0.1 - resource "google_sql_database_instance" "postgres" { - name = "postgres-instance-a" - database_version = "POSTGRES_11" - - settings { - tier = "db-f1-micro" - - ip_configuration { - ipv4_enabled = false - authorized_networks { - value = "108.12.12.0/24" - name = "internal" - } - require_ssl = true - } - } - } - `, - ` - # For terraform-provider-google >= 6.0.1 - resource "google_sql_database_instance" "postgres" { - name = "postgres-instance-a" - database_version = "POSTGRES_11" - - settings { - tier = "db-f1-micro" - - ip_configuration { - ipv4_enabled = false - authorized_networks { - value = "108.12.12.0/24" - name = "internal" - } - ssl_mode = "TRUSTED_CLIENT_CERTIFICATE_REQUIRED" - } - } - } - `, -} - -var terraformEncryptInTransitDataBadExamples = []string{ - ` - resource "google_sql_database_instance" "postgres" { - name = "postgres-instance-a" - database_version = "POSTGRES_11" - - settings { - tier = "db-f1-micro" - - ip_configuration { - ipv4_enabled = false - authorized_networks { - value = "108.12.12.0/24" - name = "internal" - } - require_ssl = false - } - } - } - `, - ` - resource "google_sql_database_instance" "postgres" { - name = "postgres-instance-a" - database_version = "POSTGRES_11" - - settings { - tier = "db-f1-micro" - - ip_configuration { - ipv4_enabled = false - authorized_networks { - value = "108.12.12.0/24" - name = "internal" - } - ssl_mode = "ALLOW_UNENCRYPTED_AND_ENCRYPTED" - } - } - } -`, -} - -var terraformEncryptInTransitDataLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance`, -} - -var terraformEncryptInTransitDataRemediationMarkdown = `` diff --git a/checks/cloud/google/sql/mysql_no_local_infile.go b/checks/cloud/google/sql/mysql_no_local_infile.go deleted file mode 100755 index 0a308214..00000000 --- a/checks/cloud/google/sql/mysql_no_local_infile.go +++ /dev/null @@ -1,54 +0,0 @@ -package sql - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/google/sql" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckMysqlNoLocalInfile = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0026", - Provider: providers.GoogleProvider, - Service: "sql", - ShortCode: "mysql-no-local-infile", - Summary: "Disable local_infile setting in MySQL", - Impact: "Arbitrary files read by attackers when combined with a SQL injection vulnerability.", - Resolution: "Disable the local infile setting", - Explanation: `Arbitrary files can be read from the system using LOAD_DATA unless this setting is disabled.`, - Links: []string{ - "https://dev.mysql.com/doc/refman/8.0/en/load-data-local-security.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformMysqlNoLocalInfileGoodExamples, - BadExamples: terraformMysqlNoLocalInfileBadExamples, - Links: terraformMysqlNoLocalInfileLinks, - RemediationMarkdown: terraformMysqlNoLocalInfileRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.SQL.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.DatabaseFamily() != sql.DatabaseFamilyMySQL { - continue - } - if instance.Settings.Flags.LocalInFile.IsTrue() { - results.Add( - "Database instance has local file read access enabled.", - instance.Settings.Flags.LocalInFile, - ) - } else { - results.AddPassed(&instance) - } - - } - return - }, -) diff --git a/checks/cloud/google/sql/mysql_no_local_infile.tf.go b/checks/cloud/google/sql/mysql_no_local_infile.tf.go deleted file mode 100644 index a460e9b4..00000000 --- a/checks/cloud/google/sql/mysql_no_local_infile.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package sql - -var terraformMysqlNoLocalInfileGoodExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "MYSQL_5_6" - region = "us-central1" - settings { - database_flags { - name = "local_infile" - value = "off" - } - } - } - `, -} - -var terraformMysqlNoLocalInfileBadExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "MYSQL_5_6" - region = "us-central1" - settings { - database_flags { - name = "local_infile" - value = "on" - } - } - } - `, -} - -var terraformMysqlNoLocalInfileLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance`, `https://dev.mysql.com/doc/refman/8.0/en/load-data-local-security.html`, -} - -var terraformMysqlNoLocalInfileRemediationMarkdown = `` diff --git a/checks/cloud/google/sql/no_contained_db_auth.go b/checks/cloud/google/sql/no_contained_db_auth.go deleted file mode 100755 index d2fe9015..00000000 --- a/checks/cloud/google/sql/no_contained_db_auth.go +++ /dev/null @@ -1,54 +0,0 @@ -package sql - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/google/sql" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoContainedDbAuth = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0023", - Provider: providers.GoogleProvider, - Service: "sql", - ShortCode: "no-contained-db-auth", - Summary: "Contained database authentication should be disabled", - Impact: "Access can be granted without knowledge of the database administrator", - Resolution: "Disable contained database authentication", - Explanation: `Users with ALTER permissions on users can grant access to a contained database without the knowledge of an administrator`, - Links: []string{ - "https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/contained-database-authentication-server-configuration-option?view=sql-server-ver15", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoContainedDbAuthGoodExamples, - BadExamples: terraformNoContainedDbAuthBadExamples, - Links: terraformNoContainedDbAuthLinks, - RemediationMarkdown: terraformNoContainedDbAuthRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.SQL.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.DatabaseFamily() != sql.DatabaseFamilySQLServer { - continue - } - if instance.Settings.Flags.ContainedDatabaseAuthentication.IsTrue() { - results.Add( - "Database instance has contained database authentication enabled.", - instance.Settings.Flags.ContainedDatabaseAuthentication, - ) - } else { - results.AddPassed(&instance) - } - - } - return - }, -) diff --git a/checks/cloud/google/sql/no_contained_db_auth.tf.go b/checks/cloud/google/sql/no_contained_db_auth.tf.go deleted file mode 100644 index 440191aa..00000000 --- a/checks/cloud/google/sql/no_contained_db_auth.tf.go +++ /dev/null @@ -1,33 +0,0 @@ -package sql - -var terraformNoContainedDbAuthGoodExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "SQLSERVER_2017_STANDARD" - region = "us-central1" - settings { - database_flags { - name = "contained database authentication" - value = "off" - } - } - } - `, -} - -var terraformNoContainedDbAuthBadExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "SQLSERVER_2017_STANDARD" - region = "us-central1" - } - `, -} - -var terraformNoContainedDbAuthLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance`, -} - -var terraformNoContainedDbAuthRemediationMarkdown = `` diff --git a/checks/cloud/google/sql/no_cross_db_ownership_chaining.go b/checks/cloud/google/sql/no_cross_db_ownership_chaining.go deleted file mode 100755 index 1f77cfb8..00000000 --- a/checks/cloud/google/sql/no_cross_db_ownership_chaining.go +++ /dev/null @@ -1,54 +0,0 @@ -package sql - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/google/sql" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoCrossDbOwnershipChaining = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0019", - Provider: providers.GoogleProvider, - Service: "sql", - ShortCode: "no-cross-db-ownership-chaining", - Summary: "Cross-database ownership chaining should be disabled", - Impact: "Unintended access to sensitive data", - Resolution: "Disable cross database ownership chaining", - Explanation: `Cross-database ownership chaining, also known as cross-database chaining, is a security feature of SQL Server that allows users of databases access to other databases besides the one they are currently using.`, - Links: []string{ - "https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/cross-db-ownership-chaining-server-configuration-option?view=sql-server-ver15", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoCrossDbOwnershipChainingGoodExamples, - BadExamples: terraformNoCrossDbOwnershipChainingBadExamples, - Links: terraformNoCrossDbOwnershipChainingLinks, - RemediationMarkdown: terraformNoCrossDbOwnershipChainingRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.SQL.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.DatabaseFamily() != sql.DatabaseFamilySQLServer { - continue - } - if instance.Settings.Flags.CrossDBOwnershipChaining.IsTrue() { - results.Add( - "Database instance has cross database ownership chaining enabled.", - instance.Settings.Flags.CrossDBOwnershipChaining, - ) - } else { - results.AddPassed(&instance) - } - - } - return - }, -) diff --git a/checks/cloud/google/sql/no_cross_db_ownership_chaining.tf.go b/checks/cloud/google/sql/no_cross_db_ownership_chaining.tf.go deleted file mode 100644 index 01238201..00000000 --- a/checks/cloud/google/sql/no_cross_db_ownership_chaining.tf.go +++ /dev/null @@ -1,33 +0,0 @@ -package sql - -var terraformNoCrossDbOwnershipChainingGoodExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "SQLSERVER_2017_STANDARD" - region = "us-central1" - settings { - database_flags { - name = "cross db ownership chaining" - value = "off" - } - } - } - `, -} - -var terraformNoCrossDbOwnershipChainingBadExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "SQLSERVER_2017_STANDARD" - region = "us-central1" - } - `, -} - -var terraformNoCrossDbOwnershipChainingLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance`, -} - -var terraformNoCrossDbOwnershipChainingRemediationMarkdown = `` diff --git a/checks/cloud/google/sql/no_public_access.go b/checks/cloud/google/sql/no_public_access.go deleted file mode 100755 index 3c1ebe25..00000000 --- a/checks/cloud/google/sql/no_public_access.go +++ /dev/null @@ -1,58 +0,0 @@ -package sql - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicAccess = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0017", - Provider: providers.GoogleProvider, - Service: "sql", - ShortCode: "no-public-access", - Summary: "Ensure that Cloud SQL Database Instances are not publicly exposed", - Impact: "Public exposure of sensitive data", - Resolution: "Remove public access from database instances", - Explanation: `Database instances should be configured so that they are not available over the public internet, but to internal compute resources which access them.`, - Links: []string{ - "https://www.cloudconformity.com/knowledge-base/gcp/CloudSQL/publicly-accessible-cloud-sql-instances.html", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicAccessGoodExamples, - BadExamples: terraformNoPublicAccessBadExamples, - Links: terraformNoPublicAccessLinks, - RemediationMarkdown: terraformNoPublicAccessRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.SQL.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.Settings.IPConfiguration.EnableIPv4.IsTrue() { - results.Add( - "Database instance is granted a public internet address.", - instance.Settings.IPConfiguration.EnableIPv4, - ) - } - for _, network := range instance.Settings.IPConfiguration.AuthorizedNetworks { - if cidr.IsPublic(network.CIDR.Value()) { - results.Add( - "Database instance allows access from the public internet.", - network.CIDR, - ) - } else { - results.AddPassed(&instance) - } - } - } - return - }, -) diff --git a/checks/cloud/google/sql/no_public_access.tf.go b/checks/cloud/google/sql/no_public_access.tf.go deleted file mode 100644 index 258e31ab..00000000 --- a/checks/cloud/google/sql/no_public_access.tf.go +++ /dev/null @@ -1,54 +0,0 @@ -package sql - -var terraformNoPublicAccessGoodExamples = []string{ - ` - resource "google_sql_database_instance" "postgres" { - name = "postgres-instance-a" - database_version = "POSTGRES_11" - - settings { - tier = "db-f1-micro" - - ip_configuration { - ipv4_enabled = false - authorized_networks { - value = "10.0.0.1/24" - name = "internal" - } - } - } - } - `, -} - -var terraformNoPublicAccessBadExamples = []string{ - ` - resource "google_sql_database_instance" "postgres" { - name = "postgres-instance-a" - database_version = "POSTGRES_11" - - settings { - tier = "db-f1-micro" - - ip_configuration { - ipv4_enabled = false - authorized_networks { - value = "108.12.12.0/24" - name = "internal" - } - - authorized_networks { - value = "0.0.0.0/0" - name = "internet" - } - } - } - } - `, -} - -var terraformNoPublicAccessLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance`, -} - -var terraformNoPublicAccessRemediationMarkdown = `` diff --git a/checks/cloud/google/sql/pg_log_checkpoints.go b/checks/cloud/google/sql/pg_log_checkpoints.go deleted file mode 100755 index 6d0fc9bb..00000000 --- a/checks/cloud/google/sql/pg_log_checkpoints.go +++ /dev/null @@ -1,53 +0,0 @@ -package sql - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/google/sql" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckPgLogCheckpoints = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0025", - Provider: providers.GoogleProvider, - Service: "sql", - ShortCode: "pg-log-checkpoints", - Summary: "Ensure that logging of checkpoints is enabled.", - Impact: "Insufficient diagnostic data.", - Resolution: "Enable checkpoints logging.", - Explanation: `Logging checkpoints provides useful diagnostic data, which can identify performance issues in an application and potential DoS vectors.`, - Links: []string{ - "https://www.postgresql.org/docs/13/runtime-config-logging.html#GUC-LOG-CHECKPOINTS", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformPgLogCheckpointsGoodExamples, - BadExamples: terraformPgLogCheckpointsBadExamples, - Links: terraformPgLogCheckpointsLinks, - RemediationMarkdown: terraformPgLogCheckpointsRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.SQL.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.DatabaseFamily() != sql.DatabaseFamilyPostgres { - continue - } - if instance.Settings.Flags.LogCheckpoints.IsFalse() { - results.Add( - "Database instance is not configured to log checkpoints.", - instance.Settings.Flags.LogCheckpoints, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/google/sql/pg_log_checkpoints.tf.go b/checks/cloud/google/sql/pg_log_checkpoints.tf.go deleted file mode 100644 index ee9c0afd..00000000 --- a/checks/cloud/google/sql/pg_log_checkpoints.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package sql - -var terraformPgLogCheckpointsGoodExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "POSTGRES_12" - region = "us-central1" - settings { - database_flags { - name = "log_checkpoints" - value = "on" - } - } - } - `, -} - -var terraformPgLogCheckpointsBadExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "POSTGRES_12" - region = "us-central1" - settings { - database_flags { - name = "log_checkpoints" - value = "off" - } - } - } - `, -} - -var terraformPgLogCheckpointsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance`, -} - -var terraformPgLogCheckpointsRemediationMarkdown = `` diff --git a/checks/cloud/google/sql/pg_log_connections.go b/checks/cloud/google/sql/pg_log_connections.go deleted file mode 100755 index cf958759..00000000 --- a/checks/cloud/google/sql/pg_log_connections.go +++ /dev/null @@ -1,53 +0,0 @@ -package sql - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/google/sql" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckPgLogConnections = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0016", - Provider: providers.GoogleProvider, - Service: "sql", - ShortCode: "pg-log-connections", - Summary: "Ensure that logging of connections is enabled.", - Impact: "Insufficient diagnostic data.", - Resolution: "Enable connection logging.", - Explanation: `Logging connections provides useful diagnostic data such as session length, which can identify performance issues in an application and potential DoS vectors.`, - Links: []string{ - "https://www.postgresql.org/docs/13/runtime-config-logging.html#GUC-LOG-CONNECTIONS", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformPgLogConnectionsGoodExamples, - BadExamples: terraformPgLogConnectionsBadExamples, - Links: terraformPgLogConnectionsLinks, - RemediationMarkdown: terraformPgLogConnectionsRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.SQL.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.DatabaseFamily() != sql.DatabaseFamilyPostgres { - continue - } - if instance.Settings.Flags.LogConnections.IsFalse() { - results.Add( - "Database instance is not configured to log connections.", - instance.Settings.Flags.LogConnections, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/google/sql/pg_log_connections.tf.go b/checks/cloud/google/sql/pg_log_connections.tf.go deleted file mode 100644 index 538068c0..00000000 --- a/checks/cloud/google/sql/pg_log_connections.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package sql - -var terraformPgLogConnectionsGoodExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "POSTGRES_12" - region = "us-central1" - settings { - database_flags { - name = "log_connections" - value = "on" - } - } - } - `, -} - -var terraformPgLogConnectionsBadExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "POSTGRES_12" - region = "us-central1" - settings { - database_flags { - name = "log_connections" - value = "off" - } - } - } - `, -} - -var terraformPgLogConnectionsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance`, -} - -var terraformPgLogConnectionsRemediationMarkdown = `` diff --git a/checks/cloud/google/sql/pg_log_disconnections.go b/checks/cloud/google/sql/pg_log_disconnections.go deleted file mode 100755 index be777691..00000000 --- a/checks/cloud/google/sql/pg_log_disconnections.go +++ /dev/null @@ -1,54 +0,0 @@ -package sql - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/google/sql" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckPgLogDisconnections = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0022", - Provider: providers.GoogleProvider, - Service: "sql", - ShortCode: "pg-log-disconnections", - Summary: "Ensure that logging of disconnections is enabled.", - Impact: "Insufficient diagnostic data.", - Resolution: "Enable disconnection logging.", - Explanation: `Logging disconnections provides useful diagnostic data such as session length, which can identify performance issues in an application and potential DoS vectors.`, - Links: []string{ - "https://www.postgresql.org/docs/13/runtime-config-logging.html#GUC-LOG-DISCONNECTIONS", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformPgLogDisconnectionsGoodExamples, - BadExamples: terraformPgLogDisconnectionsBadExamples, - Links: terraformPgLogDisconnectionsLinks, - RemediationMarkdown: terraformPgLogDisconnectionsRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.SQL.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.DatabaseFamily() != sql.DatabaseFamilyPostgres { - continue - } - if instance.Settings.Flags.LogDisconnections.IsFalse() { - results.Add( - "Database instance is not configured to log disconnections.", - instance.Settings.Flags.LogDisconnections, - ) - } else { - results.AddPassed(&instance) - } - - } - return - }, -) diff --git a/checks/cloud/google/sql/pg_log_disconnections.tf.go b/checks/cloud/google/sql/pg_log_disconnections.tf.go deleted file mode 100644 index 63843e76..00000000 --- a/checks/cloud/google/sql/pg_log_disconnections.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package sql - -var terraformPgLogDisconnectionsGoodExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "POSTGRES_12" - region = "us-central1" - settings { - database_flags { - name = "log_disconnections" - value = "on" - } - } - } - `, -} - -var terraformPgLogDisconnectionsBadExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "POSTGRES_12" - region = "us-central1" - settings { - database_flags { - name = "log_disconnections" - value = "off" - } - } - } - `, -} - -var terraformPgLogDisconnectionsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance`, -} - -var terraformPgLogDisconnectionsRemediationMarkdown = `` diff --git a/checks/cloud/google/sql/pg_log_errors.go b/checks/cloud/google/sql/pg_log_errors.go deleted file mode 100755 index 80c77488..00000000 --- a/checks/cloud/google/sql/pg_log_errors.go +++ /dev/null @@ -1,55 +0,0 @@ -package sql - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/google/sql" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckPgLogErrors = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0018", - Provider: providers.GoogleProvider, - Service: "sql", - ShortCode: "pg-log-errors", - Summary: "Ensure that Postgres errors are logged", - Impact: "Loss of error logging", - Resolution: "Set the minimum log severity to at least ERROR", - Explanation: `Setting the minimum log severity too high will cause errors not to be logged`, - Links: []string{ - "https://postgresqlco.nf/doc/en/param/log_min_messages/", - "https://www.postgresql.org/docs/13/runtime-config-logging.html#GUC-LOG-MIN-MESSAGES", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformPgLogErrorsGoodExamples, - BadExamples: terraformPgLogErrorsBadExamples, - Links: terraformPgLogErrorsLinks, - RemediationMarkdown: terraformPgLogErrorsRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.SQL.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.DatabaseFamily() != sql.DatabaseFamilyPostgres { - continue - } - if instance.Settings.Flags.LogMinMessages.IsOneOf("FATAL", "PANIC", "LOG") { - results.Add( - "Database instance is not configured to log errors.", - instance.Settings.Flags.LogMinMessages, - ) - } else { - results.AddPassed(&instance) - } - - } - return - }, -) diff --git a/checks/cloud/google/sql/pg_log_errors.tf.go b/checks/cloud/google/sql/pg_log_errors.tf.go deleted file mode 100644 index 482ef089..00000000 --- a/checks/cloud/google/sql/pg_log_errors.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package sql - -var terraformPgLogErrorsGoodExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "POSTGRES_12" - region = "us-central1" - settings { - database_flags { - name = "log_min_messages" - value = "WARNING" - } - } - } - `, -} - -var terraformPgLogErrorsBadExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "POSTGRES_12" - region = "us-central1" - settings { - database_flags { - name = "log_min_messages" - value = "PANIC" - } - } - } - `, -} - -var terraformPgLogErrorsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance`, -} - -var terraformPgLogErrorsRemediationMarkdown = `` diff --git a/checks/cloud/google/sql/pg_log_lock_waits.go b/checks/cloud/google/sql/pg_log_lock_waits.go deleted file mode 100755 index 16c840ed..00000000 --- a/checks/cloud/google/sql/pg_log_lock_waits.go +++ /dev/null @@ -1,54 +0,0 @@ -package sql - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/google/sql" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckPgLogLockWaits = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0020", - Provider: providers.GoogleProvider, - Service: "sql", - ShortCode: "pg-log-lock-waits", - Summary: "Ensure that logging of lock waits is enabled.", - Impact: "Issues leading to denial of service may not be identified.", - Resolution: "Enable lock wait logging.", - Explanation: `Lock waits are often an indication of poor performance and often an indicator of a potential denial of service vulnerability, therefore occurrences should be logged for analysis.`, - Links: []string{ - "https://www.postgresql.org/docs/13/runtime-config-logging.html#GUC-LOG-LOCK-WAITS", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformPgLogLockWaitsGoodExamples, - BadExamples: terraformPgLogLockWaitsBadExamples, - Links: terraformPgLogLockWaitsLinks, - RemediationMarkdown: terraformPgLogLockWaitsRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.SQL.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.DatabaseFamily() != sql.DatabaseFamilyPostgres { - continue - } - if instance.Settings.Flags.LogLockWaits.IsFalse() { - results.Add( - "Database instance is not configured to log lock waits.", - instance.Settings.Flags.LogLockWaits, - ) - } else { - results.AddPassed(&instance) - } - - } - return - }, -) diff --git a/checks/cloud/google/sql/pg_log_lock_waits.tf.go b/checks/cloud/google/sql/pg_log_lock_waits.tf.go deleted file mode 100644 index d6d4f3d4..00000000 --- a/checks/cloud/google/sql/pg_log_lock_waits.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package sql - -var terraformPgLogLockWaitsGoodExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "POSTGRES_12" - region = "us-central1" - settings { - database_flags { - name = "log_lock_waits" - value = "on" - } - } - } - `, -} - -var terraformPgLogLockWaitsBadExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "POSTGRES_12" - region = "us-central1" - settings { - database_flags { - name = "log_lock_waits" - value = "off" - } - } - } - `, -} - -var terraformPgLogLockWaitsLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance`, -} - -var terraformPgLogLockWaitsRemediationMarkdown = `` diff --git a/checks/cloud/google/sql/pg_no_min_statement_logging.go b/checks/cloud/google/sql/pg_no_min_statement_logging.go deleted file mode 100755 index fdefd4a1..00000000 --- a/checks/cloud/google/sql/pg_no_min_statement_logging.go +++ /dev/null @@ -1,54 +0,0 @@ -package sql - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/providers/google/sql" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckPgNoMinStatementLogging = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0021", - Provider: providers.GoogleProvider, - Service: "sql", - ShortCode: "pg-no-min-statement-logging", - Summary: "Ensure that logging of long statements is disabled.", - Impact: "Sensitive data could be exposed in the database logs.", - Resolution: "Disable minimum duration statement logging completely", - Explanation: `Logging of statements which could contain sensitive data is not advised, therefore this setting should preclude all statements from being logged.`, - Links: []string{ - "https://www.postgresql.org/docs/13/runtime-config-logging.html#GUC-LOG-MIN-DURATION-STATEMENT", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformPgNoMinStatementLoggingGoodExamples, - BadExamples: terraformPgNoMinStatementLoggingBadExamples, - Links: terraformPgNoMinStatementLoggingLinks, - RemediationMarkdown: terraformPgNoMinStatementLoggingRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Google.SQL.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.DatabaseFamily() != sql.DatabaseFamilyPostgres { - continue - } - if instance.Settings.Flags.LogMinDurationStatement.NotEqualTo(-1) { - results.Add( - "Database instance is configured to log statements.", - instance.Settings.Flags.LogMinDurationStatement, - ) - } else { - results.AddPassed(&instance) - } - - } - return - }, -) diff --git a/checks/cloud/google/sql/pg_no_min_statement_logging.tf.go b/checks/cloud/google/sql/pg_no_min_statement_logging.tf.go deleted file mode 100644 index 4db208fc..00000000 --- a/checks/cloud/google/sql/pg_no_min_statement_logging.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package sql - -var terraformPgNoMinStatementLoggingGoodExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "POSTGRES_12" - region = "us-central1" - settings { - database_flags { - name = "log_min_duration_statement" - value = "-1" - } - } - } - `, -} - -var terraformPgNoMinStatementLoggingBadExamples = []string{ - ` - resource "google_sql_database_instance" "db" { - name = "db" - database_version = "POSTGRES_12" - region = "us-central1" - settings { - database_flags { - name = "log_min_duration_statement" - value = "99" - } - } - } - `, -} - -var terraformPgNoMinStatementLoggingLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance`, -} - -var terraformPgNoMinStatementLoggingRemediationMarkdown = `` diff --git a/checks/cloud/google/storage/bucket_encryption_customer_key.go b/checks/cloud/google/storage/bucket_encryption_customer_key.go deleted file mode 100755 index ab9807ab..00000000 --- a/checks/cloud/google/storage/bucket_encryption_customer_key.go +++ /dev/null @@ -1,49 +0,0 @@ -package storage - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckBucketEncryptionCustomerKey = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0066", - Provider: providers.GoogleProvider, - Service: "storage", - ShortCode: "bucket-encryption-customer-key", - Summary: "Cloud Storage buckets should be encrypted with a customer-managed key.", - Impact: "Using unmanaged keys does not allow for proper key management.", - Resolution: "Encrypt Cloud Storage buckets using customer-managed keys.", - Explanation: `Using unmanaged keys makes rotation and general management difficult.`, - Links: []string{ - "https://cloud.google.com/storage/docs/encryption/customer-managed-keys", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformBucketEncryptionCustomerKeyGoodExamples, - BadExamples: terraformBucketEncryptionCustomerKeyBadExamples, - Links: terraformBucketEncryptionCustomerKeyLinks, - RemediationMarkdown: terraformBucketEncryptionCustomerKeyRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, bucket := range s.Google.Storage.Buckets { - if bucket.Metadata.IsUnmanaged() { - continue - } - if bucket.Encryption.DefaultKMSKeyName.IsEmpty() { - results.Add( - "Storage bucket encryption does not use a customer-managed key.", - bucket.Encryption.DefaultKMSKeyName, - ) - } else { - results.AddPassed(&bucket) - } - } - return - }, -) diff --git a/checks/cloud/google/storage/bucket_encryption_customer_key.tf.go b/checks/cloud/google/storage/bucket_encryption_customer_key.tf.go deleted file mode 100644 index 78c73a06..00000000 --- a/checks/cloud/google/storage/bucket_encryption_customer_key.tf.go +++ /dev/null @@ -1,33 +0,0 @@ -package storage - -var terraformBucketEncryptionCustomerKeyGoodExamples = []string{ - ` - resource "google_storage_bucket" "default" { - name = "my-default-bucket" - location = "EU" - force_destroy = true - uniform_bucket_level_access = true - - encryption { - default_kms_key_name = "projects/my-pet-project/locations/us-east1/keyRings/my-key-ring/cryptoKeys/my-key" - } - } - `, -} - -var terraformBucketEncryptionCustomerKeyBadExamples = []string{ - ` - resource "google_storage_bucket" "default" { - name = "my-default-bucket" - location = "EU" - force_destroy = true - uniform_bucket_level_access = true - } - `, -} - -var terraformBucketEncryptionCustomerKeyLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_bucket#encryption`, -} - -var terraformBucketEncryptionCustomerKeyRemediationMarkdown = `` diff --git a/checks/cloud/google/storage/enable_ubla.go b/checks/cloud/google/storage/enable_ubla.go deleted file mode 100755 index ea974af4..00000000 --- a/checks/cloud/google/storage/enable_ubla.go +++ /dev/null @@ -1,50 +0,0 @@ -package storage - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckEnableUbla = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0002", - Provider: providers.GoogleProvider, - Service: "storage", - ShortCode: "enable-ubla", - Summary: "Ensure that Cloud Storage buckets have uniform bucket-level access enabled", - Impact: "ACLs are difficult to manage and often lead to incorrect/unintended configurations.", - Resolution: "Enable uniform bucket level access to provide a uniform permissioning system.", - Explanation: `When you enable uniform bucket-level access on a bucket, Access Control Lists (ACLs) are disabled, and only bucket-level Identity and Access Management (IAM) permissions grant access to that bucket and the objects it contains. You revoke all access granted by object ACLs and the ability to administrate permissions using bucket ACLs.`, - Links: []string{ - "https://cloud.google.com/storage/docs/uniform-bucket-level-access", - "https://jbrojbrojbro.medium.com/you-make-the-rules-with-authentication-controls-for-cloud-storage-53c32543747b", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformEnableUblaGoodExamples, - BadExamples: terraformEnableUblaBadExamples, - Links: terraformEnableUblaLinks, - RemediationMarkdown: terraformEnableUblaRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, bucket := range s.Google.Storage.Buckets { - if bucket.Metadata.IsUnmanaged() { - continue - } - if bucket.EnableUniformBucketLevelAccess.IsFalse() { - results.Add( - "Bucket has uniform bucket level access disabled.", - bucket.EnableUniformBucketLevelAccess, - ) - } else { - results.AddPassed(&bucket) - } - } - return - }, -) diff --git a/checks/cloud/google/storage/enable_ubla.tf.go b/checks/cloud/google/storage/enable_ubla.tf.go deleted file mode 100644 index 3c126b43..00000000 --- a/checks/cloud/google/storage/enable_ubla.tf.go +++ /dev/null @@ -1,53 +0,0 @@ -package storage - -var terraformEnableUblaGoodExamples = []string{ - ` - resource "google_storage_bucket" "static-site" { - name = "image-store.com" - location = "EU" - force_destroy = true - - uniform_bucket_level_access = true - - website { - main_page_suffix = "index.html" - not_found_page = "404.html" - } - cors { - origin = ["http://image-store.com"] - method = ["GET", "HEAD", "PUT", "POST", "DELETE"] - response_header = ["*"] - max_age_seconds = 3600 - } - } - `, -} - -var terraformEnableUblaBadExamples = []string{ - ` - resource "google_storage_bucket" "static-site" { - name = "image-store.com" - location = "EU" - force_destroy = true - - uniform_bucket_level_access = false - - website { - main_page_suffix = "index.html" - not_found_page = "404.html" - } - cors { - origin = ["http://image-store.com"] - method = ["GET", "HEAD", "PUT", "POST", "DELETE"] - response_header = ["*"] - max_age_seconds = 3600 - } - } - `, -} - -var terraformEnableUblaLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_bucket#uniform_bucket_level_access`, -} - -var terraformEnableUblaRemediationMarkdown = `` diff --git a/checks/cloud/google/storage/no_public_access.go b/checks/cloud/google/storage/no_public_access.go deleted file mode 100755 index ef92b14e..00000000 --- a/checks/cloud/google/storage/no_public_access.go +++ /dev/null @@ -1,64 +0,0 @@ -package storage - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicAccess = rules.Register( - scan.Rule{ - AVDID: "AVD-GCP-0001", - Provider: providers.GoogleProvider, - Service: "storage", - ShortCode: "no-public-access", - Summary: "Ensure that Cloud Storage bucket is not anonymously or publicly accessible.", - Impact: "Public exposure of sensitive data.", - Resolution: "Restrict public access to the bucket.", - Explanation: `Using 'allUsers' or 'allAuthenticatedUsers' as members in an IAM member/binding causes data to be exposed outside of the organisation.`, - Links: []string{ - "https://jbrojbrojbro.medium.com/you-make-the-rules-with-authentication-controls-for-cloud-storage-53c32543747b", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicAccessGoodExamples, - BadExamples: terraformNoPublicAccessBadExamples, - Links: terraformNoPublicAccessLinks, - RemediationMarkdown: terraformNoPublicAccessRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, bucket := range s.Google.Storage.Buckets { - for _, binding := range bucket.Bindings { - for _, member := range binding.Members { - if googleIAMMemberIsExternal(member.Value()) { - results.Add( - "Bucket allows public access.", - member, - ) - } else { - results.AddPassed(member) - } - } - } - for _, member := range bucket.Members { - if googleIAMMemberIsExternal(member.Member.Value()) { - results.Add( - "Bucket allows public access.", - member.Member, - ) - } else { - results.AddPassed(member.Member) - } - } - } - return - }, -) - -func googleIAMMemberIsExternal(member string) bool { - return member == "allUsers" || member == "allAuthenticatedUsers" -} diff --git a/checks/cloud/google/storage/no_public_access.tf.go b/checks/cloud/google/storage/no_public_access.tf.go deleted file mode 100644 index a0960185..00000000 --- a/checks/cloud/google/storage/no_public_access.tf.go +++ /dev/null @@ -1,31 +0,0 @@ -package storage - -var terraformNoPublicAccessGoodExamples = []string{ - ` - resource "google_storage_bucket_iam_binding" "binding" { - bucket = google_storage_bucket.default.name - role = "roles/storage.admin" - members = [ - "user:jane@example.com", - ] - } - `, -} - -var terraformNoPublicAccessBadExamples = []string{ - ` - resource "google_storage_bucket_iam_binding" "binding" { - bucket = google_storage_bucket.default.name - role = "roles/storage.admin" - members = [ - "allAuthenticatedUsers", - ] - } - `, -} - -var terraformNoPublicAccessLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_bucket_iam#member/members`, -} - -var terraformNoPublicAccessRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/computing/add_description_to_security_group.go b/checks/cloud/nifcloud/computing/add_description_to_security_group.go deleted file mode 100755 index 50fa9359..00000000 --- a/checks/cloud/nifcloud/computing/add_description_to_security_group.go +++ /dev/null @@ -1,57 +0,0 @@ -package computing - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckAddDescriptionToSecurityGroup = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0002", - Aliases: []string{"nifcloud-computing-add-description-to-security-group"}, - Provider: providers.NifcloudProvider, - Service: "computing", - ShortCode: "add-description-to-security-group", - Summary: "Missing description for security group.", - Impact: "Descriptions provide context for the firewall rule reasons", - Resolution: "Add descriptions for all security groups", - Explanation: `Security groups should include a description for auditing purposes. - -Simplifies auditing, debugging, and managing security groups.`, - Links: []string{ - "https://pfs.nifcloud.com/help/fw/change.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformAddDescriptionToSecurityGroupGoodExamples, - BadExamples: terraformAddDescriptionToSecurityGroupBadExamples, - Links: terraformAddDescriptionToSecurityGroupLinks, - RemediationMarkdown: terraformAddDescriptionToSecurityGroupRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.Nifcloud.Computing.SecurityGroups { - if group.Metadata.IsUnmanaged() { - continue - } - if group.Description.IsEmpty() { - results.Add( - "Security group does not have a description.", - group.Description, - ) - } else if group.Description.EqualTo("Managed by Terraform") { - results.Add( - "Security group explicitly uses the default description.", - group.Description, - ) - } else { - results.AddPassed(&group) - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/computing/add_description_to_security_group.tf.go b/checks/cloud/nifcloud/computing/add_description_to_security_group.tf.go deleted file mode 100644 index 7565d1e4..00000000 --- a/checks/cloud/nifcloud/computing/add_description_to_security_group.tf.go +++ /dev/null @@ -1,25 +0,0 @@ -package computing - -var terraformAddDescriptionToSecurityGroupGoodExamples = []string{ - ` - resource "nifcloud_security_group" "good_example" { - group_name = "http" - description = "Allow inbound HTTP traffic" - } - `, -} - -var terraformAddDescriptionToSecurityGroupBadExamples = []string{ - ` - resource "nifcloud_security_group" "bad_example" { - group_name = "http" - description = "" - } - `, -} - -var terraformAddDescriptionToSecurityGroupLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/security_group#description`, -} - -var terraformAddDescriptionToSecurityGroupRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/computing/add_description_to_security_group_rule.go b/checks/cloud/nifcloud/computing/add_description_to_security_group_rule.go deleted file mode 100755 index 17890e71..00000000 --- a/checks/cloud/nifcloud/computing/add_description_to_security_group_rule.go +++ /dev/null @@ -1,52 +0,0 @@ -package computing - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckAddDescriptionToSecurityGroupRule = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0003", - Aliases: []string{"nifcloud-computing-add-description-to-security-group-rule"}, - Provider: providers.NifcloudProvider, - Service: "computing", - ShortCode: "add-description-to-security-group-rule", - Summary: "Missing description for security group rule.", - Impact: "Descriptions provide context for the firewall rule reasons", - Resolution: "Add descriptions for all security groups rules", - Explanation: `Security group rules should include a description for auditing purposes. - -Simplifies auditing, debugging, and managing security groups.`, - Links: []string{ - "https://pfs.nifcloud.com/help/fw/rule_new.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformAddDescriptionToSecurityGroupRuleGoodExamples, - BadExamples: terraformAddDescriptionToSecurityGroupRuleBadExamples, - Links: terraformAddDescriptionToSecurityGroupRuleLinks, - RemediationMarkdown: terraformAddDescriptionToSecurityGroupRuleRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.Nifcloud.Computing.SecurityGroups { - for _, rule := range append(group.EgressRules, group.IngressRules...) { - if rule.Description.IsEmpty() { - results.Add( - "Security group rule does not have a description.", - rule.Description, - ) - } else { - results.AddPassed(&rule) - } - } - - } - return - }, -) diff --git a/checks/cloud/nifcloud/computing/add_description_to_security_group_rule.tf.go b/checks/cloud/nifcloud/computing/add_description_to_security_group_rule.tf.go deleted file mode 100644 index 41dd4968..00000000 --- a/checks/cloud/nifcloud/computing/add_description_to_security_group_rule.tf.go +++ /dev/null @@ -1,34 +0,0 @@ -package computing - -var terraformAddDescriptionToSecurityGroupRuleGoodExamples = []string{ - ` - resource "nifcloud_security_group_rule" "good_example" { - type = "IN" - description = "HTTP from VPC" - from_port = 80 - to_port = 80 - protocol = "TCP" - cidr_ip = nifcloud_private_lan.main.cidr_block - } - `, -} - -var terraformAddDescriptionToSecurityGroupRuleBadExamples = []string{ - ` - resource "nifcloud_security_group_rule" "bad_example" { - type = "IN" - description = "" - from_port = 80 - to_port = 80 - protocol = "TCP" - cidr_ip = nifcloud_private_lan.main.cidr_block - } - - `, -} - -var terraformAddDescriptionToSecurityGroupRuleLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/security_group_rule#description`, -} - -var terraformAddDescriptionToSecurityGroupRuleRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/computing/add_security_group_to_instance.go b/checks/cloud/nifcloud/computing/add_security_group_to_instance.go deleted file mode 100755 index d90d7ea5..00000000 --- a/checks/cloud/nifcloud/computing/add_security_group_to_instance.go +++ /dev/null @@ -1,50 +0,0 @@ -package computing - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckAddSecurityGroupToInstance = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0004", - Aliases: []string{"nifcloud-computing-add-security-group-to-instance"}, - Provider: providers.NifcloudProvider, - Service: "computing", - ShortCode: "add-security-group-to-instance", - Summary: "Missing security group for instance.", - Impact: "A security group controls the traffic that is allowed to reach and leave the resources that it is associated with.", - Resolution: "Add security group for all instances", - Explanation: "Need to add a security group to your instance.", - Links: []string{ - "https://pfs.nifcloud.com/help/server/change_fw.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformAddSecurityGroupToInstanceGoodExamples, - BadExamples: terraformAddSecurityGroupToInstanceBadExamples, - Links: terraformAddSecurityGroupToInstanceLinks, - RemediationMarkdown: terraformAddSecurityGroupToInstanceRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Nifcloud.Computing.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.SecurityGroup.IsEmpty() { - results.Add( - "Instance does not have a securiy group.", - instance.SecurityGroup, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/computing/add_security_group_to_instance.tf.go b/checks/cloud/nifcloud/computing/add_security_group_to_instance.tf.go deleted file mode 100644 index 9e547484..00000000 --- a/checks/cloud/nifcloud/computing/add_security_group_to_instance.tf.go +++ /dev/null @@ -1,33 +0,0 @@ -package computing - -var terraformAddSecurityGroupToInstanceGoodExamples = []string{ - ` - resource "nifcloud_instance" "good_example" { - image_id = data.nifcloud_image.ubuntu.id - security_group = nifcloud_security_group.example.group_name - - network_interface { - network_id = "net-COMMON_GLOBAL" - } - } - `, -} - -var terraformAddSecurityGroupToInstanceBadExamples = []string{ - ` - resource "nifcloud_instance" "bad_example" { - image_id = data.nifcloud_image.ubuntu.id - security_group = "" - - network_interface { - network_id = "net-COMMON_GLOBAL" - } - } - `, -} - -var terraformAddSecurityGroupToInstanceLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/instance#security_group`, -} - -var terraformAddSecurityGroupToInstanceRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/computing/no_common_private_instance.go b/checks/cloud/nifcloud/computing/no_common_private_instance.go deleted file mode 100755 index daf6a74b..00000000 --- a/checks/cloud/nifcloud/computing/no_common_private_instance.go +++ /dev/null @@ -1,49 +0,0 @@ -package computing - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoCommonPrivateInstance = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0005", - Aliases: []string{"nifcloud-computing-no-common-private-instance"}, - Provider: providers.NifcloudProvider, - Service: "computing", - ShortCode: "no-common-private-instance", - Summary: "The instance has common private network", - Impact: "The common private network is shared with other users", - Resolution: "Use private LAN", - Explanation: `When handling sensitive data between servers, please consider using a private LAN to isolate the private side network from the shared network.`, - Links: []string{ - "https://pfs.nifcloud.com/service/plan.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoCommonPrivateInstanceGoodExamples, - BadExamples: terraformNoCommonPrivateInstanceBadExamples, - Links: terraformNoCommonPrivateInstanceLinks, - RemediationMarkdown: terraformNoCommonPrivateInstanceRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Nifcloud.Computing.Instances { - for _, ni := range instance.NetworkInterfaces { - if ni.NetworkID.EqualTo("net-COMMON_PRIVATE") { - results.Add( - "The instance has common private network", - ni.NetworkID, - ) - } else { - results.AddPassed(&ni) - } - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/computing/no_common_private_instance.tf.go b/checks/cloud/nifcloud/computing/no_common_private_instance.tf.go deleted file mode 100644 index 05c3f53e..00000000 --- a/checks/cloud/nifcloud/computing/no_common_private_instance.tf.go +++ /dev/null @@ -1,33 +0,0 @@ -package computing - -var terraformNoCommonPrivateInstanceGoodExamples = []string{ - ` - resource "nifcloud_instance" "good_example" { - image_id = data.nifcloud_image.ubuntu.id - security_group = nifcloud_security_group.example.group_name - - network_interface { - network_id = nifcloud_private_lan.main.id - } - } - `, -} - -var terraformNoCommonPrivateInstanceBadExamples = []string{ - ` - resource "nifcloud_instance" "bad_example" { - image_id = data.nifcloud_image.ubuntu.id - security_group = nifcloud_security_group.example.group_name - - network_interface { - network_id = "net-COMMON_PRIVATE" - } - } - `, -} - -var terraformNoCommonPrivateInstanceLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/instance#network_id`, -} - -var terraformNoCommonPrivateInstanceRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/computing/no_public_ingress_sgr.go b/checks/cloud/nifcloud/computing/no_public_ingress_sgr.go deleted file mode 100755 index 869cc51d..00000000 --- a/checks/cloud/nifcloud/computing/no_public_ingress_sgr.go +++ /dev/null @@ -1,52 +0,0 @@ -package computing - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicIngressSgr = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0001", - Aliases: []string{"nifcloud-computing-no-public-ingress-sgr"}, - Provider: providers.NifcloudProvider, - Service: "computing", - ShortCode: "no-public-ingress-sgr", - Summary: "An ingress security group rule allows traffic from /0.", - Impact: "Your port exposed to the internet", - Resolution: "Set a more restrictive cidr range", - Explanation: `Opening up ports to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that explicitly require it where possible. -When publishing web applications, use a load balancer instead of publishing directly to instances. - `, - Links: []string{ - "https://pfs.nifcloud.com/help/fw/rule_new.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicIngressSgrGoodExamples, - BadExamples: terraformNoPublicIngressSgrBadExamples, - Links: terraformNoPublicIngressSgrLinks, - RemediationMarkdown: terraformNoPublicIngressSgrRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.Nifcloud.Computing.SecurityGroups { - for _, rule := range group.IngressRules { - if cidr.IsPublic(rule.CIDR.Value()) && cidr.CountAddresses(rule.CIDR.Value()) > 1 { - results.Add( - "Security group rule allows ingress from public internet.", - rule.CIDR, - ) - } else { - results.AddPassed(&rule) - } - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/computing/no_public_ingress_sgr.tf.go b/checks/cloud/nifcloud/computing/no_public_ingress_sgr.tf.go deleted file mode 100644 index 60206563..00000000 --- a/checks/cloud/nifcloud/computing/no_public_ingress_sgr.tf.go +++ /dev/null @@ -1,35 +0,0 @@ -package computing - -var terraformNoPublicIngressSgrGoodExamples = []string{ - ` - resource "nifcloud_security_group_rule" "good_example" { - type = "IN" - cidr_ip = "10.0.0.0/16" - } - `, - ` -resource "nifcloud_security_group_rule" "allow_partner_rsync" { - type = "IN" - security_group_names = [nifcloud_security_group.….group_name] - from_port = 22 - to_port = 22 - protocol = "TCP" - cidr_ip = "10.0.0.0/16" -} -`, -} - -var terraformNoPublicIngressSgrBadExamples = []string{ - ` - resource "nifcloud_security_group_rule" "bad_example" { - type = "IN" - cidr_ip = "0.0.0.0/0" - } - `, -} - -var terraformNoPublicIngressSgrLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/security_group_rule#cidr_ip`, -} - -var terraformNoPublicIngressSgrRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/dns/remove_verified_record.go b/checks/cloud/nifcloud/dns/remove_verified_record.go deleted file mode 100644 index dc101b98..00000000 --- a/checks/cloud/nifcloud/dns/remove_verified_record.go +++ /dev/null @@ -1,44 +0,0 @@ -package dns - -import ( - "github.com/aquasecurity/trivy/pkg/iac/providers/nifcloud/dns" - "github.com/aquasecurity/trivy/pkg/iac/severity" - - "github.com/aquasecurity/trivy/pkg/iac/state" - - "github.com/aquasecurity/trivy/pkg/iac/scan" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - - "github.com/aquasecurity/trivy/pkg/iac/providers" -) - -var CheckRemoveVerifiedRecord = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0007", - Provider: providers.NifcloudProvider, - Service: "dns", - ShortCode: "remove-verified-record", - Summary: "Delete verified record", - Impact: "Risk of DNS records be used by others", - Resolution: "Remove verified record", - Explanation: ` -Removing verified record of TXT auth the risk that -If the authentication record remains, anyone can register the zone`, - Links: []string{ - "https://pfs.nifcloud.com/guide/dns/zone_new.htm", - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, record := range s.Nifcloud.DNS.Records { - if record.Type.EqualTo("TXT") && record.Record.StartsWith(dns.ZoneRegistrationAuthTxt) { - results.Add("Authentication TXT record exists.", &record) - } else { - results.AddPassed(&record) - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/nas/add_description_to_nas_security_group.go b/checks/cloud/nifcloud/nas/add_description_to_nas_security_group.go deleted file mode 100755 index 2de3a55d..00000000 --- a/checks/cloud/nifcloud/nas/add_description_to_nas_security_group.go +++ /dev/null @@ -1,57 +0,0 @@ -package nas - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckAddDescriptionToNASSecurityGroup = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0015", - Aliases: []string{"nifcloud-nas-add-description-to-nas-security-group"}, - Provider: providers.NifcloudProvider, - Service: "nas", - ShortCode: "add-description-to-nas-security-group", - Summary: "Missing description for nas security group.", - Impact: "Descriptions provide context for the firewall rule reasons", - Resolution: "Add descriptions for all nas security groups", - Explanation: `NAS security groups should include a description for auditing purposes. - -Simplifies auditing, debugging, and managing nas security groups.`, - Links: []string{ - "https://pfs.nifcloud.com/help/nas/fw_new.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformAddDescriptionToNASSecurityGroupGoodExamples, - BadExamples: terraformAddDescriptionToNASSecurityGroupBadExamples, - Links: terraformAddDescriptionToNASSecurityGroupLinks, - RemediationMarkdown: terraformAddDescriptionToNASSecurityGroupRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.Nifcloud.NAS.NASSecurityGroups { - if group.Metadata.IsUnmanaged() { - continue - } - if group.Description.IsEmpty() { - results.Add( - "NAS security group does not have a description.", - group.Description, - ) - } else if group.Description.EqualTo("Managed by Terraform") { - results.Add( - "NAS security group explicitly uses the default description.", - group.Description, - ) - } else { - results.AddPassed(&group) - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/nas/add_description_to_nas_security_group.tf.go b/checks/cloud/nifcloud/nas/add_description_to_nas_security_group.tf.go deleted file mode 100644 index 03b5a5ab..00000000 --- a/checks/cloud/nifcloud/nas/add_description_to_nas_security_group.tf.go +++ /dev/null @@ -1,25 +0,0 @@ -package nas - -var terraformAddDescriptionToNASSecurityGroupGoodExamples = []string{ - ` - resource "nifcloud_nas_security_group" "good_example" { - group_name = "app" - description = "Allow from app traffic" - } - `, -} - -var terraformAddDescriptionToNASSecurityGroupBadExamples = []string{ - ` - resource "nifcloud_nas_security_group" "bad_example" { - name = "app" - description = "" - } - `, -} - -var terraformAddDescriptionToNASSecurityGroupLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/nas_security_group#description`, -} - -var terraformAddDescriptionToNASSecurityGroupRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/nas/no_common_private_nas_instance.go b/checks/cloud/nifcloud/nas/no_common_private_nas_instance.go deleted file mode 100755 index e74c5b1c..00000000 --- a/checks/cloud/nifcloud/nas/no_common_private_nas_instance.go +++ /dev/null @@ -1,47 +0,0 @@ -package nas - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoCommonPrivateNASInstance = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0013", - Aliases: []string{"nifcloud-nas-no-common-private-nas-instance"}, - Provider: providers.NifcloudProvider, - Service: "nas", - ShortCode: "no-common-private-nas-instance", - Summary: "The nas instance has common private network", - Impact: "The common private network is shared with other users", - Resolution: "Use private LAN", - Explanation: `When handling sensitive data between servers, please consider using a private LAN to isolate the private side network from the shared network.`, - Links: []string{ - "https://pfs.nifcloud.com/service/plan.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoCommonPrivateNASInstanceGoodExamples, - BadExamples: terraformNoCommonPrivateNASInstanceBadExamples, - Links: terraformNoCommonPrivateNASInstanceLinks, - RemediationMarkdown: terraformNoCommonPrivateNASInstanceRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Nifcloud.NAS.NASInstances { - if instance.NetworkID.EqualTo("net-COMMON_PRIVATE") { - results.Add( - "The nas instance has common private network", - instance.NetworkID, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/nas/no_common_private_nas_instance.tf.go b/checks/cloud/nifcloud/nas/no_common_private_nas_instance.tf.go deleted file mode 100644 index 5f18c759..00000000 --- a/checks/cloud/nifcloud/nas/no_common_private_nas_instance.tf.go +++ /dev/null @@ -1,23 +0,0 @@ -package nas - -var terraformNoCommonPrivateNASInstanceGoodExamples = []string{ - ` - resource "nifcloud_nas_instance" "good_example" { - network_id = nifcloud_private_lan.main.id - } - `, -} - -var terraformNoCommonPrivateNASInstanceBadExamples = []string{ - ` - resource "nifcloud_nas_instance" "bad_example" { - network_id = "net-COMMON_PRIVATE" - } - `, -} - -var terraformNoCommonPrivateNASInstanceLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/nas_instance#network_id`, -} - -var terraformNoCommonPrivateNASInstanceRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/nas/no_public_ingress_nas_sgr.go b/checks/cloud/nifcloud/nas/no_public_ingress_nas_sgr.go deleted file mode 100755 index 3d215b4b..00000000 --- a/checks/cloud/nifcloud/nas/no_public_ingress_nas_sgr.go +++ /dev/null @@ -1,50 +0,0 @@ -package nas - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicIngressNASSgr = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0014", - Aliases: []string{"nifcloud-nas-no-public-ingress-nas-sgr"}, - Provider: providers.NifcloudProvider, - Service: "nas", - ShortCode: "no-public-ingress-nas-sgr", - Summary: "An ingress nas security group rule allows traffic from /0.", - Impact: "Your port exposed to the internet", - Resolution: "Set a more restrictive cidr range", - Explanation: `Opening up ports to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that explicitly require it where possible.`, - Links: []string{ - "https://pfs.nifcloud.com/api/nas/AuthorizeNASSecurityGroupIngress.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicIngressNASSgrGoodExamples, - BadExamples: terraformNoPublicIngressNASSgrBadExamples, - Links: terraformNoPublicIngressNASSgrLinks, - RemediationMarkdown: terraformNoPublicIngressNASSgrRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.Nifcloud.NAS.NASSecurityGroups { - for _, rule := range group.CIDRs { - if cidr.IsPublic(rule.Value()) && cidr.CountAddresses(rule.Value()) > 1 { - results.Add( - "NAS Security group rule allows ingress from public internet.", - rule, - ) - } else { - results.AddPassed(&group) - } - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/nas/no_public_ingress_nas_sgr.tf.go b/checks/cloud/nifcloud/nas/no_public_ingress_nas_sgr.tf.go deleted file mode 100644 index 6e6d5a3d..00000000 --- a/checks/cloud/nifcloud/nas/no_public_ingress_nas_sgr.tf.go +++ /dev/null @@ -1,27 +0,0 @@ -package nas - -var terraformNoPublicIngressNASSgrGoodExamples = []string{ - ` - resource "nifcloud_nas_security_group" "good_example" { - rule { - cidr_ip = "10.0.0.0/16" - } - } - `, -} - -var terraformNoPublicIngressNASSgrBadExamples = []string{ - ` - resource "nifcloud_nas_security_group" "bad_example" { - rule { - cidr_ip = "0.0.0.0/0" - } - } - `, -} - -var terraformNoPublicIngressNASSgrLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/nas_security_group#cidr_ip`, -} - -var terraformNoPublicIngressNASSgrRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/network/add_security_group_to_router.go b/checks/cloud/nifcloud/network/add_security_group_to_router.go deleted file mode 100755 index d21ced6a..00000000 --- a/checks/cloud/nifcloud/network/add_security_group_to_router.go +++ /dev/null @@ -1,50 +0,0 @@ -package network - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckAddSecurityGroupToRouter = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0016", - Aliases: []string{"nifcloud-computing-add-security-group-to-router"}, - Provider: providers.NifcloudProvider, - Service: "network", - ShortCode: "add-security-group-to-router", - Summary: "Missing security group for router.", - Impact: "A security group controls the traffic that is allowed to reach and leave the resources that it is associated with.", - Resolution: "Add security group for all routers", - Explanation: "Need to add a security group to your router.", - Links: []string{ - "https://pfs.nifcloud.com/help/router/change.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformAddSecurityGroupToRouterGoodExamples, - BadExamples: terraformAddSecurityGroupToRouterBadExamples, - Links: terraformAddSecurityGroupToRouterLinks, - RemediationMarkdown: terraformAddSecurityGroupToRouterRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, router := range s.Nifcloud.Network.Routers { - if router.Metadata.IsUnmanaged() { - continue - } - if router.SecurityGroup.IsEmpty() { - results.Add( - "Router does not have a securiy group.", - router.SecurityGroup, - ) - } else { - results.AddPassed(&router) - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/network/add_security_group_to_router.tf.go b/checks/cloud/nifcloud/network/add_security_group_to_router.tf.go deleted file mode 100644 index 9e6ab852..00000000 --- a/checks/cloud/nifcloud/network/add_security_group_to_router.tf.go +++ /dev/null @@ -1,31 +0,0 @@ -package network - -var terraformAddSecurityGroupToRouterGoodExamples = []string{ - ` - resource "nifcloud_router" "good_example" { - security_group = nifcloud_security_group.example.group_name - - network_interface { - network_id = "net-COMMON_GLOBAL" - } - } - `, -} - -var terraformAddSecurityGroupToRouterBadExamples = []string{ - ` - resource "nifcloud_router" "bad_example" { - security_group = "" - - network_interface { - network_id = "net-COMMON_GLOBAL" - } - } - `, -} - -var terraformAddSecurityGroupToRouterLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/router#security_group`, -} - -var terraformAddSecurityGroupToRouterRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/network/add_security_group_to_vpn_gateway.go b/checks/cloud/nifcloud/network/add_security_group_to_vpn_gateway.go deleted file mode 100755 index 6c48c2d0..00000000 --- a/checks/cloud/nifcloud/network/add_security_group_to_vpn_gateway.go +++ /dev/null @@ -1,50 +0,0 @@ -package network - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckAddSecurityGroupToVpnGateway = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0018", - Aliases: []string{"nifcloud-computing-add-security-group-to-vpn-gateway"}, - Provider: providers.NifcloudProvider, - Service: "network", - ShortCode: "add-security-group-to-vpn-gateway", - Summary: "Missing security group for vpnGateway.", - Impact: "A security group controls the traffic that is allowed to reach and leave the resources that it is associated with.", - Resolution: "Add security group for all vpnGateways", - Explanation: "Need to add a security group to your vpnGateway.", - Links: []string{ - "https://pfs.nifcloud.com/help/vpngw/change.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformAddSecurityGroupToVpnGatewayGoodExamples, - BadExamples: terraformAddSecurityGroupToVpnGatewayBadExamples, - Links: terraformAddSecurityGroupToVpnGatewayLinks, - RemediationMarkdown: terraformAddSecurityGroupToVpnGatewayRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, vpnGateway := range s.Nifcloud.Network.VpnGateways { - if vpnGateway.Metadata.IsUnmanaged() { - continue - } - if vpnGateway.SecurityGroup.IsEmpty() { - results.Add( - "VpnGateway does not have a securiy group.", - vpnGateway.SecurityGroup, - ) - } else { - results.AddPassed(&vpnGateway) - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/network/add_security_group_to_vpn_gateway.tf.go b/checks/cloud/nifcloud/network/add_security_group_to_vpn_gateway.tf.go deleted file mode 100644 index 4d559c5e..00000000 --- a/checks/cloud/nifcloud/network/add_security_group_to_vpn_gateway.tf.go +++ /dev/null @@ -1,31 +0,0 @@ -package network - -var terraformAddSecurityGroupToVpnGatewayGoodExamples = []string{ - ` - resource "nifcloud_vpn_gateway" "good_example" { - security_group = nifcloud_security_group.example.group_name - - network_interface { - network_id = "net-COMMON_GLOBAL" - } - } - `, -} - -var terraformAddSecurityGroupToVpnGatewayBadExamples = []string{ - ` - resource "nifcloud_vpn_gateway" "bad_example" { - security_group = "" - - network_interface { - network_id = "net-COMMON_GLOBAL" - } - } - `, -} - -var terraformAddSecurityGroupToVpnGatewayLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/vpn_gateway#security_group`, -} - -var terraformAddSecurityGroupToVpnGatewayRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/network/http_not_used.go b/checks/cloud/nifcloud/network/http_not_used.go deleted file mode 100755 index 7240370b..00000000 --- a/checks/cloud/nifcloud/network/http_not_used.go +++ /dev/null @@ -1,76 +0,0 @@ -package network - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckHttpNotUsed = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0021", - Provider: providers.NifcloudProvider, - Service: "network", - ShortCode: "http-not-used", - Summary: "Use of plain HTTP.", - Impact: "Your traffic is not protected", - Resolution: "Switch to HTTPS to benefit from TLS security features", - Explanation: `Plain HTTP is unencrypted and human-readable. This means that if a malicious actor was to eavesdrop on your connection, they would be able to see all of your data flowing back and forth. - -You should use HTTPS, which is HTTP over an encrypted (TLS) connection, meaning eavesdroppers cannot read your traffic.`, - Links: []string{ - "https://www.cloudflare.com/en-gb/learning/ssl/why-is-http-not-secure/", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformHttpNotUsedGoodExamples, - BadExamples: terraformHttpNotUsedBadExamples, - Links: terraformHttpNotUsedLinks, - RemediationMarkdown: terraformHttpNotUsedRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, lb := range s.Nifcloud.Network.LoadBalancers { - for _, listener := range lb.Listeners { - if !listener.Protocol.EqualTo("HTTP") { - results.AddPassed(&listener) - continue - } - - results.Add( - "Listener for l4 load balancer does not use HTTPS.", - listener.Protocol, - ) - } - } - for _, elb := range s.Nifcloud.Network.ElasticLoadBalancers { - var publicLB bool - for _, ni := range elb.NetworkInterfaces { - if ni.NetworkID.EqualTo("net-COMMON_GLOBAL") && ni.IsVipNetwork.IsTrue() { - publicLB = true - } - } - - if !publicLB { - continue - } - - for _, listener := range elb.Listeners { - if !listener.Protocol.EqualTo("HTTP") { - results.AddPassed(&listener) - continue - } - - results.Add( - "Listener for multi load balancer does not use HTTPS.", - listener.Protocol, - ) - } - } - - return - }, -) diff --git a/checks/cloud/nifcloud/network/http_not_used.tf.go b/checks/cloud/nifcloud/network/http_not_used.tf.go deleted file mode 100644 index c5e7b248..00000000 --- a/checks/cloud/nifcloud/network/http_not_used.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package network - -var terraformHttpNotUsedGoodExamples = []string{ - ` - resource "nifcloud_elb" "good_example" { - protocol = "HTTPS" - } - `, - ` -resource "nifcloud_load_balancer" "good_example" { - load_balancer_port = 443 -} -`, -} - -var terraformHttpNotUsedBadExamples = []string{ - ` - resource "nifcloud_elb" "bad_example" { - protocol = "HTTP" - - network_interface { - network_id = "net-COMMON_GLOBAL" - is_vip_network = true - } - } - `, - ` -resource "nifcloud_load_balancer" "bad_example" { - load_balancer_port = 80 -} -`, -} - -var terraformHttpNotUsedLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/elb#protocol`, - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/load_balancer#load_balancer_port`, -} - -var terraformHttpNotUsedRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/network/no_common_private_elb.go b/checks/cloud/nifcloud/network/no_common_private_elb.go deleted file mode 100755 index b60be8de..00000000 --- a/checks/cloud/nifcloud/network/no_common_private_elb.go +++ /dev/null @@ -1,49 +0,0 @@ -package network - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoCommonPrivateElasticLoadBalancer = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0019", - Aliases: []string{"nifcloud-network-no-common-private-elb"}, - Provider: providers.NifcloudProvider, - Service: "network", - ShortCode: "no-common-private-elb", - Summary: "The elb has common private network", - Impact: "The common private network is shared with other users", - Resolution: "Use private LAN", - Explanation: `When handling sensitive data between servers, please consider using a private LAN to isolate the private side network from the shared network.`, - Links: []string{ - "https://pfs.nifcloud.com/service/plan.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoCommonPrivateElasticLoadBalancerGoodExamples, - BadExamples: terraformNoCommonPrivateElasticLoadBalancerBadExamples, - Links: terraformNoCommonPrivateElasticLoadBalancerLinks, - RemediationMarkdown: terraformNoCommonPrivateElasticLoadBalancerRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, elb := range s.Nifcloud.Network.ElasticLoadBalancers { - for _, ni := range elb.NetworkInterfaces { - if ni.NetworkID.EqualTo("net-COMMON_PRIVATE") { - results.Add( - "The elb has common private network", - ni.NetworkID, - ) - } else { - results.AddPassed(&ni) - } - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/network/no_common_private_elb.tf.go b/checks/cloud/nifcloud/network/no_common_private_elb.tf.go deleted file mode 100644 index 41c538a5..00000000 --- a/checks/cloud/nifcloud/network/no_common_private_elb.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package network - -var terraformNoCommonPrivateElasticLoadBalancerGoodExamples = []string{ - ` - resource "nifcloud_elb" "good_example" { - elb_name = "foobar" - availability_zone = "east-11" - instance_port = 80 - protocol = "HTTP" - lb_port = 80 - - network_interface { - network_id = nifcloud_private_lan.main.id - } - } - `, -} - -var terraformNoCommonPrivateElasticLoadBalancerBadExamples = []string{ - ` - resource "nifcloud_elb" "bad_example" { - elb_name = "foobar" - availability_zone = "east-11" - instance_port = 80 - protocol = "HTTP" - lb_port = 80 - - network_interface { - network_id = "net-COMMON_PRIVATE" - } - } - `, -} - -var terraformNoCommonPrivateElasticLoadBalancerLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/elb#network_id`, -} - -var terraformNoCommonPrivateElasticLoadBalancerRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/network/no_common_private_router.go b/checks/cloud/nifcloud/network/no_common_private_router.go deleted file mode 100755 index 1fa88c6d..00000000 --- a/checks/cloud/nifcloud/network/no_common_private_router.go +++ /dev/null @@ -1,49 +0,0 @@ -package network - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoCommonPrivateRouter = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0017", - Aliases: []string{"nifcloud-network-no-common-private-router"}, - Provider: providers.NifcloudProvider, - Service: "network", - ShortCode: "no-common-private-router", - Summary: "The router has common private network", - Impact: "The common private network is shared with other users", - Resolution: "Use private LAN", - Explanation: `When handling sensitive data between servers, please consider using a private LAN to isolate the private side network from the shared network.`, - Links: []string{ - "https://pfs.nifcloud.com/service/plan.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoCommonPrivateRouterGoodExamples, - BadExamples: terraformNoCommonPrivateRouterBadExamples, - Links: terraformNoCommonPrivateRouterLinks, - RemediationMarkdown: terraformNoCommonPrivateRouterRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, router := range s.Nifcloud.Network.Routers { - for _, ni := range router.NetworkInterfaces { - if ni.NetworkID.EqualTo("net-COMMON_PRIVATE") { - results.Add( - "The router has common private network", - ni.NetworkID, - ) - } else { - results.AddPassed(&ni) - } - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/network/no_common_private_router.tf.go b/checks/cloud/nifcloud/network/no_common_private_router.tf.go deleted file mode 100644 index 3e9b8a1b..00000000 --- a/checks/cloud/nifcloud/network/no_common_private_router.tf.go +++ /dev/null @@ -1,31 +0,0 @@ -package network - -var terraformNoCommonPrivateRouterGoodExamples = []string{ - ` - resource "nifcloud_router" "good_example" { - security_group = nifcloud_security_group.example.group_name - - network_interface { - network_id = nifcloud_private_lan.main.id - } - } - `, -} - -var terraformNoCommonPrivateRouterBadExamples = []string{ - ` - resource "nifcloud_router" "bad_example" { - security_group = nifcloud_security_group.example.group_name - - network_interface { - network_id = "net-COMMON_PRIVATE" - } - } - `, -} - -var terraformNoCommonPrivateRouterLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/router#network_id`, -} - -var terraformNoCommonPrivateRouterRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/network/use_secure_tls_policy.go b/checks/cloud/nifcloud/network/use_secure_tls_policy.go deleted file mode 100755 index 4a133e1b..00000000 --- a/checks/cloud/nifcloud/network/use_secure_tls_policy.go +++ /dev/null @@ -1,64 +0,0 @@ -package network - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var outdatedSSLPolicies = []string{ - "", - "1", - "Standard Ciphers A ver1", - "2", - "Standard Ciphers B ver1", - "3", - "Standard Ciphers C ver1", - "5", - "Ats Ciphers A ver1", - "8", - "Ats Ciphers D ver1", -} - -var CheckUseSecureTlsPolicy = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0020", - Provider: providers.NifcloudProvider, - Service: "network", - ShortCode: "use-secure-tls-policy", - Summary: "An outdated SSL policy is in use by a load balancer.", - Impact: "The SSL policy is outdated and has known vulnerabilities", - Resolution: "Use a more recent TLS/SSL policy for the load balancer", - Explanation: `You should not use outdated/insecure TLS versions for encryption. You should be using TLS v1.2+.`, - Links: []string{ - "https://pfs.nifcloud.com/service/lb_l4.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformUseSecureTlsPolicyGoodExamples, - BadExamples: terraformUseSecureTlsPolicyBadExamples, - Links: terraformUseSecureTlsPolicyLinks, - RemediationMarkdown: terraformUseSecureTlsPolicyRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, lb := range s.Nifcloud.Network.LoadBalancers { - for _, listener := range lb.Listeners { - for _, outdated := range outdatedSSLPolicies { - if listener.TLSPolicy.EqualTo(outdated) && listener.Protocol.EqualTo("HTTPS") { - results.Add( - "Listener uses an outdated TLS policy.", - listener.TLSPolicy, - ) - } else { - results.AddPassed(&listener) - } - } - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/network/use_secure_tls_policy.tf.go b/checks/cloud/nifcloud/network/use_secure_tls_policy.tf.go deleted file mode 100644 index 7b47fd00..00000000 --- a/checks/cloud/nifcloud/network/use_secure_tls_policy.tf.go +++ /dev/null @@ -1,28 +0,0 @@ -package network - -var terraformUseSecureTlsPolicyGoodExamples = []string{ - ` - resource "nifcloud_load_balancer" "good_example" { - load_balancer_port = 443 - policy_type = "standard" - ssl_policy_name = "Standard Ciphers D ver1" - } - `, -} - -var terraformUseSecureTlsPolicyBadExamples = []string{ - ` - resource "nifcloud_load_balancer" "bad_example" { - load_balancer_port = 443 - policy_type = "standard" - ssl_policy_name = "" - } - `, -} - -var terraformUseSecureTlsPolicyLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/load_balancer#ssl_policy_name`, - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/load_balancer_listener#ssl_policy_name`, -} - -var terraformUseSecureTlsPolicyRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/rdb/add_description_to_db_security_group.go b/checks/cloud/nifcloud/rdb/add_description_to_db_security_group.go deleted file mode 100755 index ec440949..00000000 --- a/checks/cloud/nifcloud/rdb/add_description_to_db_security_group.go +++ /dev/null @@ -1,57 +0,0 @@ -package rdb - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckAddDescriptionToDBSecurityGroup = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0012", - Aliases: []string{"nifcloud-rdb-add-description-to-db-security-group"}, - Provider: providers.NifcloudProvider, - Service: "rdb", - ShortCode: "add-description-to-db-security-group", - Summary: "Missing description for db security group.", - Impact: "Descriptions provide context for the firewall rule reasons", - Resolution: "Add descriptions for all db security groups", - Explanation: `DB security groups should include a description for auditing purposes. - -Simplifies auditing, debugging, and managing db security groups.`, - Links: []string{ - "https://pfs.nifcloud.com/help/rdb/fw_new.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformAddDescriptionToDBSecurityGroupGoodExamples, - BadExamples: terraformAddDescriptionToDBSecurityGroupBadExamples, - Links: terraformAddDescriptionToDBSecurityGroupLinks, - RemediationMarkdown: terraformAddDescriptionToDBSecurityGroupRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.Nifcloud.RDB.DBSecurityGroups { - if group.Metadata.IsUnmanaged() { - continue - } - if group.Description.IsEmpty() { - results.Add( - "DB security group does not have a description.", - group.Description, - ) - } else if group.Description.EqualTo("Managed by Terraform") { - results.Add( - "DB security group explicitly uses the default description.", - group.Description, - ) - } else { - results.AddPassed(&group) - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/rdb/add_description_to_db_security_group.tf.go b/checks/cloud/nifcloud/rdb/add_description_to_db_security_group.tf.go deleted file mode 100644 index f3e5f49c..00000000 --- a/checks/cloud/nifcloud/rdb/add_description_to_db_security_group.tf.go +++ /dev/null @@ -1,25 +0,0 @@ -package rdb - -var terraformAddDescriptionToDBSecurityGroupGoodExamples = []string{ - ` - resource "nifcloud_db_security_group" "good_example" { - group_name = "app" - description = "Allow from app traffic" - } - `, -} - -var terraformAddDescriptionToDBSecurityGroupBadExamples = []string{ - ` - resource "nifcloud_db_security_group" "bad_example" { - name = "app" - description = "" - } - `, -} - -var terraformAddDescriptionToDBSecurityGroupLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/db_security_group#description`, -} - -var terraformAddDescriptionToDBSecurityGroupRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/rdb/no_common_private_db_instance.go b/checks/cloud/nifcloud/rdb/no_common_private_db_instance.go deleted file mode 100755 index b4b89519..00000000 --- a/checks/cloud/nifcloud/rdb/no_common_private_db_instance.go +++ /dev/null @@ -1,47 +0,0 @@ -package rdb - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoCommonPrivateDBInstance = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0010", - Aliases: []string{"nifcloud-rdb-no-common-private-db-instance"}, - Provider: providers.NifcloudProvider, - Service: "rdb", - ShortCode: "no-common-private-db-instance", - Summary: "The db instance has common private network", - Impact: "The common private network is shared with other users", - Resolution: "Use private LAN", - Explanation: `When handling sensitive data between servers, please consider using a private LAN to isolate the private side network from the shared network.`, - Links: []string{ - "https://pfs.nifcloud.com/service/plan.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoCommonPrivateDBInstanceGoodExamples, - BadExamples: terraformNoCommonPrivateDBInstanceBadExamples, - Links: terraformNoCommonPrivateDBInstanceLinks, - RemediationMarkdown: terraformNoCommonPrivateDBInstanceRemediationMarkdown, - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Nifcloud.RDB.DBInstances { - if instance.NetworkID.EqualTo("net-COMMON_PRIVATE") { - results.Add( - "The db instance has common private network", - instance.NetworkID, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/rdb/no_common_private_db_instance.tf.go b/checks/cloud/nifcloud/rdb/no_common_private_db_instance.tf.go deleted file mode 100644 index 7836d3e7..00000000 --- a/checks/cloud/nifcloud/rdb/no_common_private_db_instance.tf.go +++ /dev/null @@ -1,23 +0,0 @@ -package rdb - -var terraformNoCommonPrivateDBInstanceGoodExamples = []string{ - ` - resource "nifcloud_db_instance" "good_example" { - network_id = nifcloud_private_lan.main.id - } - `, -} - -var terraformNoCommonPrivateDBInstanceBadExamples = []string{ - ` - resource "nifcloud_db_instance" "bad_example" { - network_id = "net-COMMON_PRIVATE" - } - `, -} - -var terraformNoCommonPrivateDBInstanceLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/db_instance#network_id`, -} - -var terraformNoCommonPrivateDBInstanceRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/rdb/no_public_db_access.go b/checks/cloud/nifcloud/rdb/no_public_db_access.go deleted file mode 100755 index ccf1a57b..00000000 --- a/checks/cloud/nifcloud/rdb/no_public_db_access.go +++ /dev/null @@ -1,46 +0,0 @@ -package rdb - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicDbAccess = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0008", - Provider: providers.NifcloudProvider, - Service: "rdb", - ShortCode: "no-public-db-access", - Summary: "A database resource is marked as publicly accessible.", - Impact: "The database instance is publicly accessible", - Resolution: "Set the database to not be publicly accessible", - Explanation: `Database resources should not publicly available. You should limit all access to the minimum that is required for your application to function.`, - Links: []string{ - "https://pfs.nifcloud.com/guide/rdb/server_new.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicDbAccessGoodExamples, - BadExamples: terraformNoPublicDbAccessBadExamples, - Links: terraformNoPublicDbAccessLinks, - RemediationMarkdown: terraformNoPublicDbAccessRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Nifcloud.RDB.DBInstances { - if instance.PublicAccess.IsTrue() { - results.Add( - "Instance is exposed publicly.", - instance.PublicAccess, - ) - } else { - results.AddPassed(&instance) - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/rdb/no_public_db_access.tf.go b/checks/cloud/nifcloud/rdb/no_public_db_access.tf.go deleted file mode 100644 index 8a35ddb0..00000000 --- a/checks/cloud/nifcloud/rdb/no_public_db_access.tf.go +++ /dev/null @@ -1,23 +0,0 @@ -package rdb - -var terraformNoPublicDbAccessGoodExamples = []string{ - ` - resource "nifcloud_db_instance" "good_example" { - publicly_accessible = false - } - `, -} - -var terraformNoPublicDbAccessBadExamples = []string{ - ` - resource "nifcloud_db_instance" "bad_example" { - publicly_accessible = true - } - `, -} - -var terraformNoPublicDbAccessLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/db_instance#publicly_accessible`, -} - -var terraformNoPublicDbAccessRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/rdb/no_public_ingress_db_sgr.go b/checks/cloud/nifcloud/rdb/no_public_ingress_db_sgr.go deleted file mode 100755 index 5efb0f90..00000000 --- a/checks/cloud/nifcloud/rdb/no_public_ingress_db_sgr.go +++ /dev/null @@ -1,50 +0,0 @@ -package rdb - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicIngressDBSgr = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0011", - Aliases: []string{"nifcloud-rdb-no-public-ingress-db-sgr"}, - Provider: providers.NifcloudProvider, - Service: "rdb", - ShortCode: "no-public-ingress-db-sgr", - Summary: "An ingress db security group rule allows traffic from /0.", - Impact: "Your port exposed to the internet", - Resolution: "Set a more restrictive cidr range", - Explanation: `Opening up ports to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that explicitly require it where possible.`, - Links: []string{ - "https://pfs.nifcloud.com/api/rdb/AuthorizeDBSecurityGroupIngress.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicIngressDBSgrGoodExamples, - BadExamples: terraformNoPublicIngressDBSgrBadExamples, - Links: terraformNoPublicIngressDBSgrLinks, - RemediationMarkdown: terraformNoPublicIngressDBSgrRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.Nifcloud.RDB.DBSecurityGroups { - for _, rule := range group.CIDRs { - if cidr.IsPublic(rule.Value()) && cidr.CountAddresses(rule.Value()) > 1 { - results.Add( - "DB Security group rule allows ingress from public internet.", - rule, - ) - } else { - results.AddPassed(&group) - } - } - } - return - }, -) diff --git a/checks/cloud/nifcloud/rdb/no_public_ingress_db_sgr.tf.go b/checks/cloud/nifcloud/rdb/no_public_ingress_db_sgr.tf.go deleted file mode 100644 index c7b7b430..00000000 --- a/checks/cloud/nifcloud/rdb/no_public_ingress_db_sgr.tf.go +++ /dev/null @@ -1,27 +0,0 @@ -package rdb - -var terraformNoPublicIngressDBSgrGoodExamples = []string{ - ` - resource "nifcloud_db_security_group" "good_example" { - rule { - cidr_ip = "10.0.0.0/16" - } - } - `, -} - -var terraformNoPublicIngressDBSgrBadExamples = []string{ - ` - resource "nifcloud_db_security_group" "bad_example" { - rule { - cidr_ip = "0.0.0.0/0" - } - } - `, -} - -var terraformNoPublicIngressDBSgrLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/db_security_group#cidr_ip`, -} - -var terraformNoPublicIngressDBSgrRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/rdb/specify_backup_retention.go b/checks/cloud/nifcloud/rdb/specify_backup_retention.go deleted file mode 100755 index 1d15fb40..00000000 --- a/checks/cloud/nifcloud/rdb/specify_backup_retention.go +++ /dev/null @@ -1,50 +0,0 @@ -package rdb - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckBackupRetentionSpecified = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0009", - Provider: providers.NifcloudProvider, - Service: "rdb", - ShortCode: "specify-backup-retention", - Summary: "RDB instance should have backup retention longer than 1 day", - Impact: "Potential loss of data and short opportunity for recovery", - Resolution: "Explicitly set the retention period to greater than the default", - Explanation: `Backup retention periods should be set to a period that is a balance on cost and limiting risk.`, - Links: []string{ - "https://pfs.nifcloud.com/spec/rdb/snapshot_backup.htm", - }, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformSpecifyBackupRetentionGoodExamples, - BadExamples: terraformSpecifyBackupRetentionBadExamples, - Links: terraformSpecifyBackupRetentionLinks, - RemediationMarkdown: terraformSpecifyBackupRetentionRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.Nifcloud.RDB.DBInstances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.BackupRetentionPeriodDays.LessThan(2) { - results.Add( - "Instance has very low backup retention period.", - instance.BackupRetentionPeriodDays, - ) - } else { - results.AddPassed(&instance) - } - } - - return - }, -) diff --git a/checks/cloud/nifcloud/rdb/specify_backup_retention.tf.go b/checks/cloud/nifcloud/rdb/specify_backup_retention.tf.go deleted file mode 100644 index ecb015e7..00000000 --- a/checks/cloud/nifcloud/rdb/specify_backup_retention.tf.go +++ /dev/null @@ -1,40 +0,0 @@ -package rdb - -var terraformSpecifyBackupRetentionGoodExamples = []string{ - ` - resource "nifcloud_db_instance" "good_example" { - allocated_storage = 100 - engine = "mysql" - engine_version = "5.7" - instance_class = "db.large8" - name = "mydb" - username = "foo" - password = "foobarbaz" - parameter_group_name = "default.mysql5.7" - backup_retention_period = 5 - skip_final_snapshot = true - } - `, -} - -var terraformSpecifyBackupRetentionBadExamples = []string{ - ` - resource "nifcloud_db_instance" "bad_example" { - allocated_storage = 100 - engine = "mysql" - engine_version = "5.7" - instance_class = "db.large8" - name = "mydb" - username = "foo" - password = "foobarbaz" - parameter_group_name = "default.mysql5.7" - skip_final_snapshot = true - } -`, -} - -var terraformSpecifyBackupRetentionLinks = []string{ - `https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/db_instance#backup_retention_period`, -} - -var terraformSpecifyBackupRetentionRemediationMarkdown = `` diff --git a/checks/cloud/nifcloud/sslcertificate/remove_expired_certificates.go b/checks/cloud/nifcloud/sslcertificate/remove_expired_certificates.go deleted file mode 100644 index 4669af56..00000000 --- a/checks/cloud/nifcloud/sslcertificate/remove_expired_certificates.go +++ /dev/null @@ -1,48 +0,0 @@ -package sslcertificate - -import ( - "time" - - "github.com/aquasecurity/trivy/pkg/iac/severity" - - "github.com/aquasecurity/trivy/pkg/iac/state" - - "github.com/aquasecurity/trivy/pkg/iac/scan" - - "github.com/aquasecurity/trivy-checks/pkg/rules" - - "github.com/aquasecurity/trivy/pkg/iac/providers" -) - -var CheckRemoveExpiredCertificates = rules.Register( - scan.Rule{ - AVDID: "AVD-NIF-0006", - Provider: providers.NifcloudProvider, - Service: "ssl-certificate", - ShortCode: "remove-expired-certificates", - Summary: "Delete expired SSL certificates", - Impact: "Risk of misconfiguration and damage to credibility", - Resolution: "Remove expired certificates", - Explanation: ` -Removing expired SSL/TLS certificates eliminates the risk that an invalid certificate will be -deployed accidentally to a resource such as NIFCLOUD Load Balancer(L4LB), which candamage the -credibility of the application/website behind the L4LB. As a best practice, it is -recommended to delete expired certificates. - `, - Links: []string{ - "https://pfs.nifcloud.com/help/ssl/del.htm", - }, - Severity: severity.Low, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, certificate := range s.Nifcloud.SSLCertificate.ServerCertificates { - if certificate.Expiration.Before(time.Now()) { - results.Add("Certificate has expired.", &certificate) - } else { - results.AddPassed(&certificate) - } - } - return - }, -) diff --git a/checks/cloud/openstack/compute/no_plaintext_password.go b/checks/cloud/openstack/compute/no_plaintext_password.go deleted file mode 100755 index 29404d6e..00000000 --- a/checks/cloud/openstack/compute/no_plaintext_password.go +++ /dev/null @@ -1,47 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPlaintextPassword = rules.Register( - scan.Rule{ - AVDID: "AVD-OPNSTK-0001", - Provider: providers.OpenStackProvider, - Service: "compute", - ShortCode: "no-plaintext-password", - Summary: "No plaintext password for compute instance", - Impact: "Including a plaintext password could lead to compromised instance", - Resolution: "Do not use plaintext passwords in terraform files", - Explanation: `Assigning a password to the compute instance using plaintext could lead to compromise; it would be preferable to use key-pairs as a login mechanism`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPlaintextPasswordGoodExamples, - BadExamples: terraformNoPlaintextPasswordBadExamples, - Links: terraformNoPlaintextPasswordLinks, - RemediationMarkdown: terraformNoPlaintextPasswordRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, instance := range s.OpenStack.Compute.Instances { - if instance.Metadata.IsUnmanaged() { - continue - } - if instance.AdminPassword.IsNotEmpty() { - results.Add( - "Instance has admin password set.", - instance.AdminPassword, - ) - } else { - results.AddPassed(instance) - } - } - return - }, -) diff --git a/checks/cloud/openstack/compute/no_plaintext_password.tf.go b/checks/cloud/openstack/compute/no_plaintext_password.tf.go deleted file mode 100644 index c2e537bc..00000000 --- a/checks/cloud/openstack/compute/no_plaintext_password.tf.go +++ /dev/null @@ -1,39 +0,0 @@ -package compute - -var terraformNoPlaintextPasswordGoodExamples = []string{ - ` - resource "openstack_compute_instance_v2" "good_example" { - name = "basic" - image_id = "ad091b52-742f-469e-8f3c-fd81cadf0743" - flavor_id = "3" - key_pair = "my_key_pair_name" - security_groups = ["default"] - user_data = "#cloud-config\nhostname: instance_1.example.com\nfqdn: instance_1.example.com" - - network { - name = "my_network" - } - }`, -} - -var terraformNoPlaintextPasswordBadExamples = []string{ - ` - resource "openstack_compute_instance_v2" "bad_example" { - name = "basic" - image_id = "ad091b52-742f-469e-8f3c-fd81cadf0743" - flavor_id = "3" - admin_pass = "N0tSoS3cretP4ssw0rd" - security_groups = ["default"] - user_data = "#cloud-config\nhostname: instance_1.example.com\nfqdn: instance_1.example.com" - - network { - name = "my_network" - } - }`, -} - -var terraformNoPlaintextPasswordLinks = []string{ - `https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/compute_instance_v2#admin_pass`, -} - -var terraformNoPlaintextPasswordRemediationMarkdown = `` diff --git a/checks/cloud/openstack/compute/no_public_access.go b/checks/cloud/openstack/compute/no_public_access.go deleted file mode 100755 index 4a53d1b6..00000000 --- a/checks/cloud/openstack/compute/no_public_access.go +++ /dev/null @@ -1,67 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicAccess = rules.Register( - scan.Rule{ - AVDID: "AVD-OPNSTK-0002", - Provider: providers.OpenStackProvider, - Service: "compute", - ShortCode: "no-public-access", - Summary: "A firewall rule allows traffic from/to the public internet", - Impact: "Exposure of infrastructure to the public internet", - Resolution: "Employ more restrictive firewall rules", - Explanation: `Opening up ports to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that explicitly require it where possible.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicAccessGoodExamples, - BadExamples: terraformNoPublicAccessBadExamples, - Links: terraformNoPublicAccessLinks, - RemediationMarkdown: terraformNoPublicAccessRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, rule := range s.OpenStack.Compute.Firewall.AllowRules { - if rule.Metadata.IsUnmanaged() { - continue - } - if rule.Enabled.IsFalse() { - continue - } - if rule.Destination.IsEmpty() { - results.Add( - "Firewall rule does not restrict destination address internally.", - rule.Destination, - ) - } else if cidr.IsPublic(rule.Destination.Value()) { - results.Add( - "Firewall rule allows public egress.", - rule.Destination, - ) - } else if rule.Source.IsEmpty() { - results.Add( - "Firewall rule does not restrict source address internally.", - rule.Source, - ) - } else if cidr.IsPublic(rule.Source.Value()) { - results.Add( - "Firewall rule allows public ingress.", - rule.Source, - ) - } else { - results.AddPassed(rule) - } - - } - return - }, -) diff --git a/checks/cloud/openstack/compute/no_public_access.tf.go b/checks/cloud/openstack/compute/no_public_access.tf.go deleted file mode 100644 index 3f1f60ed..00000000 --- a/checks/cloud/openstack/compute/no_public_access.tf.go +++ /dev/null @@ -1,35 +0,0 @@ -package compute - -var terraformNoPublicAccessGoodExamples = []string{ - ` - resource "openstack_fw_rule_v1" "rule_1" { - name = "my_rule" - description = "don't let just anyone in" - action = "allow" - protocol = "tcp" - destination_ip_address = "10.10.10.1" - source_ip_address = "10.10.10.2" - destination_port = "22" - enabled = "true" - } - `, -} - -var terraformNoPublicAccessBadExamples = []string{ - ` - resource "openstack_fw_rule_v1" "rule_1" { - name = "my_rule" - description = "let anyone in" - action = "allow" - protocol = "tcp" - destination_port = "22" - enabled = "true" - } - `, -} - -var terraformNoPublicAccessLinks = []string{ - `https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/fw_rule_v1`, -} - -var terraformNoPublicAccessRemediationMarkdown = `` diff --git a/checks/cloud/openstack/networking/add_description_to_security_group.go b/checks/cloud/openstack/networking/add_description_to_security_group.go deleted file mode 100755 index b3c12a55..00000000 --- a/checks/cloud/openstack/networking/add_description_to_security_group.go +++ /dev/null @@ -1,47 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckSecurityGroupHasDescription = rules.Register( - scan.Rule{ - AVDID: "AVD-OPNSTK-0005", - Provider: providers.OpenStackProvider, - Service: "networking", - ShortCode: "describe-security-group", - Summary: "Missing description for security group.", - Impact: "Auditing capability and awareness limited.", - Resolution: "Add descriptions for all security groups", - Explanation: `Security groups should include a description for auditing purposes. Simplifies auditing, debugging, and managing security groups.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformSecurityGroupHasDescriptionGoodExamples, - BadExamples: terraformSecurityGroupHasDescriptionBadExamples, - Links: terraformSecurityGroupHasDescriptionLinks, - RemediationMarkdown: terraformSecurityGroupHasDescriptionRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.OpenStack.Networking.SecurityGroups { - if group.Metadata.IsUnmanaged() { - continue - } - if group.Description.IsEmpty() { - results.Add( - "Security group rule allows egress to multiple public addresses.", - group.Description, - ) - } else { - results.AddPassed(group) - } - } - return - }, -) diff --git a/checks/cloud/openstack/networking/add_description_to_security_group.tf.go b/checks/cloud/openstack/networking/add_description_to_security_group.tf.go deleted file mode 100644 index 10018c46..00000000 --- a/checks/cloud/openstack/networking/add_description_to_security_group.tf.go +++ /dev/null @@ -1,20 +0,0 @@ -package compute - -var terraformSecurityGroupHasDescriptionGoodExamples = []string{ - ` - resource "openstack_networking_secgroup_v2" "group_1" { - description = "don't let just anyone in" - } - `, -} - -var terraformSecurityGroupHasDescriptionBadExamples = []string{ - ` - resource "openstack_networking_secgroup_v2" "group_1" { - } - `, -} - -var terraformSecurityGroupHasDescriptionLinks = []string{} - -var terraformSecurityGroupHasDescriptionRemediationMarkdown = `` diff --git a/checks/cloud/openstack/networking/no_public_egress.go b/checks/cloud/openstack/networking/no_public_egress.go deleted file mode 100755 index 5ba2bd98..00000000 --- a/checks/cloud/openstack/networking/no_public_egress.go +++ /dev/null @@ -1,50 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicEgress = rules.Register( - scan.Rule{ - AVDID: "AVD-OPNSTK-0004", - Provider: providers.OpenStackProvider, - Service: "networking", - ShortCode: "no-public-egress", - Summary: "A security group rule allows egress traffic to multiple public addresses", - Impact: "Potential exfiltration of data to the public internet", - Resolution: "Employ more restrictive security group rules", - Explanation: `Opening up ports to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that explicitly require it where possible.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicEgressGoodExamples, - BadExamples: terraformNoPublicEgressBadExamples, - Links: terraformNoPublicEgressLinks, - RemediationMarkdown: terraformNoPublicEgressRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.OpenStack.Networking.SecurityGroups { - for _, rule := range group.Rules { - if rule.Metadata.IsUnmanaged() || rule.IsIngress.IsTrue() { - continue - } - if cidr.IsPublic(rule.CIDR.Value()) && cidr.CountAddresses(rule.CIDR.Value()) > 1 { - results.Add( - "Security group rule allows egress to multiple public addresses.", - rule.CIDR, - ) - } else { - results.AddPassed(rule) - } - } - } - return - }, -) diff --git a/checks/cloud/openstack/networking/no_public_egress.tf.go b/checks/cloud/openstack/networking/no_public_egress.tf.go deleted file mode 100644 index 21cb01eb..00000000 --- a/checks/cloud/openstack/networking/no_public_egress.tf.go +++ /dev/null @@ -1,33 +0,0 @@ -package compute - -var terraformNoPublicEgressGoodExamples = []string{ - ` -resource "openstack_networking_secgroup_rule_v2" "rule_1" { - direction = "egress" - ethertype = "IPv4" - protocol = "tcp" - port_range_min = 22 - port_range_max = 22 - remote_ip_prefix = "1.2.3.4/32" -} -`, -} - -var terraformNoPublicEgressBadExamples = []string{ - ` - resource "openstack_networking_secgroup_rule_v2" "rule_1" { - direction = "egress" - ethertype = "IPv4" - protocol = "tcp" - port_range_min = 22 - port_range_max = 22 - remote_ip_prefix = "0.0.0.0/0" - } -`, -} - -var terraformNoPublicEgressLinks = []string{ - `https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/networking_secgroup_rule_v2`, -} - -var terraformNoPublicEgressRemediationMarkdown = `` diff --git a/checks/cloud/openstack/networking/no_public_ingress.go b/checks/cloud/openstack/networking/no_public_ingress.go deleted file mode 100755 index 414ff87e..00000000 --- a/checks/cloud/openstack/networking/no_public_ingress.go +++ /dev/null @@ -1,50 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicIngress = rules.Register( - scan.Rule{ - AVDID: "AVD-OPNSTK-0003", - Provider: providers.OpenStackProvider, - Service: "networking", - ShortCode: "no-public-ingress", - Summary: "A security group rule allows ingress traffic from multiple public addresses", - Impact: "Exposure of infrastructure to the public internet", - Resolution: "Employ more restrictive security group rules", - Explanation: `Opening up ports to the public internet is generally to be avoided. You should restrict access to IP addresses or ranges that explicitly require it where possible.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicIngressGoodExamples, - BadExamples: terraformNoPublicIngressBadExamples, - Links: terraformNoPublicIngressLinks, - RemediationMarkdown: terraformNoPublicIngressRemediationMarkdown, - }, - Severity: severity.Medium, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, group := range s.OpenStack.Networking.SecurityGroups { - for _, rule := range group.Rules { - if rule.Metadata.IsUnmanaged() || rule.IsIngress.IsFalse() { - continue - } - if cidr.IsPublic(rule.CIDR.Value()) && cidr.CountAddresses(rule.CIDR.Value()) > 1 { - results.Add( - "Security group rule allows ingress from multiple public addresses.", - rule.CIDR, - ) - } else { - results.AddPassed(rule) - } - } - } - return - }, -) diff --git a/checks/cloud/openstack/networking/no_public_ingress.tf.go b/checks/cloud/openstack/networking/no_public_ingress.tf.go deleted file mode 100644 index a6333cbb..00000000 --- a/checks/cloud/openstack/networking/no_public_ingress.tf.go +++ /dev/null @@ -1,33 +0,0 @@ -package compute - -var terraformNoPublicIngressGoodExamples = []string{ - ` - resource "openstack_networking_secgroup_rule_v2" "rule_1" { - direction = "ingress" - ethertype = "IPv4" - protocol = "tcp" - port_range_min = 22 - port_range_max = 22 - remote_ip_prefix = "1.2.3.4/32" - } - `, -} - -var terraformNoPublicIngressBadExamples = []string{ - ` - resource "openstack_networking_secgroup_rule_v2" "rule_1" { - direction = "ingress" - ethertype = "IPv4" - protocol = "tcp" - port_range_min = 22 - port_range_max = 22 - remote_ip_prefix = "0.0.0.0/0" - } - `, -} - -var terraformNoPublicIngressLinks = []string{ - `https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/fw_rule_v1`, -} - -var terraformNoPublicIngressRemediationMarkdown = `` diff --git a/checks/cloud/oracle/compute/no_public_ip.go b/checks/cloud/oracle/compute/no_public_ip.go deleted file mode 100755 index 628fdc59..00000000 --- a/checks/cloud/oracle/compute/no_public_ip.go +++ /dev/null @@ -1,49 +0,0 @@ -package compute - -import ( - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicIp = rules.Register( - scan.Rule{ - AVDID: "AVD-OCI-0001", - Provider: providers.OracleProvider, - Service: "compute", - ShortCode: "no-public-ip", - Summary: "Compute instance requests an IP reservation from a public pool", - Impact: "The compute instance has the ability to be reached from outside", - Resolution: "Reconsider the use of an public IP", - Explanation: `Compute instance requests an IP reservation from a public pool - -The compute instance has the ability to be reached from outside, you might want to sonder the use of a non public IP.`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicIpGoodExamples, - BadExamples: terraformNoPublicIpBadExamples, - Links: terraformNoPublicIpLinks, - RemediationMarkdown: terraformNoPublicIpRemediationMarkdown, - }, - Severity: severity.Critical, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, reservation := range s.Oracle.Compute.AddressReservations { - if reservation.Metadata.IsUnmanaged() { - continue - } - if reservation.Pool.EqualTo("public-ippool") { // TODO: future improvement: we need to see what this IP is used for before flagging - results.Add( - "Reservation made for public IP address.", - reservation.Pool, - ) - } else { - results.AddPassed(reservation) - } - } - return - }, -) diff --git a/checks/cloud/oracle/compute/no_public_ip.tf.go b/checks/cloud/oracle/compute/no_public_ip.tf.go deleted file mode 100644 index 4f39fb74..00000000 --- a/checks/cloud/oracle/compute/no_public_ip.tf.go +++ /dev/null @@ -1,25 +0,0 @@ -package compute - -var terraformNoPublicIpGoodExamples = []string{ - ` - resource "opc_compute_ip_address_reservation" "good_example" { - name = "my-ip-address" - ip_address_pool = "cloud-ippool" - } - `, -} - -var terraformNoPublicIpBadExamples = []string{ - ` - resource "opc_compute_ip_address_reservation" "bad_example" { - name = "my-ip-address" - ip_address_pool = "public-ippool" - } - `, -} - -var terraformNoPublicIpLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/opc/latest/docs/resources/opc_compute_ip_address_reservation`, `https://registry.terraform.io/providers/hashicorp/opc/latest/docs/resources/opc_compute_instance`, -} - -var terraformNoPublicIpRemediationMarkdown = `` diff --git a/checks/kubernetes/network/no_public_egress.go b/checks/kubernetes/network/no_public_egress.go deleted file mode 100755 index 1dc735a8..00000000 --- a/checks/kubernetes/network/no_public_egress.go +++ /dev/null @@ -1,50 +0,0 @@ -package network - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicEgress = rules.Register( - scan.Rule{ - AVDID: "AVD-KUBE-0002", - Provider: providers.KubernetesProvider, - Service: "network", - ShortCode: "no-public-egress", - Summary: "Public egress should not be allowed via network policies", - Impact: "Exfiltration of data to the public internet", - Resolution: "Remove public access except where explicitly required", - Explanation: `You should not expose infrastructure to the public internet except where explicitly required`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicEgressGoodExamples, - BadExamples: terraformNoPublicEgressBadExamples, - Links: terraformNoPublicEgressLinks, - RemediationMarkdown: terraformNoPublicEgressRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, policy := range s.Kubernetes.NetworkPolicies { - if policy.Metadata.IsUnmanaged() { - continue - } - for _, destination := range policy.Spec.Egress.DestinationCIDRs { - if cidr.IsPublic(destination.Value()) { - results.Add( - "Network policy allows egress to the public internet.", - destination, - ) - } else { - results.AddPassed(destination) - } - } - } - return - }, -) diff --git a/checks/kubernetes/network/no_public_egress.tf.go b/checks/kubernetes/network/no_public_egress.tf.go deleted file mode 100644 index 82f502aa..00000000 --- a/checks/kubernetes/network/no_public_egress.tf.go +++ /dev/null @@ -1,137 +0,0 @@ -package network - -var terraformNoPublicEgressGoodExamples = []string{ - ` - resource "kubernetes_network_policy" "good_example" { - metadata { - name = "terraform-example-network-policy" - namespace = "default" - } - - spec { - pod_selector { - match_expressions { - key = "name" - operator = "In" - values = ["webfront", "api"] - } - } - - egress { - ports { - port = "http" - protocol = "TCP" - } - ports { - port = "8125" - protocol = "UDP" - } - - to { - ip_block { - cidr = "10.0.0.0/16" - except = [ - "10.0.0.0/24", - "10.0.1.0/24", - ] - } - } - } - - ingress { - ports { - port = "http" - protocol = "TCP" - } - ports { - port = "8125" - protocol = "UDP" - } - - from { - ip_block { - cidr = "10.0.0.0/16" - except = [ - "10.0.0.0/24", - "10.0.1.0/24", - ] - } - } - } - - policy_types = ["Ingress", "Egress"] - } - } - `, -} - -var terraformNoPublicEgressBadExamples = []string{ - ` - resource "kubernetes_network_policy" "bad_example" { - metadata { - name = "terraform-example-network-policy" - namespace = "default" - } - - spec { - pod_selector { - match_expressions { - key = "name" - operator = "In" - values = ["webfront", "api"] - } - } - - egress { - ports { - port = "http" - protocol = "TCP" - } - ports { - port = "8125" - protocol = "UDP" - } - - to { - ip_block { - cidr = "0.0.0.0/0" - except = [ - "10.0.0.0/24", - "10.0.1.0/24", - ] - } - } - } - - ingress { - ports { - port = "http" - protocol = "TCP" - } - ports { - port = "8125" - protocol = "UDP" - } - - from { - ip_block { - cidr = "10.0.0.0/16" - except = [ - "10.0.0.0/24", - "10.0.1.0/24", - ] - } - } - } - - policy_types = ["Ingress", "Egress"] - } - } - `, -} - -var terraformNoPublicEgressLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/network_policy#spec.ingress.from.ip_block.cidr`, -} - -var terraformNoPublicEgressRemediationMarkdown = `` diff --git a/checks/kubernetes/network/no_public_ingress.go b/checks/kubernetes/network/no_public_ingress.go deleted file mode 100755 index 41d435b6..00000000 --- a/checks/kubernetes/network/no_public_ingress.go +++ /dev/null @@ -1,50 +0,0 @@ -package network - -import ( - "github.com/aquasecurity/trivy-checks/internal/cidr" - "github.com/aquasecurity/trivy-checks/pkg/rules" - "github.com/aquasecurity/trivy/pkg/iac/providers" - "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/severity" - "github.com/aquasecurity/trivy/pkg/iac/state" -) - -var CheckNoPublicIngress = rules.Register( - scan.Rule{ - AVDID: "AVD-KUBE-0001", - Provider: providers.KubernetesProvider, - Service: "network", - ShortCode: "no-public-ingress", - Summary: "Public ingress should not be allowed via network policies", - Impact: "Exposure of infrastructure to the public internet", - Resolution: "Remove public access except where explicitly required", - Explanation: `You should not expose infrastructure to the public internet except where explicitly required`, - Links: []string{}, - Terraform: &scan.EngineMetadata{ - GoodExamples: terraformNoPublicIngressGoodExamples, - BadExamples: terraformNoPublicIngressBadExamples, - Links: terraformNoPublicIngressLinks, - RemediationMarkdown: terraformNoPublicIngressRemediationMarkdown, - }, - Severity: severity.High, - Deprecated: true, - }, - func(s *state.State) (results scan.Results) { - for _, policy := range s.Kubernetes.NetworkPolicies { - if policy.Metadata.IsUnmanaged() { - continue - } - for _, source := range policy.Spec.Ingress.SourceCIDRs { - if cidr.IsPublic(source.Value()) { - results.Add( - "Network policy allows ingress from the public internet.", - source, - ) - } else { - results.AddPassed(source) - } - } - } - return - }, -) diff --git a/checks/kubernetes/network/no_public_ingress.tf.go b/checks/kubernetes/network/no_public_ingress.tf.go deleted file mode 100644 index 5e00dd99..00000000 --- a/checks/kubernetes/network/no_public_ingress.tf.go +++ /dev/null @@ -1,137 +0,0 @@ -package network - -var terraformNoPublicIngressGoodExamples = []string{ - ` - resource "kubernetes_network_policy" "good_example" { - metadata { - name = "terraform-example-network-policy" - namespace = "default" - } - - spec { - pod_selector { - match_expressions { - key = "name" - operator = "In" - values = ["webfront", "api"] - } - } - - ingress { - ports { - port = "http" - protocol = "TCP" - } - ports { - port = "8125" - protocol = "UDP" - } - - from { - ip_block { - cidr = "10.0.0.0/16" - except = [ - "10.0.0.0/24", - "10.0.1.0/24", - ] - } - } - } - - egress { - ports { - port = "http" - protocol = "TCP" - } - ports { - port = "8125" - protocol = "UDP" - } - - to { - ip_block { - cidr = "0.0.0.0/0" - except = [ - "10.0.0.0/24", - "10.0.1.0/24", - ] - } - } - } - - policy_types = ["Ingress", "Egress"] - } - } - `, -} - -var terraformNoPublicIngressBadExamples = []string{ - ` - resource "kubernetes_network_policy" "bad_example" { - metadata { - name = "terraform-example-network-policy" - namespace = "default" - } - - spec { - pod_selector { - match_expressions { - key = "name" - operator = "In" - values = ["webfront", "api"] - } - } - - ingress { - ports { - port = "http" - protocol = "TCP" - } - ports { - port = "8125" - protocol = "UDP" - } - - from { - ip_block { - cidr = "0.0.0.0/0" - except = [ - "10.0.0.0/24", - "10.0.1.0/24", - ] - } - } - } - - egress { - ports { - port = "http" - protocol = "TCP" - } - ports { - port = "8125" - protocol = "UDP" - } - - to { - ip_block { - cidr = "0.0.0.0/0" - except = [ - "10.0.0.0/24", - "10.0.1.0/24", - ] - } - } - } - - policy_types = ["Ingress", "Egress"] - } - } - `, -} - -var terraformNoPublicIngressLinks = []string{ - `https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/network_policy#spec.ingress.from.ip_block.cidr`, -} - -var terraformNoPublicIngressRemediationMarkdown = `` diff --git a/go.mod b/go.mod index c4dc9a15..8d0012ca 100644 --- a/go.mod +++ b/go.mod @@ -1,16 +1,16 @@ module github.com/aquasecurity/trivy-checks -go 1.22.1 +go 1.22.9 toolchain go1.23.0 require ( - github.com/aquasecurity/trivy v0.55.1-0.20240920045012-1f9fc13da4a1 + github.com/aquasecurity/trivy v0.57.1-0.20241127185709-c238c515b831 github.com/aws-cloudformation/rain v1.19.0 github.com/hashicorp/hcl/v2 v2.23.0 github.com/liamg/iamgo v0.0.9 github.com/liamg/memoryfs v1.6.0 - github.com/open-policy-agent/opa v0.67.1 + github.com/open-policy-agent/opa v0.70.0 github.com/owenrumney/squealer v1.2.5 github.com/samber/lo v1.47.0 github.com/stretchr/testify v1.10.0 @@ -20,12 +20,13 @@ require ( require ( dario.cat/mergo v1.0.1 // indirect - github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect + github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 // indirect + github.com/BurntSushi/toml v1.4.0 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/OneOfOne/xxhash v1.2.8 // indirect github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect github.com/agext/levenshtein v1.2.3 // indirect - github.com/agnivade/levenshtein v1.1.1 // indirect + github.com/agnivade/levenshtein v1.2.0 // indirect github.com/alecthomas/chroma v0.10.0 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -34,13 +35,13 @@ require ( github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chzyer/readline v1.5.1 // indirect - github.com/cloudflare/circl v1.3.7 // indirect - github.com/containerd/containerd v1.7.21 // indirect - github.com/containerd/errdefs v0.1.0 // indirect + github.com/cloudflare/circl v1.3.8 // indirect + github.com/containerd/containerd v1.7.23 // indirect + github.com/containerd/errdefs v1.0.0 // indirect github.com/containerd/log v0.1.0 // indirect - github.com/containerd/platforms v0.2.1 // indirect - github.com/containerd/typeurl/v2 v2.1.1 // indirect - github.com/cyphar/filepath-securejoin v0.2.5 // indirect + github.com/containerd/platforms v1.0.0-rc.0 // indirect + github.com/containerd/typeurl/v2 v2.2.2 // indirect + github.com/cyphar/filepath-securejoin v0.3.4 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dgraph-io/badger/v3 v3.2103.5 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect @@ -59,7 +60,7 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/gobwas/glob v0.2.3 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/glog v1.2.1 // indirect + github.com/golang/glog v1.2.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect @@ -69,11 +70,13 @@ require ( github.com/gookit/color v1.5.4 // indirect github.com/gorilla/mux v1.8.1 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/hcl v1.0.1-vault-5 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.17.9 // indirect + github.com/klauspost/compress v1.17.11 // indirect github.com/liamg/jfather v0.0.7 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect @@ -81,7 +84,7 @@ require ( github.com/mattn/go-runewidth v0.0.15 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/moby/buildkit v0.15.2 // indirect + github.com/moby/buildkit v0.17.2 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect github.com/moby/locker v1.0.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect @@ -89,12 +92,13 @@ require ( github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect - github.com/pelletier/go-toml/v2 v2.2.2 // indirect + github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/peterh/liner v1.2.2 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.20.1 // indirect + github.com/prometheus/client_golang v1.20.5 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect @@ -121,31 +125,31 @@ require ( github.com/yashtewari/glob-intersection v0.2.0 // indirect github.com/zclconf/go-cty v1.15.0 // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect - go.opentelemetry.io/otel v1.28.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 // indirect + go.opentelemetry.io/otel v1.31.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 // indirect - go.opentelemetry.io/otel/metric v1.28.0 // indirect - go.opentelemetry.io/otel/sdk v1.28.0 // indirect - go.opentelemetry.io/otel/trace v1.28.0 // indirect + go.opentelemetry.io/otel/metric v1.31.0 // indirect + go.opentelemetry.io/otel/sdk v1.31.0 // indirect + go.opentelemetry.io/otel/trace v1.31.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/automaxprocs v1.5.3 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.28.0 // indirect + golang.org/x/crypto v0.29.0 // indirect golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect - golang.org/x/mod v0.21.0 // indirect - golang.org/x/net v0.30.0 // indirect - golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/term v0.25.0 // indirect - golang.org/x/text v0.19.0 // indirect - golang.org/x/time v0.6.0 // indirect + golang.org/x/mod v0.22.0 // indirect + golang.org/x/net v0.31.0 // indirect + golang.org/x/sync v0.9.0 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/term v0.26.0 // indirect + golang.org/x/text v0.20.0 // indirect + golang.org/x/time v0.7.0 // indirect golang.org/x/tools v0.26.0 // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect - google.golang.org/grpc v1.65.0 // indirect - google.golang.org/protobuf v1.34.2 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect + google.golang.org/grpc v1.67.1 // indirect + google.golang.org/protobuf v1.35.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 865bdca1..9996ad24 100644 --- a/go.sum +++ b/go.sum @@ -1,16 +1,18 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= -github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= -github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 h1:He8afgbRMd7mFxO99hRNu+6tazq8nFF9lIwo9JFroBk= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= +github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/Microsoft/hcsshim v0.12.0 h1:rbICA+XZFwrBef2Odk++0LjFvClNCJGRK+fsrP254Ts= -github.com/Microsoft/hcsshim v0.12.0/go.mod h1:RZV12pcHCXQ42XnlQ3pz6FZfmrC1C+R4gaOHhRNML1g= +github.com/Microsoft/hcsshim v0.12.9 h1:2zJy5KA+l0loz1HzEGqyNnjd3fyZA31ZBCGKacp6lLg= +github.com/Microsoft/hcsshim v0.12.9/go.mod h1:fJ0gkFAna6ukt0bLdKB8djt4XIJhF/vEPuoIWYVvZ8Y= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8= github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= @@ -18,16 +20,16 @@ github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97 github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= -github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= +github.com/agnivade/levenshtein v1.2.0 h1:U9L4IOT0Y3i0TIlUIDJ7rVUziKi/zPbrJGaFrtYH3SY= +github.com/agnivade/levenshtein v1.2.0/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU= github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek= github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= -github.com/aquasecurity/trivy v0.55.1-0.20240920045012-1f9fc13da4a1 h1:73LIE4lUNO9QBo65hsWaTam85wAySri2mlQIza6fZXk= -github.com/aquasecurity/trivy v0.55.1-0.20240920045012-1f9fc13da4a1/go.mod h1:Q/GQxnF41AI1oeeo68n18HFRn11Mkji5T8oZjQfbNk8= +github.com/aquasecurity/trivy v0.57.1-0.20241127185709-c238c515b831 h1:Ol9LT6V3KXCwaJE6lyeOR+3NGgDyA0HOXvPtumz/dxA= +github.com/aquasecurity/trivy v0.57.1-0.20241127185709-c238c515b831/go.mod h1:fURPZjqUDH08tYy/2EhU4k0uAOzXcPAJeM2O0Z6k0nU= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= @@ -54,33 +56,35 @@ github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObk github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04= github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= -github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= +github.com/cloudflare/circl v1.3.8 h1:j+V8jJt09PoeMFIu2uh5JUyEaIHTXVOHslFoLNAKqwI= +github.com/cloudflare/circl v1.3.8/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= -github.com/containerd/cgroups/v3 v3.0.2 h1:f5WFqIVSgo5IZmtTT3qVBo6TzI1ON6sycSBKkymb9L0= -github.com/containerd/cgroups/v3 v3.0.2/go.mod h1:JUgITrzdFqp42uI2ryGA+ge0ap/nxzYgkGmIcetmErE= -github.com/containerd/containerd v1.7.21 h1:USGXRK1eOC/SX0L195YgxTHb0a00anxajOzgfN0qrCA= -github.com/containerd/containerd v1.7.21/go.mod h1:e3Jz1rYRUZ2Lt51YrH9Rz0zPyJBOlSvB3ghr2jbVD8g= -github.com/containerd/continuity v0.4.3 h1:6HVkalIp+2u1ZLH1J/pYX2oBVXlJZvh1X1A7bEZ9Su8= -github.com/containerd/continuity v0.4.3/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= -github.com/containerd/errdefs v0.1.0 h1:m0wCRBiu1WJT/Fr+iOoQHMQS/eP5myQ8lCv4Dz5ZURM= -github.com/containerd/errdefs v0.1.0/go.mod h1:YgWiiHtLmSeBrvpw+UfPijzbLaB77mEG1WwJTDETIV0= +github.com/containerd/cgroups/v3 v3.0.3 h1:S5ByHZ/h9PMe5IOQoN7E+nMc2UcLEM/V48DGDJ9kip0= +github.com/containerd/cgroups/v3 v3.0.3/go.mod h1:8HBe7V3aWGLFPd/k03swSIsGjZhHI2WzJmticMgVuz0= +github.com/containerd/containerd v1.7.23 h1:H2CClyUkmpKAGlhQp95g2WXHfLYc7whAuvZGBNYOOwQ= +github.com/containerd/containerd v1.7.23/go.mod h1:7QUzfURqZWCZV7RLNEn1XjUCQLEf0bkaK4GjUaZehxw= +github.com/containerd/continuity v0.4.4 h1:/fNVfTJ7wIl/YPMHjf+5H32uFhl63JucB34PlCpMKII= +github.com/containerd/continuity v0.4.4/go.mod h1:/lNJvtJKUQStBzpVQ1+rasXO1LAWtUQssk28EZvJ3nE= +github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= +github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= +github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= +github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= -github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A= -github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw= -github.com/containerd/typeurl/v2 v2.1.1 h1:3Q4Pt7i8nYwy2KmQWIw2+1hTvwTE/6w9FqcttATPO/4= -github.com/containerd/typeurl/v2 v2.1.1/go.mod h1:IDp2JFvbwZ31H8dQbEIY7sDl2L3o3HZj1hsSQlywkQ0= +github.com/containerd/platforms v1.0.0-rc.0 h1:GuHWSKgVVO3POn6nRBB4sH63uPOLa87yuuhsGLWaXAA= +github.com/containerd/platforms v1.0.0-rc.0/go.mod h1:T1XAzzOdYs3it7l073MNXyxRwQofJfqwi/8cRjufIk4= +github.com/containerd/typeurl/v2 v2.2.2 h1:3jN/k2ysKuPCsln5Qv8bzR9cxal8XjkxPogJfSNO31k= +github.com/containerd/typeurl/v2 v2.2.2/go.mod h1:95ljDnPfD3bAbDJRugOiShd/DlAAsxGtUBhJxIn7SCk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= -github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= +github.com/cpuguy83/dockercfg v0.3.2 h1:DlJTyZGBDlXqUZ2Dk2Q3xHs/FtnooJJVaad2S9GKorA= +github.com/cpuguy83/dockercfg v0.3.2/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/cyphar/filepath-securejoin v0.2.5 h1:6iR5tXJ/e6tJZzzdMc1km3Sa7RRIVBKAK32O2s7AYfo= -github.com/cyphar/filepath-securejoin v0.2.5/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= +github.com/cyphar/filepath-securejoin v0.3.4 h1:VBWugsJh2ZxJmLFSM06/0qzQyiQX2Qs0ViKrUAcqdZ8= +github.com/cyphar/filepath-securejoin v0.3.4/go.mod h1:8s/MCNJREmFK0H02MF6Ihv1nakJe4L/w3WZLHNkvlYM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -92,14 +96,14 @@ github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkz github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g= -github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= +github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54 h1:SG7nF6SRlWhcT7cNTs5R6Hk4V2lcmLz2NsG2VnInyNo= +github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E= github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= -github.com/docker/docker v27.2.0+incompatible h1:Rk9nIVdfH3+Vz4cyI/uhbINhEZ/oLmc+CBXmH6fbNk4= -github.com/docker/docker v27.2.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.3.1+incompatible h1:KttF0XoteNTicmUtBO0L2tP+J7FGRFTjaEF4k6WdhfI= +github.com/docker/docker v27.3.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -156,8 +160,8 @@ github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJA github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4= -github.com/golang/glog v1.2.1/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= +github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= @@ -173,7 +177,6 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -189,7 +192,6 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -202,6 +204,11 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= +github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= +github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl v1.0.1-vault-5 h1:kI3hhbbyzr4dldA8UdTb7ZlVVlI2DACdCfz31RPDgJM= github.com/hashicorp/hcl v1.0.1-vault-5/go.mod h1:XYhtn6ijBSAj6n4YqAaf7RBPS4I06AItNorpy+MoQNM= @@ -217,8 +224,8 @@ github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= +github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -256,18 +263,18 @@ github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTS github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/moby/buildkit v0.15.2 h1:DnONr0AoceTWyv+plsQ7IhkSaj+6o0WyoaxYPyTFIxs= -github.com/moby/buildkit v0.15.2/go.mod h1:Yis8ZMUJTHX9XhH9zVyK2igqSHV3sxi3UN0uztZocZk= +github.com/moby/buildkit v0.17.2 h1:/jgk/MuXbA7jeXMkknOpHYB+Ct4aNvQHkBB7SxD3D4U= +github.com/moby/buildkit v0.17.2/go.mod h1:vr5vltV8wt4F2jThbNOChfbAklJ0DOW11w36v210hOg= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= -github.com/moby/sys/mountinfo v0.7.1 h1:/tTvQaSJRr2FshkhXiIpux6fQ2Zvc4j7tAhMTStAG2g= -github.com/moby/sys/mountinfo v0.7.1/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI= -github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc= -github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo= +github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9KouLrg= +github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4= +github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7zgvCU= +github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiTWd+lL+7b/Ko= github.com/moby/sys/user v0.3.0 h1:9ni5DlcW5an3SvRSx4MouotOygvzaXbaSrc/wGDFWPo= github.com/moby/sys/user v0.3.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs= github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g= @@ -293,14 +300,16 @@ github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2sz github.com/owenrumney/squealer v1.2.5 h1:zxaDuYTTwqyOlh6koqE57SZ1TdKX06Khu3HSofFMi7M= github.com/owenrumney/squealer v1.2.5/go.mod h1:lTHxnEfjl8y3QIQpoawfl/Bpe9A7SYKptgKSNtzkHOw= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= -github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= +github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= github.com/peterh/liner v1.2.2 h1:aJ4AOodmL+JxOZZEL2u9iJf8omNRpqHc/EbrK+3mAXw= github.com/peterh/liner v1.2.2/go.mod h1:xFwJyiKIXJZUKItq5dGHZSTBRAuG/CpeNpWLyiNRNwI= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= +github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -308,8 +317,8 @@ github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= -github.com/prometheus/client_golang v1.20.1 h1:IMJXHOD6eARkQpxo8KkhgEVFlBNm+nkrFUyGlIu7Na8= -github.com/prometheus/client_golang v1.20.1/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y= +github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= @@ -367,25 +376,22 @@ github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/tchap/go-patricia/v2 v2.3.1 h1:6rQp39lgIYZ+MHmdEq4xzuk1t7OdC35z/xm0BGhTkes= github.com/tchap/go-patricia/v2 v2.3.1/go.mod h1:VZRHKAb53DLaG+nA9EaYYiaEx6YztwDlLElMsnSHD4k= -github.com/testcontainers/testcontainers-go v0.33.0 h1:zJS9PfXYT5O0ZFXM2xxXfk4J5UMw/kRiISng037Gxdw= -github.com/testcontainers/testcontainers-go v0.33.0/go.mod h1:W80YpTa8D5C3Yy16icheD01UTDu+LmXIA2Keo+jWtT8= -github.com/testcontainers/testcontainers-go/modules/localstack v0.33.0 h1:AhbUGUjneEnMyTV5aTsPYzDiAWrba1duPtiV+Z9CKdY= -github.com/testcontainers/testcontainers-go/modules/localstack v0.33.0/go.mod h1:J5vMq1fXXiTfwcJplMClHhn+j8+MbIMv7Lic4d9E8qU= +github.com/testcontainers/testcontainers-go v0.34.0 h1:5fbgF0vIN5u+nD3IWabQwRybuB4GY8G2HHgCkbMzMHo= +github.com/testcontainers/testcontainers-go v0.34.0/go.mod h1:6P/kMkQe8yqPHfPWNulFGdFHTD8HB2vLq/231xY2iPQ= +github.com/testcontainers/testcontainers-go/modules/localstack v0.34.0 h1:WkjVmea0XQyGTY10Er8fOsVjHQ77iJCmTExnx6fC3Tw= +github.com/testcontainers/testcontainers-go/modules/localstack v0.34.0/go.mod h1:rTo76O/BBeAtfazMQqLvfwBrntBBwDP7/+Z60dm3e9U= github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08lq3r4= github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0= github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr4= @@ -415,20 +421,20 @@ github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmB go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 h1:4K4tsIXefpVJtvA/8srF4V4y0akAoPHkIslgAkjixJA= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0/go.mod h1:jjdQuTGVsXV4vSs+CJ2qYDeDPf9yIJV23qlIzBm73Vg= -go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= -go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 h1:UP6IpuHFkUgOQL9FFQFrZ+5LiwhhYRbi7VZSIx6Nj5s= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0/go.mod h1:qxuZLtbq5QDtdeSHsS7bcf6EH6uO6jUAgk764zd3rhM= +go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= +go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 h1:3Q/xZUyC1BBkualc9ROb4G8qkH90LXEIICcs5zv1OYY= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0/go.mod h1:s75jGIWA9OfCMzF0xr+ZgfrB5FEbbV7UuYo32ahUiFI= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 h1:R3X6ZXmNPRR8ul6i3WgFURCHzaXjHdm0karRG/+dj3s= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0/go.mod h1:QWFXnDavXWwMx2EEcZsf3yxgEKAqsxQ+Syjp+seyInw= -go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= -go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= -go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= -go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= -go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= -go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE= +go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY= +go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk= +go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0= +go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys= +go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A= go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8= @@ -442,8 +448,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= +golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= +golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY= golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8= @@ -452,8 +458,8 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= -golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= +golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -464,8 +470,8 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= +golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -473,8 +479,8 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -492,18 +498,18 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= +golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= -golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= +golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= +golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -526,18 +532,18 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 h1:0+ozOGcrp+Y8Aq8TLNN2Aliibms5LEzsq99ZZmAGYm0= -google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094/go.mod h1:fJ/e3If/Q67Mj99hin0hMhiNyCRmt6BQ2aWIJshUSJw= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 h1:BwIjyKYGsK9dMCBOorzRri8MQwmi7mT9rGHsCEinZkA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 h1:T6rh4haD3GVYsgEfWExoCZA2o2FmbNyKpTuAxbEFPTg= +google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9/go.mod h1:wp2WsuBYj6j8wUdo3ToZsdxxixbvQNAHqVJrTgi5E5M= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 h1:zciRKQ4kBpFgpfC5QQCVtnnNAcLIqweL7plyZRQHVpI= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= -google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -547,10 +553,8 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= +google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/test/rego/aws_ecs_test.go b/test/rego/aws_ecs_test.go index 80903553..ad9ebf2a 100644 --- a/test/rego/aws_ecs_test.go +++ b/test/rego/aws_ecs_test.go @@ -129,8 +129,8 @@ var awsEcsTestCases = testCases{ Metadata: trivyTypes.NewTestMetadata(), Name: trivyTypes.String("my_service", trivyTypes.NewTestMetadata()), Image: trivyTypes.String("my_image", trivyTypes.NewTestMetadata()), - CPU: trivyTypes.Int(2, trivyTypes.NewTestMetadata()), - Memory: trivyTypes.Int(256, trivyTypes.NewTestMetadata()), + CPU: trivyTypes.String("2", trivyTypes.NewTestMetadata()), + Memory: trivyTypes.String("256", trivyTypes.NewTestMetadata()), Essential: trivyTypes.Bool(true, trivyTypes.NewTestMetadata()), Environment: []ecs.EnvVar{ { diff --git a/test/rego/rego_checks_test.go b/test/rego/rego_checks_test.go index df8311b0..1d34ba04 100644 --- a/test/rego/rego_checks_test.go +++ b/test/rego/rego_checks_test.go @@ -9,7 +9,6 @@ import ( "github.com/aquasecurity/trivy/pkg/iac/rego" "github.com/aquasecurity/trivy/pkg/iac/rules" "github.com/aquasecurity/trivy/pkg/iac/scan" - "github.com/aquasecurity/trivy/pkg/iac/scanners/options" "github.com/aquasecurity/trivy/pkg/iac/state" trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types" ruleTypes "github.com/aquasecurity/trivy/pkg/iac/types/rules" @@ -35,7 +34,7 @@ func addTests(tc testCases) { func TestRegoChecks(t *testing.T) { regoScanner := rego.NewScanner( trivyTypes.SourceCloud, - options.ScannerWithFrameworks(framework.CIS_AWS_1_2, framework.CIS_AWS_1_4, framework.Default), + rego.WithFrameworks(framework.CIS_AWS_1_2, framework.CIS_AWS_1_4, framework.Default), rego.WithPolicyDirs("."), rego.WithEmbeddedLibraries(true), )