ai-helper-agent 1.3.2 → 1.3.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/security.js +5 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-helper-agent",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "AI Helper 本地代理服务 - 为 Chrome 扩展提供本地文件读写和系统命令执行能力",
5
5
  "type": "module",
6
6
  "main": "./src/server.js",
package/src/security.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // agent/src/security.js - 安全管控:文件沙箱 + 命令分级
2
- import { resolve, normalize, sep } from 'path';
2
+ import { resolve, normalize, sep, isAbsolute } from 'path';
3
3
  import { realpathSync } from 'fs';
4
4
  import { loadConfig } from './config.js';
5
5
 
@@ -14,10 +14,12 @@ function checkPath(pathStr) {
14
14
  }
15
15
 
16
16
  try {
17
- const resolved = resolve(pathStr);
17
+ const config = loadConfig();
18
+
19
+ // 相对路径基于 config.workdir 解析,而非 process.cwd()
20
+ const resolved = isAbsolute(pathStr) ? resolve(pathStr) : resolve(config.workdir, pathStr);
18
21
  const normalized = normalize(resolved);
19
22
 
20
- const config = loadConfig();
21
23
  const allowedPaths = config.allowedPaths.length > 0 ? config.allowedPaths : [config.workdir];
22
24
 
23
25
  // 先做前缀检查(快速路径,兼容 Windows/Unix)