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

Method getECSEnvironmentVariablesPerRegion

aws/env-vars.go:335–374  ·  view source on GitHub ↗
(region string, wg *sync.WaitGroup, semaphore chan struct{}, dataReceiver chan EnvironmentVariable)

Source from the content-addressed store, hash-verified

333}
334
335func (m *EnvsModule) getECSEnvironmentVariablesPerRegion(region string, wg *sync.WaitGroup, semaphore chan struct{}, dataReceiver chan EnvironmentVariable) {
336 defer func() {
337 m.CommandCounter.DecrExecuting()
338 m.CommandCounter.IncrComplete()
339 wg.Done()
340
341 }()
342 semaphore <- struct{}{}
343 defer func() {
344 <-semaphore
345 }()
346 // m.CommandCounter.IncrTotal()
347 m.CommandCounter.DecrPending()
348 m.CommandCounter.IncrExecuting()
349 // "PaginationMarker" is a control variable used for output continuity, as AWS return the output in pages.
350 //var PaginationMarker *string
351
352 // This new approach takes one active task from each task family and grabs the container envs from that. Ran into a case where every version
353 // of a task was listed as active and it brought cloudfox to a halt for a really long time.
354 for _, familyName := range m.getTaskDefinitionFamilies(region) {
355
356 DescribeTaskDefinition, err := m.ECSClient.DescribeTaskDefinition(
357 context.TODO(),
358 &ecs.DescribeTaskDefinitionInput{
359 TaskDefinition: &familyName,
360 },
361 func(o *ecs.Options) {
362 o.Region = region
363 },
364 )
365 if err != nil {
366 m.modLog.Error(err.Error())
367 m.CommandCounter.IncrError()
368 break
369 }
370 for _, containerDefinition := range DescribeTaskDefinition.TaskDefinition.ContainerDefinitions {
371 m.getECSEnvironmentVariablesPerDefinition(*DescribeTaskDefinition.TaskDefinition, containerDefinition, region, dataReceiver)
372 }
373 }
374}
375
376func (m *EnvsModule) getTaskDefinitionFamilies(region string) []string {
377 var allFamilyNames []string

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