Skip to content

Dynamic rule versions apply over the previous version instead of the base config #95

Closed

Description

@rennf93

Port of the reference fix Guard-Core/guard-core#169 (merged as 859ac345).

DynamicRuleManager.applyRulesLocked snapshots the live config and applies the new version on top of it, so every version stacks on the previous one instead of overlaying the base config. Emergency mode halves AutoBanThreshold again for every version (base 16 gives 8, 4, 2 for versions 1 to 3), a version that stops setting a field keeps the value the previous version set, and a different rule id inherits the previous rule's changes. Expiry already restores the base, so only the apply path is wrong.

Two further divergences from the reference in the same area: a repeated suspicious_patterns entry is registered again by every version that repeats it, and the global rate limit log line prints the pointer address of GlobalRateLimit instead of its value.

The fix restores the retained base snapshot before applying (previous state is the rollback target on failure), skips patterns the registry already holds, and logs the dereferenced limit. Tests mirror the eight reference tests in tests/test_dynamic_rule_overlay.py.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions