github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/google/compute/enable_shielded_vm_sb.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 CheckEnableShieldedVMSecureBoot = rules.Register(
    12  	scan.Rule{
    13  		AVDID:       "AVD-GCP-0067",
    14  		Provider:    providers.GoogleProvider,
    15  		Service:     "compute",
    16  		ShortCode:   "enable-shielded-vm-sb",
    17  		Summary:     "Instances should have Shielded VM secure boot enabled",
    18  		Impact:      "Unable to verify digital signature of boot components, and unable to stop the boot process if verificaiton fails.",
    19  		Resolution:  "Enable Shielded VM secure boot",
    20  		Explanation: `Secure boot helps ensure that the system only runs authentic software.`,
    21  		Links: []string{
    22  			"https://cloud.google.com/security/shielded-cloud/shielded-vm#secure-boot",
    23  		},
    24  		Terraform: &scan.EngineMetadata{
    25  			GoodExamples:        terraformEnableShieldedVmSbGoodExamples,
    26  			BadExamples:         terraformEnableShieldedVmSbBadExamples,
    27  			Links:               terraformEnableShieldedVmSbLinks,
    28  			RemediationMarkdown: terraformEnableShieldedVmSbRemediationMarkdown,
    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.SecureBootEnabled.IsFalse() {
    38  				results.Add(
    39  					"Instance does not have shielded VM secure boot enabled.",
    40  					instance.ShieldedVM.SecureBootEnabled,
    41  				)
    42  			} else {
    43  				results.AddPassed(&instance)
    44  			}
    45  		}
    46  		return
    47  	},
    48  )