MCPcopy Index your code
hub / github.com/crashappsec/github-analyzer / runCmd

Function runCmd

cmd/github-analyzer/main.go:49–148  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47}
48
49func runCmd() {
50 var issues []issue.Issue
51 var stats []issue.Issue
52 var checkStatuses map[issue.IssueID]error
53
54 futils.Init()
55
56 if config.ViperEnv.EnableScraping {
57 if config.ViperEnv.Username == "" ||
58 config.ViperEnv.Password == "" ||
59 config.ViperEnv.OtpSeed == "" {
60 log.Logger.Fatalf(
61 "The following flags are required for scraping --username, --password, --otp",
62 )
63 }
64 sissues, execStatus, err := scraping.AuditScraping(
65 config.ViperEnv.Username,
66 config.ViperEnv.Password,
67 config.ViperEnv.OtpSeed,
68 config.ViperEnv.Organization)
69 if err != nil {
70 log.Logger.Error(err)
71 }
72 issues = append(issues, sissues...)
73 checkStatuses = execStatus
74 }
75
76 if config.ViperEnv.Token == "" {
77 log.Logger.Errorf("Github token not set")
78 } else {
79 auditor, err := auditor.NewGithubAuditor(config.ViperEnv.Token)
80 if err != nil {
81 log.Logger.Error(err)
82 return
83 }
84 results, execStatus, err := auditor.AuditOrg(config.ViperEnv.Organization, config.ViperEnv.UserPermissionStats)
85 if err != nil {
86 log.Logger.Error(err)
87 }
88 for _, r := range results {
89 if strings.HasPrefix(string(r.ID), "STATS") {
90 stats = append(stats, r)
91 } else {
92 issues = append(issues, r)
93 }
94 }
95
96 // update the map of what has executed if we have info from scraping
97 if len(checkStatuses) > 0 {
98 for id, err := range execStatus {
99 prevError, ok := checkStatuses[id]
100 if !ok {
101 // this is the first time we see this check
102 checkStatuses[id] = err
103 continue
104 }
105 // if we have additional errors just merge them for now
106 if err != nil {

Callers 1

NewRootCommandFunction · 0.85

Calls 5

AuditOrgMethod · 0.95
InitFunction · 0.92
AuditScrapingFunction · 0.92
SerializeFileFunction · 0.92
ServeFunction · 0.92

Tested by

no test coverage detected