From 37200806118d39ef8afe84ad5887a294d54e2659 Mon Sep 17 00:00:00 2001 From: Martin Basti Date: Sep 20 2016 15:35:28 +0000 Subject: Fix regexp patterns in parameters to not enforce length Regexp should not enforce lenght of string, we have different checks for that. Secondly regexp with length specified produces an incorrect error message. https://fedorahosted.org/freeipa/ticket/5822 Reviewed-By: Stanislav Laznicka Reviewed-By: Alexander Bokovoy --- diff --git a/ipaserver/plugins/baseuser.py b/ipaserver/plugins/baseuser.py index 5e36a66..608e2d4 100644 --- a/ipaserver/plugins/baseuser.py +++ b/ipaserver/plugins/baseuser.py @@ -172,7 +172,7 @@ class baseuser(LDAPObject): takes_params = ( Str('uid', - pattern='^[a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,252}[a-zA-Z0-9_.$-]?$', + pattern='^[a-zA-Z0-9_.][a-zA-Z0-9_.-]*[a-zA-Z0-9_.$-]?$', pattern_errmsg='may only include letters, numbers, _, -, . and $', maxlength=255, cli_name='login', diff --git a/ipaserver/plugins/group.py b/ipaserver/plugins/group.py index dcd4a91..5f0e9af 100644 --- a/ipaserver/plugins/group.py +++ b/ipaserver/plugins/group.py @@ -260,7 +260,7 @@ class group(LDAPObject): takes_params = ( Str('cn', - pattern='^[a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,252}[a-zA-Z0-9_.$-]?$', + pattern='^[a-zA-Z0-9_.][a-zA-Z0-9_.-]*[a-zA-Z0-9_.$-]?$', pattern_errmsg='may only include letters, numbers, _, -, . and $', maxlength=255, cli_name='group_name', diff --git a/ipaserver/plugins/idviews.py b/ipaserver/plugins/idviews.py index 92d47f5..371e092 100644 --- a/ipaserver/plugins/idviews.py +++ b/ipaserver/plugins/idviews.py @@ -841,7 +841,7 @@ class idoverrideuser(baseidoverride): takes_params = baseidoverride.takes_params + ( Str('uid?', - pattern='^[a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,252}[a-zA-Z0-9_.$-]?$', + pattern='^[a-zA-Z0-9_.][a-zA-Z0-9_.-]*[a-zA-Z0-9_.$-]?$', pattern_errmsg='may only include letters, numbers, _, -, . and $', maxlength=255, cli_name='login', @@ -944,7 +944,7 @@ class idoverridegroup(baseidoverride): takes_params = baseidoverride.takes_params + ( Str('cn?', - pattern='^[a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,252}[a-zA-Z0-9_.$-]?$', + pattern='^[a-zA-Z0-9_.][a-zA-Z0-9_.-]*[a-zA-Z0-9_.$-]?$', pattern_errmsg='may only include letters, numbers, _, -, . and $', maxlength=255, cli_name='group_name', diff --git a/ipaserver/plugins/servicedelegation.py b/ipaserver/plugins/servicedelegation.py index 6f38c36..c8052e9 100644 --- a/ipaserver/plugins/servicedelegation.py +++ b/ipaserver/plugins/servicedelegation.py @@ -143,7 +143,7 @@ class servicedelegation(LDAPObject): takes_params = ( Str( 'cn', - pattern='^[a-zA-Z0-9_.][a-zA-Z0-9_ .-]{0,253}[a-zA-Z0-9_.-]?$', + pattern='^[a-zA-Z0-9_.][a-zA-Z0-9_ .-]*[a-zA-Z0-9_.-]?$', pattern_errmsg='may only include letters, numbers, _, -, ., ' 'and a space inside', maxlength=255, diff --git a/ipaserver/plugins/topology.py b/ipaserver/plugins/topology.py index 0cccf90..7e3891c 100644 --- a/ipaserver/plugins/topology.py +++ b/ipaserver/plugins/topology.py @@ -129,7 +129,7 @@ class topologysegment(LDAPObject): ), Str( 'iparepltoposegmentleftnode', - pattern='^[a-zA-Z0-9.][a-zA-Z0-9.-]{0,252}[a-zA-Z0-9.$-]?$', + pattern='^[a-zA-Z0-9.][a-zA-Z0-9.-]*[a-zA-Z0-9.$-]?$', pattern_errmsg='may only include letters, numbers, -, . and $', maxlength=255, cli_name='leftnode', @@ -140,7 +140,7 @@ class topologysegment(LDAPObject): ), Str( 'iparepltoposegmentrightnode', - pattern='^[a-zA-Z0-9.][a-zA-Z0-9.-]{0,252}[a-zA-Z0-9.$-]?$', + pattern='^[a-zA-Z0-9.][a-zA-Z0-9.-]*[a-zA-Z0-9.$-]?$', pattern_errmsg='may only include letters, numbers, -, . and $', maxlength=255, cli_name='rightnode',