def __init__(self, cb, bridge_options): try: Action.__init__(self, cb) # TODO -- maybe a ThreadedAction class? threading.Thread.__init__(self) self.flask_feed = FlaskFeed(__name__) self.bridge_options = bridge_options self.data_dir = "/usr/share/cb/integrations/infoblox" self.sync_needed = False self.feed_name = "infoblox" self.display_name = "Infoblox" self.feed = {} self.feed_domains = defaultdict(dict) self.feed_lock = threading.Lock() self.directory = self.data_dir self.cb_image_path = "/carbonblack.png" self.integration_image_path = "/infoblox.png" self.json_feed_path = "/infoblox/json" self.flask_feed.app.add_url_rule( self.cb_image_path, view_func=self.handle_cb_image_request) self.flask_feed.app.add_url_rule( self.integration_image_path, view_func=self.handle_integration_image_request) self.flask_feed.app.add_url_rule( self.json_feed_path, view_func=self.handle_json_feed_request, methods=['GET']) self.flask_feed.app.add_url_rule( "/", view_func=self.handle_index_request, methods=['GET']) self.flask_feed.app.add_url_rule( "/feed.html", view_func=self.handle_html_feed_request, methods=['GET']) except: logger.error('%s' % traceback.format_exc())
def __init__(self, name, configfile, logfile=None, pidfile=None, debug=False, dbfile=None): CbIntegrationDaemon.__init__(self, name, configfile=configfile, logfile=logfile, pidfile=pidfile, debug=debug) template_folder = "/usr/share/cb/integrations/threatexchange/content" self.db_file = dbfile or "/usr/share/cb/integrations/threatexchange/db/threatexchange.db" self.flask_feed = FlaskFeed(__name__, False, template_folder) self.bridge_options = {} self.bridge_auth = {} if 'bridge' in self.options: self.debug = self.options['bridge'].get("debug", 0) if self.debug: self.logger.setLevel(logging.DEBUG) self.validated_config = self.validate_config() self.cb = None self.feed_name = "threatexchangeconnector" self.display_name = "ThreatExchange" self.directory = template_folder self.cb_image_path = "/carbonblack.png" self.integration_image_path = "/threatexchange.png" self.integration_small_image_path = "/threatexchange-small.png" self.json_feed_path = "/threatexchange/json" self.feed_lock = threading.RLock() self.flask_feed.app.add_url_rule(self.cb_image_path, view_func=self.handle_cb_image_request) self.flask_feed.app.add_url_rule(self.integration_image_path, view_func=self.handle_integration_image_request) self.flask_feed.app.add_url_rule(self.json_feed_path, view_func=self.handle_json_feed_request, methods=['GET']) self.flask_feed.app.add_url_rule("/", view_func=self.handle_index_request, methods=['GET']) self.flask_feed.app.add_url_rule("/feed.html", view_func=self.handle_html_feed_request, methods=['GET']) self.logger.debug("generating feed metadata") with self.feed_lock: self.feed = self.create_feed() self.last_sync = "No sync performed" self.last_successful_sync = "No sync performed"