🔥 chore(template): delete unused files and imports
This commit removes unused files and imports from the template directory. The deleted files are base.py, fields.py, and nodes.py. The deleted imports are from langflow.template.constants. This improves the codebase by removing unnecessary code and reducing clutter. ✨ feat(frontend_node): add constants module This commit adds a new module called constants to the frontend_node directory. The module contains constants used in the frontend_node module. The constants are FORCE_SHOW_FIELDS, DEFAULT_PROMPT, SYSTEM_PROMPT, and HUMAN_PROMPT. This improves the codebase by centralizing the constants in one module. 🐛 fix(frontend_node): use ast.literal_eval instead of eval This commit fixes a security vulnerability by replacing the use of eval with ast.literal_eval in the UtilitiesFrontendNode class. The method converts a string representation of a list to an actual list. The use of eval is dangerous as it can execute arbitrary code. This improves the codebase by making it more secure.
This commit is contained in:
parent
263274d266
commit
ea59375ba5
8 changed files with 9 additions and 6 deletions
|
|
@ -1 +0,0 @@
|
|||
|
||||
|
|
@ -3,7 +3,7 @@ from typing import List, Optional
|
|||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from langflow.template.constants import FORCE_SHOW_FIELDS
|
||||
from langflow.template.frontend_node.constants import FORCE_SHOW_FIELDS
|
||||
from langflow.template.field.base import TemplateField
|
||||
from langflow.template.template.base import Template
|
||||
from langflow.utils import constants
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@ from typing import Optional
|
|||
|
||||
from langchain.agents.mrkl import prompt
|
||||
|
||||
from langflow.template.constants import DEFAULT_PROMPT, HUMAN_PROMPT, SYSTEM_PROMPT
|
||||
from langflow.template.frontend_node.constants import (
|
||||
DEFAULT_PROMPT,
|
||||
HUMAN_PROMPT,
|
||||
SYSTEM_PROMPT,
|
||||
)
|
||||
from langflow.template.field.base import TemplateField
|
||||
from langflow.template.frontend_node.base import FrontendNode
|
||||
from langflow.template.template.base import Template
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
|
||||
|
|
@ -6,7 +6,7 @@ from typing import Dict, Optional
|
|||
|
||||
from docstring_parser import parse # type: ignore
|
||||
|
||||
from langflow.template.constants import FORCE_SHOW_FIELDS
|
||||
from langflow.template.frontend_node.constants import FORCE_SHOW_FIELDS
|
||||
from langflow.utils import constants
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue