Skip to content
Merged
Changes from 8 commits
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
20 changes: 18 additions & 2 deletions web/reNgine/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4495,11 +4495,27 @@ def save_endpoint(
if not validators.url(http_url):
return None, False
http_url = sanitize_url(http_url)
endpoint, created = EndPoint.objects.get_or_create(

# Try to get the first matching record (prevent duplicate error)
endpoints = EndPoint.objects.filter(
scan_history=scan,
target_domain=domain,
http_url=http_url,
**endpoint_data)
**endpoint_data
)

if endpoints.exists():
endpoint = endpoints.first()
created = False
else:
# No existing record, create a new one
endpoint = EndPoint.objects.create(
scan_history=scan,
target_domain=domain,
http_url=http_url,
**endpoint_data
)
created = True

if created:
endpoint.is_default = is_default
Expand Down