Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ This project adheres to `Semantic Versioning <https://semver.org/>`_.

Unreleased
===========================
* **Security fix.** ``connections/create_upload/`` had no permission check, so anyone, including
anonymous visitors, could load the upload page and see the list of uploaded database aliases and
ids. It now requires ``EXPLORER_PERMISSION_CONNECTIONS`` like the rest of the connection views.

* `#722`_: The query list (home page) no longer loads the entire query log history on every view. Run counts and
last runs are computed in SQL, so the page stays fast as logs accumulate (300k logs: ~9.7s -> ~0.9s). The query
list and query log pages also no longer run an extra database query per row.
Expand Down
3 changes: 2 additions & 1 deletion explorer/ee/db_connections/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ class DatabaseConnectionCreateView(PermissionRequiredMixin, ExplorerContextMixin
success_url = reverse_lazy("explorer_connections")


class DatabaseConnectionUploadCreateView(TemplateView):
class DatabaseConnectionUploadCreateView(PermissionRequiredMixin, ExplorerContextMixin, TemplateView):
permission_required = "connections_permission"
template_name = "connections/connection_upload.html"

def get_context_data(self, **kwargs):
Expand Down
14 changes: 14 additions & 0 deletions explorer/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,20 @@ def setUp(self):
port=""
)

def test_database_connection_upload_view_requires_permission(self):
self.client.logout()
response = self.client.get(reverse("explorer_upload_create"))
self.assertTemplateUsed(response, "admin/login.html")

def test_database_connection_upload_view_hides_connections_from_unauthorized_users(self):
self.client.logout()
response = self.client.get(reverse("explorer_upload_create"))
self.assertNotContains(response, "test_alias")

def test_database_connection_upload_view_allows_staff(self):
response = self.client.get(reverse("explorer_upload_create"))
self.assertEqual(response.status_code, 200)

def test_database_connection_detail_view(self):
response = self.client.get(reverse("explorer_connection_detail", args=[self.connection.pk]))
self.assertEqual(response.status_code, 200)
Expand Down
Loading