From 8e44b578794c3a47af4d6949cb74149895ceb060 Mon Sep 17 00:00:00 2001 From: Andy Oknen Date: Fri, 15 Aug 2025 20:25:29 +0000 Subject: [PATCH] Remove backup creation logic from SaveConfig function and update related documentation. Adjust WebUIServer response structure and translations to reflect the absence of backup path information. --- src/config/SECURITY.md | 1 - src/config/config.go | 17 ----------------- src/webui/server.go | 2 -- src/webui/static/lang/en.js | 1 - src/webui/static/lang/ru.js | 1 - 5 files changed, 22 deletions(-) diff --git a/src/config/SECURITY.md b/src/config/SECURITY.md index f8f72677..13ecf976 100644 --- a/src/config/SECURITY.md +++ b/src/config/SECURITY.md @@ -19,7 +19,6 @@ The `validateConfigPath()` function performs comprehensive validation of file pa All file operations now use validated paths: - **Config File Reading/Writing**: All `os.ReadFile()` and `os.WriteFile()` operations use validated paths -- **Backup File Creation**: Backup paths are also validated to prevent attacks - **Directory Creation**: Directory paths are cleaned before `os.MkdirAll()` operations - **Private Key Loading**: Private key file paths are validated in `postprocessConfig()` diff --git a/src/config/config.go b/src/config/config.go index 7bef506b..283427ea 100644 --- a/src/config/config.go +++ b/src/config/config.go @@ -521,23 +521,6 @@ func SaveConfig(configData interface{}, configPath, format string) error { } } - // Create backup if file exists - if _, err := os.Stat(targetPath); err == nil { // Path already validated above - backupPath := targetPath + ".backup" - // Validate backup path as well - validatedBackupPath, err := validateConfigPath(backupPath) - if err != nil { - return fmt.Errorf("invalid backup path: %v", err) - } - backupPath = validatedBackupPath - - if data, err := os.ReadFile(targetPath); err == nil { // Path already validated above - if err := os.WriteFile(backupPath, data, 0600); err != nil { // Path already validated above - return fmt.Errorf("failed to create backup: %v", err) - } - } - } - // Ensure directory exists dir := filepath.Dir(targetPath) // Clean the directory path as well diff --git a/src/webui/server.go b/src/webui/server.go index a697442f..6457ec10 100644 --- a/src/webui/server.go +++ b/src/webui/server.go @@ -402,7 +402,6 @@ type ConfigSetResponse struct { Success bool `json:"success"` Message string `json:"message"` ConfigPath string `json:"config_path"` - BackupPath string `json:"backup_path,omitempty"` RestartRequired bool `json:"restart_required"` } @@ -489,7 +488,6 @@ func (w *WebUIServer) setConfigHandler(rw http.ResponseWriter, r *http.Request) Success: true, Message: "Configuration saved successfully", ConfigPath: configPath, - BackupPath: configPath + ".backup", RestartRequired: req.Restart, } diff --git a/src/webui/static/lang/en.js b/src/webui/static/lang/en.js index 41d65886..5bf62f41 100644 --- a/src/webui/static/lang/en.js +++ b/src/webui/static/lang/en.js @@ -115,7 +115,6 @@ window.translations.en = { 'config_readonly': 'Configuration file is read-only', 'config_save_confirm_title': 'Confirm Save', 'config_save_confirm_text': 'Are you sure you want to save changes to the configuration file?', - 'config_backup_info': 'Backup will be created automatically', 'config_warning': '⚠️ Warning: Incorrect configuration may cause node failure!', // Editor status translations diff --git a/src/webui/static/lang/ru.js b/src/webui/static/lang/ru.js index e9e0ed2f..711b1012 100644 --- a/src/webui/static/lang/ru.js +++ b/src/webui/static/lang/ru.js @@ -115,7 +115,6 @@ window.translations.ru = { 'config_readonly': 'Файл конфигурации доступен только для чтения', 'config_save_confirm_title': 'Подтверждение сохранения', 'config_save_confirm_text': 'Вы уверены, что хотите сохранить изменения в конфигурационный файл?', - 'config_backup_info': 'Резервная копия будет создана автоматически', 'config_warning': '⚠️ Внимание: Неправильная конфигурация может привести к сбою работы узла!', // Editor status translations