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

@@ -1252,8 +1252,9 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
$scope.couldNotConnect = true;
$scope.installationFailed = true;
$scope.installationSuccess = true;
$scope.ruleFiles = true;
///// ModSec configs
/////
var owaspInstalled = false;
var comodoInstalled = false;
@@ -1262,25 +1263,27 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
$('#owaspInstalled').change(function() {
counterOWASP = counterOWASP + 1;
owaspInstalled = $(this).prop('checked');
$scope.ruleFiles = true;
if(counterOWASP > 2) {
if(counterOWASP !== 0) {
if (owaspInstalled === true) {
installModSecRulesPack('installOWASP');
} else {
installModSecRulesPack('disableOWASP')
}
}
counterOWASP = counterOWASP + 1;
});
$('#comodoInstalled').change(function() {
counterComodo = counterComodo + 1;
$scope.ruleFiles = true;
comodoInstalled = $(this).prop('checked');
if(counterComodo > 2) {
if(counterComodo !== 0) {
if (comodoInstalled === true) {
installModSecRulesPack('installComodo');
@@ -1289,16 +1292,16 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
}
}
counterComodo = counterComodo + 1;
});
getOWASPAndComodoStatus();
function getOWASPAndComodoStatus(){
getOWASPAndComodoStatus(true);
function getOWASPAndComodoStatus(updateToggle){
$scope.modsecLoading = false;
$('#owaspInstalled').bootstrapToggle('off');
$('#comodoInstalled').bootstrapToggle('off');
url = "/firewall/getOWASPAndComodoStatus";
@@ -1321,20 +1324,35 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
if(response.data.modSecInstalled === 1){
if (updateToggle === true){
if (response.data.owaspInstalled === 1) {
$('#owaspInstalled').bootstrapToggle('on');
$scope.owaspDisable = false;
}else{
} else {
$('#owaspInstalled').bootstrapToggle('off');
$scope.owaspDisable = true;
}
if (response.data.comodoInstalled === 1) {
$('#comodoInstalled').bootstrapToggle('on');
$scope.comodoDisable = false;
}else{
} else {
$('#comodoInstalled').bootstrapToggle('off');
$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;
url = "/firewall/installModSecRulesPack";
var data = {
@@ -1384,7 +1400,7 @@ app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) {
$scope.installationFailed = true;
$scope.installationSuccess = false;
$timeout(function() { $window.location.reload(); }, 3000);
getOWASPAndComodoStatus(false);
}else{
$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;
}
}
});