github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/oracle/compute/no_public_ip.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 CheckNoPublicIp = rules.Register( 12 scan.Rule{ 13 AVDID: "AVD-OCI-0001", 14 Provider: providers.OracleProvider, 15 Service: "compute", 16 ShortCode: "no-public-ip", 17 Summary: "Compute instance requests an IP reservation from a public pool", 18 Impact: "The compute instance has the ability to be reached from outside", 19 Resolution: "Reconsider the use of an public IP", 20 Explanation: `Compute instance requests an IP reservation from a public pool 21 22 The compute instance has the ability to be reached from outside, you might want to sonder the use of a non public IP.`, 23 Links: []string{}, 24 Terraform: &scan.EngineMetadata{ 25 GoodExamples: terraformNoPublicIpGoodExamples, 26 BadExamples: terraformNoPublicIpBadExamples, 27 Links: terraformNoPublicIpLinks, 28 RemediationMarkdown: terraformNoPublicIpRemediationMarkdown, 29 }, 30 Severity: severity.Critical, 31 }, 32 func(s *state.State) (results scan.Results) { 33 for _, reservation := range s.Oracle.Compute.AddressReservations { 34 if reservation.Metadata.IsUnmanaged() { 35 continue 36 } 37 if reservation.Pool.EqualTo("public-ippool") { // TODO: future improvement: we need to see what this IP is used for before flagging 38 results.Add( 39 "Reservation made for public IP address.", 40 reservation.Pool, 41 ) 42 } else { 43 results.AddPassed(reservation) 44 } 45 } 46 return 47 }, 48 )