agentboxes 0.2.3__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentboxes
3
- Version: 0.2.3
3
+ Version: 0.3.0
4
4
  Summary: Python client for an agentbox server: sandboxes for AI agents on your own Linux box
5
5
  License: MIT
6
6
  Requires-Python: >=3.9
@@ -39,6 +39,8 @@ class ExecResult:
39
39
  duration_ms: int
40
40
  timed_out: bool
41
41
  truncated: bool
42
+ # "ttl" when the command was stopped because the sandbox's remaining TTL ran out, not the requested timeout.
43
+ reason: Optional[str] = None
42
44
 
43
45
 
44
46
  class ExecTimeout(Exception):
@@ -50,7 +52,7 @@ class ExecTimeout(Exception):
50
52
 
51
53
 
52
54
  def _result(data: Dict[str, Any]) -> ExecResult:
53
- return ExecResult(data["exitCode"], data["stdout"], data["stderr"], data["durationMs"], data["timedOut"], data["truncated"])
55
+ return ExecResult(data["exitCode"], data["stdout"], data["stderr"], data["durationMs"], data["timedOut"], data["truncated"], data.get("reason"))
54
56
 
55
57
 
56
58
  class Agentbox:
@@ -172,7 +174,7 @@ class Sandbox:
172
174
  for name in ("stdout", "stderr"):
173
175
  if pending[name]:
174
176
  yield (name, pending[name])
175
- yield ("exit", ExecResult(data["exitCode"], "", "", data["durationMs"], data["timedOut"], data["truncated"]))
177
+ yield ("exit", ExecResult(data["exitCode"], "", "", data["durationMs"], data["timedOut"], data["truncated"], data.get("reason")))
176
178
  elif event == "error":
177
179
  raise AgentboxError(data["message"], 0, data["error"])
178
180
 
@@ -211,6 +213,7 @@ class Sandbox:
211
213
  target = os.path.realpath(os.path.join(base, member.name))
212
214
  if target != base and not target.startswith(base + os.sep):
213
215
  raise AgentboxError(f"archive from the sandbox has an unsafe path: {member.name}", 0, "UnsafeArchive")
216
+ member.mode &= 0o777 # drop setuid, setgid and sticky bits so an extracted file cannot carry them
214
217
  archive.extractall(local_dir)
215
218
 
216
219
  def egress_log(self) -> Dict[str, Any]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentboxes
3
- Version: 0.2.3
3
+ Version: 0.3.0
4
4
  Summary: Python client for an agentbox server: sandboxes for AI agents on your own Linux box
5
5
  License: MIT
6
6
  Requires-Python: >=3.9
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "agentboxes"
3
- version = "0.2.3"
3
+ version = "0.3.0"
4
4
  description = "Python client for an agentbox server: sandboxes for AI agents on your own Linux box"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.9"
@@ -82,6 +82,27 @@ class ClientTest(unittest.TestCase):
82
82
  finally:
83
83
  box.destroy()
84
84
 
85
+ def test_download_directory_strips_setuid_bits(self):
86
+ import io
87
+ import stat
88
+ import tarfile
89
+
90
+ box = self.client.create()
91
+ try:
92
+ buf = io.BytesIO()
93
+ with tarfile.open(fileobj=buf, mode="w") as archive:
94
+ info = tarfile.TarInfo("tool")
95
+ info.size = 2
96
+ info.mode = 0o4755
97
+ archive.addfile(info, io.BytesIO(b"hi"))
98
+ box.upload_tar(buf.getvalue(), "proj")
99
+ with tempfile.TemporaryDirectory() as out:
100
+ box.download_directory("proj", out)
101
+ mode = os.stat(os.path.join(out, "tool")).st_mode
102
+ self.assertFalse(mode & stat.S_ISUID)
103
+ finally:
104
+ box.destroy()
105
+
85
106
  def test_typed_errors(self):
86
107
  with self.assertRaises(SandboxNotFound):
87
108
  self.client.get("sbx_nope")
File without changes
File without changes