| 
									
										
										
										
											2017-10-24 19:16:36 +05:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Created by usman on 9/5/17. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Java script code to ADD Firewall Rules */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | app.controller('firewallController', function($scope,$http) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             $scope.rulesLoading = true; | 
					
						
							|  |  |  |             $scope.actionFailed = true; | 
					
						
							|  |  |  |             $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             $scope.canNotAddRule = true; | 
					
						
							|  |  |  |             $scope.ruleAdded = true; | 
					
						
							|  |  |  |             $scope.couldNotConnect = true; | 
					
						
							|  |  |  |             $scope.rulesDetails = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            firewallStatus(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            populateCurrentRecords(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $scope.addRule = function(){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesLoading = false; | 
					
						
							|  |  |  |                         $scope.actionFailed = true; | 
					
						
							|  |  |  |                         $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                         $scope.ruleAdded = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         url = "/firewall/addRule"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var ruleName = $scope.ruleName; | 
					
						
							|  |  |  |                         var ruleProtocol = $scope.ruleProtocol; | 
					
						
							|  |  |  |                         var rulePort = $scope.rulePort; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var data = { | 
					
						
							|  |  |  |                             ruleName:ruleName, | 
					
						
							|  |  |  |                             ruleProtocol:ruleProtocol, | 
					
						
							|  |  |  |                             rulePort:rulePort, | 
					
						
							| 
									
										
										
										
											2017-11-02 02:23:09 +05:00
										 |  |  |                             ruleIP:$scope.ruleIP, | 
					
						
							| 
									
										
										
										
											2017-10-24 19:16:36 +05:00
										 |  |  |                         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var config = { | 
					
						
							|  |  |  |                             headers : { | 
					
						
							|  |  |  |                                 'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     if(response.data.add_status == 1){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         populateCurrentRecords(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesLoading = true; | 
					
						
							|  |  |  |                         $scope.actionFailed = true; | 
					
						
							|  |  |  |                         $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                         $scope.ruleAdded = false; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     else{ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesLoading = true; | 
					
						
							|  |  |  |                         $scope.actionFailed = true; | 
					
						
							|  |  |  |                         $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.canNotAddRule = false; | 
					
						
							|  |  |  |                         $scope.ruleAdded = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.errorMessage = response.data.error_message; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     $scope.rulesLoading = true; | 
					
						
							|  |  |  |                     $scope.actionFailed = true; | 
					
						
							|  |  |  |                     $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                     $scope.ruleAdded = true; | 
					
						
							|  |  |  |                     $scope.couldNotConnect = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            function populateCurrentRecords(){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesLoading = false; | 
					
						
							|  |  |  |                         $scope.actionFailed = true; | 
					
						
							|  |  |  |                         $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         url = "/firewall/getCurrentRules"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var data = { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var config = { | 
					
						
							|  |  |  |                             headers : { | 
					
						
							|  |  |  |                                 'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     if(response.data.fetchStatus == 1){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rules = JSON.parse(response.data.data); | 
					
						
							|  |  |  |                         $scope.rulesLoading = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     else{ | 
					
						
							|  |  |  |                         $scope.rulesLoading = true; | 
					
						
							|  |  |  |                         $scope.errorMessage = response.data.error_message; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  |                     $scope.couldNotConnect = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-02 02:23:09 +05:00
										 |  |  |            $scope.deleteRule = function(id,proto,port,ruleIP){ | 
					
						
							| 
									
										
										
										
											2017-10-24 19:16:36 +05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesLoading = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         url = "/firewall/deleteRule"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var data = { | 
					
						
							|  |  |  |                             id:id, | 
					
						
							|  |  |  |                             proto:proto, | 
					
						
							|  |  |  |                             port:port, | 
					
						
							| 
									
										
										
										
											2017-11-02 02:23:09 +05:00
										 |  |  |                             ruleIP:ruleIP, | 
					
						
							| 
									
										
										
										
											2017-10-24 19:16:36 +05:00
										 |  |  |                         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var config = { | 
					
						
							|  |  |  |                             headers : { | 
					
						
							|  |  |  |                                 'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     if(response.data.delete_status == 1){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         populateCurrentRecords(); | 
					
						
							|  |  |  |                         $scope.rulesLoading = true; | 
					
						
							|  |  |  |                         $scope.actionFailed = true; | 
					
						
							|  |  |  |                         $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                         $scope.ruleAdded = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     else{ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesLoading = true; | 
					
						
							|  |  |  |                         $scope.actionFailed = true; | 
					
						
							|  |  |  |                         $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.canNotAddRule = false; | 
					
						
							|  |  |  |                         $scope.ruleAdded = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesLoading = true; | 
					
						
							|  |  |  |                         $scope.errorMessage = response.data.error_message; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     $scope.rulesLoading = true; | 
					
						
							|  |  |  |                     $scope.actionFailed = true; | 
					
						
							|  |  |  |                     $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                     $scope.ruleAdded = true; | 
					
						
							|  |  |  |                     $scope.couldNotConnect = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $scope.reloadFireWall = function(){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.actionFailed = true; | 
					
						
							|  |  |  |                         $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                         $scope.ruleAdded = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesLoading = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         url = "/firewall/reloadFirewall"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var data = { | 
					
						
							|  |  |  |                         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var config = { | 
					
						
							|  |  |  |                             headers : { | 
					
						
							|  |  |  |                                 'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     if(response.data.reload_status == 1){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesLoading = true; | 
					
						
							|  |  |  |                         $scope.actionFailed = true; | 
					
						
							|  |  |  |                         $scope.actionSuccess = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                         $scope.ruleAdded = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     else{ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesLoading = true; | 
					
						
							|  |  |  |                         $scope.actionFailed = false; | 
					
						
							|  |  |  |                         $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                         $scope.ruleAdded = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.errorMessage = response.data.error_message; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     $scope.rulesLoading = true; | 
					
						
							|  |  |  |                     $scope.actionFailed = true; | 
					
						
							|  |  |  |                     $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                     $scope.ruleAdded = true; | 
					
						
							|  |  |  |                     $scope.couldNotConnect = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $scope.startFirewall = function(){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.actionFailed = true; | 
					
						
							|  |  |  |                         $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                         $scope.ruleAdded = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesLoading = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         url = "/firewall/startFirewall"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var data = { | 
					
						
							|  |  |  |                         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var config = { | 
					
						
							|  |  |  |                             headers : { | 
					
						
							|  |  |  |                                 'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     if(response.data.start_status == 1){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesLoading = true; | 
					
						
							|  |  |  |                         $scope.actionFailed = true; | 
					
						
							|  |  |  |                         $scope.actionSuccess = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                         $scope.ruleAdded = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesDetails = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                          firewallStatus(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     else{ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesLoading = true; | 
					
						
							|  |  |  |                         $scope.actionFailed = false; | 
					
						
							|  |  |  |                         $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                         $scope.ruleAdded = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.errorMessage = response.data.error_message; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     $scope.rulesLoading = true; | 
					
						
							|  |  |  |                     $scope.actionFailed = true; | 
					
						
							|  |  |  |                     $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                     $scope.ruleAdded = true; | 
					
						
							|  |  |  |                     $scope.couldNotConnect = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $scope.stopFirewall = function(){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.actionFailed = true; | 
					
						
							|  |  |  |                         $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                         $scope.ruleAdded = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesLoading = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         url = "/firewall/stopFirewall"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var data = { | 
					
						
							|  |  |  |                         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var config = { | 
					
						
							|  |  |  |                             headers : { | 
					
						
							|  |  |  |                                 'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     if(response.data.stop_status == 1){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesLoading = true; | 
					
						
							|  |  |  |                         $scope.actionFailed = true; | 
					
						
							|  |  |  |                         $scope.actionSuccess = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                         $scope.ruleAdded = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesDetails = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         firewallStatus(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     else{ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesLoading = true; | 
					
						
							|  |  |  |                         $scope.actionFailed = false; | 
					
						
							|  |  |  |                         $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                         $scope.ruleAdded = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.errorMessage = response.data.error_message; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     $scope.rulesLoading = true; | 
					
						
							|  |  |  |                     $scope.actionFailed = true; | 
					
						
							|  |  |  |                     $scope.actionSuccess = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     $scope.canNotAddRule = true; | 
					
						
							|  |  |  |                     $scope.ruleAdded = true; | 
					
						
							|  |  |  |                     $scope.couldNotConnect = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            function firewallStatus(){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         url = "/firewall/firewallStatus"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var data = { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var config = { | 
					
						
							|  |  |  |                             headers : { | 
					
						
							|  |  |  |                                 'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     if(response.data.status == 1){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         if(response.data.firewallStatus == 1){ | 
					
						
							|  |  |  |                             $scope.rulesDetails = false; | 
					
						
							|  |  |  |                             $scope.status = "ON"; | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                         else{ | 
					
						
							|  |  |  |                             $scope.rulesDetails = true; | 
					
						
							|  |  |  |                             $scope.status = "OFF"; | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     else{ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.rulesDetails = true; | 
					
						
							|  |  |  |                         $scope.status = "OFF"; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     $scope.couldNotConnect = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Java script code to ADD Firewall Rules */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Java script code to Secure SSH */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | app.controller('secureSSHCTRL', function($scope,$http) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $scope.couldNotSave = true; | 
					
						
							|  |  |  |            $scope.detailsSaved = true; | 
					
						
							|  |  |  |            $scope.couldNotConnect = true; | 
					
						
							|  |  |  |            $scope.secureSSHLoading = true; | 
					
						
							|  |  |  |            $scope.keyDeleted = true; | 
					
						
							|  |  |  |            $scope.keyBox = true; | 
					
						
							|  |  |  |            $scope.showKeyBox = false; | 
					
						
							|  |  |  |            $scope.saveKeyBtn = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $scope.addKey = function(){ | 
					
						
							|  |  |  |                 $scope.saveKeyBtn = false; | 
					
						
							|  |  |  |                 $scope.showKeyBox = true; | 
					
						
							|  |  |  |                 $scope.keyBox = false; | 
					
						
							|  |  |  |            }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            getSSHConfigs(); | 
					
						
							|  |  |  |            populateCurrentKeys(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            // Checking root login
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             var rootLogin = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             $('#rootLogin').change(function() { | 
					
						
							|  |  |  |                 rootLogin = $(this).prop('checked'); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            function getSSHConfigs(){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.couldNotSave = true; | 
					
						
							|  |  |  |                         $scope.detailsSaved = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                         $scope.secureSSHLoading = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         url = "/firewall/getSSHConfigs"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var data = { | 
					
						
							|  |  |  |                             type:"1", | 
					
						
							|  |  |  |                         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var config = { | 
					
						
							|  |  |  |                             headers : { | 
					
						
							|  |  |  |                                 'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     $scope.sshPort = response.data.sshPort; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     if(response.data.permitRootLogin == 1){ | 
					
						
							|  |  |  |                         $('#rootLogin').bootstrapToggle('on'); | 
					
						
							|  |  |  |                         $scope.couldNotSave = true; | 
					
						
							|  |  |  |                        $scope.detailsSaved = true; | 
					
						
							|  |  |  |                        $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                        $scope.secureSSHLoading = true; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     else{ | 
					
						
							|  |  |  |                         $scope.errorMessage = response.data.error_message; | 
					
						
							|  |  |  |                         $scope.couldNotSave = true; | 
					
						
							|  |  |  |                         $scope.detailsSaved = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                         $scope.secureSSHLoading = true; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  |                     $scope.couldNotConnect = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $scope.saveChanges = function () { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                $scope.couldNotSave = true; | 
					
						
							|  |  |  |                $scope.detailsSaved = true; | 
					
						
							|  |  |  |                $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                $scope.secureSSHLoading = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                url = "/firewall/saveSSHConfigs"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var data = { | 
					
						
							|  |  |  |                             type:"1", | 
					
						
							|  |  |  |                             sshPort:$scope.sshPort, | 
					
						
							|  |  |  |                             rootLogin:rootLogin, | 
					
						
							|  |  |  |                         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var config = { | 
					
						
							|  |  |  |                             headers : { | 
					
						
							|  |  |  |                                 'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     if(response.data.saveStatus == 1){ | 
					
						
							|  |  |  |                         $scope.couldNotSave = true; | 
					
						
							|  |  |  |                         $scope.detailsSaved = false; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                         $scope.secureSSHLoading = true; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     else{ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.couldNotSave = false; | 
					
						
							|  |  |  |                        $scope.detailsSaved = true; | 
					
						
							|  |  |  |                        $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                        $scope.secureSSHLoading = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.errorMessage = response.data.error_message; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  |                     $scope.couldNotSave = true; | 
					
						
							|  |  |  |                     $scope.detailsSaved = true; | 
					
						
							|  |  |  |                     $scope.couldNotConnect = false; | 
					
						
							|  |  |  |                     $scope.secureSSHLoading = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |            }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            function populateCurrentKeys(){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         url = "/firewall/getSSHConfigs"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var data = { | 
					
						
							|  |  |  |                             type:"2", | 
					
						
							|  |  |  |                         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var config = { | 
					
						
							|  |  |  |                             headers : { | 
					
						
							|  |  |  |                                 'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     if(response.data.status == 1){ | 
					
						
							|  |  |  |                         $scope.records = JSON.parse(response.data.data); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  |                     $scope.couldNotConnect = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $scope.deleteKey =  function(key){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.secureSSHLoading = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         url = "/firewall/deleteSSHKey"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var data = { | 
					
						
							|  |  |  |                             key:key, | 
					
						
							|  |  |  |                         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var config = { | 
					
						
							|  |  |  |                             headers : { | 
					
						
							|  |  |  |                                 'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  |                     if(response.data.delete_status === 1){ | 
					
						
							| 
									
										
										
										
											2017-10-24 19:16:36 +05:00
										 |  |  |                         $scope.secureSSHLoading = true; | 
					
						
							|  |  |  |                         $scope.keyDeleted = false; | 
					
						
							|  |  |  |                         populateCurrentKeys(); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     else{ | 
					
						
							|  |  |  |                         $scope.couldNotConnect = false; | 
					
						
							|  |  |  |                         $scope.secureSSHLoading = true; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  |                     $scope.couldNotConnect = false; | 
					
						
							|  |  |  |                     $scope.secureSSHLoading = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $scope.saveKey =  function(key){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.secureSSHLoading = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         url = "/firewall/addSSHKey"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var data = { | 
					
						
							|  |  |  |                             key:$scope.keyData, | 
					
						
							|  |  |  |                         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var config = { | 
					
						
							|  |  |  |                             headers : { | 
					
						
							|  |  |  |                                 'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  |                     if(response.data.add_status === 1){ | 
					
						
							| 
									
										
										
										
											2017-10-24 19:16:36 +05:00
										 |  |  |                         $scope.secureSSHLoading = true; | 
					
						
							|  |  |  |                         $scope.saveKeyBtn = true; | 
					
						
							|  |  |  |                         $scope.showKeyBox = false; | 
					
						
							|  |  |  |                         $scope.keyBox = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         populateCurrentKeys(); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     else{ | 
					
						
							|  |  |  |                         $scope.secureSSHLoading = true; | 
					
						
							|  |  |  |                         $scope.saveKeyBtn = false; | 
					
						
							|  |  |  |                         $scope.showKeyBox = true; | 
					
						
							|  |  |  |                         $scope.keyBox = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = false; | 
					
						
							|  |  |  |                         $scope.secureSSHLoading = true; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  |                     $scope.secureSSHLoading = true; | 
					
						
							|  |  |  |                     $scope.saveKeyBtn = false; | 
					
						
							|  |  |  |                     $scope.showKeyBox = true; | 
					
						
							|  |  |  |                     $scope.keyBox = true; | 
					
						
							|  |  |  |                     $scope.couldNotConnect = false; | 
					
						
							|  |  |  |                     $scope.secureSSHLoading = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | /* Java script code to Secure SSH */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Java script code for ModSec */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | app.controller('modSec', function($scope, $http, $timeout, $window) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $scope.modSecNotifyBox  = true; | 
					
						
							|  |  |  |            $scope.modeSecInstallBox = true; | 
					
						
							|  |  |  |            $scope.modsecLoading = true; | 
					
						
							|  |  |  |            $scope.failedToStartInallation = true; | 
					
						
							|  |  |  |            $scope.couldNotConnect = true; | 
					
						
							|  |  |  |            $scope.modSecSuccessfullyInstalled = true; | 
					
						
							|  |  |  |            $scope.installationFailed = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $scope.installModSec = function(){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                $scope.modSecNotifyBox  = true; | 
					
						
							|  |  |  |                $scope.modeSecInstallBox = true; | 
					
						
							|  |  |  |                $scope.modsecLoading = false; | 
					
						
							|  |  |  |                $scope.failedToStartInallation = true; | 
					
						
							|  |  |  |                $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                $scope.modSecSuccessfullyInstalled = true; | 
					
						
							|  |  |  |                $scope.installationFailed = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                url = "/firewall/installModSec"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var data = {}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var config = { | 
					
						
							|  |  |  |                             headers : { | 
					
						
							|  |  |  |                                 'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     if(response.data.installModSec === 1){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.modSecNotifyBox  = true; | 
					
						
							|  |  |  |                         $scope.modeSecInstallBox = false; | 
					
						
							|  |  |  |                         $scope.modsecLoading = false; | 
					
						
							|  |  |  |                         $scope.failedToStartInallation = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                         $scope.modSecSuccessfullyInstalled = true; | 
					
						
							|  |  |  |                         $scope.installationFailed = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         getRequestStatus(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     else{ | 
					
						
							|  |  |  |                         $scope.errorMessage = response.data.error_message; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.modSecNotifyBox  = false; | 
					
						
							|  |  |  |                         $scope.modeSecInstallBox = true; | 
					
						
							|  |  |  |                         $scope.modsecLoading = true; | 
					
						
							|  |  |  |                         $scope.failedToStartInallation = false; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                         $scope.modSecSuccessfullyInstalled = true; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.modSecNotifyBox  = false; | 
					
						
							|  |  |  |                         $scope.modeSecInstallBox = false; | 
					
						
							|  |  |  |                         $scope.modsecLoading = true; | 
					
						
							|  |  |  |                         $scope.failedToStartInallation = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = false; | 
					
						
							|  |  |  |                         $scope.modSecSuccessfullyInstalled = true; | 
					
						
							|  |  |  |                         $scope.installationFailed = true; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            function getRequestStatus(){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.modSecNotifyBox  = true; | 
					
						
							|  |  |  |                         $scope.modeSecInstallBox = false; | 
					
						
							|  |  |  |                         $scope.modsecLoading = false; | 
					
						
							|  |  |  |                         $scope.failedToStartInallation = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                         $scope.modSecSuccessfullyInstalled = true; | 
					
						
							|  |  |  |                         $scope.installationFailed = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         url = "/firewall/installStatusModSec"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var data = {}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var config = { | 
					
						
							|  |  |  |                             headers : { | 
					
						
							|  |  |  |                                 'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     if(response.data.abort === 0){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.modSecNotifyBox  = true; | 
					
						
							|  |  |  |                         $scope.modeSecInstallBox = false; | 
					
						
							|  |  |  |                         $scope.modsecLoading = false; | 
					
						
							|  |  |  |                         $scope.failedToStartInallation = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                         $scope.modSecSuccessfullyInstalled = true; | 
					
						
							|  |  |  |                         $scope.installationFailed = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.requestData = response.data.requestStatus; | 
					
						
							|  |  |  |                         $timeout(getRequestStatus,1000); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     else{ | 
					
						
							|  |  |  |                         // Notifications
 | 
					
						
							|  |  |  |                         $timeout.cancel(); | 
					
						
							|  |  |  |                         $scope.modSecNotifyBox  = false; | 
					
						
							|  |  |  |                         $scope.modeSecInstallBox = false; | 
					
						
							|  |  |  |                         $scope.modsecLoading = true; | 
					
						
							|  |  |  |                         $scope.failedToStartInallation = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.requestData = response.data.requestStatus; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         if(response.data.installed === 0) { | 
					
						
							|  |  |  |                             $scope.installationFailed = false; | 
					
						
							|  |  |  |                             $scope.errorMessage = response.data.error_message; | 
					
						
							|  |  |  |                         }else{ | 
					
						
							|  |  |  |                             $scope.modSecSuccessfullyInstalled = false; | 
					
						
							|  |  |  |                             $timeout(function() {  $window.location.reload(); }, 3000); | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.modSecNotifyBox  = false; | 
					
						
							|  |  |  |                         $scope.modeSecInstallBox = false; | 
					
						
							|  |  |  |                         $scope.modsecLoading = true; | 
					
						
							|  |  |  |                         $scope.failedToStartInallation = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = false; | 
					
						
							|  |  |  |                         $scope.modSecSuccessfullyInstalled = true; | 
					
						
							|  |  |  |                         $scope.installationFailed = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |            ///// ModSec configs
 | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |            var modsecurity_status = false; | 
					
						
							|  |  |  |            var SecAuditEngine = false; | 
					
						
							|  |  |  |            var SecRuleEngine = false; | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |            $('#modsecurity_status').change(function() { | 
					
						
							|  |  |  |                 modsecurity_status = $(this).prop('checked'); | 
					
						
							|  |  |  |            }); | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |            $('#SecAuditEngine').change(function() { | 
					
						
							|  |  |  |                 SecAuditEngine = $(this).prop('checked'); | 
					
						
							|  |  |  |            }); | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |            $('#SecRuleEngine').change(function() { | 
					
						
							|  |  |  |                 SecRuleEngine = $(this).prop('checked'); | 
					
						
							|  |  |  |            }); | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |            fetchModSecSettings(); | 
					
						
							|  |  |  |            function fetchModSecSettings(){ | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |                $scope.modsecLoading = false; | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |                $('#modsecurity_status').bootstrapToggle('off'); | 
					
						
							|  |  |  |                $('#SecAuditEngine').bootstrapToggle('off'); | 
					
						
							|  |  |  |                $('#SecRuleEngine').bootstrapToggle('off'); | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |                url = "/firewall/fetchModSecSettings"; | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |                var phpSelection = $scope.phpSelection; | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |                var data = {}; | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |                var config = { | 
					
						
							|  |  |  |                    headers : { | 
					
						
							|  |  |  |                        'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                    } | 
					
						
							|  |  |  |                }; | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |                     $scope.modsecLoading = true; | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |                     if(response.data.fetchStatus === 1){ | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |                         if(response.data.installed === 1) { | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |                             if (response.data.modsecurity === 1) { | 
					
						
							|  |  |  |                                 $('#modsecurity_status').bootstrapToggle('on'); | 
					
						
							|  |  |  |                             } | 
					
						
							|  |  |  |                             if (response.data.SecAuditEngine === 1) { | 
					
						
							|  |  |  |                                 $('#SecAuditEngine').bootstrapToggle('on'); | 
					
						
							|  |  |  |                             } | 
					
						
							|  |  |  |                             if (response.data.SecRuleEngine === 1) { | 
					
						
							|  |  |  |                                 $('#SecRuleEngine').bootstrapToggle('on'); | 
					
						
							|  |  |  |                             } | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |                             $scope.SecDebugLogLevel = response.data.SecDebugLogLevel; | 
					
						
							|  |  |  |                             $scope.SecAuditLogParts = response.data.SecAuditLogParts; | 
					
						
							|  |  |  |                             $scope.SecAuditLogRelevantStatus = response.data.SecAuditLogRelevantStatus; | 
					
						
							|  |  |  |                             $scope.SecAuditLogType = response.data.SecAuditLogType; | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |                         } | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |                     $scope.modsecLoading = true; | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |            /////
 | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |            /// Save ModSec Changes
 | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 03:04:56 +05:00
										 |  |  |           $scope.failedToSave = true; | 
					
						
							|  |  |  |           $scope.successfullySaved = true; | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-23 23:05:55 +05:00
										 |  |  |           $scope.saveModSecConfigurations = function () { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                $scope.failedToSave = true; | 
					
						
							|  |  |  |                $scope.successfullySaved = true; | 
					
						
							|  |  |  |                $scope.modsecLoading = false; | 
					
						
							|  |  |  |                $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         url = "/firewall/saveModSecConfigurations"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var data = { | 
					
						
							|  |  |  |                             modsecurity_status:modsecurity_status, | 
					
						
							|  |  |  |                             SecAuditEngine:SecAuditEngine, | 
					
						
							|  |  |  |                             SecRuleEngine:SecRuleEngine, | 
					
						
							|  |  |  |                             SecDebugLogLevel:$scope.SecDebugLogLevel, | 
					
						
							|  |  |  |                             SecAuditLogParts:$scope.SecAuditLogParts, | 
					
						
							|  |  |  |                             SecAuditLogRelevantStatus:$scope.SecAuditLogRelevantStatus, | 
					
						
							|  |  |  |                             SecAuditLogType:$scope.SecAuditLogType, | 
					
						
							|  |  |  |                         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         var config = { | 
					
						
							|  |  |  |                             headers : { | 
					
						
							|  |  |  |                                 'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  |                             }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     if(response.data.saveStatus === 1){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.failedToSave = true; | 
					
						
							|  |  |  |                         $scope.successfullySaved = false; | 
					
						
							|  |  |  |                         $scope.modsecLoading = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     else{ | 
					
						
							|  |  |  |                         $scope.errorMessage = response.data.error_message; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.failedToSave = false; | 
					
						
							|  |  |  |                         $scope.successfullySaved = true; | 
					
						
							|  |  |  |                         $scope.modsecLoading = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  |                         $scope.failedToSave = true; | 
					
						
							|  |  |  |                         $scope.successfullySaved = false; | 
					
						
							|  |  |  |                         $scope.modsecLoading = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | app.controller('modSecRules', function($scope, $http) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $scope.modsecLoading = true; | 
					
						
							|  |  |  |            $scope.rulesSaved = true; | 
					
						
							|  |  |  |            $scope.couldNotConnect = true; | 
					
						
							|  |  |  |            $scope.couldNotSave = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            fetchModSecRules(); | 
					
						
							|  |  |  |            function fetchModSecRules(){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                $scope.modsecLoading = false; | 
					
						
							|  |  |  |                $scope.modsecLoading = true; | 
					
						
							|  |  |  |                $scope.rulesSaved = true; | 
					
						
							|  |  |  |                $scope.couldNotConnect = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                url = "/firewall/fetchModSecRules"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                var data = {}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                var config = { | 
					
						
							|  |  |  |                    headers : { | 
					
						
							|  |  |  |                        'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                    } | 
					
						
							|  |  |  |                }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     $scope.modsecLoading = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     if(response.data.modSecInstalled === 1){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.currentModSecRules = response.data.currentModSecRules; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  |                     $scope.modsecLoading = true; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $scope.saveModSecRules = function(){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                $scope.modsecLoading = false; | 
					
						
							|  |  |  |                $scope.rulesSaved = true; | 
					
						
							|  |  |  |                $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                $scope.couldNotSave = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                url = "/firewall/saveModSecRules"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                var data = { | 
					
						
							|  |  |  |                    modSecRules:$scope.currentModSecRules | 
					
						
							|  |  |  |                }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                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.rulesSaved = false; | 
					
						
							|  |  |  |                        $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                        $scope.couldNotSave = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     }else{ | 
					
						
							|  |  |  |                         $scope.rulesSaved = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                         $scope.couldNotSave = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.errorMessage = response.data.error_message; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  |                     $scope.modsecLoading = true; | 
					
						
							|  |  |  |                     $scope.rulesSaved = true; | 
					
						
							|  |  |  |                     $scope.couldNotConnect = false; | 
					
						
							|  |  |  |                     $scope.couldNotSave = true; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |            } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Java script code for ModSec */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | app.controller('modSecRulesPack', function($scope, $http, $timeout, $window) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $scope.modsecLoading = true; | 
					
						
							|  |  |  |            $scope.owaspDisable = true; | 
					
						
							|  |  |  |            $scope.comodoDisable = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            //
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $scope.installationQuote = true; | 
					
						
							|  |  |  |            $scope.couldNotConnect = true; | 
					
						
							|  |  |  |            $scope.installationFailed = true; | 
					
						
							|  |  |  |            $scope.installationSuccess = true; | 
					
						
							| 
									
										
										
										
											2018-04-05 00:31:16 +05:00
										 |  |  |            $scope.ruleFiles = true; | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 00:31:16 +05:00
										 |  |  |            /////
 | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  | 
 | 
					
						
							|  |  |  |            var owaspInstalled = false; | 
					
						
							|  |  |  |            var comodoInstalled = false; | 
					
						
							|  |  |  |            var counterOWASP = 0; | 
					
						
							|  |  |  |            var counterComodo = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $('#owaspInstalled').change(function() { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 00:31:16 +05:00
										 |  |  |                 owaspInstalled = $(this).prop('checked'); | 
					
						
							|  |  |  |                 $scope.ruleFiles = true; | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 00:31:16 +05:00
										 |  |  |                 if(counterOWASP !== 0) { | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  |                     if (owaspInstalled === true) { | 
					
						
							|  |  |  |                         installModSecRulesPack('installOWASP'); | 
					
						
							|  |  |  |                     } else { | 
					
						
							|  |  |  |                         installModSecRulesPack('disableOWASP') | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2018-04-05 00:31:16 +05:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 counterOWASP = counterOWASP + 1; | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  |            }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $('#comodoInstalled').change(function() { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 00:31:16 +05:00
										 |  |  |                $scope.ruleFiles = true; | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  |                comodoInstalled = $(this).prop('checked'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 00:31:16 +05:00
										 |  |  |                if(counterComodo !== 0) { | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  | 
 | 
					
						
							|  |  |  |                    if (comodoInstalled === true) { | 
					
						
							|  |  |  |                        installModSecRulesPack('installComodo'); | 
					
						
							|  |  |  |                    } else { | 
					
						
							|  |  |  |                        installModSecRulesPack('disableComodo') | 
					
						
							|  |  |  |                    } | 
					
						
							|  |  |  |                } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 00:31:16 +05:00
										 |  |  |                counterComodo = counterComodo + 1; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  |            }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 00:31:16 +05:00
										 |  |  |            getOWASPAndComodoStatus(true); | 
					
						
							|  |  |  |            function getOWASPAndComodoStatus(updateToggle){ | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  | 
 | 
					
						
							|  |  |  |                $scope.modsecLoading = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                url = "/firewall/getOWASPAndComodoStatus"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                var data = {}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                var config = { | 
					
						
							|  |  |  |                    headers : { | 
					
						
							|  |  |  |                        'X-CSRFToken': getCookie('csrftoken') | 
					
						
							|  |  |  |                    } | 
					
						
							|  |  |  |                }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 function ListInitialDatas(response) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     $scope.modsecLoading = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     if(response.data.modSecInstalled === 1){ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 00:31:16 +05:00
										 |  |  |                         if (updateToggle === true){ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  |                             if (response.data.owaspInstalled === 1) { | 
					
						
							|  |  |  |                                 $('#owaspInstalled').bootstrapToggle('on'); | 
					
						
							|  |  |  |                                 $scope.owaspDisable = false; | 
					
						
							| 
									
										
										
										
											2018-04-05 00:31:16 +05:00
										 |  |  |                             } else { | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  |                                 $('#owaspInstalled').bootstrapToggle('off'); | 
					
						
							|  |  |  |                                 $scope.owaspDisable = true; | 
					
						
							|  |  |  |                             } | 
					
						
							|  |  |  |                             if (response.data.comodoInstalled === 1) { | 
					
						
							|  |  |  |                                 $('#comodoInstalled').bootstrapToggle('on'); | 
					
						
							|  |  |  |                                 $scope.comodoDisable = false; | 
					
						
							| 
									
										
										
										
											2018-04-05 00:31:16 +05:00
										 |  |  |                             } else { | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  |                                 $('#comodoInstalled').bootstrapToggle('off'); | 
					
						
							|  |  |  |                                 $scope.comodoDisable = true; | 
					
						
							|  |  |  |                             } | 
					
						
							| 
									
										
										
										
											2018-04-05 00:31:16 +05:00
										 |  |  |                         }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; | 
					
						
							|  |  |  |                             } | 
					
						
							|  |  |  |                         } | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  | 
 | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 function cantLoadInitialDatas(response) { | 
					
						
							|  |  |  |                     $scope.modsecLoading = true; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            /////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            function installModSecRulesPack(packName) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                $scope.modsecLoading = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 url = "/firewall/installModSecRulesPack"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 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.installStatus === 1){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.modsecLoading = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         //
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         $scope.installationQuote = true; | 
					
						
							|  |  |  |                         $scope.couldNotConnect = true; | 
					
						
							|  |  |  |                         $scope.installationFailed = true; | 
					
						
							|  |  |  |                         $scope.installationSuccess = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 00:31:16 +05:00
										 |  |  |                         getOWASPAndComodoStatus(false); | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  | 
 | 
					
						
							|  |  |  |                     }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; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 00:31:16 +05:00
										 |  |  |            /////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            $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; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 02:17:12 +05:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-19 22:15:02 +05:00
										 |  |  | /* Java script code for ModSec */ |