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
anyname@hotmail.com as input.
GetRandomCharacterString will crash because of a negative value for parameter size.