fix: add security comments to handle non-critical errors in ratchet persistence
This commit is contained in:
@@ -524,19 +524,24 @@ func (d *Destination) persistRatchets() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, err := file.Write(finalData); err != nil {
|
if _, err := file.Write(finalData); err != nil {
|
||||||
|
// #nosec G104 - Error already being handled, cleanup errors are non-critical
|
||||||
file.Close()
|
file.Close()
|
||||||
|
// #nosec G104 - Error already being handled, cleanup errors are non-critical
|
||||||
os.Remove(tempPath)
|
os.Remove(tempPath)
|
||||||
return fmt.Errorf("failed to write ratchet data: %w", err)
|
return fmt.Errorf("failed to write ratchet data: %w", err)
|
||||||
}
|
}
|
||||||
|
// #nosec G104 - File is being closed after successful write, error is non-critical
|
||||||
file.Close()
|
file.Close()
|
||||||
|
|
||||||
// Remove old file if exists
|
// Remove old file if exists
|
||||||
if _, err := os.Stat(d.ratchetPath); err == nil {
|
if _, err := os.Stat(d.ratchetPath); err == nil {
|
||||||
|
// #nosec G104 - Removing old file, error is non-critical if it doesn't exist
|
||||||
os.Remove(d.ratchetPath)
|
os.Remove(d.ratchetPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Atomic rename
|
// Atomic rename
|
||||||
if err := os.Rename(tempPath, d.ratchetPath); err != nil {
|
if err := os.Rename(tempPath, d.ratchetPath); err != nil {
|
||||||
|
// #nosec G104 - Error already being handled, cleanup errors are non-critical
|
||||||
os.Remove(tempPath)
|
os.Remove(tempPath)
|
||||||
return fmt.Errorf("failed to rename ratchet file: %w", err)
|
return fmt.Errorf("failed to rename ratchet file: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user