Repository navigation
fix(dynamic-rules): apply each rule version over the base config - #141
Merged
Merged
Conversation
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.
Closes #140
Ports Guard-Core/guard-core#169 to the Rust engine.
DynamicRuleManager::apply_rulenow restores the retained base snapshot before applying, so each version (or a different rule id) is an overlay on the base config and not on the previous version. Expiry is unchanged. Emergency mode no longer compounds: base 16 gives 8, 8, 8 across versions 1 to 3, and expiry restores 16.Other divergences fixed in the same area: country rules are skipped when neither
geo_ip_handlernor a non-emptyipinfo_tokencan resolve a country, a zeroglobal_rate_limitorglobal_rate_windowis ignored (falsy in the reference), a zeroauto_ban_thresholdorauto_ban_durationrejects the whole delivery and the last-known snapshot (ge=1in the reference), andhydrate_last_known_rulesonly runs withenable_dynamic_rulesand persists the snapshot like_apply_rulesdoes. The existing tests that applied countries or hydrated now setipinfo_tokenandenable_dynamic_rules.I ported the eight reference tests with the same scenarios and values. On master five of them fail (halving gives 8, 4, 2; a version keeps the previous version's change; a different rule id inherits it; expiry restores 4 instead of 16; a version after hydration compounds to 4). The collection test and the pattern test pass on both sides, because the engine replaces collections per version and
SusPatternsManager::add_patternalready deduplicates. The failed-apply scenario has no reachable failure here (apply_to_configis infallible), so that test only pins that a poisoned config lock leaves the active version and base untouched, and it also passes on master.