Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
7031b922
Commit
7031b922
authored
May 19, 2020
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only allow 32 hexadecimal digits for the avatar hash
parent
a04ef6ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
pkg/api/avatar/avatar.go
+11
-5
No files found.
pkg/api/avatar/avatar.go
View file @
7031b922
...
@@ -15,14 +15,14 @@ import (
...
@@ -15,14 +15,14 @@ import (
"net/http"
"net/http"
"net/url"
"net/url"
"path/filepath"
"path/filepath"
"regexp"
"strconv"
"strconv"
"strings"
"sync"
"sync"
"time"
"time"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/setting"
"gopkg.in/macaron.v1"
gocache
"github.com/patrickmn/go-cache"
gocache
"github.com/patrickmn/go-cache"
)
)
...
@@ -73,9 +73,15 @@ type CacheServer struct {
...
@@ -73,9 +73,15 @@ type CacheServer struct {
cache
*
gocache
.
Cache
cache
*
gocache
.
Cache
}
}
func
(
this
*
CacheServer
)
Handler
(
ctx
*
macaron
.
Context
)
{
var
validMD5
=
regexp
.
MustCompile
(
"^[a-fA-F0-9]{32}$"
)
urlPath
:=
ctx
.
Req
.
URL
.
Path
hash
:=
urlPath
[
strings
.
LastIndex
(
urlPath
,
"/"
)
+
1
:
]
func
(
this
*
CacheServer
)
Handler
(
ctx
*
models
.
ReqContext
)
{
hash
:=
ctx
.
Params
(
"hash"
)
if
len
(
hash
)
!=
32
||
!
validMD5
.
MatchString
(
hash
)
{
ctx
.
JsonApiErr
(
404
,
"Avatar not found"
,
nil
)
return
}
var
avatar
*
Avatar
var
avatar
*
Avatar
obj
,
exists
:=
this
.
cache
.
Get
(
hash
)
obj
,
exists
:=
this
.
cache
.
Get
(
hash
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment