Skip to content

Commit

Permalink
change domain validation scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Mar 5, 2020
2 parents 0e92dc7 + aaed42e commit 74070be
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
Binary file removed .DS_Store
Binary file not shown.
16 changes: 10 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

if [ -f "/etc/os-release" ]; then
if [ -f "/etc/os-release" ]; then
. /etc/os-release
else
ID="unsupported"
Expand All @@ -11,28 +11,32 @@ if [ "$ID" = "ubuntu" ] && [ "$UBUNTU_CODENAME" = "bionic" ]; then
export DEBIAN_FRONTEND=noninteractive
apt -q -y -o Dpkg::Options::=--force-confnew update
apt -q -y -o Dpkg::Options::=--force-confnew install wget curl
SERVER_OS="$NAME"
SERVER_OS="Ubuntu"
elif [ "$ID" = "centos" ] || [ "$ID" = "cloudlinux" ]; then
case "$VERSION_ID" in
7|7.*)
yum install curl wget -y 1> /dev/null
yum update curl wget ca-certificates -y 1> /dev/null
SERVER_OS="$NAME"
if [ "$ID" = "centos" ]; then
SERVER_OS="CentOS"
else
SERVER_OS="CloudLinux"
fi
;;
8|8.*)
printf >&2 '\nCentOS 8/CloudLinux 8 support is currently experimental!\n'
yum install curl wget -y 1> /dev/null
yum update curl wget ca-certificates -y 1> /dev/null
SERVER_OS="${NAME}${VERSION_ID}"
SERVER_OS="CentOS8"
;;
esac
else
else
printf >&2 '\nYour OS -- %s -- is not currently supported!\n' "$PRETTY_NAME"
printf >&2 '\nCyberPanel is currently supported on Ubuntu 18.04, CentOS 7 and CloudLinux 7.\n'
exit 1
fi

rm -f cyberpanel.sh install.tar.gz
rm -f cyberpanel.sh install.tar.gz
curl --silent -o cyberpanel.sh "https://cyberpanel.sh/?dl&${SERVER_OS}" 2>/dev/null
chmod +x cyberpanel.sh
./cyberpanel.sh "$@"
3 changes: 2 additions & 1 deletion requirments.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ urllib3==1.22
websocket-client==0.56.0
zope.component==4.4.1
zope.event==4.3.0
zope.interface==4.5.0
zope.interface==4.5.0
validators==0.14.2
30 changes: 14 additions & 16 deletions websiteFunctions/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
from ApachController.ApacheVhosts import ApacheVhost
from plogical.vhostConfs import vhostConfs
from plogical.cronUtil import CronUtil
from re import match,I,M
from plogical import randomPassword
from .StagingSetup import StagingSetup
import validators


class WebsiteManager:
Expand Down Expand Up @@ -180,14 +180,13 @@ def submitWebsiteCreation(self, userID=None, data=None):
return ACLManager.loadErrorJson('createWebSiteStatus', 0)


if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', domain,
M | I):

if not validators.domain(domain):
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

if not match(r'\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b', adminEmail,
M | I):
if not validators.email(adminEmail):
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid email."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
Expand Down Expand Up @@ -267,8 +266,8 @@ def submitDomainCreation(self, userID=None, data=None):
path = data['path']
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))

if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', domain,
M | I):

if not validators.domain(domain):
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
Expand Down Expand Up @@ -1635,8 +1634,7 @@ def submitAliasCreation(self, userID=None, data=None):
aliasDomain = data['aliasDomain']
ssl = data['ssl']

if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', aliasDomain,
M | I):
if not validators.domain(aliasDomain):
data_ret = {'status': 0, 'createAliasStatus': 0, 'error_message': "Invalid domain."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
Expand Down Expand Up @@ -2725,14 +2723,14 @@ def startCloning(self, userID=None, data=None):

self.domain = data['masterDomain']

if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', self.domain,
M | I):

if not validators.domain(self.domain):
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', data['domainName'],
M | I):

if not validators.domain(data['domainName']):
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
Expand Down Expand Up @@ -2798,8 +2796,8 @@ def startSync(self, userID=None, data=None):
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)

if not match(r'^[a-zA-Z0-9-]*[a-zA-Z0-9-]{0,61}[a-zA-Z0-9-](?:\.[a-zA-Z0-9-]{2,})+$', data['childDomain'],
M | I):

if not validators.domain(data['childDomain']):
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': "Invalid domain."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
Expand Down Expand Up @@ -2870,4 +2868,4 @@ def convertDomainToSite(self, userID=None, request=None):
except BaseException as msg:
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
return HttpResponse(json_data)

0 comments on commit 74070be

Please sign in to comment.