Skip to content

Commit

Permalink
Ref #8 Fixed Uncontrolled data used in path expression issue
Browse files Browse the repository at this point in the history
Signed-off-by: Krzysztof Kaźmierczyk <kazm@ibm.com>
  • Loading branch information
kkazmierczyk committed Oct 31, 2024
1 parent 69bf537 commit 95eeff9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions javacore_analyser_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,12 @@ def delete(path):
# Checking if the report exists. This is to prevent attempt to delete any data by deleting any file outside
# report dir if you prepare path variable.
reports_list = os.listdir(reports_dir)
if path in reports_list:
report_location = os.path.join(reports_dir, path)
logging.info("Deleting directory " + report_location)
shutil.rmtree(report_location)
else:
report_location = os.path.normpath(os.path.join(reports_dir, path))
if not report_location.startswith(reports_dir):
logging.error("Deleted report in report list. Not deleting")
return "Cannot delete the report. The report <b>" + path + "</b> does not exist", 503

Check warning

Code scanning / CodeQL

Reflected server-side cross-site scripting Medium

Cross-site scripting vulnerability due to a
user-provided value
.
shutil.rmtree(report_location)

return redirect("/")

# Assisted by WCA@IBM
Expand Down

0 comments on commit 95eeff9

Please sign in to comment.