Skip to content

Commit bfe9777

Browse files
committed
Add a check to verify the name of the environment variable
1 parent ef953f5 commit bfe9777

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

eb_hooks.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ def parse_hook(ec, *args, **kwargs):
145145

146146

147147
def parse_list_of_dicts_env(var_name):
148+
"""Parse a list of dicts that are stored in an environment variable string"""
149+
150+
# Check if the environment variable name is valid (letters, numbers, underscores, and doesn't start with a digit)
151+
if not re.match(r'^[A-Za-z_][A-Za-z0-9_]*$', var_name):
152+
raise ValueError(f"Invalid environment variable name: {var_name}")
148153
list_string = os.getenv(var_name, '[]')
149154

150155
list_of_dicts = []

0 commit comments

Comments
 (0)