Exemplo n.º 1
0
	def post(self,firewall,object):
		logger.debug('handler.rules_rename.get()')
		fw = Firewall(firewall=firewall).getConfig()
		if not fw:
			logger.error('Firewall not found.')
			return {'error' : 'Firewall not found.'}, 404
		if fw['brand'] == "paloalto":
			c = PaloAlto.objects_rename(firewall_config=fw)
			if not c.primary:
				logger.error("Could not get {0} active ip.".format(firewall))
				return {'error' : 'Could not get firewall active IP.'}, 502
			else:
				logger.info("{0} active ip {1}".format(firewall, c.primary))
				if 'oldname' not in request.json or 'newname' not in request.json:
					logger.warning("'oldname' or 'newname' not in request.")
					return {'error' : "'oldname' or 'newname' not in request."}, 400
				elif option not in ['address', 'service', 'address-group', 'service-group']:
					logger.warning("{0} not found".format(option))
					return {'error' : "URL not found."}, 404
				else:
					return c.get(object,request.json['oldname'],request.json['newname'])
		elif fw['brand'] == "juniper":
			c = Juniper.configuration(firewall)
			return c.get()
		elif fw['brand'] == "cisco":
			return Cisco.configuration(firewall)
		elif fw['brand'] == "checkpoint":
			return Checkpoint.configuration(firewall)
		elif fw['brand'] == "fortinet":
			return Fortinet.configuration(firewall)
		elif fw['brand'] == "pfsense":
			return PfSense.configuration(firewall)
		else:
			logger.error("{0}: Firewall brand not found.".format(request.remote_addr))
			return {'error' : 'URL not found.'}, 404
Exemplo n.º 2
0
	def get(self,firewall):
		logger.debug('handler.config.get()')
		fw = Firewall(firewall=firewall).getConfig()
		if not fw:
			logger.error('Firewall not found.')
			return {'error' : 'Firewall not found.'}, 404
		if fw['brand'] == "paloalto":
			c = PaloAlto.interfaces(firewall_config=fw)
			if not c.primary:
				logger.error("Could not get {0} active ip.".format(firewall))
				return {'error' : 'Could not get firewall active IP.'}, 504
			else:
				logger.info("{0} active ip {1}".format(firewall, c.primary))
				return c.get(request.args)
		elif fw['brand'] == "juniper":
			c = Juniper.configuration(firewall_config=fw)
			return c.get()
		elif fw['brand'] == "cisco":
			return Cisco.configuration(firewall)
		elif fw['brand'] == "checkpoint":
			return Checkpoint.configuration(firewall)
		elif fw['brand'] == "fortinet":
			return Fortinet.configuration(firewall)
		elif fw['brand'] == "pfsense":
			return PfSense.configuration(firewall)
		else:
			logger.error("{0}: Firewall brand not found.".format(request.remote_addr))
			return {'error' : 'URL not found.'}, 404
Exemplo n.º 3
0
	def delete(self,firewall,object):
		logger.debug('handler.objects.delete()')
		fw = Firewall(firewall=firewall).getConfig()
		if not fw:
			logger.error('Firewall not found.')
			return {'error' : 'Firewall not found.'}, 404
		if fw['brand'] == "paloalto":
			c = PaloAlto.objects(firewall_config=fw)
			if not c.primary:
				logger.error("Could not get {0} active ip.".format(firewall))
				return {'error' : 'Could not get firewall active IP.'}, 502
			else:
				logger.info("{0} active ip {1}".format(firewall, c.primary))
				if 'name' not in request.args:
					logger.warning("No rule name given.")
					return {'error' : 'No rule name given.'}, 400
				else:
					return c.delete(request.args['name'],object)
		elif fw['brand'] == "juniper":
			c = Juniper.configuration(firewall)
			return c.get()
		elif fw['brand'] == "cisco":
			return Cisco.configuration(firewall)
		elif fw['brand'] == "checkpoint":
			return Checkpoint.configuration(firewall)
		elif fw['brand'] == "fortinet":
			return Fortinet.configuration(firewall)
		elif fw['brand'] == "pfsense":
			return PfSense.configuration(firewall)
		else:
			logger.error("{0}: Firewall brand not found.".format(request.remote_addr))
			return {'error' : 'URL not found.'}, 404
Exemplo n.º 4
0
	def put(self,firewall,object):
		logger.debug('handler.objects.put()')
		fw = Firewall(firewall=firewall).getConfig()
		if not fw:
			logger.error('Firewall not found.')
			return {'error' : 'Firewall not found.'}, 404
		if fw['brand'] == "paloalto":
			c = PaloAlto.objects(firewall_config=fw)
			if not c.primary:
				logger.error("Could not get {0} active ip.".format(firewall))
				return {'error' : 'Could not get firewall active IP.'}, 502
			else:
				logger.info("{0} active ip {1}".format(firewall, c.primary))
				if not request.json:
					return {'error' : 'Content type needs to be application/json.'}, 400
				else:
					return c.put(request.json,object)
		elif fw['brand'] == "juniper":
			c = Juniper.configuration(firewall)
			return c.get()
		elif fw['brand'] == "cisco":
			return Cisco.configuration(firewall)
		elif fw['brand'] == "checkpoint":
			return Checkpoint.configuration(firewall)
		elif fw['brand'] == "fortinet":
			return Fortinet.configuration(firewall)
		elif fw['brand'] == "pfsense":
			return PfSense.configuration(firewall)
		else:
			logger.error("{0}: Firewall brand not found.".format(request.remote_addr))
			return {'error' : 'URL not found.'}, 404
