mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-08-25 08:25:07 +03:00
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:
parent
443f9d0afd
commit
2180e12b73
2 changed files with 2 additions and 37 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue