Skip to content

Commit 5aeb81f

Browse files
authored
fix(service): snyk xss warnings (#3234)
1 parent f367cc7 commit 5aeb81f

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,6 @@ tmp/
9797

9898
# pytest-recording cache
9999
cassettes
100+
101+
# snyk
102+
.dccache

renku/ui/service/entrypoint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def exceptions(e):
117117

118118
# NOTE: craft user messages
119119
if hasattr(e, "code"):
120-
code = e.code
120+
code = int(e.code)
121121

122122
# NOTE: return an http error for methods with no body allowed. This prevents undesired exceptions.
123123
NO_PAYLOAD_METHODS = "HEAD"

renku/ui/service/views/__init__.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@
1616
# See the License for the specific language governing permissions and
1717
# limitations under the License.
1818
"""Renku service views."""
19-
from flask import current_app
19+
from flask import jsonify
20+
from marshmallow import Schema
2021

2122
from renku.ui.service.config import SVC_ERROR_GENERIC
2223
from renku.ui.service.serializers.rpc import JsonRPCResponse
2324

2425

25-
def result_response(serializer, data):
26+
def result_response(serializer: Schema, data):
2627
"""Construct flask response."""
27-
return current_app.response_class(response=serializer.dumps({"result": data}), mimetype="application/json")
28+
return jsonify(serializer.dump({"result": data}))
2829

2930

3031
def error_response(serviceError):
@@ -40,4 +41,4 @@ def error_response(serviceError):
4041
if hasattr(serviceError, "sentry"):
4142
error["sentry"] = serviceError.sentry
4243

43-
return current_app.response_class(response=JsonRPCResponse().dumps({"error": error}), mimetype="application/json")
44+
return jsonify(JsonRPCResponse().dump({"error": error}))

0 commit comments

Comments
 (0)