async def fetch_cofense_indicators_and_ingest_malware_data(self):
        """Get Malware Ids from Cofense Indicators, Fetch Malware Data and Post to Sentinel."""
        __method_name = inspect.currentframe().f_code.co_name
        try:
            get_indicator_url = "{}{}".format(
                consts.COFENSE_BASE_URL, consts.ENDPOINTS["search_indicators"]
            )
            params = {"resultsPerPage": consts.COFENSE_PAGE_SIZE}
            checkpoint_since_last_published = self.get_checkpoint_data(
                "malware_sinceLastPublished"
            )
            checkpoint_page = self.get_checkpoint_data("malware_page")
            if checkpoint_since_last_published:
                applogger.info(
                    "{}(method={}) : {} : SincelastPublished Checkpoint found : {}.".format(
                        consts.LOGS_STARTS_WITH,
                        __method_name,
                        consts.COFENSE_MALWARE_DATA_TO_LOG_ANALYTICS,
                        checkpoint_since_last_published,
                    )
                )
                params["sinceLastPublished"] = checkpoint_since_last_published
            else:
                applogger.info(
                    "{}(method={}) : {} : SincelastPublished Checkpoint not found,\
                        Fetching data of last 15 days.".format(
                        consts.LOGS_STARTS_WITH,
                        __method_name,
                        consts.COFENSE_MALWARE_DATA_TO_LOG_ANALYTICS,
                    )
                )
                now = datetime.now(timezone.utc)
                midnight = now.replace(hour=0, minute=0, second=0, microsecond=0)
                params["sinceLastPublished"] = (
                    int(midnight.timestamp()) - consts.FIFTEEN_DAYS
                )
                applogger.info(
                    "{}(method={}) : {} : Updating Initial SincelastPublished Checkpoint {}.".format(
                        consts.LOGS_STARTS_WITH,
                        __method_name,
                        consts.COFENSE_MALWARE_DATA_TO_LOG_ANALYTICS,
                        params["sinceLastPublished"],
                    )
                )
                self.post_data_to_checkpoint(
                    "malware_sinceLastPublished", params["sinceLastPublished"]
                )
            if checkpoint_page is not None:
                applogger.info(
                    "{}(method={}) : {} : Page Checkpoint found : {}.".format(
                        consts.LOGS_STARTS_WITH,
                        __method_name,
                        consts.COFENSE_MALWARE_DATA_TO_LOG_ANALYTICS,
                        checkpoint_page,
                    )
                )
                params["page"] = checkpoint_page
            while True:
                indicators_data = self.get_cofense_data(
                    url=get_indicator_url,
                    params=params,
                    endpoint_name="get indicators",
                    proxies=self.proxy,
                )
                applogger.info(
                    "{}(method={}) : {} : Indicators fetched successfully.".format(
                        consts.LOGS_STARTS_WITH,
                        __method_name,
                        consts.COFENSE_MALWARE_DATA_TO_LOG_ANALYTICS,
                    )
                )
                if len(indicators_data.get("data", {}).get("indicators", [])) == 0:
                    applogger.info(
                        "{}(method={}) : {} : No indicators found.".format(
                            consts.LOGS_STARTS_WITH,
                            __method_name,
                            consts.COFENSE_MALWARE_DATA_TO_LOG_ANALYTICS,
                        )
                    )
                    break
                await self.fetch_malware_data_and_ingest_to_log_analytics(
                    indicators_data
                )
                next_page = (
                    indicators_data.get("data", {})
                    .get("page", {})
                    .get("currentPage", 0)
                    + 1
                )
                if next_page == indicators_data.get("data", {}).get("page", {}).get(
                    "totalPages", 0
                ):
                    break
                params["page"] = next_page
                applogger.info(
                    "{}(method={}) : {} : Updating page checkpoint : {}.".format(
                        consts.LOGS_STARTS_WITH,
                        __method_name,
                        consts.COFENSE_MALWARE_DATA_TO_LOG_ANALYTICS,
                        next_page,
                    )
                )
                self.post_data_to_checkpoint("malware_page", next_page)
            self.post_data_to_checkpoint("malware_sinceLastPublished", int(time.time()))
            self.post_data_to_checkpoint("malware_page", 0)
            applogger.info(
                "{}(method={}) : {} : Updated page and LastPublished checkpoint Successfully.".format(
                    consts.LOGS_STARTS_WITH,
                    __method_name,
                    consts.COFENSE_MALWARE_DATA_TO_LOG_ANALYTICS,
                )
            )
        except CofenseIntelligenceException:
            raise CofenseIntelligenceException()
        except Exception as error:
            applogger.error(
                "{}(method={}) : {} : error occured : {}.".format(
                    consts.LOGS_STARTS_WITH,
                    __method_name,
                    consts.COFENSE_MALWARE_DATA_TO_LOG_ANALYTICS,
                    error,
                )
            )
            raise CofenseIntelligenceException()
Get Malware Ids from Cofense Indicators, Fetch Malware Data and Post to Sentinel.
Solutions/CofenseIntelligence/Data Connectors/CofenseIntelligenceDataConnector/CofenseIntelligenceMalware/cofense_malware_data_to_sentinel.py