| 52 | } |
| 53 | |
| 54 | func (m *CodeBuildModule) PrintCodeBuildProjects(outputDirectory string, verbosity int) { |
| 55 | // These struct values are used by the output module |
| 56 | m.output.Verbosity = verbosity |
| 57 | m.output.Directory = outputDirectory |
| 58 | m.output.CallingModule = "codebuild" |
| 59 | localAdminMap := make(map[string]bool) |
| 60 | |
| 61 | m.modLog = internal.TxtLog.WithFields(logrus.Fields{ |
| 62 | "module": m.output.CallingModule, |
| 63 | }) |
| 64 | if m.AWSProfile == "" { |
| 65 | m.AWSProfile = internal.BuildAWSPath(m.Caller) |
| 66 | } |
| 67 | |
| 68 | fmt.Printf("[%s][%s] Enumerating CodeBuild projects for account %s.\n", cyan(m.output.CallingModule), cyan(m.AWSProfile), aws.ToString(m.Caller.Account)) |
| 69 | m.pmapperMod, m.pmapperError = InitPmapperGraph(m.Caller, m.AWSProfile, m.Goroutines, m.PmapperDataBasePath) |
| 70 | m.iamSimClient = InitIamCommandClient(m.IAMClient, m.Caller, m.AWSProfile, m.Goroutines) |
| 71 | |
| 72 | wg := new(sync.WaitGroup) |
| 73 | semaphore := make(chan struct{}, m.Goroutines) |
| 74 | |
| 75 | // Create a channel to signal the spinner aka task status goroutine to finish |
| 76 | spinnerDone := make(chan bool) |
| 77 | //fire up the the task status spinner/updated |
| 78 | go internal.SpinUntil(m.output.CallingModule, &m.CommandCounter, spinnerDone, "regions") |
| 79 | |
| 80 | //create a channel to receive the objects |
| 81 | dataReceiver := make(chan Project) |
| 82 | |
| 83 | // Create a channel to signal to stop |
| 84 | receiverDone := make(chan bool) |
| 85 | |
| 86 | go m.Receiver(dataReceiver, receiverDone) |
| 87 | |
| 88 | for _, region := range m.AWSRegions { |
| 89 | wg.Add(1) |
| 90 | m.CommandCounter.IncrPending() |
| 91 | go m.executeChecks(region, wg, semaphore, dataReceiver) |
| 92 | |
| 93 | } |
| 94 | |
| 95 | wg.Wait() |
| 96 | |
| 97 | // Send a message to the spinner goroutine to close the channel and stop |
| 98 | spinnerDone <- true |
| 99 | <-spinnerDone |
| 100 | receiverDone <- true |
| 101 | <-receiverDone |
| 102 | |
| 103 | // Perform role analysis |
| 104 | if m.pmapperError == nil { |
| 105 | for i := range m.Projects { |
| 106 | m.Projects[i].Admin, m.Projects[i].CanPrivEsc = GetPmapperResults(m.SkipAdminCheck, m.pmapperMod, &m.Projects[i].Role) |
| 107 | } |
| 108 | } else { |
| 109 | for i := range m.Projects { |
| 110 | m.Projects[i].Admin, m.Projects[i].CanPrivEsc = GetIamSimResult(m.SkipAdminCheck, &m.Projects[i].Role, m.iamSimClient, localAdminMap) |
| 111 | } |