ModSecurity OWASP and Comodo Rules Integrated.

This commit is contained in:
usmannasir
2018-04-05 00:31:16 +05:00
parent e217076352
commit 5a6e0f48c0
7 changed files with 559 additions and 78 deletions

View File

@@ -548,6 +548,7 @@
<li><a href="{% url 'secureSSH' %}" title="{% trans 'Secure SSH' %}"><span>{% trans "Secure SSH" %}</span></a></li> <li><a href="{% url 'secureSSH' %}" title="{% trans 'Secure SSH' %}"><span>{% trans "Secure SSH" %}</span></a></li>
<li><a href="{% url 'modSecurity' %}" title="{% trans 'ModSecurity Configurations' %}"><span>{% trans "ModSecurity Conf" %}</span></a></li> <li><a href="{% url 'modSecurity' %}" title="{% trans 'ModSecurity Configurations' %}"><span>{% trans "ModSecurity Conf" %}</span></a></li>
<li><a href="{% url 'modSecRules' %}" title="{% trans 'ModSecurity Rules' %}"><span>{% trans "ModSecurity Rules" %}</span></a></li> <li><a href="{% url 'modSecRules' %}" title="{% trans 'ModSecurity Rules' %}"><span>{% trans "ModSecurity Rules" %}</span></a></li>
<li><a href="{% url 'modSecRulesPacks' %}" title="{% trans 'ModSecurity Rules Packs' %}"><span>{% trans "ModSecurity Rules Packs" %}</span></a></li>
</ul> </ul>
</div><!-- .sidebar-submenu --> </div><!-- .sidebar-submenu -->

View File

@@ -1252,8 +1252,9 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.installationFailed = true; $scope.installationFailed = true;
$scope.installationSuccess = true; $scope.installationSuccess = true;
$scope.ruleFiles = true;
///// ModSec configs /////
var owaspInstalled = false; var owaspInstalled = false;
var comodoInstalled = false; var comodoInstalled = false;
@@ -1262,25 +1263,27 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
$('#owaspInstalled').change(function() { $('#owaspInstalled').change(function() {
counterOWASP = counterOWASP + 1;
owaspInstalled = $(this).prop('checked'); owaspInstalled = $(this).prop('checked');
$scope.ruleFiles = true;
if(counterOWASP !== 0) {
if(counterOWASP > 2) {
if (owaspInstalled === true) { if (owaspInstalled === true) {
installModSecRulesPack('installOWASP'); installModSecRulesPack('installOWASP');
} else { } else {
installModSecRulesPack('disableOWASP') installModSecRulesPack('disableOWASP')
} }
} }
counterOWASP = counterOWASP + 1;
}); });
$('#comodoInstalled').change(function() { $('#comodoInstalled').change(function() {
counterComodo = counterComodo + 1; $scope.ruleFiles = true;
comodoInstalled = $(this).prop('checked'); comodoInstalled = $(this).prop('checked');
if(counterComodo > 2) { if(counterComodo !== 0) {
if (comodoInstalled === true) { if (comodoInstalled === true) {
installModSecRulesPack('installComodo'); installModSecRulesPack('installComodo');
@@ -1289,16 +1292,16 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
} }
} }
counterComodo = counterComodo + 1;
}); });
getOWASPAndComodoStatus(); getOWASPAndComodoStatus(true);
function getOWASPAndComodoStatus(){ function getOWASPAndComodoStatus(updateToggle){
$scope.modsecLoading = false; $scope.modsecLoading = false;
$('#owaspInstalled').bootstrapToggle('off');
$('#comodoInstalled').bootstrapToggle('off');
url = "/firewall/getOWASPAndComodoStatus"; url = "/firewall/getOWASPAndComodoStatus";
@@ -1321,20 +1324,35 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
if(response.data.modSecInstalled === 1){ if(response.data.modSecInstalled === 1){
if (updateToggle === true){
if (response.data.owaspInstalled === 1) { if (response.data.owaspInstalled === 1) {
$('#owaspInstalled').bootstrapToggle('on'); $('#owaspInstalled').bootstrapToggle('on');
$scope.owaspDisable = false; $scope.owaspDisable = false;
}else{ } else {
$('#owaspInstalled').bootstrapToggle('off'); $('#owaspInstalled').bootstrapToggle('off');
$scope.owaspDisable = true; $scope.owaspDisable = true;
} }
if (response.data.comodoInstalled === 1) { if (response.data.comodoInstalled === 1) {
$('#comodoInstalled').bootstrapToggle('on'); $('#comodoInstalled').bootstrapToggle('on');
$scope.comodoDisable = false; $scope.comodoDisable = false;
}else{ } else {
$('#comodoInstalled').bootstrapToggle('off'); $('#comodoInstalled').bootstrapToggle('off');
$scope.comodoDisable = true; $scope.comodoDisable = true;
} }
}else{
if (response.data.owaspInstalled === 1) {
$scope.owaspDisable = false;
} else {
$scope.owaspDisable = true;
}
if (response.data.comodoInstalled === 1) {
$scope.comodoDisable = false;
} else {
$scope.comodoDisable = true;
}
}
} }
@@ -1351,8 +1369,6 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
$scope.modsecLoading = false; $scope.modsecLoading = false;
url = "/firewall/installModSecRulesPack"; url = "/firewall/installModSecRulesPack";
var data = { var data = {
@@ -1384,7 +1400,7 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
$scope.installationFailed = true; $scope.installationFailed = true;
$scope.installationSuccess = false; $scope.installationSuccess = false;
$timeout(function() { $window.location.reload(); }, 3000); getOWASPAndComodoStatus(false);
}else{ }else{
$scope.modsecLoading = true; $scope.modsecLoading = true;
@@ -1414,6 +1430,136 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
} }
/////
$scope.fetchRulesFile = function (packName) {
$scope.modsecLoading = false;
$scope.ruleFiles = false;
$scope.installationQuote = true;
$scope.couldNotConnect = true;
$scope.installationFailed = true;
$scope.installationSuccess = true;
url = "/firewall/getRulesFiles";
var data = {
packName:packName
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.modsecLoading = true;
if(response.data.fetchStatus === 1){
$scope.records = JSON.parse(response.data.data);
$scope.installationQuote = true;
$scope.couldNotConnect = true;
$scope.installationFailed = true;
$scope.installationSuccess = false;
}
else{
$scope.installationQuote = true;
$scope.couldNotConnect = true;
$scope.installationFailed = false;
$scope.installationSuccess = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.modsecLoading = true;
$scope.installationQuote = true;
$scope.couldNotConnect = false;
$scope.installationFailed = true;
$scope.installationSuccess = true;
}
};
$scope.removeRuleFile = function (fileName, packName, status) {
$scope.modsecLoading = false;
url = "/firewall/enableDisableRuleFile";
var data = {
packName:packName,
fileName:fileName,
status:status
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.modsecLoading = true;
if(response.data.saveStatus === 1){
$scope.modsecLoading = true;
//
$scope.installationQuote = true;
$scope.couldNotConnect = true;
$scope.installationFailed = true;
$scope.installationSuccess = false;
$scope.fetchRulesFile(packName);
}else{
$scope.modsecLoading = true;
//
$scope.installationQuote = true;
$scope.couldNotConnect = true;
$scope.installationFailed = false;
$scope.installationSuccess = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.modsecLoading = true;
//
$scope.installationQuote = true;
$scope.couldNotConnect = false;
$scope.installationFailed = true;
$scope.installationSuccess = true;
}
}
}); });

View File

@@ -22,7 +22,7 @@
{% if modSecInstalled == 0 %} {% if modSecInstalled == 0 %}
<div class="content-box-wrapper"> <div class="content-box-wrapper">
<div class="row"> <div class="row">
<div class="col-md-12 text-center" style="margin-bottom: 2%;"> <div class="col-md-12 text-center" style="margin-bottom: 2%;">
<h3>{% trans "ModSecurity is not installed " %} <h3>{% trans "ModSecurity is not installed " %}
@@ -39,63 +39,92 @@
<!----- ModeSec Install Log box -----------------> <!----- ModeSec Install Log box ----------------->
{% else %} {% else %}
<div class="content-box-wrapper"> <div class="content-box-wrapper">
<div class="row"> <div class="row">
<table cellpadding="0" cellspacing="0" border="0" class="table text-center" id="datatable-example"> <table cellpadding="0" cellspacing="0" border="0" class="table text-center" id="datatable-example">
<thead> <thead>
<tr> <tr>
<th style="width: 33%" >Package</th> <th style="width: 33%" >Package</th>
<th style="width: 33%">Status</th> <th style="width: 33%">Status</th>
<th style="width: 33%"></th> <th style="width: 33%"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>OWASP ModSecurity Core Rules</td> <td>OWASP ModSecurity Core Rules</td>
<td><input type="checkbox" id="owaspInstalled" data-toggle="toggle"></td> <td><input type="checkbox" id="owaspInstalled" data-toggle="toggle"></td>
<td> <td>
<button ng-disabled="owaspDisable" ng-click="installModSec()" class="btn btn-alt btn-hover btn-blue-alt"> <button ng-disabled="owaspDisable" ng-click="fetchRulesFile('owasp')" class="btn btn-alt btn-hover btn-blue-alt">
<span >{% trans "Configure" %}</span> <span >{% trans "Configure" %}</span>
<i class="glyph-icon icon-arrow-right"></i> <i class="glyph-icon icon-arrow-right"></i>
</button> </button>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>COMODO ModSecurity 3.0</td> <td>COMODO ModSecurity 3.0</td>
<td><input type="checkbox" id="comodoInstalled" data-toggle="toggle"></td> <td><input type="checkbox" id="comodoInstalled" data-toggle="toggle"></td>
<td> <td>
<button ng-disabled="comodoDisable" ng-click="installModSec()" class="btn btn-alt btn-hover btn-blue-alt"> <button ng-disabled="comodoDisable" ng-click="fetchRulesFile('comodo')" class="btn btn-alt btn-hover btn-blue-alt">
<span>{% trans "Configure" %}</span> <span>{% trans "Configure" %}</span>
<i class="glyph-icon icon-arrow-right"></i> <i class="glyph-icon icon-arrow-right"></i>
</button> </button>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div class="col-sm-3"></div> <div class="col-sm-3"></div>
<div class="col-sm-6"> <div class="col-sm-6">
<div ng-hide="installationQuote" class="alert alert-success"> <div ng-hide="installationQuote" class="alert alert-success">
<p>{% trans "Operation successful." %}</p> <p>{% trans "Operation successful." %}</p>
</div> </div>
<div ng-hide="couldNotConnect" class="alert alert-danger"> <div ng-hide="couldNotConnect" class="alert alert-danger">
<p>{% trans "Could not connect. Please refresh this page." %} </p> <p>{% trans "Could not connect. Please refresh this page." %} </p>
</div> </div>
<div ng-hide="installationFailed" class="alert alert-danger"> <div ng-hide="installationFailed" class="alert alert-danger">
<p>{% trans "Installation failed." %} {$ errorMessage $}</p> <p>{% trans "Operation failed, Error message: " %} {$ errorMessage $}</p>
</div> </div>
<div ng-hide="installationSuccess" class="alert alert-success"> <div ng-hide="installationSuccess" class="alert alert-success">
<p>{% trans "Operation successful, refreshing page in 3 seconds.." %}</p> <p>{% trans "Operation successful." %}</p>
</div> </div>
</div> </div>
<!------ List of rule files --------------->
<div ng-hide="ruleFiles" class="form-group">
<div class="col-sm-12">
<table class="table">
<thead>
<tr>
<th>{% trans "ID" %}</th>
<th>{% trans "Supplier" %}</th>
<th>{% trans "Filename" %}</th>
<th>{% trans "Status" %}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="record in records track by $index">
<td ng-bind="record.id"></td>
<td ng-bind="record.packName"></td>
<td ng-bind="record.fileName"></td>
<td ><input ng-click="removeRuleFile(record.fileName,record.packName,record.status)" ng-checked="record.status" type="checkbox" ></td>
</tr>
</tbody>
</table>
</div>
</div>
<!------ List of rule files --------------->