Exemplo n.º 5
0
	def post(self,firewall):
		logger.debug('handler.rules_move.post()')
		fw = Firewall(firewall=firewall).getConfig()
		if not fw:
			logger.error('Firewall not found.')
			return {'error' : 'Firewall not found.'}, 404
		if fw['brand'] == "paloalto":
			c = PaloAlto.rules_move(firewall_config=fw)
			if not c.primary:
				logger.error("Could not get {0} active ip.".format(firewall))
				return {'error' : 'Could not get firewall active IP.'}, 502
			else:
				logger.info("{0} active ip {1}".format(firewall, c.primary))
				if 'where' in request.json.keys() and 'rule1' in request.json.keys() and 'rule2' in request.json.keys():
					return c.post(request.json['where'],request.json['rule1'],request.json['rule2'])
				elif 'where' in request.json.keys() and 'rule1' in request.json.keys():
					return c.post(request.json['where'],request.json['rule1'])
				else:
					logger.warning("No 'where' or 'rule1' in request.")
					return {'error' : "No 'where' or 'rule1' in request."}, 400
		elif fw['brand'] == "juniper":
			c = Juniper.configuration(firewall)
			return c.get()
		elif fw['brand'] == "cisco":
			return Cisco.configuration(firewall)
		elif fw['brand'] == "checkpoint":
			return Checkpoint.configuration(firewall)
		elif fw['brand'] == "fortinet":
			return Fortinet.configuration(firewall)
		elif fw['brand'] == "pfsense":
			return PfSense.configuration(firewall)
		else:
			logger.error("{0}: Firewall brand not found.".format(request.remote_addr))
			return {'error' : 'URL not found.'}, 404
Exemplo n.º 6
0
 def patch(self, firewall):
     logger.debug('handler.config.patch()')
     fw = Firewall(firewall=firewall).getConfig()
     if not fw:
         logger.error('Firewall not found.')
         return {'error': 'Firewall not found.'}, 404
     if fw['brand'] == "paloalto":
         c = PaloAlto.rules(firewall_config=fw)
         if not c.primary:
             logger.error("Could not get {0} active ip.".format(firewall))
             return {'error': 'Could not get firewall active IP.'}, 502
         else:
             logger.info("{0} active ip {1}".format(firewall, c.primary))
             if not request.json:
                 return {
                     'error': 'Content type needs to be application/json.'
                 }, 400
             elif 'name' not in request.args:
                 return {'error': 'No rule name supplied.'}, 400
             else:
                 return c.patch(request.args['name'], request.json)
     elif fw['brand'] == "juniper":
         c = Juniper.rules(firewall_config=fw)
         if not c.primary:
             logger.error("Could not get {0} active ip.".format(firewall))
             return {'error': 'Could not get firewall active IP.'}, 502
         else:
             logger.info("{0} active ip {1}".format(firewall, c.primary))
             if not request.json:
                 return {
                     'error': 'Content type needs to be application/json.'
                 }, 400
             elif 'name' not in request.json:
                 return {'error': 'No rule name supplied.'}, 400
             else:
                 return c.patch(request.json['name'],
                                request.json,
                                comment=request.args['comment'])
     elif fw['brand'] == "cisco":
         return Cisco.configuration(firewall)
     elif fw['brand'] == "aws":
         return Cisco.configuration(firewall)
     elif fw['brand'] == "checkpoint":
         return Checkpoint.configuration(firewall)
     elif fw['brand'] == "fortinet":
         return Fortinet.configuration(firewall)
     elif fw['brand'] == "pfsense":
         return PfSense.configuration(firewall)
     else:
         #That Firewall Brand does not exists.
         logger.error("{0}: Firewall brand not found.".format(
             request.remote_addr))
         return {'error': 'URL not found.'}, 404
Exemplo n.º 7
0
	def get(self,brand,firewall):
		logger.debug('handler.route.get()')
		fw = Firewall(firewall=firewall).getConfig()
		if not fw:
			logger.error('Firewall not found.')
			return {'error' : 'Firewall not found.'}, 404
		c = Juniper.hitcount(firewall_config=fw)
		if not c.primary:
			logger.error("Could not get {0} active ip.".format(firewall))
			return {'error' : 'Could not get firewall active IP.'}, 504
		else:
			logger.info("{0} active ip {1}".format(firewall, c.primary))
			return c.get()
Exemplo n.º 8
0
 def post(self, firewall):
     logger.debug('handler.commit.post()')
     fw = Firewall(firewall=firewall).getConfig()
     if not fw:
         logger.error('Firewall not found.')
         return {'error': 'Firewall not found.'}, 404
     if fw['brand'] == "paloalto":
         c = PaloAlto.commit(firewall_config=fw)
         if not c.primary:
             logger.error("Could not get {0} active ip.".format(firewall))
             return {'error': 'Could not get firewall active IP.'}, 502
         else:
             logger.info("{0} active ip {1}".format(firewall, c.primary))
             return c.post()
     elif fw['brand'] == "juniper":
         c = Juniper.commit(firewall_config=fw)
         if not c.primary:
             logger.error("Could not get {0} active ip.".format(firewall))
             return {'error': 'Could not get firewall active IP.'}, 502
         else:
             logger.info("{0} active ip {1}".format(firewall, c.primary))
             return c.post(comment=request.json['comment'])
     elif fw['brand'] == "cisco":
         return Cisco.configuration(firewall)
     elif fw['brand'] == "aws":
         return Cisco.configuration(firewall)
     elif fw['brand'] == "checkpoint":
         return Checkpoint.configuration(firewall)
     elif fw['brand'] == "fortinet":
         return Fortinet.configuration(firewall)
     elif fw['brand'] == "pfsense":
         return PfSense.configuration(firewall)
     else:
         #That Firewall Brand does not exists.
         logger.error("{0}: Firewall brand not found.".format(
             request.remote_addr))
         return {'error': 'URL not found.'}, 404