Skip to content

Commit

Permalink
remove unused 404 import
Browse files Browse the repository at this point in the history
  • Loading branch information
BenediktMKuehne committed Jul 3, 2024
1 parent 5d2664b commit f262e3c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions embark/reporter/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from django.conf import settings
from django.forms import model_to_dict
from django.http.response import Http404
from django.shortcuts import redirect, render
from django.contrib import messages
from django.template.loader import get_template
Expand Down Expand Up @@ -76,7 +75,7 @@ def html_report_path(request, analysis_id, html_path, file):
content_type = "text/plain"
try:
with open(resource_path, 'rb') as requested_file:

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
This path depends on a
user-provided value
.
This path depends on a
user-provided value
.
response = HttpResponse(requested_file.read(), content_type="text/plain")
response = HttpResponse(requested_file.read(), content_type=content_type)
response['Content-Disposition'] = 'attachment; filename=' + requested_file
logger.info("html_report - analysis_id: %s html_path: %s download_file: %s", analysis_id, html_path, requested_file)
return response
Expand All @@ -89,7 +88,7 @@ def html_report_path(request, analysis_id, html_path, file):
content_type = "text/html"
logger.debug("html_report - analysis_id: %s path: %s html_file: %s", analysis_id, html_path, file)
try:
return render(request, resource_path, {'embarkBackUrl': reverse('embark-ReportDashboard')}, content_type='text/html')
return render(request, resource_path, {'embarkBackUrl': reverse('embark-ReportDashboard')}, content_type=content_type)
except UnicodeDecodeError as decode_error:
logger.error("{%s} with error: %s", resource_path, decode_error)
# removes all non utf8 chars from html USING: https://stackoverflow.com/questions/191359/how-to-convert-a-file-to-utf-8-in-python
Expand All @@ -105,10 +104,10 @@ def html_report_path(request, analysis_id, html_path, file):
move(resource_path, f'{resource_path}.old')

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
This path depends on a
user-provided value
.
This path depends on a
user-provided value
.

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
This path depends on a
user-provided value
.
This path depends on a
user-provided value
.
move(f'{resource_path}.new', resource_path)

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
This path depends on a
user-provided value
.
This path depends on a
user-provided value
.

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
This path depends on a
user-provided value
.
This path depends on a
user-provided value
.
logger.debug("Removed problematic char from %s", resource_path)
return render(request, resource_path, {'embarkBackUrl': reverse('embark-ReportDashboard')}, content_type='text/html')
return render(request, resource_path, {'embarkBackUrl': reverse('embark-ReportDashboard')}, content_type=content_type)
messages.error(request, "Can't server that file")
logger.error("Server can't handle that file - %s", request)
return redirect("..")
return redirect("..")
messages.error(request, "User not authorized")
logger.error("User not authorized - %s", request)
return redirect("..")
Expand Down

0 comments on commit f262e3c

Please sign in to comment.