Remove Python version from /_synapse/admin/v1/server_version (#16380)

There's no reason to expose the full Python version over what is
frequently a public API.
This commit is contained in:
MomentQYC 2023-10-02 21:07:53 +08:00 committed by GitHub
parent d40a939ff6
commit 5725712d47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 12 deletions

View file

@ -0,0 +1 @@
Remove Python version from `/_synapse/admin/v1/server_version`.

View file

@ -1,7 +1,7 @@
# Version API # Version API
This API returns the running Synapse version and the Python version This API returns the running Synapse version.
on which Synapse is being run. This is useful when a Synapse instance This is useful when a Synapse instance
is behind a proxy that does not forward the 'Server' header (which also is behind a proxy that does not forward the 'Server' header (which also
contains Synapse version information). contains Synapse version information).
@ -15,7 +15,9 @@ It returns a JSON body like the following:
```json ```json
{ {
"server_version": "0.99.2rc1 (b=develop, abcdef123)", "server_version": "0.99.2rc1 (b=develop, abcdef123)"
"python_version": "3.7.8"
} }
``` ```
*Changed in Synapse 1.94.0:* The `python_version` key was removed from the
response body.

View file

@ -16,7 +16,6 @@
# limitations under the License. # limitations under the License.
import logging import logging
import platform
from http import HTTPStatus from http import HTTPStatus
from typing import TYPE_CHECKING, Optional, Tuple from typing import TYPE_CHECKING, Optional, Tuple
@ -107,10 +106,7 @@ class VersionServlet(RestServlet):
PATTERNS = admin_patterns("/server_version$") PATTERNS = admin_patterns("/server_version$")
def __init__(self, hs: "HomeServer"): def __init__(self, hs: "HomeServer"):
self.res = { self.res = {"server_version": SYNAPSE_VERSION}
"server_version": SYNAPSE_VERSION,
"python_version": platform.python_version(),
}
def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]: def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
return HTTPStatus.OK, self.res return HTTPStatus.OK, self.res

View file

@ -42,9 +42,7 @@ class VersionTestCase(unittest.HomeserverTestCase):
channel = self.make_request("GET", self.url, shorthand=False) channel = self.make_request("GET", self.url, shorthand=False)
self.assertEqual(200, channel.code, msg=channel.json_body) self.assertEqual(200, channel.code, msg=channel.json_body)
self.assertEqual( self.assertEqual({"server_version"}, set(channel.json_body.keys()))
{"server_version", "python_version"}, set(channel.json_body.keys())
)
class QuarantineMediaTestCase(unittest.HomeserverTestCase): class QuarantineMediaTestCase(unittest.HomeserverTestCase):