Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAX_INCLUDE_DEPTH include parsing for querystring is wrong #174

Open
iamareebjamal opened this issue Oct 3, 2019 · 0 comments
Open

MAX_INCLUDE_DEPTH include parsing for querystring is wrong #174

iamareebjamal opened this issue Oct 3, 2019 · 0 comments

Comments

@iamareebjamal
Copy link
Contributor

Let's take a look at this code

include_param = self.qs.get('include', [])
if current_app.config.get('MAX_INCLUDE_DEPTH') is not None:
for include_path in include_param:
if len(include_path.split('.')) > current_app.config['MAX_INCLUDE_DEPTH']:
raise InvalidInclude("You can't use include through more than {} relationships"
.format(current_app.config['MAX_INCLUDE_DEPTH']))
return include_param.split(',') if include_param else []

include_param = self.qs.get('include', [])

This expects self.querystring['include'] to be a list, whereas we know that it is a string by looking at last line

return include_param.split(',') if include_param else []

Hence, this block of code is wrong.

if current_app.config.get('MAX_INCLUDE_DEPTH') is not None:
for include_path in include_param:
if len(include_path.split('.')) > current_app.config['MAX_INCLUDE_DEPTH']:
raise InvalidInclude("You can't use include through more than {} relationships"
.format(current_app.config['MAX_INCLUDE_DEPTH']))

If MAX_INCLUDE_DEPTH is not None and querystring is not empty, it'll loop through the individual characters of the querystring and not different parts of include string separated by commas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant