Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code scanning alert no. 1: Information exposure through an exception #4619

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
13 changes: 12 additions & 1 deletion scripts/accumulator-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
# * This script requires at least Flask 2.0.2, which comes with Werkzeug 2.0.2.

from flask import Flask, request, Response
import logging
from getopt import getopt, GetoptError
from datetime import datetime
from math import trunc
Expand Down Expand Up @@ -375,7 +376,8 @@ def record_request(request):
s += json.dumps(raw, indent=4, sort_keys=True)
s += '\n'
except ValueError as e:
s += str(e)
log_error(str(e)) # Log the error details
s += "An error occurred while processing the request."
else:
s += request.data.decode("utf-8")

Expand All @@ -389,6 +391,15 @@ def record_request(request):
print(s)


def log_error(error_message):
"""
Log the error message to a file or standard output.

:param error_message: The error message to log
"""
logging.error(error_message)


def send_continue(request):
fgalan marked this conversation as resolved.
Show resolved Hide resolved
"""
Inspect request header in order to look if we have to continue or not
Expand Down
Loading