示例#1
0
    def __init__(self, base_url, username, password, public_key, private_key,
                 days_back_to_retrieve, save_responses_directory):
        """
        TODO
        """
        if not base_url or \
            not username or \
            not password or \
            not public_key or \
            not private_key or \
            not days_back_to_retrieve:
            raise ImporterDisabled(
                "iSightRemoteImporter missing required field(s)")

        self.api = ISightAPI(base_url, username, password, public_key,
                             private_key)
        self.days_back_to_retrieve = days_back_to_retrieve
        self.save_responses_directory = save_responses_directory
示例#2
0
class iSightRemoteImporter(object):
    """
    Basic API for downloading IOCs and Reports from iSight Partners
    """
    def __init__(self, base_url, username, password, public_key, private_key,
                 days_back_to_retrieve, save_responses_directory):
        """
        TODO
        """
        if not base_url or \
            not username or \
            not password or \
            not public_key or \
            not private_key or \
            not days_back_to_retrieve:
            raise ImporterDisabled(
                "iSightRemoteImporter missing required field(s)")

        self.api = ISightAPI(base_url, username, password, public_key,
                             private_key)
        self.days_back_to_retrieve = days_back_to_retrieve
        self.save_responses_directory = save_responses_directory

    def get_csv_data(self):
        """
        Uses the iSight API Class to download the file, optionally save the response,
        and return the data.
        """
        rawcsv = self.api.get_i_and_w(self.days_back_to_retrieve)
        if len(rawcsv) > 0:
            if self.save_responses_directory and os.path.exists(
                    self.save_responses_directory):
                try:
                    filename = "isight-remote-api-%s.csv" % time.strftime(
                        '%Y-%m-%d-%H_%M_%S', time.gmtime(time.time()))
                    file(os.path.join(self.save_responses_directory, filename),
                         'wb').write(rawcsv)
                except:
                    _logger.exception("Trying to save response!")
            return [rawcsv]
        else:
            _logger.error("Received blank response!")
            return []

    def on_processing_done(self):
        """
        Nothing to see here.
        """
        return
示例#3
0
文件: importer.py 项目: Mr19/cbfeeds
    def __init__(self, base_url, username, password, public_key, private_key, days_back_to_retrieve, save_responses_directory):
        """
        TODO
        """
        if not base_url or \
            not username or \
            not password or \
            not public_key or \
            not private_key or \
            not days_back_to_retrieve:
            raise ImporterDisabled("iSightRemoteImporter missing required field(s)")

        self.api = ISightAPI(base_url, username, password, public_key, private_key)
        self.days_back_to_retrieve = days_back_to_retrieve
        self.save_responses_directory = save_responses_directory
示例#4
0
文件: importer.py 项目: Mr19/cbfeeds
class iSightRemoteImporter(object):
    """
    Basic API for downloading IOCs and Reports from iSight Partners
    """
    def __init__(self, base_url, username, password, public_key, private_key, days_back_to_retrieve, save_responses_directory):
        """
        TODO
        """
        if not base_url or \
            not username or \
            not password or \
            not public_key or \
            not private_key or \
            not days_back_to_retrieve:
            raise ImporterDisabled("iSightRemoteImporter missing required field(s)")

        self.api = ISightAPI(base_url, username, password, public_key, private_key)
        self.days_back_to_retrieve = days_back_to_retrieve
        self.save_responses_directory = save_responses_directory

    def get_csv_data(self):
        """
        Uses the iSight API Class to download the file, optionally save the response,
        and return the data.
        """
        rawcsv = self.api.get_i_and_w(self.days_back_to_retrieve)
        if len(rawcsv) > 0:
            if self.save_responses_directory and os.path.exists(self.save_responses_directory):
                try:
                    filename = "isight-remote-api-%s.csv" % time.strftime('%Y-%m-%d-%H_%M_%S', time.gmtime(time.time()))
                    file(os.path.join(self.save_responses_directory, filename), 'wb').write(rawcsv)
                except:
                    _logger.exception("Trying to save response!")
            return [rawcsv]
        else:
            _logger.error("Received blank response!")
            return []

    def on_processing_done(self):
        """
        Nothing to see here.
        """
        return