Skip to content

Commit

Permalink
fix: do not use eval
Browse files Browse the repository at this point in the history
  • Loading branch information
saranyailla committed Nov 27, 2023
1 parent 9d54a25 commit 3648fc2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gdk/CLIParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def _get_arg_from_model(self, argument):
if param in argument and param != "name":
modified_arg[param] = argument[param]
if param in argument and param == "type":
modified_arg[param] = eval(argument[param])
modified_arg[param] = getattr(utils, argument[param])
return argument["name"], modified_arg

def _add_common_args_for_all_commands(self):
Expand Down
3 changes: 3 additions & 0 deletions gdk/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ def is_recipe_size_valid(file_path):
file_size = Path(file_path).stat().st_size
return file_size <= MAX_RECIPE_FILE_SIZE_BYTES, file_size

def convertToLowercase(value):
return str.lower(value)


error_line = "\n=============================== ERROR ===============================\n"
help_line = "\n=============================== HELP ===============================\n"
Expand Down
2 changes: 1 addition & 1 deletion gdk/static/cli_model.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"python",
"java"
],
"type": "str.lower"
"type": "convertToLowercase"
},
"template": {
"name": [
Expand Down

0 comments on commit 3648fc2

Please sign in to comment.