faker icon indicating copy to clipboard operation
faker copied to clipboard

Ability to prevent usage of some email domains

Open hlascelles opened this issue 2 years ago • 3 comments

Using faker 2.22.0 (and prior) you can ask for an email address.

We would like to prevent Faker using any "dodgy" domains. Specifically one of these: https://github.com/FGRibreau/mailchecker/blob/198ab3fc99cfa35571a6858b992e6006dbdb5af7/list.txt

Can we add config (a callback?) where Faker asks "is this one of OK?" and we can check and reject it? Or be able to set a known list of banned domains?

Thanks!

hlascelles avatar Aug 22 '22 14:08 hlascelles

hi @hlascelles could you explain more of the reason behind this proposal? Is it a security concern? Thanks!

stefannibrasil avatar Sep 06 '22 03:09 stefannibrasil

It's a problem that has arisen during or acceptance testing. We use Faker at runtime in our test environment to generate fake data that a user (or automated test) can use to fill in forms.

We also are complying with various regulations to make sure that our customers don't choose false / throwaway email addresses. To do this we use that list of "throw away" domains and reject any customer signing up with one.

The problem is that Faker does use some of them.

So, we ask Faker for a fake email, and it creates (eg) [email protected], which is normally fine. But in our acceptance test flow that is rejected as a fake domain.

It would be good to tell Faker which domain names are "too fake", if you see what I mean?

hlascelles avatar Sep 15 '22 17:09 hlascelles

hi @hlascelles thanks for providing more details. It makes sense.

The faker team has been discussing the possibility of only using safe domains here. Generally, for test data, we don't want to use real addresses anymore.

In that case, maybe you could generate random usernames and concatenate them to a list of domains that work for your usecase?

stefannibrasil avatar Sep 23 '22 03:09 stefannibrasil

Hey @hlascelles do you think the approach @stefannibrasil suggested could work for you? If so would it be okay if we close this issue?

fbuys avatar Oct 07 '22 16:10 fbuys

Aha, yes, I guess that the other bug is another side of the same coin.

OK - I'll add my comments to that. Thanks!

hlascelles avatar Oct 07 '22 17:10 hlascelles