Skip to content

Commit

Permalink
Merge pull request #1063 from psyray/fix-1006-db
Browse files Browse the repository at this point in the history
Fix crash on saving endpoint (FFUF related only)
  • Loading branch information
yogeshojha authored Nov 27, 2023
2 parents 7c01a46 + caa0f2d commit 2e089dc
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions web/reNgine/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,6 @@ def dir_file_fuzz(self, ctx={}, description=None):
logger.error(f'FUZZ not found for "{url}"')
continue
endpoint, created = save_endpoint(url, crawl=False, ctx=ctx)
# endpoint.is_default = False
endpoint.http_status = status
endpoint.content_length = length
endpoint.response_time = duration / 1000000000
Expand Down Expand Up @@ -4511,11 +4510,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

0 comments on commit 2e089dc

Please sign in to comment.