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
a55be07e
Commit
a55be07e
authored
Nov 17, 2017
by
Alexander Zobnin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard history clean up: avoid potential SQL injections
parent
59d89e42
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
6 deletions
+4
-6
pkg/services/sqlstore/dashboard_version.go
+4
-6
No files found.
pkg/services/sqlstore/dashboard_version.go
View file @
a55be07e
package
sqlstore
package
sqlstore
import
(
import
(
"fmt"
"math"
"math"
"strings"
"strings"
...
@@ -72,13 +71,12 @@ func DeleteExpiredVersions(cmd *m.DeleteExpiredVersionsCommand) error {
...
@@ -72,13 +71,12 @@ func DeleteExpiredVersions(cmd *m.DeleteExpiredVersionsCommand) error {
// Don't clean up if user set versions_to_keep to 2147483647 (MaxInt32)
// Don't clean up if user set versions_to_keep to 2147483647 (MaxInt32)
if
versionsToKeep
:=
setting
.
DashboardVersionsToKeep
;
versionsToKeep
<
math
.
MaxInt32
{
if
versionsToKeep
:=
setting
.
DashboardVersionsToKeep
;
versionsToKeep
<
math
.
MaxInt32
{
// Get dashboard ids to clean up
affectedDashboardsQuery
:=
fmt
.
Sprintf
(
`SELECT dashboard_id FROM dashboard_version
GROUP BY dashboard_id HAVING COUNT(dashboard_version.id)>%d`
,
versionsToKeep
)
err
:=
sess
.
Table
(
"dashboard_version"
)
.
err
:=
sess
.
Table
(
"dashboard_version"
)
.
Select
(
"dashboard_version.id, dashboard_version.version, dashboard_version.dashboard_id"
)
.
Select
(
"dashboard_version.id, dashboard_version.version, dashboard_version.dashboard_id"
)
.
Where
(
fmt
.
Sprintf
(
"dashboard_id IN (%s)"
,
affectedDashboardsQuery
))
.
Where
(
`dashboard_id IN (
SELECT dashboard_id FROM dashboard_version
GROUP BY dashboard_id HAVING COUNT(dashboard_version.id) > ?
)`
,
versionsToKeep
)
.
Desc
(
"dashboard_version.dashboard_id"
,
"dashboard_version.version"
)
.
Desc
(
"dashboard_version.dashboard_id"
,
"dashboard_version.version"
)
.
Find
(
&
versions
)
Find
(
&
versions
)
...
...
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