Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
5af83efe
Unverified
Commit
5af83efe
authored
3 years ago
by
Patrick Cloke
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Validate the max_rooms_per_space parameter to ensure it is non-negative. (#10611)
parent
0ace38b7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/10611.bugfix
+1
-0
1 addition, 0 deletions
changelog.d/10611.bugfix
synapse/federation/transport/server/federation.py
+18
-4
18 additions, 4 deletions
synapse/federation/transport/server/federation.py
synapse/rest/client/v1/room.py
+20
-5
20 additions, 5 deletions
synapse/rest/client/v1/room.py
with
39 additions
and
9 deletions
changelog.d/10611.bugfix
0 → 100644
+
1
−
0
View file @
5af83efe
Additional validation for the spaces summary API to avoid errors like `ValueError: Stop argument for islice() must be None or an integer`. The missing validation has existed since v1.31.0.
This diff is collapsed.
Click to expand it.
synapse/federation/transport/server/federation.py
+
18
−
4
View file @
5af83efe
...
...
@@ -557,7 +557,14 @@ class FederationSpaceSummaryServlet(BaseFederationServlet):
room_id
:
str
,
)
->
Tuple
[
int
,
JsonDict
]:
suggested_only
=
parse_boolean_from_args
(
query
,
"
suggested_only
"
,
default
=
False
)
max_rooms_per_space
=
parse_integer_from_args
(
query
,
"
max_rooms_per_space
"
)
if
max_rooms_per_space
is
not
None
and
max_rooms_per_space
<
0
:
raise
SynapseError
(
400
,
"
Value for
'
max_rooms_per_space
'
must be a non-negative integer
"
,
Codes
.
BAD_JSON
,
)
exclude_rooms
=
parse_strings_from_args
(
query
,
"
exclude_rooms
"
,
default
=
[])
...
...
@@ -586,10 +593,17 @@ class FederationSpaceSummaryServlet(BaseFederationServlet):
raise
SynapseError
(
400
,
"
bad value for
'
exclude_rooms
'"
,
Codes
.
BAD_JSON
)
max_rooms_per_space
=
content
.
get
(
"
max_rooms_per_space
"
)
if
max_rooms_per_space
is
not
None
and
not
isinstance
(
max_rooms_per_space
,
int
):
raise
SynapseError
(
400
,
"
bad value for
'
max_rooms_per_space
'"
,
Codes
.
BAD_JSON
)
if
max_rooms_per_space
is
not
None
:
if
not
isinstance
(
max_rooms_per_space
,
int
):
raise
SynapseError
(
400
,
"
bad value for
'
max_rooms_per_space
'"
,
Codes
.
BAD_JSON
)
if
max_rooms_per_space
<
0
:
raise
SynapseError
(
400
,
"
Value for
'
max_rooms_per_space
'
must be a non-negative integer
"
,
Codes
.
BAD_JSON
,
)
return
200
,
await
self
.
handler
.
federation_space_summary
(
origin
,
room_id
,
suggested_only
,
max_rooms_per_space
,
exclude_rooms
...
...
This diff is collapsed.
Click to expand it.
synapse/rest/client/v1/room.py
+
20
−
5
View file @
5af83efe
...
...
@@ -993,11 +993,19 @@ class RoomSpaceSummaryRestServlet(RestServlet):
)
->
Tuple
[
int
,
JsonDict
]:
requester
=
await
self
.
_auth
.
get_user_by_req
(
request
,
allow_guest
=
True
)
max_rooms_per_space
=
parse_integer
(
request
,
"
max_rooms_per_space
"
)
if
max_rooms_per_space
is
not
None
and
max_rooms_per_space
<
0
:
raise
SynapseError
(
400
,
"
Value for
'
max_rooms_per_space
'
must be a non-negative integer
"
,
Codes
.
BAD_JSON
,
)
return
200
,
await
self
.
_room_summary_handler
.
get_space_summary
(
requester
.
user
.
to_string
(),
room_id
,
suggested_only
=
parse_boolean
(
request
,
"
suggested_only
"
,
default
=
False
),
max_rooms_per_space
=
parse_integer
(
request
,
"
max_rooms_per_space
"
)
,
max_rooms_per_space
=
max_rooms_per_space
,
)
# TODO When switching to the stable endpoint, remove the POST handler.
...
...
@@ -1014,10 +1022,17 @@ class RoomSpaceSummaryRestServlet(RestServlet):
)
max_rooms_per_space
=
content
.
get
(
"
max_rooms_per_space
"
)
if
max_rooms_per_space
is
not
None
and
not
isinstance
(
max_rooms_per_space
,
int
):
raise
SynapseError
(
400
,
"'
max_rooms_per_space
'
must be an integer
"
,
Codes
.
BAD_JSON
)
if
max_rooms_per_space
is
not
None
:
if
not
isinstance
(
max_rooms_per_space
,
int
):
raise
SynapseError
(
400
,
"'
max_rooms_per_space
'
must be an integer
"
,
Codes
.
BAD_JSON
)
if
max_rooms_per_space
<
0
:
raise
SynapseError
(
400
,
"
Value for
'
max_rooms_per_space
'
must be a non-negative integer
"
,
Codes
.
BAD_JSON
,
)
return
200
,
await
self
.
_room_summary_handler
.
get_space_summary
(
requester
.
user
.
to_string
(),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment