Repository navigation
database: dedup decisions within the filtered set - #4883
Open
Vigneshwarans32241 wants to merge 1 commit into
Open
Vigneshwarans32241 wants to merge 1 commit into
Vigneshwarans32241 wants to merge 1 commit into
Conversation
The longest decision for a value/type/scope was picked over the whole table, so a longer decision excluded by the query filters hid the matching one. A bouncer asking for origin=crowdsec received nothing for a value that also had a longer CAPI decision. Apply the origin and scenario filters to the dedup subquery.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bouncers filtering the decision stream silently missed bans.
longestDecisionForScopeTypeValue picks the longest decision for a value/type/scope over
the whole decisions table, while the origins and scenarios_* filters are applied to the
outer query only. A decision matching the filter is dropped as soon as a longer
filtered-out decision exists for the same value: with ?origins=crowdsec&startup=true, a
value that also has a longer CAPI decision returns {"new": [], "deleted": []} and the
bouncer never blocks it (#3373). The delta stream behaves the same way. dedup=false was
the only workaround.
The origin and scenario filters now also apply inside the dedup subquery, so the longest
decision is picked among the decisions the caller asked for. Behaviour without filters is
unchanged, and dedup still spans origins when several are requested.
Tested:
new test fails: 3 subtests, including origin_filter and delta_stream_with_origin_filter
AI: the patch and the test were drafted with an AI assistant; I reviewed the diff and
verified the reproduction and the test results myself.