Skip to content

Commit

Permalink
fix information exposure issue in server.py & interface.py
Browse files Browse the repository at this point in the history
  • Loading branch information
niklastheman committed Jun 17, 2024
1 parent 1eea9ee commit dd0d81b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion fedn/network/api/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ def set_initial_model(self, file):
self.control.commit(file.filename, model)
except Exception as e:
logger.debug(e)
return jsonify({"success": False, "message": e})
return jsonify({"success": False, "message": "Failed to add initial model."})

return jsonify({"success": True, "message": "Initial model added successfully."})

Expand Down
27 changes: 17 additions & 10 deletions fedn/network/api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
from fedn.common.config import get_controller_config
from fedn.network.api.auth import jwt_auth_required
from fedn.network.api.interface import API
from fedn.network.api.shared import control, statestore
from fedn.network.api.v1 import _routes
from fedn.network.api.shared import statestore, control


custom_url_prefix = os.environ.get("FEDN_CUSTOM_URL_PREFIX", False)
api = API(statestore, control)
Expand Down Expand Up @@ -569,8 +568,10 @@ def add_combiner():
remote_addr = request.remote_addr
try:
response = api.add_combiner(**json_data, remote_addr=remote_addr)
except TypeError as e:
return jsonify({"success": False, "message": str(e)}), 400
except TypeError:
return jsonify({"success": False, "message": "Invalid data provided"}), 400
except Exception:
return jsonify({"success": False, "message": "An unexpected error occurred"}), 500
return response


Expand All @@ -589,8 +590,10 @@ def add_client():
remote_addr = request.remote_addr
try:
response = api.add_client(**json_data, remote_addr=remote_addr)
except TypeError as e:
return jsonify({"success": False, "message": str(e)}), 400
except TypeError:
return jsonify({"success": False, "message": "Invalid data provided"}), 400
except Exception:
return jsonify({"success": False, "message": "An unexpected error occurred"}), 500
return response


Expand All @@ -612,8 +615,10 @@ def list_combiners_data():

try:
response = api.list_combiners_data(combiners)
except TypeError as e:
return jsonify({"success": False, "message": str(e)}), 400
except TypeError:
return jsonify({"success": False, "message": "Invalid data provided"}), 400
except Exception:
return jsonify({"success": False, "message": "An unexpected error occurred"}), 500
return response


Expand All @@ -630,8 +635,10 @@ def get_plot_data():
try:
feature = request.args.get("feature", None)
response = api.get_plot_data(feature=feature)
except TypeError as e:
return jsonify({"success": False, "message": str(e)}), 400
except TypeError:
return jsonify({"success": False, "message": "Invalid data provided"}), 400
except Exception:
return jsonify({"success": False, "message": "An unexpected error occurred"}), 500
return response


Expand Down

0 comments on commit dd0d81b

Please sign in to comment.