示例工程 62-workspace-shell-sandbox

62-workspace-shell-sandbox/demo-01-path-guard/README.md

markdown · 0.7 KB

# demo-01-path-guard

工作区路径守卫:规范化、越界、绝对路径、符号链接逃逸与工作区内链接。

## 运行

```bash
pnpm --filter @tutorial/62-workspace-shell-sandbox-demo-01-path-guard start
```

## 验证

```bash
pnpm --filter @tutorial/62-workspace-shell-sandbox-demo-01-path-guard smoke
# {"evt":"smoke","ok":true,"escape":{"code":"SYMLINK_ESCAPE",...},...}
```

## 说明

- 规范化后再比较,避免前缀欺骗。
- 符号链接要按真实目标判断,不能只看链接名。
- 绝对路径直接拒绝,不尝试重写。

## 已知限制

- 不调用 `fs.realpath`,用固定映射模拟。
- 不处理大小写不敏感文件系统。