-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix engagements filters in 'engagements by product view' #10046
Fix engagements filters in 'engagements by product view' #10046
Conversation
Hi there 👋, @DryRunSecurity here, below is a summary of our analysis and findings.
Note 🔴 Risk threshold exceeded. Adding a reviewer if one is configured in notification list: @mtesauro @grendel513 Powered by DryRun Security |
[sc-5299] |
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
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
# Conflicts: # dojo/engagement/views.py # dojo/filters.py
Conflicts have been resolved. A maintainer will review the pull request shortly. |
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.
Please add support for filters without object lookups as well. Here is an example of doing so https://github.com/DefectDojo/django-DefectDojo/blob/f66e6dbb07bcddfb607ab81e76cca073080a6c2b/dojo/filters.py#L1065C1-L1093C75
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
# Conflicts: # dojo/engagement/views.py
Conflicts have been resolved. A maintainer will review the pull request shortly. |
…10046) * fix engagements filters in 'engagements by product view' * fix linter * add filtering without object lookups * fix imports order
It's the same as #9913 but with the correct branching.
sc-[5299]
Description
The engagement filters inside the "Engagements By Product" view are not working properly. Searching by the exact name in the "Engagement name" filter returns incorrect results.
The Problem
Building relationship filters as we currently do in
EngagementFilter
generates a query that gets filtered products with all the related engagements, where at least one engagement satisfies the filter criteria. Theengagements_all
view iterates over the engagements of each product to render the table rows. As a result, we showed all product engagements that satisfied the filter criteria. For example, if two engagements fulfill the filter criteria from two different products, the rendered table will show all engagements that belong to those two products.Solution
When prefetching the engament_set, an additional filter will filter the engagements at the query level, so only filtered engagements related to filtered products will be obtained.
Also, the paginator object had to be modified to represent the correct number of rows currently shown on the page.