Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Disable directory listing for StaticResource (#15438)
Browse files Browse the repository at this point in the history
  • Loading branch information
dklimpel committed Apr 14, 2023
1 parent e4a25d0 commit 24b61f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/15438.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disable directory listing for static resources in `/_matrix/static/`.
10 changes: 10 additions & 0 deletions synapse/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
from twisted.internet.defer import CancelledError
from twisted.python import failure
from twisted.web import resource

try:
from twisted.web.pages import notFound
except ImportError:
from twisted.web.resource import NoResource as notFound # type: ignore[assignment]

from twisted.web.resource import IResource
from twisted.web.server import NOT_DONE_YET, Request
from twisted.web.static import File
from twisted.web.util import redirectTo
Expand Down Expand Up @@ -569,6 +576,9 @@ def render_GET(self, request: Request) -> bytes:
set_clickjacking_protection_headers(request)
return super().render_GET(request)

def directoryListing(self) -> IResource:
return notFound()


class UnrecognizedRequestResource(resource.Resource):
"""
Expand Down

0 comments on commit 24b61f3

Please sign in to comment.