fix: harden profile imports and release dependencies
This commit is contained in:
@@ -33,6 +33,8 @@ const (
|
||||
|
||||
saltLength = 32
|
||||
nonceLength = 12 // AES-GCM standard nonce size
|
||||
|
||||
maxEncryptedImportBytes = 10 * 1024 * 1024
|
||||
)
|
||||
|
||||
// ExportBundle is the cleartext payload that gets encrypted.
|
||||
@@ -131,6 +133,14 @@ func DecryptAndImport(filePath, password string) ([]models.Profile, error) {
|
||||
return nil, errors.New("exportimport: password cannot be empty")
|
||||
}
|
||||
|
||||
info, err := os.Stat(filePath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("exportimport: failed to stat file: %w", err)
|
||||
}
|
||||
if info.Size() > maxEncryptedImportBytes {
|
||||
return nil, fmt.Errorf("exportimport: file is too large (max %d bytes)", maxEncryptedImportBytes)
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("exportimport: failed to read file: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user