Beispiel #1
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
Beispiel #2
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