Skip to content

Commit 3b2660a

Browse files
Merge pull request #1 from LightYagami28/alert-autofix-6
Potential fix for code scanning alert no. 6: Code injection
2 parents 4503139 + 8e84909 commit 3b2660a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/gui.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import hmac
33
import os
44
import sys
5+
import json
56
from dotenv import load_dotenv
67
from flask import Flask, jsonify, request, render_template, abort
78
from flask_cors import CORS
@@ -77,9 +78,9 @@ def getUserFromQuery(query):
7778
user = user.replace('true', 'True').replace('false', 'False')
7879

7980
try:
80-
# Safely parse the string into a dictionary or list (avoiding eval)
81-
user = eval(user, {"__builtins__": None}, {})
82-
except (SyntaxError, ValueError):
81+
# Safely parse the string into a dictionary or list using json.loads
82+
user = json.loads(user)
83+
except (json.JSONDecodeError, ValueError):
8384
return None
8485
return user
8586

0 commit comments

Comments
 (0)