MCPcopy Create free account
hub / github.com/canwhite/Krebs / validatePath

Function validatePath

tools/lua-runtime.ts:61–73  ·  view source on GitHub ↗

* 安全路径校验

(path: string)

Source from the content-addressed store, hash-verified

59 * 安全路径校验
60 */
61function validatePath(path: string): string {
62 if (path.startsWith("/")) {
63 throw new Error("Absolute paths not allowed");
64 }
65 if (path.includes("..")) {
66 throw new Error("Path traversal not allowed");
67 }
68 const fullPath = join(CUSTOM_DIR, path);
69 if (!fullPath.startsWith(CUSTOM_DIR)) {
70 throw new Error("Path traversal detected");
71 }
72 return fullPath;
73}
74
75export const luaRuntime: LuaRuntime = {
76 async initialize(): Promise<void> {

Callers 1

initializeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected