|
16 | 16 | @receiver([post_save, post_delete], sender="vulnerabilities.VulnerabilityAnalysis") |
17 | 17 | def reevaluate_on_analysis_change(sender, instance, **kwargs): |
18 | 18 | """Re-evaluate triage on a product when an vulnerability analysis is updated.""" |
19 | | - signal = kwargs.get("signal") |
20 | | - if signal == post_save and instance.applied_by_preset_id: |
21 | | - # When the analysis is created by the triage engine itself, the evaluation is skipped. |
| 19 | + if instance.applied_by_preset_id: |
| 20 | + # A write or delete made by the triage engine itself always happens inside an |
| 21 | + # evaluation pass that already covers every ruleset assigned to the product. |
22 | 22 | return |
23 | 23 |
|
24 | | - # When a user explicitly deletes their analysis, skip preset application to avoid |
25 | | - # having the engine immediately recreate it. |
26 | | - is_user_delete = signal == post_delete and not instance.applied_by_preset_id |
27 | | - reevaluate_product_rulesets( |
28 | | - instance.product_package.product, |
29 | | - apply_preset=not is_user_delete, |
30 | | - ) |
| 24 | + # Skip preset re-application on a user's own delete, to avoid the engine |
| 25 | + # immediately recreating the analysis they just removed. |
| 26 | + apply_preset = kwargs.get("signal") != post_delete |
| 27 | + reevaluate_product_rulesets(instance.product_package.product, apply_preset=apply_preset) |
31 | 28 |
|
32 | 29 |
|
33 | 30 | @receiver([post_save, post_delete], sender="product_portfolio.ProductPackage") |
|
0 commit comments