-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from nikpivkin/fix/change-aws-0078-r
fix(rule): restate the AVD-AWS-0078 rule
- Loading branch information
Showing
5 changed files
with
87 additions
and
93 deletions.
There are no files selected for viewing
76 changes: 0 additions & 76 deletions
76
rules/cloud/policies/aws/rds/enable_performance_insights_encryption.go
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
rules/cloud/policies/aws/rds/performance_insights_encryption_customer_key.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package rds | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/aquasecurity/defsec/pkg/providers" | ||
"github.com/aquasecurity/defsec/pkg/providers/aws/rds" | ||
"github.com/aquasecurity/defsec/pkg/scan" | ||
"github.com/aquasecurity/defsec/pkg/severity" | ||
"github.com/aquasecurity/defsec/pkg/state" | ||
|
||
"github.com/aquasecurity/trivy-policies/pkg/rules" | ||
) | ||
|
||
var CheckPerformanceInsightsEncryptionCustomerKey = rules.Register( | ||
scan.Rule{ | ||
AVDID: "AVD-AWS-0078", | ||
Provider: providers.AWSProvider, | ||
Service: "rds", | ||
ShortCode: "performance-insights-encryption-customer-key", | ||
Summary: "Performance Insights encryption should use Customer Managed Keys", | ||
Impact: "Using AWS managed keys does not allow for fine grained control", | ||
Resolution: "Use Customer Managed Keys to encrypt Performance Insights data", | ||
Explanation: `Amazon RDS uses the AWS managed key for your new DB instance. For complete control over KMS keys, including establishing and maintaining their key policies, IAM policies, and grants, enabling and disabling them, and rotating their cryptographic material, use a customer managed keys. | ||
The encryption key specified in ` + "`" + `performance_insights_kms_key_id` + "`" + ` references a KMS ARN`, | ||
Links: []string{ | ||
"https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PerfInsights.access-control.html#USER_PerfInsights.access-control.cmk-policy", | ||
"https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-mgmt", | ||
}, | ||
Terraform: &scan.EngineMetadata{ | ||
GoodExamples: terraformPerformanceInsightsEncryptionCustomerKeyGoodExamples, | ||
BadExamples: terraformPerformanceInsightsEncryptionCustomerKeyBadExamples, | ||
Links: terraformPerformanceInsightsEncryptionCustomerKeyLinks, | ||
RemediationMarkdown: terraformPerformanceInsightsEncryptionCustomerKeyRemediationMarkdown, | ||
}, | ||
CloudFormation: &scan.EngineMetadata{ | ||
GoodExamples: cloudFormationPerformanceInsightsEncryptionCustomerKeyGoodExamples, | ||
BadExamples: cloudFormationPerformanceInsightsEncryptionCustomerKeyBadExamples, | ||
Links: cloudFormationPerformanceInsightsEncryptionCustomerKeyLinks, | ||
RemediationMarkdown: cloudFormationPerformanceInsightsEncryptionCustomerKeyRemediationMarkdown, | ||
}, | ||
Severity: severity.Low, | ||
}, | ||
func(s *state.State) (results scan.Results) { | ||
|
||
checkCMK := func(entity string, instance rds.Instance) { | ||
if instance.Metadata.IsUnmanaged() || instance.PerformanceInsights.Enabled.IsFalse() { | ||
return | ||
} | ||
|
||
if instance.PerformanceInsights.KMSKeyID.IsEmpty() { | ||
results.Add( | ||
fmt.Sprintf("%s Perfomance Insights enctyption does not use a customer-managed KMS key.", entity), | ||
instance.PerformanceInsights.KMSKeyID, | ||
) | ||
} else { | ||
results.AddPassed(&instance) | ||
} | ||
} | ||
|
||
for _, cluster := range s.AWS.RDS.Clusters { | ||
for _, instance := range cluster.Instances { | ||
checkCMK("Cluster instance", instance.Instance) | ||
} | ||
} | ||
for _, instance := range s.AWS.RDS.Instances { | ||
checkCMK("Instance", instance) | ||
} | ||
|
||
return | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters