{"record":{"id":"20b23e5dc8b24ca1","repo":"flipped-aurora/gin-vue-admin","slug":"w-20b23e","errorCode":null,"errorMessage":"服务端目录无效: %w","messagePattern":"服务端目录无效: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/auto_code_task.go","lineNumber":58,"sourceCode":"\tKind          string\n\tExisted       bool\n\tMode          fs.FileMode\n\tBeforeHash    string\n\tAfterHash     string\n\tBeforeContent []byte\n\tStagedPath    string\n}\n\ntype autoCodeFilePublisher func(file *autoCodeTaskFile) (published bool, err error)\n\nfunc newAutoCodeTaskLayout(root, server, web string) (autoCodeTaskLayout, error) {\n\troot, err := filepath.Abs(root)\n\tif err != nil {\n\t\treturn autoCodeTaskLayout{}, fmt.Errorf(\"解析自动代码根目录失败: %w\", err)\n\t}\n\tserverRoot, err := pathWithin(root, server)\n\tif err != nil {\n\t\treturn autoCodeTaskLayout{}, fmt.Errorf(\"服务端目录无效: %w\", err)\n\t}\n\twebRoot, err := pathWithin(root, web)\n\tif err != nil {\n\t\treturn autoCodeTaskLayout{}, fmt.Errorf(\"前端目录无效: %w\", err)\n\t}\n\treturn autoCodeTaskLayout{\n\t\troot:       filepath.Clean(root),\n\t\tserverRoot: serverRoot,\n\t\twebRoot:    webRoot,\n\t}, nil\n}\n\nfunc prepareAutoCodeFileTask(layout autoCodeTaskLayout, files map[string][]byte) (_ *autoCodeFileTask, err error) {\n\tstagingDir, err := os.MkdirTemp(layout.root, autoCodeStagingPrefix)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"创建自动代码 staging 目录失败: %w\", err)\n\t}\n\ttask := &autoCodeFileTask{","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/auto_code_task.go#L40-L76","documentation":"Thrown by newAutoCodeTaskLayout when pathWithin(root, server) rejects the configured server subdirectory — meaning the server path escapes or is outside the auto-code root, an unsafe sandbox violation for staging generated files.","triggerScenarios":"Create (or the layout test) is invoked with a server-relative path that resolves outside the resolved root: absolute paths, '..' segments, or symlinked directories that escape the root.","commonSituations":"Config's server path edited to an absolute path like /etc or ../other; symlinks in the project tree causing filepath eval to escape root; OS path separator mistakes on Windows-style config values.","solutions":["Set the server path to a plain relative subdirectory inside the auto-code root (e.g. 'server').","Remove '..' segments and symlink hops; verify with filepath.EvalSymlinks.","Check the config file for the autoCode server setting and correct it."],"exampleFix":"// before (config)\nautoCode:\n  server: ../outside-server\n// after\nautoCode:\n  server: server","handlingStrategy":"validation","validationCode":"srvAbs, _ := filepath.Abs(server)\nrootAbs, _ := filepath.Abs(root)\nif !strings.HasPrefix(srvAbs+string(os.PathSeparator), rootAbs+string(os.PathSeparator)) {\n    return fmt.Errorf(\"server path %s escapes root %s\", srvAbs, rootAbs)\n}","typeGuard":null,"tryCatchPattern":"layout, err := newAutoCodeTaskLayout(root, server, web)\nif err != nil {\n    return fmt.Errorf(\"invalid autoCode config: %w\", err)\n}","preventionTips":["Keep server/web config values as plain relative subpaths.","Audit config for '..' or absolute paths.","Avoid symlinks inside the generated tree."],"tags":["filesystem","path-traversal","auto-code","config"],"backgroundTag":"path-escape-rejected","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}