Skip to content

The agent that grows with you

fix(plugins): bound the /proc write check, see r+/rb+/O_WRONLY writes, drop the raw env copy

Teknium04cd9ac3fa66
diff --git a/tools/plugin_guard.py b/tools/plugin_guard.py
index f0bd4ea6c45..545dd13a347 100644
--- a/tools/plugin_guard.py
+++ b/tools/plugin_guard.py
@@ -322,8 +322,7 @@ def _tracked_bytecode(plugin_dir: Path) -> set[str]:
try:
out = subprocess.run(
["git", "-c", "core.fsmonitor=false", "-C", str(plugin_dir), "ls-files", "-z", "--", "*.pyc", "*.pyo"],
- capture_output=True, check=True, timeout=60, stdin=subprocess.DEVNULL,
- env={**os.environ, "GIT_OPTIONAL_LOCKS": "0"}).stdout
+ capture_output=True, check=True, timeout=60, stdin=subprocess.DEVNULL).stdout
except (OSError, subprocess.SubprocessError):
return set()
return {os.fsdecode(p) for p in out.split(b"\0") if p}
diff --git a/tools/plugin_guard_context.py b/tools/plugin_guard_context.py
index 949a3f20e90..6777d5e91c1 100644
--- a/tools/plugin_guard_context.py
+++ b/tools/plugin_guard_context.py
@@ -789,7 +789,8 @@ _BENIGN_PROC_LEAVES = frozenset({
"cgroup", "mountinfo", "mounts", "stat", "statm", "status", "limits", "io", "comm", "cpuset",
"sched", "schedstat", "oom_score"})
_PROC_PATH = re.compile(r"/proc/(?:self|\d+)(?:/([\w.-]*))?")
-_PROC_WRITE = re.compile(r"write_text|write_bytes|\.write\s*\(|open\s*\([^)]*['\"][wax+]|>\s*/proc/|\btee\b")
+_PROC_WRITE = re.compile(
+ r"write_text|write_bytes|\.write\s*\(|open\s*\([^)\n]{0,300}?['\"][rbt]*[wax+][rbt+]*['\"]|O_WRONLY|O_RDWR|>\s*/proc/|\btee\b")
def is_own_proc_read(finding: Finding, line: str) -> bool: