Skip to content

Remove ipRulesProvider.get's skipRule parameter#11610

Merged
iain-macdonald merged 2 commits intomasterfrom
im/ae58ee21f53
Mar 18, 2026
Merged

Remove ipRulesProvider.get's skipRule parameter#11610
iain-macdonald merged 2 commits intomasterfrom
im/ae58ee21f53

Conversation

@iain-macdonald
Copy link
Contributor

@iain-macdonald iain-macdonald commented Mar 18, 2026

Copilot AI review requested due to automatic review settings March 18, 2026 00:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the IP rules enforcement API to remove the skipCache flag, replacing it with an explicit cache invalidation method, and updates the IP rules service + tests to use the new flow.

Changes:

  • Update interfaces.IPRulesEnforcer to add InvalidateCache() and simplify Check() signature.
  • Update ip_rules_service to invalidate cached rules before performing lockout-prevention checks.
  • Rework ip_rules_enforcer caching to retain rule IDs in cached entries so skipRuleID can be applied at check time.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
server/interfaces/interfaces.go Adjusts IPRulesEnforcer interface to add cache invalidation and simplify Check.
enterprise/server/ip_rules_service/ip_rules_service.go Uses InvalidateCache() before Check() when enabling enforcement or validating rule deletion.
enterprise/server/ip_rules_service/ip_rules_service_test.go Updates fake enforcer + assertions to reflect the new invalidation/check call sequence.
enterprise/server/ip_rules_enforcer/ip_rules_enforcer.go Introduces ipRule (ID + CIDR) cache entries, adds invalidation plumbing, and updates Check() behavior.
enterprise/server/ip_rules_enforcer/ip_rules_enforcer_test.go Updates tests for the new Check() signature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@iain-macdonald iain-macdonald marked this pull request as draft March 18, 2026 00:20
@iain-macdonald iain-macdonald marked this pull request as ready for review March 18, 2026 02:29
@iain-macdonald iain-macdonald requested a review from vanja-p March 18, 2026 02:30
allowed *net.IPNet
}

type ipRuleCache interface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type has some weird stuff going on with exports. It's not exported, but it's method are, but the method operate on the unexported ipRule type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to just use an lru.LRU as an implementation, so the methods need to be public, unless I'm missing something.

iain-macdonald and others added 2 commits March 18, 2026 10:51
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@iain-macdonald iain-macdonald merged commit 2614daf into master Mar 18, 2026
12 checks passed
@iain-macdonald iain-macdonald deleted the im/ae58ee21f53 branch March 18, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants