Skip to content
Permalink
Browse files Browse the repository at this point in the history
security: check site admin before returning site usage stats (#23026)
  • Loading branch information
unknwon committed Jul 20, 2021
1 parent 7b475da commit 6e51f45
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/frontend/graphqlbackend/site_usage_stats.go
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"time"

"github.com/sourcegraph/sourcegraph/cmd/frontend/backend"
"github.com/sourcegraph/sourcegraph/cmd/frontend/internal/usagestatsdeprecated"
"github.com/sourcegraph/sourcegraph/internal/types"
)
Expand All @@ -13,6 +14,10 @@ func (r *siteResolver) UsageStatistics(ctx context.Context, args *struct {
Weeks *int32
Months *int32
}) (*siteUsageStatisticsResolver, error) {
if err := backend.CheckCurrentUserIsSiteAdmin(ctx, r.db); err != nil {
return nil, err
}

opt := &usagestatsdeprecated.SiteUsageStatisticsOptions{}
if args.Days != nil {
d := int(*args.Days)
Expand Down

0 comments on commit 6e51f45

Please sign in to comment.