Skip to content

Commit

Permalink
[Security Solution] Add rule upgrade review cache invalidation (#202969)
Browse files Browse the repository at this point in the history
**Resolves: #202779

## Summary

Implemented proper cache invalidation after rule CRUD operations to
prevent displaying stale data in rule upgrade flyouts. See the linked
issue for more details.

### How to Test

1. Ensure rule customization is enabled
2. Navigate to the Rule Updates page 
3. Locate any rule with updates
4. Make changes to the rule:
   - Edit the rule via the Rule Editing page
   - Use bulk actions
   - Delete the rule
5. Return to the Rule Updates page
   - All introduced changes should be reflected:
     - Modifications should be visible
     - If the rule was deleted, it should no longer appear on the page
  • Loading branch information
xcrzx authored Dec 5, 2024
1 parent 54e1032 commit 94c5614
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export const useBulkActionMutation = (
invalidateFetchRuleByIdQuery();
invalidateFetchRuleManagementFilters();
invalidateFetchCoverageOverviewQuery();
invalidateFetchPrebuiltRulesUpgradeReviewQuery();
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useInvalidateFindRulesQuery } from './use_find_rules_query';
import { useUpdateRuleByIdCache } from './use_fetch_rule_by_id_query';
import { useInvalidateFetchRuleManagementFiltersQuery } from './use_fetch_rule_management_filters_query';
import { useInvalidateFetchCoverageOverviewQuery } from './use_fetch_coverage_overview_query';
import { useInvalidateFetchPrebuiltRulesUpgradeReviewQuery } from './prebuilt_rules/use_fetch_prebuilt_rules_upgrade_review_query';

export const UPDATE_RULE_MUTATION_KEY = ['PUT', DETECTION_ENGINE_RULES_URL];

Expand All @@ -26,6 +27,7 @@ export const useUpdateRuleMutation = (
const invalidateFindRulesQuery = useInvalidateFindRulesQuery();
const invalidateFetchRuleManagementFilters = useInvalidateFetchRuleManagementFiltersQuery();
const invalidateFetchCoverageOverviewQuery = useInvalidateFetchCoverageOverviewQuery();
const invalidatePrebuiltRulesUpdateReview = useInvalidateFetchPrebuiltRulesUpgradeReviewQuery();
const updateRuleCache = useUpdateRuleByIdCache();

return useMutation<RuleResponse, Error, RuleUpdateProps>(
Expand All @@ -37,6 +39,7 @@ export const useUpdateRuleMutation = (
invalidateFindRulesQuery();
invalidateFetchRuleManagementFilters();
invalidateFetchCoverageOverviewQuery();
invalidatePrebuiltRulesUpdateReview();

const [response] = args;

Expand Down

0 comments on commit 94c5614

Please sign in to comment.