github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/digitalocean/spaces/versioning_enabled.go (about) 1 package spaces 2 3 import ( 4 "github.com/khulnasoft-lab/defsec/internal/rules" 5 "github.com/khulnasoft-lab/defsec/pkg/providers" 6 "github.com/khulnasoft-lab/defsec/pkg/scan" 7 "github.com/khulnasoft-lab/defsec/pkg/severity" 8 "github.com/khulnasoft-lab/defsec/pkg/state" 9 ) 10 11 var CheckVersioningEnabled = rules.Register( 12 scan.Rule{ 13 AVDID: "AVD-DIG-0007", 14 Provider: providers.DigitalOceanProvider, 15 Service: "spaces", 16 ShortCode: "versioning-enabled", 17 Summary: "Spaces buckets should have versioning enabled", 18 Impact: "Deleted or modified data would not be recoverable", 19 Resolution: "Enable versioning to protect against accidental or malicious removal or modification", 20 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.`, 21 Links: []string{ 22 "https://docs.aws.amazon.com/AmazonS3/latest/userguide/Versioning.html", 23 }, 24 Terraform: &scan.EngineMetadata{ 25 GoodExamples: terraformVersioningEnabledGoodExamples, 26 BadExamples: terraformVersioningEnabledBadExamples, 27 Links: terraformVersioningEnabledLinks, 28 RemediationMarkdown: terraformVersioningEnabledRemediationMarkdown, 29 }, 30 Severity: severity.Medium, 31 }, 32 func(s *state.State) (results scan.Results) { 33 for _, bucket := range s.DigitalOcean.Spaces.Buckets { 34 if bucket.Metadata.IsUnmanaged() { 35 continue 36 } 37 if bucket.Versioning.Enabled.IsFalse() { 38 results.Add( 39 "Bucket does not have versioning enabled.", 40 bucket.Versioning.Enabled, 41 ) 42 } else { 43 results.AddPassed(&bucket) 44 } 45 } 46 return 47 }, 48 )