github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/google/compute/enable_shielded_vm_im.go (about) 1 package compute 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 CheckEnableShieldedVMIntegrityMonitoring = rules.Register( 12 scan.Rule{ 13 AVDID: "AVD-GCP-0045", 14 Provider: providers.GoogleProvider, 15 Service: "compute", 16 ShortCode: "enable-shielded-vm-im", 17 Summary: "Instances should have Shielded VM integrity monitoring enabled", 18 Impact: "No visibility of VM instance boot state.", 19 Resolution: "Enable Shielded VM Integrity Monitoring", 20 Explanation: `Integrity monitoring helps you understand and make decisions about the state of your VM instances.`, 21 Links: []string{ 22 "https://cloud.google.com/security/shielded-cloud/shielded-vm#integrity-monitoring", 23 }, 24 Terraform: &scan.EngineMetadata{ 25 GoodExamples: terraformEnableShieldedVmImGoodExamples, 26 BadExamples: terraformEnableShieldedVmImBadExamples, 27 Links: terraformEnableShieldedVmImLinks, 28 RemediationMarkdown: terraformEnableShieldedVmImRemediationMarkdown, 29 }, 30 Severity: severity.Medium, 31 }, 32 func(s *state.State) (results scan.Results) { 33 for _, instance := range s.Google.Compute.Instances { 34 if instance.Metadata.IsUnmanaged() { 35 continue 36 } 37 if instance.ShieldedVM.IntegrityMonitoringEnabled.IsFalse() { 38 results.Add( 39 "Instance does not have shielded VM integrity monitoring enabled.", 40 instance.ShieldedVM.IntegrityMonitoringEnabled, 41 ) 42 } else { 43 results.AddPassed(&instance) 44 } 45 } 46 return 47 }, 48 )