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 disjunctive search operation #1092

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

discomrade
Copy link
Contributor

@discomrade discomrade commented Feb 24, 2024

This commit adds the disjunctive operands to search, e.g. ~computer ~thing ~score:>5 (means: computer OR thing OR score:>5), as well as negative disjunctive operands e.g. ~cat ~-phone (means: cat OR NOT phone). This also works with image conditions.

While I believe this operation is acceptably efficient for legitimate use, it's probably wise to add limits, especially for SPEED_HAX, but for security in general. Abusing wildcards (or really just a huge number of tags) compounds with negated disjunction e.g. searching ~-*f* ~-*a* ~-*s* ~-*t* is an effective DoS attack on a decent-sized booru, even just two of those letters forces my (20,000 image, 7,000 tags) test booru into 14 seconds of computation. Maybe make negated disjunction disabled or limited by default?

Closes #292
Closes #824
Built on top of #1082

This makes future optimisations easier, such as only selecting specific columns to return and making disjunctive operations more efficient
@discomrade discomrade marked this pull request as ready for review March 4, 2024 22:46
@shish
Copy link
Owner

shish commented Apr 27, 2024

(Sorry for the delays here - this seems pretty great but I have some foundational bits I'd like to merge first and things at my day job got hectic which has been taking my code time ^^;; )

@discomrade
Copy link
Contributor Author

No problem :) This one is big and has the mentioned caveats, so definitely best not to rush it.

@discomrade discomrade marked this pull request as draft May 15, 2024 23:34
@discomrade
Copy link
Contributor Author

Marked as draft to avoid this being merged as-is:

  • The current code is capable of malicious DoS abuse and does not yet have sane default settings to mitigate this risk.
  • If QueryBuilder #1153 is merged, this will require significant refactoring. This code should be rewritten and resubmitted after that pull request is accepted.

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.

OR operator for tag search OR operator
2 participants