Skip to content

Commit 281699d

Browse files
authored
Fix Path Hijacking in Semantic Store (#146)
1 parent d812b4e commit 281699d

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/ledgermind/core/stores/semantic.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import uuid
77
import threading
88
import subprocess
9+
import shutil
910
from datetime import datetime
1011
from typing import List, Optional, Any, Dict, Tuple
1112
from contextlib import contextmanager, nullcontext
@@ -88,8 +89,10 @@ def __init__(self, repo_path: str, trust_boundary: TrustBoundary = TrustBoundary
8889

8990
git_available = False
9091
try:
91-
subprocess.run(["git", "--version"], capture_output=True, check=True) # nosec B603 B607
92-
git_available = True
92+
git_path = shutil.which("git")
93+
if git_path:
94+
subprocess.run([git_path, "--version"], capture_output=True, check=True) # nosec B603 B607
95+
git_available = True
9396
except (subprocess.CalledProcessError, FileNotFoundError):
9497
pass
9598

@@ -130,7 +133,9 @@ def reconcile_untracked(self):
130133
recovered = False
131134
for f in disk_files:
132135
if isinstance(self.audit, GitAuditProvider):
133-
res = subprocess.run(["git", "ls-files", "--error-unmatch", f],
136+
git_path = shutil.which("git")
137+
if not git_path: continue
138+
res = subprocess.run([git_path, "ls-files", "--error-unmatch", f],
134139
cwd=self.repo_path, capture_output=True) # nosec B603 B607
135140
if res.returncode != 0:
136141
logger.info(f"Recovering untracked file: {f}")

0 commit comments

Comments
 (0)