Skip to content

Commit ea3d4da

Browse files
author
Agent Bot
committed
Added security check for path traversal
1 parent 586c6af commit ea3d4da

3 files changed

Lines changed: 27 additions & 13 deletions

File tree

pyproject.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ description = "Add your description here"
55
readme = "README.md"
66
requires-python = ">=3.11"
77
dependencies = [
8-
"docker>=7.1.0",
9-
"langchain>=1.2.10",
10-
"langchain-community>=0.0.38",
11-
"langchain-groq>=1.1.2",
12-
"langgraph>=1.0.10",
13-
"langchain-chroma>=0.1.0",
14-
"sentence-transformers>=2.7.0",
15-
"chromadb>=0.5.0",
16-
"pygithub>=2.8.1",
17-
"python-dotenv>=1.2.2",
18-
"streamlit>=1.55.0",
8+
"docker==7.1.0",
9+
"langchain==1.2.10",
10+
"langchain-community==0.0.38",
11+
"langchain-groq==1.1.2",
12+
"langgraph==1.0.10",
13+
"langchain-chroma==0.1.0",
14+
"sentence-transformers==2.7.0",
15+
"chromadb==0.5.0",
16+
"pygithub==2.8.1",
17+
"python-dotenv==1.2.2",
18+
"streamlit==1.55.0",
1919
]
2020

2121
[project.optional-dependencies]

src/agents/coder.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,14 @@ def coder_node(state: ASEState):
5050
lines = lines[:-1]
5151
new_content = "\n".join(lines).strip()
5252

53-
# Apply fix locally
54-
full_path = os.path.join(state["repo_path"], file_path)
53+
# Apply fix locally with security check
54+
full_path = os.path.abspath(os.path.join(state["repo_path"], file_path))
55+
56+
# Security Check: Ensure path is within repo_path
57+
if not full_path.startswith(os.path.abspath(state["repo_path"])):
58+
print(f"⚠️ SECURITY ALERT: Attempted directory traversal detected for path: {file_path}")
59+
continue
60+
5561
os.makedirs(os.path.dirname(full_path), exist_ok=True)
5662
with open(full_path, 'w', encoding='utf-8') as f:
5763
f.write(new_content)

src/tools/docker_sandbox.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,11 @@ def run_test(self, repo_path: str, test_script_content: str, test_file_name="tes
5656
container.remove(force=True)
5757
except:
5858
pass
59+
60+
# Sandbox Cleanliness: Remove the local test file to keep the repo clean
61+
try:
62+
test_file_path = os.path.join(repo_path, test_file_name)
63+
if os.path.exists(test_file_path):
64+
os.remove(test_file_path)
65+
except:
66+
pass

0 commit comments

Comments
 (0)