neosync icon indicating copy to clipboard operation
neosync copied to clipboard

Email transformation crashes when `maxLength` is too low and `preserveDomain` is true

Open agedemenli opened this issue 7 months ago • 0 comments

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

  1. Set preserveDomain: true, maxLength: 11, emailType: 'fullname'
  2. Pass [email protected] as input.
  3. GetRandomCharacterString will crash because of a negative value for parameter size.

agedemenli avatar Jun 12 '25 14:06 agedemenli