-
Notifications
You must be signed in to change notification settings - Fork 13
Allow graphs to not be anonymous #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -77,6 +77,12 @@ func GetServiceStatus(w http.ResponseWriter, r *http.Request) { | |||||||||||||||||||||||||||||||||||||||||||
| series = append(series, s) | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| if shouldScrub(r) { | ||||||||||||||||||||||||||||||||||||||||||||
| for i := range series { | ||||||||||||||||||||||||||||||||||||||||||||
| series[i].Name = "Team" | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| data := map[string]any{"series": series, "roundID": round.ID} | ||||||||||||||||||||||||||||||||||||||||||||
| WriteJSON(w, http.StatusOK, data) | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -126,15 +132,8 @@ func GetScoreStatus(w http.ResponseWriter, r *http.Request) { | |||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| if r.Context().Value("roles") != nil { | ||||||||||||||||||||||||||||||||||||||||||||
| req_roles := r.Context().Value("roles").([]string) | ||||||||||||||||||||||||||||||||||||||||||||
| if !slices.Contains(req_roles, "admin") { | ||||||||||||||||||||||||||||||||||||||||||||
| for i, _ := range series { | ||||||||||||||||||||||||||||||||||||||||||||
| series[i].Name = "Team" | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||
| for i, _ := range series { | ||||||||||||||||||||||||||||||||||||||||||||
| if shouldScrub(r) { | ||||||||||||||||||||||||||||||||||||||||||||
| for i := range series { | ||||||||||||||||||||||||||||||||||||||||||||
| series[i].Name = "Team" | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -207,19 +206,26 @@ func GetUptimeStatus(w http.ResponseWriter, r *http.Request) { | |||||||||||||||||||||||||||||||||||||||||||
| series = append(series, s) | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| if r.Context().Value("roles") != nil { | ||||||||||||||||||||||||||||||||||||||||||||
| req_roles := r.Context().Value("roles").([]string) | ||||||||||||||||||||||||||||||||||||||||||||
| if !slices.Contains(req_roles, "admin") { | ||||||||||||||||||||||||||||||||||||||||||||
| for i, _ := range series { | ||||||||||||||||||||||||||||||||||||||||||||
| series[i].Name = "Team" | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||
| for i, _ := range series { | ||||||||||||||||||||||||||||||||||||||||||||
| if shouldScrub(r) { | ||||||||||||||||||||||||||||||||||||||||||||
| for i := range series { | ||||||||||||||||||||||||||||||||||||||||||||
| series[i].Name = "Team" | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| data := map[string]any{"series": series} | ||||||||||||||||||||||||||||||||||||||||||||
| WriteJSON(w, http.StatusOK, data) | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| func shouldScrub(r *http.Request) bool { | ||||||||||||||||||||||||||||||||||||||||||||
| if r.Context().Value("roles") != nil { | ||||||||||||||||||||||||||||||||||||||||||||
| req_roles := r.Context().Value("roles").([]string) | ||||||||||||||||||||||||||||||||||||||||||||
| if slices.Contains(req_roles, "admin") { | ||||||||||||||||||||||||||||||||||||||||||||
| return false | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| if conf.UISettings.AllowNonAnonymizedGraphsForBlueTeam { | ||||||||||||||||||||||||||||||||||||||||||||
| return false | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+220
to
+229
|
||||||||||||||||||||||||||||||||||||||||||||
| if r.Context().Value("roles") != nil { | |
| req_roles := r.Context().Value("roles").([]string) | |
| if slices.Contains(req_roles, "admin") { | |
| return false | |
| } | |
| } | |
| if conf.UISettings.AllowNonAnonymizedGraphsForBlueTeam { | |
| return false | |
| } | |
| rolesVal := r.Context().Value("roles") | |
| if rolesVal != nil { | |
| if reqRoles, ok := rolesVal.([]string); ok { | |
| if slices.Contains(reqRoles, "admin") { | |
| return false | |
| } | |
| if conf.UISettings.AllowNonAnonymizedGraphsForBlueTeam && slices.Contains(reqRoles, "team") { | |
| return false | |
| } | |
| } | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When scrubbing team names, the team ID is still exposed in the Series struct. This defeats the purpose of anonymization since clients can still identify teams by their IDs. Consider also scrubbing or removing the ID field when shouldScrub returns true, similar to how the Name field is scrubbed.