bug fix to modsecurity, containerization and s3backups

This commit is contained in:
usmannasir
2019-04-28 03:19:24 +05:00
parent 75744c0f12
commit d8d9f20da3
6 changed files with 25 additions and 11 deletions

View File

@@ -1068,11 +1068,14 @@ class FirewallManager:
owaspInstalled = 0
try:
command = 'sudo cat /usr/local/lsws/conf/comodo_litespeed/rules.conf.main'
res = ProcessUtilities.executioner(command)
command = 'sudo ls /usr/local/lsws/conf/comodo_litespeed/'
output = ProcessUtilities.outputExecutioner(command)
if res == 1:
if output.find('No such') > -1:
comodoInstalled = 0
else:
comodoInstalled = 1
except subprocess.CalledProcessError:
pass

View File

@@ -24,18 +24,18 @@ class CronUtil:
output = os.popen(cmd).read()
if "Exists" not in output:
print "0,Not Exists"
print "0,CyberPanel,Not Exists"
return 1
try:
f = subprocess.check_output(["sudo", "crontab", "-u", externalApp, "-l"])
print f
except BaseException, msg:
print "0," + str(msg)
print "0,CyberPanel," + str(msg)
return 1
except BaseException, msg:
print "0," + str(msg)
print "0,CyberPanel," + str(msg)
@staticmethod
def saveCronChanges(externalApp, finalCron, line):

View File

@@ -356,7 +356,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/rules.conf
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [installOWASP]")
str(msg) + " [installComodo]")
print "0," + str(msg)
@staticmethod
@@ -474,6 +474,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/owasp/rules/RESPONSE-999-EXCL
conf.writelines(items)
conf.close()
installUtilities.reStartLiteSpeed()
print "1,None"
@@ -497,6 +498,7 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/owasp/rules/RESPONSE-999-EXCL
conf.writelines(items)
conf.close()
installUtilities.reStartLiteSpeed()
print "1,None"

View File

@@ -135,8 +135,8 @@ class ProcessUtilities(multi.Thread):
def containerCheck():
try:
command = 'sudo cat /etc/cgrules.conf'
result = subprocess.call(shlex.split(command))
if result == 1:
output = ProcessUtilities.outputExecutioner(command)
if output.find('No such') > -1:
return 0
else:
return 1

View File

@@ -1005,7 +1005,7 @@ class WebsiteManager:
f = ProcessUtilities.outputExecutioner(execPath)
if f.find("0,") > -1:
if f.find("0,CyberPanel,") > -1:
data_ret = {'getWebsiteCron': 0, "user": website.externalApp, "crons": {}}
final_json = json.dumps(data_ret)
return HttpResponse(final_json)
@@ -1028,7 +1028,7 @@ class WebsiteManager:
final_json = json.dumps(data_ret)
return HttpResponse(final_json)
except BaseException, msg:
print msg
logging.CyberCPLogFileWriter.writeToFile(str(msg))
dic = {'getWebsiteCron': 0, 'error_message': str(msg)}
json_data = json.dumps(dic)
return HttpResponse(json_data)

View File

@@ -542,6 +542,10 @@ class S3Backups(multi.Thread):
key,
Config=config,
)
command = 'rm -f ' + result[1] + ".tar.gz"
ProcessUtilities.normalExecutioner(command)
BackupLogs(owner=plan, level='INFO', timeStamp=time.strftime("%b %d %Y, %H:%M:%S"),
msg='Backup successful for ' + items.domain + '.').save()
else:
@@ -920,8 +924,11 @@ class S3Backups(multi.Thread):
key,
Config=config,
)
command = 'rm -f ' + result[1] + ".tar.gz"
ProcessUtilities.normalExecutioner(command)
BackupLogsDO(owner=plan, level='INFO', timeStamp=time.strftime("%b %d %Y, %H:%M:%S"),
msg='Backup successful for ' + items.domain + '.').save()
else:
BackupLogsDO(owner=plan, level='ERROR', timeStamp=time.strftime("%b %d %Y, %H:%M:%S"),
msg='Backup failed for ' + items.domain + '. Error: ' + result[1]).save()
@@ -1187,6 +1194,8 @@ class S3Backups(multi.Thread):
key,
Config=config,
)
command = 'rm -f ' + result[1] + ".tar.gz"
ProcessUtilities.normalExecutioner(command)
BackupLogsMINIO(owner=plan, level='INFO', timeStamp=time.strftime("%b %d %Y, %H:%M:%S"),
msg='Backup successful for ' + items.domain + '.').save()
else: