Reimport: Do not reactivate endpoint statuses with special statuses#14402
Open
Reimport: Do not reactivate endpoint statuses with special statuses#14402
Conversation
…ation logic fix(location): optimize get_or_create methods for LocationFindingReference and LocationProductReference test(import_reimport): enhance tests to skip reactivation for special statuses in endpoint and location contexts
… counts for performance tests
Member
|
We should find a way to do this without 40 extra database queries. |
…dpoint_status
Evaluate existing_finding_endpoint_status_list once into a list with
select_related("endpoint") before the two list comprehensions, preventing
a duplicate DB hit and N+1 endpoint lookups. Update expected performance
test counts to reflect the reduced query counts.
…avoid extra DB queries Add a named Prefetch to build_candidate_scope_queryset that fetches only non-special endpoint statuses (excluding false_positive, out_of_scope, risk_accepted) with their endpoint joined in via select_related. This replaces the two separate "status_finding" and "status_finding__endpoint" prefetches with a single query and avoids per-finding DB hits in update_endpoint_status and process_matched_special_status_finding. Update expected performance test counts to reflect the reduced query counts.
Member
Done, it's now 1 query less than |
Contributor
Author
|
@valentijnscholten you're my hero - thanks for taking this into a better direction! |
dogboat
approved these changes
Feb 27, 2026
valentijnscholten
approved these changes
Feb 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
Endpoints previously marked as false positive, out of scope, or risk accepted could still be reactivated or associated with findings during reimport. This caused:
Solution:
This update changes the reimport behavior to exclude endpoints with special statuses. Specifically:
Behavior Changes:
Impact: