MCPcopy Create free account
hub / github.com/crashappsec/github-analyzer / Serve

Function Serve

pkg/output/html/html.go:266–352  ·  view source on GitHub ↗
(
	orgName, orgStatsPath, permissionsPath, oauthAppPath, execStatusPath, issuesPath string,
	htmlDir string,
	port int,
)

Source from the content-addressed store, hash-verified

264}
265
266func Serve(
267 orgName, orgStatsPath, permissionsPath, oauthAppPath, execStatusPath, issuesPath string,
268 htmlDir string,
269 port int,
270) {
271 perms, users, permissionSummary, err := parsePermissions(permissionsPath)
272 if err != nil {
273 log.Logger.Error(err)
274 }
275
276 wrappedIssues, checksPassed, checksFailed, err := parseIssues(
277 execStatusPath,
278 issuesPath,
279 )
280 if err != nil {
281 log.Logger.Error(err)
282 }
283
284 stats, wrappedInstallations, err := parseStats(orgStatsPath)
285 if err != nil {
286 log.Logger.Error(err)
287 }
288
289 apps, err := parseOauthApps(oauthAppPath)
290 if err != nil {
291 log.Logger.Error(err)
292 }
293
294 var staticFS = http.FS(staticFiles)
295 fs := http.FileServer(staticFS)
296
297 type PageData struct {
298 Org string
299 HasNonIssueStats bool
300 Stats org.OrgStats
301 TotalRunners int
302 TotalInstallations int
303 TotalWebhooks int
304 Apps []WrappedOAuthApp
305 Issues []WrappedIssue
306 Installations []InstallationInfo
307 ChecksPassed []string
308 ChecksFailed []string
309 Permissions []string
310 Users []string
311 PermissionSummary map[string]map[string]string
312 }
313
314 t, err := template.ParseFS(indexHTML, "templates/index.html.tmpl")
315 if err != nil {
316 log.Logger.Error(err)
317 }
318 http.Handle("/static/", fs)
319 http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
320 w.Header().Add("Content-Type", "text/html")
321 t.Execute(w,
322 PageData{
323 Org: orgName,

Callers 1

runCmdFunction · 0.92

Calls 4

parsePermissionsFunction · 0.85
parseIssuesFunction · 0.85
parseStatsFunction · 0.85
parseOauthAppsFunction · 0.85

Tested by

no test coverage detected