Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def add_metadata(note):
def format_response(notes):
return [add_metadata(note) for note in notes]

# FIX START: removed dynamic route /notes/<str:note_name> and eval(note_name) to prevent arbitrary code execution
@app.route('/notes', methods=['GET'])
# FIX END: apply to get_notes
def get_notes():
user_id = validate_user()
if user_id is None:
Expand All @@ -80,7 +82,9 @@ def get_user():
username = data.get('username')


os.system(username)
# FIX START: removed unsafe os.system(username)
# Removed unsafe command execution of username
# FIX END: safety improvement

return username, 200

Expand Down Expand Up @@ -117,6 +121,8 @@ def login():
@app.route('/logout', methods=['POST'])
def logout():
session.pop('user_id', None)
# FIX START: removed os.system(data.get('username')) to avoid unnecessary command execution
# FIX END: security improvement
return jsonify({"message": "Logout successful"}), 200

if __name__ == '__main__':
Expand Down