View File

@@ -36,6 +36,8 @@ urlpatterns = [
url(r'^modSecRulesPacks', views.modSecRulesPacks, name='modSecRulesPacks'), url(r'^modSecRulesPacks', views.modSecRulesPacks, name='modSecRulesPacks'),
url(r'^getOWASPAndComodoStatus', views.getOWASPAndComodoStatus, name='getOWASPAndComodoStatus'), url(r'^getOWASPAndComodoStatus', views.getOWASPAndComodoStatus, name='getOWASPAndComodoStatus'),
url(r'^installModSecRulesPack', views.installModSecRulesPack, name='installModSecRulesPack'), url(r'^installModSecRulesPack', views.installModSecRulesPack, name='installModSecRulesPack'),
url(r'^getRulesFiles', views.getRulesFiles, name='getRulesFiles'),
url(r'^enableDisableRuleFile', views.enableDisableRuleFile, name='enableDisableRuleFile'),

View File

@@ -1121,3 +1121,107 @@ def installModSecRulesPack(request):
json_data = json.dumps(data_ret) json_data = json.dumps(data_ret)
return HttpResponse(json_data) return HttpResponse(json_data)
def getRulesFiles(request):
try:
val = request.session['userID']
try:
if request.method == 'POST':
data = json.loads(request.body)
packName = data['packName']
confPath = os.path.join(virtualHostUtilities.Server_root, 'conf/httpd_config.conf')
command = "sudo cat " + confPath
httpdConfig = subprocess.check_output(shlex.split(command)).splitlines()
json_data = "["
checker = 0
counter = 0
for items in httpdConfig:
if items.find('modsec/'+packName) > -1:
counter = counter + 1
if items[0] == '#':
status = False
else:
status = True
fileName = items.lstrip('#')
fileName = fileName.split('/')[-1]
dic = {
'id': counter,
'fileName': fileName,
'packName':packName,
'status': status,
}
if checker == 0:
json_data = json_data + json.dumps(dic)
checker = 1
else:
json_data = json_data + ',' + json.dumps(dic)
json_data = json_data + ']'
final_json = json.dumps({'fetchStatus': 1, 'error_message': "None","data":json_data})
return HttpResponse(final_json)
except BaseException,msg:
final_dic = {'fetchStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except KeyError:
final_dic = {'fetchStatus': 0, 'error_message': "Not Logged In, please refresh the page or login again."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
def enableDisableRuleFile(request):
try:
val = request.session['userID']
try:
if request.method == 'POST':
data = json.loads(request.body)
packName = data['packName']
fileName = data['fileName']
currentStatus = data['status']
if currentStatus == True:
functionName = 'disableRuleFile'
else:
functionName = 'enableRuleFile'
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/modSec.py"
execPath = execPath + " " + functionName + ' --packName ' + packName + ' --fileName ' + fileName
output = subprocess.check_output(shlex.split(execPath))
if output.find("1,None") > -1:
installUtilities.reStartLiteSpeed()
data_ret = {'saveStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
data_ret = {'saveStatus': 0, 'error_message': output}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException,msg:
data_ret = {'saveStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
data_ret = {'saveStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)

View File

@@ -389,6 +389,53 @@ modsecurity_rules_file /usr/local/lsws/conf/modsec/owasp/rules/RESPONSE-999-EXCL
str(msg) + " [disableOWASP]") str(msg) + " [disableOWASP]")
print "0," + str(msg) print "0," + str(msg)
@staticmethod
def disableRuleFile(fileName, packName):
try:
confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
confData = open(confFile).readlines()
conf = open(confFile, 'w')
for items in confData:
if items.find('modsec/'+packName) > -1 and items.find(fileName) > -1:
conf.write("#" + items)
else:
conf.writelines(items)
conf.close()
print "1,None"
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [disableRuleFile]")
print "0," + str(msg)
@staticmethod
def enableRuleFile(fileName, packName):
try:
confFile = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
confData = open(confFile).readlines()
conf = open(confFile, 'w')
for items in confData:
if items.find('modsec/' + packName) > -1 and items.find(fileName) > -1:
conf.write(items.lstrip('#'))
else:
conf.writelines(items)
conf.close()
print "1,None"
except BaseException, msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [enableRuleFile]")
print "0," + str(msg)
@@ -399,6 +446,8 @@ def main():
parser.add_argument('function', help='Specific a function to call!') parser.add_argument('function', help='Specific a function to call!')
parser.add_argument('--tempConfigPath', help='Temporary path to configurations data!') parser.add_argument('--tempConfigPath', help='Temporary path to configurations data!')
parser.add_argument('--packName', help='ModSecurity supplier name!')
parser.add_argument('--fileName', help='Filename to enable or disable!')
args = parser.parse_args() args = parser.parse_args()
@@ -420,6 +469,10 @@ def main():
modSec.installComodo() modSec.installComodo()
elif args.function == "disableComodo": elif args.function == "disableComodo":
modSec.disableComodo() modSec.disableComodo()
elif args.function == "disableRuleFile":
modSec.disableRuleFile(args.fileName, args.packName)
elif args.function == "enableRuleFile":
modSec.enableRuleFile(args.fileName, args.packName)
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@@ -1252,8 +1252,9 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
$scope.couldNotConnect = true; $scope.couldNotConnect = true;
$scope.installationFailed = true; $scope.installationFailed = true;
$scope.installationSuccess = true; $scope.installationSuccess = true;
$scope.ruleFiles = true;
///// ModSec configs /////
var owaspInstalled = false; var owaspInstalled = false;
var comodoInstalled = false; var comodoInstalled = false;
@@ -1262,25 +1263,27 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
$('#owaspInstalled').change(function() { $('#owaspInstalled').change(function() {
counterOWASP = counterOWASP + 1;
owaspInstalled = $(this).prop('checked'); owaspInstalled = $(this).prop('checked');
$scope.ruleFiles = true;
if(counterOWASP !== 0) {
if(counterOWASP > 2) {
if (owaspInstalled === true) { if (owaspInstalled === true) {
installModSecRulesPack('installOWASP'); installModSecRulesPack('installOWASP');
} else { } else {
installModSecRulesPack('disableOWASP') installModSecRulesPack('disableOWASP')
} }
} }
counterOWASP = counterOWASP + 1;
}); });
$('#comodoInstalled').change(function() { $('#comodoInstalled').change(function() {
counterComodo = counterComodo + 1; $scope.ruleFiles = true;
comodoInstalled = $(this).prop('checked'); comodoInstalled = $(this).prop('checked');
if(counterComodo > 2) { if(counterComodo !== 0) {
if (comodoInstalled === true) { if (comodoInstalled === true) {
installModSecRulesPack('installComodo'); installModSecRulesPack('installComodo');
@@ -1289,16 +1292,16 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
} }
} }
counterComodo = counterComodo + 1;
}); });
getOWASPAndComodoStatus(); getOWASPAndComodoStatus(true);
function getOWASPAndComodoStatus(){ function getOWASPAndComodoStatus(updateToggle){
$scope.modsecLoading = false; $scope.modsecLoading = false;
$('#owaspInstalled').bootstrapToggle('off');
$('#comodoInstalled').bootstrapToggle('off');
url = "/firewall/getOWASPAndComodoStatus"; url = "/firewall/getOWASPAndComodoStatus";
@@ -1321,20 +1324,35 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
if(response.data.modSecInstalled === 1){ if(response.data.modSecInstalled === 1){
if (updateToggle === true){
if (response.data.owaspInstalled === 1) { if (response.data.owaspInstalled === 1) {
$('#owaspInstalled').bootstrapToggle('on'); $('#owaspInstalled').bootstrapToggle('on');
$scope.owaspDisable = false; $scope.owaspDisable = false;
}else{ } else {
$('#owaspInstalled').bootstrapToggle('off'); $('#owaspInstalled').bootstrapToggle('off');
$scope.owaspDisable = true; $scope.owaspDisable = true;
} }
if (response.data.comodoInstalled === 1) { if (response.data.comodoInstalled === 1) {
$('#comodoInstalled').bootstrapToggle('on'); $('#comodoInstalled').bootstrapToggle('on');
$scope.comodoDisable = false; $scope.comodoDisable = false;
}else{ } else {
$('#comodoInstalled').bootstrapToggle('off'); $('#comodoInstalled').bootstrapToggle('off');
$scope.comodoDisable = true; $scope.comodoDisable = true;
} }
}else{
if (response.data.owaspInstalled === 1) {
$scope.owaspDisable = false;
} else {
$scope.owaspDisable = true;
}
if (response.data.comodoInstalled === 1) {
$scope.comodoDisable = false;
} else {
$scope.comodoDisable = true;
}
}
} }
@@ -1351,8 +1369,6 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
$scope.modsecLoading = false; $scope.modsecLoading = false;
url = "/firewall/installModSecRulesPack"; url = "/firewall/installModSecRulesPack";
var data = { var data = {
@@ -1384,7 +1400,7 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
$scope.installationFailed = true; $scope.installationFailed = true;
$scope.installationSuccess = false; $scope.installationSuccess = false;
$timeout(function() { $window.location.reload(); }, 3000); getOWASPAndComodoStatus(false);
}else{ }else{
$scope.modsecLoading = true; $scope.modsecLoading = true;
@@ -1414,6 +1430,136 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
} }
/////
$scope.fetchRulesFile = function (packName) {
$scope.modsecLoading = false;
$scope.ruleFiles = false;
$scope.installationQuote = true;
$scope.couldNotConnect = true;
$scope.installationFailed = true;
$scope.installationSuccess = true;
url = "/firewall/getRulesFiles";
var data = {
packName:packName
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.modsecLoading = true;
if(response.data.fetchStatus === 1){
$scope.records = JSON.parse(response.data.data);
$scope.installationQuote = true;
$scope.couldNotConnect = true;
$scope.installationFailed = true;
$scope.installationSuccess = false;
}
else{
$scope.installationQuote = true;
$scope.couldNotConnect = true;
$scope.installationFailed = false;
$scope.installationSuccess = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.modsecLoading = true;
$scope.installationQuote = true;
$scope.couldNotConnect = false;
$scope.installationFailed = true;
$scope.installationSuccess = true;
}
};
$scope.removeRuleFile = function (fileName, packName, status) {
$scope.modsecLoading = false;
url = "/firewall/enableDisableRuleFile";
var data = {
packName:packName,
fileName:fileName,
status:status
};
var config = {
headers : {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.modsecLoading = true;
if(response.data.saveStatus === 1){
$scope.modsecLoading = true;
//
$scope.installationQuote = true;
$scope.couldNotConnect = true;
$scope.installationFailed = true;
$scope.installationSuccess = false;
$scope.fetchRulesFile(packName);
}else{
$scope.modsecLoading = true;
//
$scope.installationQuote = true;
$scope.couldNotConnect = true;
$scope.installationFailed = false;
$scope.installationSuccess = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.modsecLoading = true;
//
$scope.installationQuote = true;
$scope.couldNotConnect = false;
$scope.installationFailed = true;
$scope.installationSuccess = true;
}
}
}); });