MCPcopy Create free account
hub / github.com/BishopFox/cloudfox / getOpenSearchPerRegion

Method getOpenSearchPerRegion

aws/endpoints.go:612–696  ·  view source on GitHub ↗
(r string, wg *sync.WaitGroup, semaphore chan struct{}, dataReceiver chan Endpoint)

Source from the content-addressed store, hash-verified

610}
611
612func (m *EndpointsModule) getOpenSearchPerRegion(r string, wg *sync.WaitGroup, semaphore chan struct{}, dataReceiver chan Endpoint) {
613 defer func() {
614 m.CommandCounter.DecrExecuting()
615 m.CommandCounter.IncrComplete()
616 wg.Done()
617
618 }()
619 semaphore <- struct{}{}
620 defer func() {
621 <-semaphore
622 }()
623 // m.CommandCounter.IncrTotal()
624 m.CommandCounter.DecrPending()
625 m.CommandCounter.IncrExecuting()
626
627 DomainNames, err := sdk.CachedOpenSearchListDomainNames(m.OpenSearchClient, aws.ToString(m.Caller.Account), r)
628 if err != nil {
629 m.modLog.Error(err.Error())
630 m.CommandCounter.IncrError()
631 return
632 }
633
634 for _, domainName := range DomainNames {
635 name := aws.ToString(domainName.DomainName)
636
637 DomainStatus, err := sdk.CachedOpenSearchDescribeDomain(m.OpenSearchClient, aws.ToString(m.Caller.Account), r, name)
638
639 if err != nil {
640 if errors.As(err, &oe) {
641 m.Errors = append(m.Errors, fmt.Sprintf(" Error: Region: %s, Service: %s, Operation: %s", r, oe.Service(), oe.Operation()))
642 }
643 m.modLog.Error(err.Error())
644 m.CommandCounter.IncrError()
645 return
646 }
647
648 rawEndpoint := DomainStatus.Endpoint
649 var endpoint string
650 var kibanaEndpoint string
651
652 // This exits the function if an opensearch domain exists but there is no endpoint
653 if rawEndpoint == nil {
654 return
655 } else {
656 endpoint = fmt.Sprintf("https://%s", aws.ToString(rawEndpoint))
657 kibanaEndpoint = fmt.Sprintf("https://%s/_plugin/kibana/", aws.ToString(rawEndpoint))
658 }
659
660 //fmt.Println(endpoint)
661
662 public := "Unknown"
663 domainConfig, err := sdk.CachedOpenSearchDescribeDomainConfig(m.OpenSearchClient, aws.ToString(m.Caller.Account), r, name)
664 if err != nil {
665 m.modLog.Error(err.Error())
666 m.CommandCounter.IncrError()
667 return
668 }
669 if aws.ToBool(domainConfig.AdvancedSecurityOptions.Options.Enabled) {

Callers 1

executeChecksMethod · 0.95

Calls 9

DecrExecutingMethod · 0.80
IncrCompleteMethod · 0.80
DecrPendingMethod · 0.80
IncrExecutingMethod · 0.80
ErrorMethod · 0.80
IncrErrorMethod · 0.80

Tested by

no test coverage detected