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

Disable directory listing for StaticResource #15438

Merged
merged 6 commits into from
Apr 14, 2023
Merged
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
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