Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions dojo/finding/deduplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,22 +292,26 @@ def build_candidate_scope_queryset(test, mode="deduplication", service=None):
)
queryset = Finding.objects.filter(scope_q)

# Base prefetches for both modes
prefetch_list = ["endpoints", "vulnerability_id_set", "found_by"]

# Additional prefetches for reimport mode: fetch only non-special endpoint statuses with their
# endpoint joined in, so endpoint_manager can read status_finding_non_special directly without
# any extra DB queries
if mode == "reimport":
prefetch_list.append(
Prefetch(
"status_finding",
queryset=Endpoint_Status.objects.exclude(
Q(false_positive=True) | Q(out_of_scope=True) | Q(risk_accepted=True),
).select_related("endpoint"),
to_attr="status_finding_non_special",
),
)
if settings.V3_FEATURE_LOCATIONS:
prefetch_list = ["locations__location__url", "vulnerability_id_set", "found_by"]
else:
# TODO: Delete this after the move to Locations
# Base prefetches for both modes
prefetch_list = ["endpoints", "vulnerability_id_set", "found_by"]

# Additional prefetches for reimport mode: fetch only non-special endpoint statuses with their
# endpoint joined in, so endpoint_manager can read status_finding_non_special directly without
# any extra DB queries
if mode == "reimport":
prefetch_list.append(
Prefetch(
"status_finding",
queryset=Endpoint_Status.objects.exclude(
Q(false_positive=True) | Q(out_of_scope=True) | Q(risk_accepted=True),
).select_related("endpoint"),
to_attr="status_finding_non_special",
),
)

return (
queryset
Expand Down