Repository navigation
fix(dynamic-rules): apply each rule version over the base config - #96
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 #95
Ports Guard-Core/guard-core#169 to the Go engine.
applyRulesLockednow takes the previous state as the rollback target, restores the retained base snapshot before applying, and then snapshots again, so each version (or a different rule id) is an overlay on the base config and not on the previous version. A failed apply restores the previous state and the base stays the true base. 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:
suspicious_patternsalready held by the registry (shipped table or earlier additions) are skipped as in the reference, and the global rate limit log line printed the pointer address ofGlobalRateLimit. I left user-agent validation onregexp.Compile(RE2, linear time) since the reference ReDoS validator guards a backtracking engine.I ported the eight reference tests with the same scenarios and values. On master six 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 boot hydration compounds to 4; a pattern is registered three times), and the collection and failed-apply tests pass on both sides.
applyFaultis a test seam so the fail-closed path can be driven. The twowriteAtomicFilewaivers move from lines 733/738 to 767/772 with identical code.