grafana/pkg/services/sqlstore
Marcus Efraimsson 53cd39fde5 Shouldn't be able to overwrite a dashboard if you don't have permissions (#10900)
* dashboards: new command for validating dashboard before update

Removes validation logic from saveDashboard and later on use the new command for validating
dashboard before saving a dashboard. This due to the fact that we need to validate permissions
for overwriting other dashboards by uid and title.

* dashboards: use the new command for validating dashboard before saving

Had to refactor dashboard provisioning a bit to be able to sidetrack the permission validation
in a somewhat reasonable way.
Adds some initial tests of the dashboard repository, but needs to be extended later. At least
now you can mock the dashboard guardian

* dashboards: removes validation logic in the save dashboard api layer

Use the dashboard repository solely for create/update dashboards and let it do all
the validation. One exception regarding quota validation which still is in api layer
since that logic is in a macaron middleware.
Need to move out-commented api tests later.

* dashboards: fix database tests for validate and saving dashboards

* dashboards: rename dashboard repository to dashboard service

Split the old dashboard repository interface in two new interfaces, IDashboardService and
IDashboardProvisioningService. Makes it more explicit when using it from the provisioning package
and there's no possibility of calling an incorrect method for saving a dashboard.

* database: make the InitTestDB function available to use from other packages

* dashboards: rename ValidateDashboardForUpdateCommand and some refactoring

* dashboards: integration tests of dashboard service

* dashboard: fix sqlstore test due to folder exist validation

* dashboards: move dashboard service integration tests to sqlstore package

Had to move it to the sqlstore package due to concurrency problems when running
against mysql and postgres. Using InitTestDB from two packages added conflicts
when clearing and running migrations on the test database

* dashboards: refactor how to find id to be used for save permission check

* dashboards: remove duplicated dashboard tests

* dashboards: cleanup dashboard service integration tests

* dashboards: handle save dashboard errors and return correct http status

* fix: remove log statement

* dashboards: import dashboard should use dashboard service

Had to move alerting commands to models package due to problems with import cycles of packages.

* dashboards: cleanup dashboard api tests and add some tests for post dashboard

* dashboards: rename dashboard service interfaces

* dashboards: rename dashboard guardian interface
2018-02-19 11:12:56 +01:00
..
migrations login: migration fix. 2018-02-16 17:36:28 +01:00
migrator tests: makes sure we all migrations are working 2018-02-14 15:30:29 +01:00
sqlutil sql: removes locale from test to mirror prod. 2018-02-14 10:31:36 +01:00
alert_notification_test.go tech(notifications): splitt into 3 queries 2016-09-06 08:43:15 +02:00
alert_notification.go tech: avoid using deprecated functions 2018-01-23 22:30:45 +01:00
alert_test.go test: added integration test for #10941 2018-02-16 14:17:41 +01:00
alert.go refactoring: alert rule query refactoring (#10941) 2018-02-16 13:56:04 +01:00
annotation_test.go dashfolders: permissions for saving annotations 2018-01-09 14:44:36 +01:00
annotation.go dashfolders: permissions for saving annotations 2018-01-09 14:44:36 +01:00
apikey_test.go Added expire option to dashboard snapshots, #1623 2015-03-26 12:00:52 +01:00
apikey.go refactor: sqlstore inTransaction consolidated to one version, fixes #8376 2017-05-23 10:56:23 +02:00
dashboard_acl_test.go Dashboard acl query fixes (#10909) 2018-02-14 15:04:26 +01:00
dashboard_acl.go Dashboard acl query fixes (#10909) 2018-02-14 15:04:26 +01:00
dashboard_folder_test.go Dashboard acl query fixes (#10909) 2018-02-14 15:04:26 +01:00
dashboard_provisioning_test.go provisioning: uses unix epoch timestamps. (#10907) 2018-02-14 15:28:30 +01:00
dashboard_provisioning.go provisioning: uses unix epoch timestamps. (#10907) 2018-02-14 15:28:30 +01:00
dashboard_service_integration_test.go Shouldn't be able to overwrite a dashboard if you don't have permissions (#10900) 2018-02-19 11:12:56 +01:00
dashboard_snapshot_test.go feat(plugins): dashboard import for data sources is working! #4298 2016-03-12 10:13:49 +01:00
dashboard_snapshot.go snapshots: improve snapshot listing performance, #9314 (#9477) 2017-10-10 14:25:19 +02:00
dashboard_test.go Shouldn't be able to overwrite a dashboard if you don't have permissions (#10900) 2018-02-19 11:12:56 +01:00
dashboard_version_test.go Shouldn't be able to overwrite a dashboard if you don't have permissions (#10900) 2018-02-19 11:12:56 +01:00
dashboard_version.go Merge branch 'master' into develop 2017-11-17 15:49:17 +01:00
dashboard.go Shouldn't be able to overwrite a dashboard if you don't have permissions (#10900) 2018-02-19 11:12:56 +01:00
datasource_test.go Shouldn't be able to overwrite a dashboard if you don't have permissions (#10900) 2018-02-19 11:12:56 +01:00
datasource.go bug: return correct err message 2018-02-14 13:32:52 +01:00
health.go feat: added api health endpoint that does not require auth and never creates sessions, returns db status as well. #3302 2017-04-25 17:17:45 +02:00
logger.go dasboard_history: security fix, added orgId filter to dashboard version lookup 2017-06-07 14:21:40 +02:00
login_attempt_test.go WIP: Protect against brute force (frequent) login attempts (#10031) 2018-01-26 10:41:41 +01:00
login_attempt.go login: uses epochs for login throtting. 2018-02-16 17:25:46 +01:00
org_test.go Dashboard acl query fixes (#10909) 2018-02-14 15:04:26 +01:00
org_users.go teams: use orgId in all team and team member operations (#10862) 2018-02-09 17:26:15 +01:00
org.go refactor: sqlstore inTransaction consolidated to one version, fixes #8376 2017-05-23 10:56:23 +02:00
playlist_test.go chore(playlist): remove commented code 2016-01-29 20:33:01 +01:00
playlist.go Merge branch 'master' into provisioning 2018-02-08 11:01:09 +01:00
plugin_setting.go refactor: sqlstore inTransaction consolidated to one version, fixes #8376 2017-05-23 10:56:23 +02:00
preferences.go refactor: sqlstore inTransaction consolidated to one version, fixes #8376 2017-05-23 10:56:23 +02:00
quota_test.go add unittests for quota sqltore methods. 2015-09-15 17:10:46 +08:00
quota.go refactor: sqlstore inTransaction consolidated to one version, fixes #8376 2017-05-23 10:56:23 +02:00
search_builder_test.go dashboard and folder search with permissions 2018-02-08 17:11:01 +01:00
search_builder.go fix: sql search permissions filter fix 2018-02-13 16:49:00 +01:00
shared.go refactor: sqlstore inTransaction consolidated to one version, fixes #8376 2017-05-23 10:56:23 +02:00
sql_test_data.go refactor: sqlstore inTransaction consolidated to one version, fixes #8376 2017-05-23 10:56:23 +02:00
sqlbuilder.go refactoring: alert rule query refactoring (#10941) 2018-02-16 13:56:04 +01:00
sqlstore.go Shouldn't be able to overwrite a dashboard if you don't have permissions (#10900) 2018-02-19 11:12:56 +01:00
sqlstore.goconvey feat(invite): small progress 2015-07-17 14:42:49 +02:00
star.go refactor: sqlstore inTransaction consolidated to one version, fixes #8376 2017-05-23 10:56:23 +02:00
stars_test.go Fixed gofmt formating, updated precommit hook 2015-03-07 16:37:19 +01:00
stats.go stats: send amount of stars as stats 2018-01-23 22:51:05 +01:00
tables.go Began work on real sql schema definitions, and migration engine 2015-01-17 21:40:22 +01:00
team_test.go teams: adds some validation to the API 2018-02-16 11:46:20 +01:00
team.go teams: adds some validation to the API 2018-02-16 11:46:20 +01:00
temp_user_test.go signup: fix email sent logic for tempuser 2017-06-30 20:21:08 +02:00
temp_user.go signup: fix email sent logic for tempuser 2017-06-30 20:21:08 +02:00
tls_mysql.go generalized database connection cert support and added to postgres 2016-11-22 15:29:22 -08:00
user_test.go Dashboard acl query fixes (#10909) 2018-02-14 15:04:26 +01:00
user.go refactor: rename User Groups to Teams 2017-12-08 18:25:45 +03:00