Skip to content

Commit 8e44b57

Browse files
committed
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.
1 parent 09f600c commit 8e44b57

File tree

5 files changed

+0
-22
lines changed

5 files changed

+0
-22
lines changed

src/config/SECURITY.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ The `validateConfigPath()` function performs comprehensive validation of file pa
1919
All file operations now use validated paths:
2020

2121
- **Config File Reading/Writing**: All `os.ReadFile()` and `os.WriteFile()` operations use validated paths
22-
- **Backup File Creation**: Backup paths are also validated to prevent attacks
2322
- **Directory Creation**: Directory paths are cleaned before `os.MkdirAll()` operations
2423
- **Private Key Loading**: Private key file paths are validated in `postprocessConfig()`
2524

src/config/config.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -521,23 +521,6 @@ func SaveConfig(configData interface{}, configPath, format string) error {
521521
}
522522
}
523523

524-
// Create backup if file exists
525-
if _, err := os.Stat(targetPath); err == nil { // Path already validated above
526-
backupPath := targetPath + ".backup"
527-
// Validate backup path as well
528-
validatedBackupPath, err := validateConfigPath(backupPath)
529-
if err != nil {
530-
return fmt.Errorf("invalid backup path: %v", err)
531-
}
532-
backupPath = validatedBackupPath
533-
534-
if data, err := os.ReadFile(targetPath); err == nil { // Path already validated above
535-
if err := os.WriteFile(backupPath, data, 0600); err != nil { // Path already validated above
536-
return fmt.Errorf("failed to create backup: %v", err)
537-
}
538-
}
539-
}
540-
541524
// Ensure directory exists
542525
dir := filepath.Dir(targetPath)
543526
// Clean the directory path as well

src/webui/server.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ type ConfigSetResponse struct {
402402
Success bool `json:"success"`
403403
Message string `json:"message"`
404404
ConfigPath string `json:"config_path"`
405-
BackupPath string `json:"backup_path,omitempty"`
406405
RestartRequired bool `json:"restart_required"`
407406
}
408407

@@ -489,7 +488,6 @@ func (w *WebUIServer) setConfigHandler(rw http.ResponseWriter, r *http.Request)
489488
Success: true,
490489
Message: "Configuration saved successfully",
491490
ConfigPath: configPath,
492-
BackupPath: configPath + ".backup",
493491
RestartRequired: req.Restart,
494492
}
495493

src/webui/static/lang/en.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ window.translations.en = {
115115
'config_readonly': 'Configuration file is read-only',
116116
'config_save_confirm_title': 'Confirm Save',
117117
'config_save_confirm_text': 'Are you sure you want to save changes to the configuration file?',
118-
'config_backup_info': 'Backup will be created automatically',
119118
'config_warning': '⚠️ Warning: Incorrect configuration may cause node failure!',
120119

121120
// Editor status translations

src/webui/static/lang/ru.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ window.translations.ru = {
115115
'config_readonly': 'Файл конфигурации доступен только для чтения',
116116
'config_save_confirm_title': 'Подтверждение сохранения',
117117
'config_save_confirm_text': 'Вы уверены, что хотите сохранить изменения в конфигурационный файл?',
118-
'config_backup_info': 'Резервная копия будет создана автоматически',
119118
'config_warning': '⚠️ Внимание: Неправильная конфигурация может привести к сбою работы узла!',
120119

121120
// Editor status translations

0 commit comments

Comments
 (0)