-
Notifications
You must be signed in to change notification settings - Fork 174
fix(cryptography): prevent BloomFilter arbitrary from generating zero hashers #2460
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
base: main
Are you sure you want to change the base?
fix(cryptography): prevent BloomFilter arbitrary from generating zero hashers #2460
Conversation
|
I think it might make more sense to make the field |
|
The public API already requires NonZeroU8, so the invariant is enforced at construction. This just fixes arbitrary to respect the same constraint. Changing the internal field would be a larger refactor for no practical benefit. |
|
With this change, you'll need to call |
83d6b88 to
768875b
Compare
Did it, thanks |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #2460 +/- ##
==========================================
- Coverage 92.64% 92.63% -0.01%
==========================================
Files 353 353
Lines 102482 102482
==========================================
- Hits 94940 94939 -1
- Misses 7542 7543 +1
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
@patrick-ogrady CI needs breaking-format label, can you add it? |
|
#2729 includes this as well (didn't see this PR before). |
Fixed a bug in BloomFilter's Arbitrary implementation where hashers could be zero.
When hashers=0, the indices() method returns an empty iterator, which causes contains() to always return true regardless of whether the item was actually inserted. This completely breaks the bloom filter semantics (100% false positive rate).
The public constructor already requires NonZeroU8, so arbitrary should respect the same invariant. Added .max(1) to ensure at least one hasher is always generated.