-
Notifications
You must be signed in to change notification settings - Fork 1.8k
perf: Use lazy loading for Product_Tab to improve edit finding performance Fixes#10313 #13805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: Use lazy loading for Product_Tab to improve edit finding performance Fixes#10313 #13805
Conversation
…mance Replace eager query execution in Product_Tab.__init__ with @cached_property decorators. This defers expensive database queries until they are actually accessed, improving page load performance. Fixes DefectDojo#10313
🔴 Risk threshold exceeded.This pull request modifies a sensitive file path (dojo/utils.py) flagged by the scanner for potentially sensitive edits; repository owners can configure sensitive paths and allowed authors in .dryrunsecurity.yaml to adjust blocking behavior.
🔴 Configured Codepaths Edit in
|
| Vulnerability | Configured Codepaths Edit |
|---|---|
| Description | Sensitive edits detected for this file. Sensitive file paths and allowed authors can be configured in .dryrunsecurity.yaml. |
We've notified @mtesauro.
All finding details can be found in the DryRun Security Dashboard.
valentijnscholten
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, I've never seen this code. I don't think we should keep this in this way as we have predefined queries for what is meant by "Open" findings etc. But for now there's no harm in merging this to make it more "lazy" :-)
|
@Vincent-Ngobeh If you want you can rebase the fix onto |
Maffooch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed with everything Val said. Excellent job!
mtesauro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
Summary
Refactored
Product_Tabclass indojo/utils.pyto use@cached_propertydecorators for lazy loading instead of executing all database queries eagerly in__init__. This significantly improves page load performance for views like Edit Finding.Related Issue: Fixes #10313
Problem
When editing a finding in a product with 100,000+ findings, the page takes 50+ seconds to load. This is because
Product_Tab.__init__executes 5+ expensive COUNT queries immediately, even though the Edit Finding page doesn't need all of them.Solution
@cached_propertydecoratorsKey changes:
functools.cached_propertyimportengagement_count,open_findings_count,endpoints_count,endpoint_hosts_count, andbenchmark_typeto@cached_property_product,_title, etc.)title,tab,product,engagementto@propertyfor consistencyTest Plan
python -m py_compile dojo/utils.pyChecklist
dev