def get(self,firewall,gateway): logger.debug('handler.gp_gateway_users.get()') fw = Firewall(firewall=firewall).getConfig() if not fw: logger.error('Firewall not found.') return {'error' : 'Firewall not found.'}, 404 c = PaloAlto.gp_gateway_users(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.get(gateway)
def delete(self,firewall,option,admin): logger.debug('handler.lock_admin.delete()') fw = Firewall(firewall=firewall).getConfig() if not fw: logger.error('Firewall not found.') return {'error' : 'Firewall not found.'}, 404 c = PaloAlto.lock(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.delete(option,admin)
def post(self, firewall): logger.debug('handler.config.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(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.post(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 else: return c.post(data=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
def get(self, 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 if fw['brand'] == "paloalto": c = PaloAlto.route(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": if 'ip' in request.args: c = Juniper.route_ip(firewall_config=fw) else: c = Juniper.route(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)) if 'ip' in request.args: return c.get(request.args['ip']) else: return c.get() 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
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
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