🐛 fix(utilities.py): use ast.literal_eval instead of eval to improve security

🐛 fix(GenericNode): add semicolon to console.log statement
The use of eval in the code can be a security risk as it can execute arbitrary code. Using ast.literal_eval instead of eval is a safer alternative as it only evaluates a subset of Python expressions. The semicolon was added to the console.log statement to improve code consistency.
This commit is contained in:
Gabriel Almeida 2023-05-28 11:55:00 -03:00
commit c4159f3af4
2 changed files with 3 additions and 2 deletions

View file

@ -1,3 +1,4 @@
import ast
import json
from typing import Optional
@ -12,7 +13,7 @@ class UtilitiesFrontendNode(FrontendNode):
# field.field_type could be "Literal['news', 'search', 'places', 'images']
# we need to convert it to a list
if "Literal" in field.field_type:
field.options = eval(field.field_type.replace("Literal", ""))
field.options = ast.literal_eval(field.field_type.replace("Literal", ""))
field.is_list = True
field.field_type = "str"

View file

@ -85,7 +85,7 @@ export default function GenericNode({
deleteNode(data.id);
return;
}
console.log(data)
console.log(data);
return (
<div