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.

This commit is contained in:
Andy Oknen 2025-08-15 20:25:29 +00:00
parent 09f600c6cf
commit 8e44b57879
5 changed files with 0 additions and 22 deletions

View file

@ -19,7 +19,6 @@ The `validateConfigPath()` function performs comprehensive validation of file pa
All file operations now use validated paths: All file operations now use validated paths:
- **Config File Reading/Writing**: All `os.ReadFile()` and `os.WriteFile()` operations 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 - **Directory Creation**: Directory paths are cleaned before `os.MkdirAll()` operations
- **Private Key Loading**: Private key file paths are validated in `postprocessConfig()` - **Private Key Loading**: Private key file paths are validated in `postprocessConfig()`

View file

@ -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 // Ensure directory exists
dir := filepath.Dir(targetPath) dir := filepath.Dir(targetPath)
// Clean the directory path as well // Clean the directory path as well

View file

@ -402,7 +402,6 @@ type ConfigSetResponse struct {
Success bool `json:"success"` Success bool `json:"success"`
Message string `json:"message"` Message string `json:"message"`
ConfigPath string `json:"config_path"` ConfigPath string `json:"config_path"`
BackupPath string `json:"backup_path,omitempty"`
RestartRequired bool `json:"restart_required"` RestartRequired bool `json:"restart_required"`
} }
@ -489,7 +488,6 @@ func (w *WebUIServer) setConfigHandler(rw http.ResponseWriter, r *http.Request)
Success: true, Success: true,
Message: "Configuration saved successfully", Message: "Configuration saved successfully",
ConfigPath: configPath, ConfigPath: configPath,
BackupPath: configPath + ".backup",
RestartRequired: req.Restart, RestartRequired: req.Restart,
} }

View file

@ -115,7 +115,6 @@ window.translations.en = {
'config_readonly': 'Configuration file is read-only', 'config_readonly': 'Configuration file is read-only',
'config_save_confirm_title': 'Confirm Save', 'config_save_confirm_title': 'Confirm Save',
'config_save_confirm_text': 'Are you sure you want to save changes to the configuration file?', '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!', 'config_warning': '⚠️ Warning: Incorrect configuration may cause node failure!',
// Editor status translations // Editor status translations

View file

@ -115,7 +115,6 @@ window.translations.ru = {
'config_readonly': 'Файл конфигурации доступен только для чтения', 'config_readonly': 'Файл конфигурации доступен только для чтения',
'config_save_confirm_title': 'Подтверждение сохранения', 'config_save_confirm_title': 'Подтверждение сохранения',
'config_save_confirm_text': 'Вы уверены, что хотите сохранить изменения в конфигурационный файл?', 'config_save_confirm_text': 'Вы уверены, что хотите сохранить изменения в конфигурационный файл?',
'config_backup_info': 'Резервная копия будет создана автоматически',
'config_warning': '⚠️ Внимание: Неправильная конфигурация может привести к сбою работы узла!', 'config_warning': '⚠️ Внимание: Неправильная конфигурация может привести к сбою работы узла!',
// Editor status translations // Editor status translations