Skip to content

Commit 2625158

Browse files
committed
security fix: CP-18: Users – Create New User
1 parent bd96fa1 commit 2625158

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

plogical/acl.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ def CheckPackageOwnership(package, admin, currentACL):
5353
else:
5454
return 0
5555

56+
@staticmethod
57+
def CheckRegEx(RegexCheck, value):
58+
import re
59+
if re.match(RegexCheck, value):
60+
return 1
61+
else:
62+
return 0
63+
5664

5765

5866
@staticmethod

userManagment/views.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,23 @@ def submitUserCreation(request):
131131
websitesLimit = data['websitesLimit']
132132
selectedACL = data['selectedACL']
133133

134+
if ACLManager.CheckRegEx("^[\w'\-,.][^0-9_!¡?÷?¿/\\+=@#$%ˆ&*(){}|~<>;:[\]]{2,}$", firstName) == 0:
135+
data_ret = {'status': 0, 'createStatus': 0, 'error_message': 'First Name can only contain Alphabets and should be more then 2 characters..'}
136+
json_data = json.dumps(data_ret)
137+
return HttpResponse(json_data)
138+
139+
if ACLManager.CheckRegEx("^[\w'\-,.][^0-9_!¡?÷?¿/\\+=@#$%ˆ&*(){}|~<>;:[\]]{2,}$", lastName) == 0:
140+
data_ret = {'status': 0, 'createStatus': 0, 'error_message': 'First Name can only contain Alphabets and should be more then 2 characters..'}
141+
json_data = json.dumps(data_ret)
142+
return HttpResponse(json_data)
143+
144+
import validators
145+
if not validators.email(email):
146+
data_ret = {'status': 0, 'createStatus': 0,
147+
'error_message': 'Invalid email address.'}
148+
json_data = json.dumps(data_ret)
149+
return HttpResponse(json_data)
150+
134151
try:
135152
securityLevel = data['securityLevel']
136153
except:

0 commit comments

Comments
 (0)