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

Add argument to disable autojoin on demand. #35

Merged
merged 2 commits into from
Jun 13, 2019

Conversation

bodik
Copy link
Contributor

@bodik bodik commented May 13, 2019

When passing filters parsed from client request it might be desirable to disable auto join feature on demand. Please consider the simple patch.

Copy link
Owner

@juliotrigo juliotrigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bodik, thank you for all the proposals!

Can I ask what the use case behind this addition is? I am wondering when you would like not to "auto join", considering that you are providing multiple models and filters for them.

I'll take a look at the rest of the PRs as soon as I can.

sqlalchemy_filters/filters.py Show resolved Hide resolved
@bodik
Copy link
Contributor Author

bodik commented Jun 7, 2019

Can I ask what the use case behind this addition is? I am wondering when you would like not to
"auto join", considering that you are providing multiple models and filters for them.

The exact use-case comes from my current project, the filter condition is taken from client input (https://github.com/bodik/sner4/blob/master/sner/server/templates/storage/vuln/list.html#L52), the syntax of the filter is handled by parser with defined grammar (https://github.com/bodik/sner4/blob/master/sner/server/sqlafilter.py#L52) and parsed filter specification/tree is finally used to filter out listing results (https://github.com/bodik/sner4/blob/master/sner/server/controller/storage/vuln.py#L62)

The queried fields are specified in code so they could not be altered by the malicious input, but the implicit auto-join feature will result in joining any user specified table to the query. Despite the user cannot change the output values per-se, I guess there might be some side effects to infer some information with the technique.

In this particular user-case, do_auto_join=False looks to me like painless, backward compatible solution, giving the developer some control over magically happening joining behind the scenes.

Copy link
Owner

@juliotrigo juliotrigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

Thank you for the detailed explanation!

Would you also mind adding a short note to the README file documenting this change?

@bodik bodik force-pushed the feature-can_disable_autojoin branch from aa1517e to 1892f40 Compare June 12, 2019 11:34
@bodik
Copy link
Contributor Author

bodik commented Jun 12, 2019

Would you also mind adding a short note to the README file documenting this change?

something like 1892f40 ?

Copy link
Owner

@juliotrigo juliotrigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks for the changes.

@juliotrigo juliotrigo merged commit beea87e into juliotrigo:master Jun 13, 2019
@bodik bodik deleted the feature-can_disable_autojoin branch August 29, 2019 13:36
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

Successfully merging this pull request may close these issues.

2 participants