Skip to content
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 crash on saving endpoint (FFUF related only) #1063

Merged
merged 9 commits into from
Nov 27, 2023
21 changes: 18 additions & 3 deletions web/reNgine/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,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 @@ -4495,11 +4494,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
Loading