Remove safe file operation wrappers from configuration handling to streamline code. Update SECURITY.md to reflect the removal of these functions and adjust the section numbering accordingly.

This commit is contained in:
Andy Oknen 2025-08-15 20:15:57 +00:00
parent 443f9d0afd
commit 2180e12b73
2 changed files with 2 additions and 37 deletions

View file

@ -370,33 +370,6 @@ func validateConfigPath(path string) (string, error) {
return absPath, nil
}
// safeReadFile safely reads a file after validating the path
func safeReadFile(path string) ([]byte, error) {
validatedPath, err := validateConfigPath(path)
if err != nil {
return nil, fmt.Errorf("invalid file path: %v", err)
}
return os.ReadFile(validatedPath)
}
// safeWriteFile safely writes a file after validating the path
func safeWriteFile(path string, data []byte, perm os.FileMode) error {
validatedPath, err := validateConfigPath(path)
if err != nil {
return fmt.Errorf("invalid file path: %v", err)
}
return os.WriteFile(validatedPath, data, perm)
}
// safeStat safely stats a file after validating the path
func safeStat(path string) (os.FileInfo, error) {
validatedPath, err := validateConfigPath(path)
if err != nil {
return nil, fmt.Errorf("invalid file path: %v", err)
}
return os.Stat(validatedPath)
}
// SetCurrentConfig sets the current configuration data and path
func SetCurrentConfig(path string, cfg *NodeConfig) {
// Validate the path before setting it