Email transformation crashes when `maxLength` is too low and `preserveDomain` is true
Bug description
Generating a fullname email and preserving the domain with a low maxLength value causing crash.
transformEmail calculates maxNameLength by substracting the domain length from maxLength.
https://github.com/nucleuscloud/neosync/blob/main/worker/pkg/benthos/transformers/transform_email.go#L326
Then calls generateNameForEmail if the email type is fullname, passing a negative value as maxNameLength if preserve_domain is true, and the domain is longer than maxLength.
https://github.com/nucleuscloud/neosync/blob/main/worker/pkg/benthos/transformers/transform_email.go#L326
Then it crashes trying to generate a random string with negative size. https://github.com/nucleuscloud/neosync/blob/main/worker/pkg/benthos/transformers/generate_email.go#L217
How to reproduce
- Set
preserveDomain: true,maxLength: 11,emailType: 'fullname' - Pass
[email protected]as input. -
GetRandomCharacterStringwill crash because of a negative value for parametersize.