WorkspaceArchiveExtractor
public class WorkspaceArchiveExtractor
源码Source
io/agentscope/harness/agent/sandbox/WorkspaceArchiveExtractor.java:37–114工作区归档 Extractor,承载智能体的部署、调度与服务化运行。位于 io.agentscope.harness.agent.sandbox 包。核心成员包括 extractTarArchive。
Securely extracts tar archives into a target directory.
Applies strict path traversal guards before extracting each archive entry:
-
Rejects entries with absolute paths (starting with
/or\) -
Rejects entries containing
..path segments -
Verifies the resolved destination path starts with the canonical root
These guards defend against the "Zip Slip" class of path traversal attacks.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static void extractTarArchive(Path destRoot, InputStream tarStream) throws Exceptionstatic | 执行 `extractTarArchive` 方法。 Extracts a tar archive stream into the given destination directory. |
方法详情Method Detail
extractTarArchive
public static void extractTarArchive(Path destRoot, InputStream tarStream) throws Exception
static
执行 extractTarArchive 方法。
Extracts a tar archive stream into the given destination directory.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
destRoot | Path | dest 根(类型 `Path`)。the directory to extract into; must already exist |
tarStream | InputStream | tar 流(类型 `InputStream`)。the tar archive input stream; caller is responsible for closing |
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source
io/agentscope/harness/agent/sandbox/WorkspaceArchiveExtractor.java:54–81