@ian2018cs/agenthub 0.1.60 → 0.1.61
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.
package/package.json
CHANGED
|
@@ -514,6 +514,10 @@ const rules = [
|
|
|
514
514
|
const scriptFile = interpreterMatch?.[1] || langMatch?.[1] || directMatch?.[1];
|
|
515
515
|
if (!scriptFile) return { result: 'allow' };
|
|
516
516
|
|
|
517
|
+
// 编程语言脚本(python/node/ruby 等)的字符串字面量(URL 路径、os.sep 等)
|
|
518
|
+
// 会被路径正则误判为文件系统路径,路径越界检查仅对 shell 脚本有意义
|
|
519
|
+
const isShellScript = !!interpreterMatch || (!langMatch && !!directMatch);
|
|
520
|
+
|
|
517
521
|
// 解析脚本路径
|
|
518
522
|
const resolvedScript = path.isAbsolute(scriptFile)
|
|
519
523
|
? path.resolve(scriptFile)
|
|
@@ -545,10 +549,12 @@ const rules = [
|
|
|
545
549
|
return { result: 'deny', reason: `脚本文件${portCheck.reason}` };
|
|
546
550
|
}
|
|
547
551
|
|
|
548
|
-
//
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
+
// 检查路径越界(仅 shell 脚本,编程语言脚本的字符串字面量会误判为文件路径)
|
|
553
|
+
if (isShellScript) {
|
|
554
|
+
const pathCheck = checkPathsInContent(content, context);
|
|
555
|
+
if (pathCheck.denied) {
|
|
556
|
+
return { result: 'deny', reason: `脚本文件${pathCheck.reason}` };
|
|
557
|
+
}
|
|
552
558
|
}
|
|
553
559
|
} catch {
|
|
554
560
|
// 文件不存在或无法读取 — 交由其他规则处理
|