refactor: use jsmod.Get for context configuration (by AI)

This commit is contained in:
AI Engineer 2026-06-10 09:45:42 +08:00
parent ba95b78adb
commit a97e1f50bf

View File

@ -308,9 +308,9 @@ func VerifyPathForSafeMode(ctx context.Context, path string) (string, error) {
return RealPath(path), nil return RealPath(path), nil
} }
// 1. 获取白名单 (约定从 ctx 获取 "AllowedDirs") // 1. 获取白名单
var allowedDirs []string var allowedDirs []string
cast.Convert(&allowedDirs, ctx.Value("AllowedDirs")) cast.Convert(&allowedDirs, jsmod.Get(ctx, "AllowedDirs"))
if len(allowedDirs) == 0 { if len(allowedDirs) == 0 {
return "", fmt.Errorf("file: access denied, AllowedDirs not found in context") return "", fmt.Errorf("file: access denied, AllowedDirs not found in context")
} }