Bug 55413 - Validate e-mail addresses more strictly
Validate e-mail addresses more strictly
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UMC - Users
UCS 4.4
Other Linux
: P5 normal (vote)
: UCS 5.0-2-errata
Assigned To: Dirk Wiesenthal
Florian Best
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2022-11-10 18:21 CET by Dirk Wiesenthal
Modified: 2022-11-16 18:04 CET (History)
1 user (show)

See Also:
What kind of report is it?: Feature Request
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Wiesenthal univentionstaff 2022-11-10 18:21:11 CET
The email validation is currently:

if not text.startswith('@') and \
  '@' in text and \
  not text.endswith('@') and \
  ' ' not in text:
    return text

This does not fail for obviously wrong mail adresses like user@@domain.de

It would be nice to have a better validation in the emailAddress syntax
Comment 1 Dirk Wiesenthal univentionstaff 2022-11-10 18:23:53 CET
Correct email address validation is hard. Having a stricter address may lead to false positives.

Therefore, we should make it optional so that customers can opt-out of the new rules.

https://packages.debian.org/buster-backports/python3-email-validator
seems to work nicely and has a debian package.
Comment 2 Dirk Wiesenthal univentionstaff 2022-11-10 20:28:37 CET
Works only if UDM is run with python3 (because there is no python-email-validator package). But I guess this is not a huge deal.

If you find the new checks annoying, you can
ucr set directory/manager/mail-address/extra-validation=false

Fixed in

univention-directory-manager-modules (15.0.13-16)
0a9c656b948d | Bug #55413: Syntax emailAddress will now be checked against external library python3-email-validator; can be disabled by directory/manager/mail-address/extra-validation

univention-directory-manager-modules.yaml
52d9cdfdd621 | Bug #55413: YAML

python-email-validator.yaml
630e04d21733 | Bug #55413: python-email-validator
Comment 3 Florian Best univentionstaff 2022-11-10 22:44:09 CET
See my comments at https://git.knut.univention.de/univention/ucs/-/commit/0a9c656b948d80484ef61af6a9c9c8fe12570e25 and make a Merge Request next time!
Comment 4 Dirk Wiesenthal univentionstaff 2022-11-14 14:01:40 CET
Added suggestions, a few fixes for different syntax classes and doctests:

univention-directory-manager-modules.yaml
2b8eafc9dc20 | Bug #55413: YAML
65893b698f8e | Bug #55413: YAML
52d9cdfdd621 | Bug #55413: YAML

univention-directory-manager-modules (15.0.13-22)
57a351a9fdb0 | Bug #55413: Add build dependency for doctest (2)
291caad61895 | Bug #55413: Add build dependency for doctest
b411b0ba3970 | Bug #55413: Default UCR value for doctests
2daa424b7f37 | Bug #55413: Fix emailAddressTemplate; add doctests

univention-directory-manager-modules (15.0.13-19)
249481cb05e2 | Bug #55413: Less strict mail validation

univention-directory-manager-modules (15.0.13-18)
89a2467f56d9 | Bug #55413: Top-level imports

univention-directory-manager-modules (15.0.13-17)
f458e068484e | Bug #55413: Fixes for dns/forward_zone

univention-directory-manager-modules (15.0.13-16)
0a9c656b948d | Bug #55413: Syntax emailAddress will now be checked against external library python3-email-validator; can be disabled by directory/manager/mail-address/extra-validation

python-email-validator.yaml
249481cb05e2 | Bug #55413: Less strict mail validation
630e04d21733 | Bug #55413: python-email-validator
Comment 5 Florian Best univentionstaff 2022-11-16 12:14:40 CET
OK: only Python 3 support
OK: usertemplates still work:
> udm settings/usertemplate create --set name=template1 --set mailPrimaryAddress="A@A@<username>@example.com"
OK: users/user:
> udm users/user create --set username=user1 --position=cn=users,l=school,l=dev --set lastname=lastname --set password=univention --set mailPrimaryAddress="A@A@@example.com"
> udm users/user create --set username=user1 --position=cn=users,l=school,l=dev --set lastname=lastname --set password=univention --set e-mail="A@A@@example.com"
OK: groups/group:
> udm groups/group create --set name=group1 --set mailAddress="A@A@@example.com"
OK: mail/*
> udm mail/folder create --set name=mail1 --set mailPrimaryAddress="A@A@@example.com"
OK: dns/forward_zone:
> udm dns/forward_zone modify --dn "zoneName=$(hostname -d),cn=dns,$(ucr get ldap/base)" --set contact="A@A@@example.com"
> udm dns/forward_zone modify --dn "zoneName=$(hostname -d),cn=dns,$(ucr get ldap/base)" --set contact="A@example.com."
OK: YAML