Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/google/adk/agents/config_agent_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,21 @@ def resolve_agent_reference(
"""
if ref_config.config_path:
if os.path.isabs(ref_config.config_path):
return from_config(ref_config.config_path)
else:
return from_config(
os.path.join(
os.path.dirname(referencing_agent_config_abs_path),
ref_config.config_path,
)
raise ValueError(
f"Absolute paths are not allowed in AgentTool config_path:"
f" {ref_config.config_path!r}"
)
agent_dir = os.path.dirname(referencing_agent_config_abs_path)
resolved_path = os.path.normpath(
os.path.join(agent_dir, ref_config.config_path)
)
canonical_agent_dir = os.path.normpath(agent_dir)
if not resolved_path.startswith(canonical_agent_dir + os.sep):
raise ValueError(
f"Path traversal detected: config_path {ref_config.config_path!r}"
" resolves outside the agent directory"
)
return from_config(resolved_path)
elif ref_config.code:
return _resolve_agent_code_reference(ref_config.code)
else:
Expand Down
Loading