mirror of
				https://gitea.com/gitea/gitea-mcp.git
				synced 2025-10-30 09:51:50 +00:00 
			
		
		
		
	fix: harden log directory creation and path resolution (#61)
- Ensure the log directory is created with secure permissions, falling back to the temp directory if creation fails - Update log file path to use the resolved log directory fix https://gitea.com/gitea/gitea-mcp/issues/58 Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/61 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com> Co-committed-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
		| @@ -32,8 +32,14 @@ func Default() *zap.Logger { | ||||
| 				home = os.TempDir() | ||||
| 			} | ||||
|  | ||||
| 			logDir := fmt.Sprintf("%s/.gitea-mcp", home) | ||||
| 			if err := os.MkdirAll(logDir, 0o700); err != nil { | ||||
| 				// Fallback to temp directory if creation fails | ||||
| 				logDir = os.TempDir() | ||||
| 			} | ||||
|  | ||||
| 			wss = append(wss, zapcore.AddSync(&lumberjack.Logger{ | ||||
| 				Filename:   fmt.Sprintf("%s/.gitea-mcp/gitea-mcp.log", home), | ||||
| 				Filename:   fmt.Sprintf("%s/gitea-mcp.log", logDir), | ||||
| 				MaxSize:    100, | ||||
| 				MaxBackups: 10, | ||||
| 				MaxAge:     30, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user