Skip to content
Permalink
Browse files
change domain validation scheme
  • Loading branch information
usmannasir committed Mar 5, 2020
2 parents 0e92dc7 + aaed42e commit 74070be0f6e15c20e70e4558081cb2b5306b98ec
Showing 4 changed files with 26 additions and 23 deletions.
BIN -12 KB .DS_Store
Binary file not shown.
@@ -1,6 +1,6 @@
#!/bin/sh

if [ -f "/etc/os-release" ]; then
if [ -f "/etc/os-release" ]; then
. /etc/os-release
else
ID="unsupported"
@@ -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 "$@"
@@ -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
@@ -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:
@@ -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)
@@ -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)
@@ -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)
@@ -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)
@@ -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)
@@ -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.