Skip to content

Commit

Permalink
fixing issue #92 (#98)
Browse files Browse the repository at this point in the history
Verify the type of the `request.data` before converting it to dict using `json.loads`
  • Loading branch information
gabrik committed Jun 12, 2019
1 parent 57878fe commit 1e4ec04
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/utils/python/rest_proxy/src/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ def plugin_info(pl_uuid, node_uuid):

@app.route('/network/add', methods=['POST'])
def network_add():
descriptor = json.loads(request.data)
data = request.data
if isinstance(data,bytes):
data = data.decode()
descriptor = json.loads(data)
return json.dumps({'result':fos_api.network.add_network(descriptor)})


Expand All @@ -65,7 +68,10 @@ def network_list():

@app.route('/connection_point/add', methods=['POST'])
def cp_add():
descriptor = json.loads(request.data)
data = request.data
if isinstance(data,bytes):
data = data.decode()
descriptor = json.loads(data)
return json.dumps({'result':fos_api.network.add_connection_point(descriptor)})


Expand All @@ -78,7 +84,10 @@ def cp_remove(cp_id):

@app.route('/fdu/onboard', methods=['POST'])
def fdu_onboard():
descriptor = json.loads(request.data)
data = request.data
if isinstance(data,bytes):
data = data.decode()
descriptor = json.loads(data)
return json.dumps({'result':fos_api.fdu.onboard(descriptor)})


Expand Down Expand Up @@ -258,7 +267,10 @@ def get_image_file(fname):

@app.route('/flavor/add', methods=['POST'])
def flavor_add():
descriptor = json.loads(request.data)
data = request.data
if isinstance(data,bytes):
data = data.decode()
descriptor = json.loads(data)
return json.dumps({'result':fos_api.flavor.add(descriptor)})


Expand Down

0 comments on commit 1e4ec04

Please sign in to comment.