further refoctor default render firewall

This commit is contained in:
Usman Nasir
2021-03-06 11:05:19 +05:00
parent c0bbf5fc2e
commit 3aeab72d91

View File

@@ -466,14 +466,6 @@ class FirewallManager:
return HttpResponse(final_json) return HttpResponse(final_json)
def loadModSecurityHome(self, request = None, userID = None): def loadModSecurityHome(self, request = None, userID = None):
try:
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()
if ProcessUtilities.decideServer() == ProcessUtilities.OLS: if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
OLS = 1 OLS = 1
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
@@ -495,9 +487,6 @@ class FirewallManager:
{'modSecInstalled': modSecInstalled, 'OLS': OLS}, 'admin') {'modSecInstalled': modSecInstalled, 'OLS': OLS}, 'admin')
return proc.render() return proc.render()
except BaseException as msg:
return HttpResponse(str(msg))
def installModSec(self, userID = None, data = None): def installModSec(self, userID = None, data = None):
try: try:
currentACL = ACLManager.loadedACL(userID) currentACL = ACLManager.loadedACL(userID)
@@ -852,15 +841,6 @@ class FirewallManager:
return HttpResponse(json_data) return HttpResponse(json_data)
def modSecRules(self, request = None, userID = None): def modSecRules(self, request = None, userID = None):
try:
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()
if ProcessUtilities.decideServer() == ProcessUtilities.OLS: if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
@@ -879,8 +859,6 @@ class FirewallManager:
proc = httpProc(request, 'firewall/modSecurityRules.html', proc = httpProc(request, 'firewall/modSecurityRules.html',
{'modSecInstalled': modSecInstalled}, 'admin') {'modSecInstalled': modSecInstalled}, 'admin')
return proc.render() return proc.render()
except BaseException as msg:
return HttpResponse(str(msg))
def fetchModSecRules(self, userID = None, data = None): def fetchModSecRules(self, userID = None, data = None):
try: try:
@@ -977,15 +955,6 @@ class FirewallManager:
return HttpResponse(json_data) return HttpResponse(json_data)
def modSecRulesPacks(self, request = None, userID = None): def modSecRulesPacks(self, request = None, userID = None):
try:
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()
if ProcessUtilities.decideServer() == ProcessUtilities.OLS: if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf") confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
@@ -1006,9 +975,6 @@ class FirewallManager:
{'modSecInstalled': modSecInstalled}, 'admin') {'modSecInstalled': modSecInstalled}, 'admin')
return proc.render() return proc.render()
except BaseException as msg:
return HttpResponse(msg)
def getOWASPAndComodoStatus(self, userID = None, data = None): def getOWASPAndComodoStatus(self, userID = None, data = None):
try: try:
@@ -1284,15 +1250,6 @@ class FirewallManager:
return HttpResponse(json_data) return HttpResponse(json_data)
def csf(self): def csf(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()
csfInstalled = 1 csfInstalled = 1
try: try:
command = 'csf -h' command = 'csf -h'
@@ -1303,12 +1260,9 @@ class FirewallManager:
csfInstalled = 0 csfInstalled = 0
proc = httpProc(self.request, 'firewall/csf.html', proc = httpProc(self.request, 'firewall/csf.html',
{'csfInstalled' : csfInstalled}, 'admin') {'csfInstalled': csfInstalled}, 'admin')
return proc.render() return proc.render()
except BaseException as msg:
return HttpResponse(str(msg))
def installCSF(self): def installCSF(self):
try: try:
userID = self.request.session['userID'] userID = self.request.session['userID']
@@ -1537,15 +1491,6 @@ class FirewallManager:
return HttpResponse(final_json) return HttpResponse(final_json)
def imunify(self): def imunify(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()
ipFile = "/etc/cyberpanel/machineIP" ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile) f = open(ipFile)
ipData = f.read() ipData = f.read()
@@ -1576,10 +1521,6 @@ class FirewallManager:
data, 'admin') data, 'admin')
return proc.render() return proc.render()
except BaseException as msg:
return HttpResponse(str(msg))
def submitinstallImunify(self): def submitinstallImunify(self):
try: try:
userID = self.request.session['userID'] userID = self.request.session['userID']
@@ -1607,15 +1548,6 @@ class FirewallManager:
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1) logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
def imunifyAV(self): def imunifyAV(self):
try:
userID = self.request.session['userID']
currentACL = ACLManager.loadedACL(userID)
if currentACL['admin'] == 1:
pass
else:
return ACLManager.loadError()
ipFile = "/etc/cyberpanel/machineIP" ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile) f = open(ipFile)
ipData = f.read() ipData = f.read()
@@ -1626,8 +1558,6 @@ class FirewallManager:
data = {} data = {}
data['ipAddress'] = fullAddress data['ipAddress'] = fullAddress
if os.path.exists(FirewallManager.imunifyAVPath): if os.path.exists(FirewallManager.imunifyAVPath):
data['imunify'] = 1 data['imunify'] = 1
else: else:
@@ -1642,11 +1572,6 @@ class FirewallManager:
data, 'admin') data, 'admin')
return proc.render() return proc.render()
except BaseException as msg:
return HttpResponse(str(msg))
def submitinstallImunifyAV(self): def submitinstallImunifyAV(self):
try: try:
userID = self.request.session['userID'] userID = self.request.session['userID']