Skip to content

Commit

Permalink
add filename check to pass CodeQL check
Browse files Browse the repository at this point in the history
  • Loading branch information
Weiyu-Kong committed Dec 28, 2024
1 parent 0404dfc commit 583a8b0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions WEBtool/phishpedia_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ def upload_file():

if file and allowed_file(file.filename):
filename = file.filename
if filename.count('.') > 1:
return jsonify({'error': 'Invalid file name'}), 400
elif any(sep in filename for sep in (os.sep, os.altsep)):
return jsonify({'error': 'Invalid file name'}), 400
elif '..' in filename:
return jsonify({'error': 'Invalid file name'}), 400
file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
file_path = os.path.normpath(file_path)
file.save(file_path)
Expand Down

0 comments on commit 583a8b0

Please sign in to comment.