mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-22 03:41:43 +00:00
fixed liting errors
This commit is contained in:
parent
9c219db9ba
commit
dc8bdae64f
@ -11,7 +11,6 @@ from concurrent.futures import Executor, ThreadPoolExecutor
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, final
|
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, final
|
||||||
|
|
||||||
from jinja2 import Template
|
|
||||||
from jinja2.sandbox import SandboxedEnvironment
|
from jinja2.sandbox import SandboxedEnvironment
|
||||||
|
|
||||||
from dbgpt._private.pydantic import ConfigDict, Field
|
from dbgpt._private.pydantic import ConfigDict, Field
|
||||||
@ -43,15 +42,15 @@ class ConversableAgent(Role, Agent):
|
|||||||
|
|
||||||
# Dangerous template patterns that could lead to code execution
|
# Dangerous template patterns that could lead to code execution
|
||||||
_DANGEROUS_TEMPLATE_PATTERNS = [
|
_DANGEROUS_TEMPLATE_PATTERNS = [
|
||||||
r'\{\{.*__.*\}\}', # Double underscore methods
|
r"\{\{.*__.*\}\}", # Double underscore methods
|
||||||
r'\{\{.*import.*\}\}', # Import statements
|
r"\{\{.*import.*\}\}", # Import statements
|
||||||
r'\{\{.*exec.*\}\}', # Exec calls
|
r"\{\{.*exec.*\}\}", # Exec calls
|
||||||
r'\{\{.*eval.*\}\}', # Eval calls
|
r"\{\{.*eval.*\}\}", # Eval calls
|
||||||
r'\{\{.*open.*\}\}', # File operations
|
r"\{\{.*open.*\}\}", # File operations
|
||||||
r'\{\{.*subprocess.*\}\}', # Subprocess calls
|
r"\{\{.*subprocess.*\}\}", # Subprocess calls
|
||||||
r'\{\{.*os\..*\}\}', # OS module access
|
r"\{\{.*os\..*\}\}", # OS module access
|
||||||
r'\{\{.*globals.*\}\}', # Globals access
|
r"\{\{.*globals.*\}\}", # Globals access
|
||||||
r'\{\{.*\[.*\].*\}\}', # Bracket notation access
|
r"\{\{.*\[.*\].*\}\}", # Bracket notation access
|
||||||
]
|
]
|
||||||
|
|
||||||
agent_context: Optional[AgentContext] = Field(None, description="Agent context")
|
agent_context: Optional[AgentContext] = Field(None, description="Agent context")
|
||||||
@ -1115,7 +1114,7 @@ class ConversableAgent(Role, Agent):
|
|||||||
def _render_bind_prompt(
|
def _render_bind_prompt(
|
||||||
self,
|
self,
|
||||||
resource_vars: Optional[Dict] = None,
|
resource_vars: Optional[Dict] = None,
|
||||||
context: Optional[Dict[str, Any]] = None
|
context: Optional[Dict[str, Any]] = None,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Render bind prompt template with sanitized parameters."""
|
"""Render bind prompt template with sanitized parameters."""
|
||||||
prompt_param = {}
|
prompt_param = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user