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
f68d2816
Commit
f68d2816
authored
Jun 22, 2017
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashfolders: security for png rendering
parent
659a5910
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
3 deletions
+9
-3
pkg/api/render.go
+2
-0
pkg/components/renderer/renderer.go
+4
-1
pkg/middleware/render_auth.go
+3
-2
No files found.
pkg/api/render.go
View file @
f68d2816
...
...
@@ -18,6 +18,8 @@ func RenderToPng(c *middleware.Context) {
Width
:
queryReader
.
Get
(
"width"
,
"800"
),
Height
:
queryReader
.
Get
(
"height"
,
"400"
),
OrgId
:
c
.
OrgId
,
UserId
:
c
.
UserId
,
OrgRole
:
c
.
OrgRole
,
Timeout
:
queryReader
.
Get
(
"timeout"
,
"30"
),
Timezone
:
queryReader
.
Get
(
"tz"
,
""
),
}
...
...
pkg/components/renderer/renderer.go
View file @
f68d2816
...
...
@@ -15,6 +15,7 @@ import (
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/middleware"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util"
)
...
...
@@ -25,6 +26,8 @@ type RenderOpts struct {
Height
string
Timeout
string
OrgId
int64
UserId
int64
OrgRole
models
.
RoleType
Timezone
string
}
...
...
@@ -72,7 +75,7 @@ func RenderToPng(params *RenderOpts) (string, error) {
pngPath
,
_
:=
filepath
.
Abs
(
filepath
.
Join
(
setting
.
ImagesDir
,
util
.
GetRandomString
(
20
)))
pngPath
=
pngPath
+
".png"
renderKey
:=
middleware
.
AddRenderAuthKey
(
params
.
OrgId
)
renderKey
:=
middleware
.
AddRenderAuthKey
(
params
.
OrgId
,
params
.
UserId
,
params
.
OrgRole
)
defer
middleware
.
RemoveRenderAuthKey
(
renderKey
)
cmdArgs
:=
[]
string
{
...
...
pkg/middleware/render_auth.go
View file @
f68d2816
...
...
@@ -33,14 +33,15 @@ func initContextWithRenderAuth(ctx *Context) bool {
type
renderContextFunc
func
(
key
string
)
(
string
,
error
)
func
AddRenderAuthKey
(
orgId
int64
)
string
{
func
AddRenderAuthKey
(
orgId
int64
,
userId
int64
,
orgRole
m
.
RoleType
)
string
{
renderKeysLock
.
Lock
()
key
:=
util
.
GetRandomString
(
32
)
renderKeys
[
key
]
=
&
m
.
SignedInUser
{
OrgId
:
orgId
,
OrgRole
:
m
.
ROLE_VIEWER
,
OrgRole
:
orgRole
,
UserId
:
userId
,
}
renderKeysLock
.
Unlock
()
...
...
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