Skip to content

Commit

Permalink
Fix code scanning alert no. 1: Information exposure through an exception
Browse files Browse the repository at this point in the history
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
fgalan and github-advanced-security[bot] authored Oct 4, 2024
1 parent f89231b commit d81ee13
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 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,13 @@ 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):
"""
Inspect request header in order to look if we have to continue or not
Expand Down

0 comments on commit d81ee13

Please sign in to comment.