Skip to content

Commit

Permalink
async censorship fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gsfk committed Nov 26, 2024
1 parent d889b95 commit 9ec200d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bento_beacon/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def before_request():
if request.blueprint != "info":
validate_request()
await verify_permissions()
save_request_data()
await save_request_data()
reject_query_if_not_permitted()
init_response_data()

Expand Down
4 changes: 2 additions & 2 deletions bento_beacon/utils/beacon_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def package_get_params(params):
return {"meta": meta, "query": query}


def save_request_data():
async def save_request_data():
defaults = request_defaults()

if request.method == "POST":
Expand All @@ -129,7 +129,7 @@ def save_request_data():
request_data["requestParameters"] = query_request_parameters

if query_filters:
reject_if_too_many_filters(query_filters)
await reject_if_too_many_filters(query_filters)
request_data["filters"] = query_filters

if request_bento:
Expand Down
8 changes: 4 additions & 4 deletions bento_beacon/utils/censorship.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ async def censored_count(count):


# we don't have the same option of returning zero here
def get_max_filters():
async def get_max_filters():
max_filters = current_app.config["MAX_FILTERS"]
return max_filters if max_filters is not None else max_filters_retry()
return max_filters if max_filters is not None else await max_filters_retry()


# ugly side-effect code, but keeps censorship code together
def reject_if_too_many_filters(filters):
async def reject_if_too_many_filters(filters):
if g.permission_query_data:
return
max_filters = get_max_filters()
max_filters = await get_max_filters()
if len(filters) > max_filters:
raise InvalidQuery(f"too many filters in request, maximum of {max_filters} permitted")

Expand Down

0 comments on commit 9ec200d

Please sign in to comment.