Skip to content

Commit 327ecb7

Browse files
committed
fix reevaluate_on_analysis_change
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent 57a7b4d commit 327ecb7

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

vulnerabilities/triage/signals.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,15 @@
1616
@receiver([post_save, post_delete], sender="vulnerabilities.VulnerabilityAnalysis")
1717
def reevaluate_on_analysis_change(sender, instance, **kwargs):
1818
"""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.
2222
return
2323

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)
3128

3229

3330
@receiver([post_save, post_delete], sender="product_portfolio.ProductPackage")

0 commit comments

Comments
 (0)