elkserver/docker/redelk-base/redelkinstalldata/scripts/modules/alarm_filehash/ioc_vt.py [27:63]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    def get_remaining_quota(self):
        """Returns the number of hashes that could be queried within this run"""
        url = f"https://www.virustotal.com/api/v3/users/{self.api_key}/overall_quotas"
        headers = {"Accept": "application/json", "x-apikey": self.api_key}

        # Get the quotas, if response code != 200, return 0 so we don't query further
        response = requests.get(url, headers=headers)
        if response.status_code == 200:
            json_response = response.json()
        else:
            self.logger.warning(
                "Error retrieving VT Quota (HTTP Status code: %d)", response.status_code
            )
            return 0

        # Extract the hourly, daily and monthly remaining quotas
        remaining_hourly = get_value(
            "data.api_requests_hourly.user.allowed", json_response, 0
        ) - get_value("data.api_requests_hourly.user.used", json_response, 0)
        remaining_daily = get_value(
            "data.api_requests_daily.user.allowed", json_response, 0
        ) - get_value("data.api_requests_daily.user.used", json_response, 0)
        remaining_monthly = get_value(
            "data.api_requests_monthly.user.allowed", json_response, 0
        ) - get_value("data.api_requests_monthly.user.used", json_response, 0)

        self.logger.debug(
            "Remaining quotas: hourly(%d) / daily(%d) / monthly(%d)",
            remaining_hourly,
            remaining_daily,
            remaining_monthly,
        )

        # Get the smallest one and return it
        remaining_min = min(remaining_hourly, remaining_daily, remaining_monthly)

        return remaining_min
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



elkserver/docker/redelk-base/redelkinstalldata/scripts/modules/enrich_domainscategorization/cat_vt.py [94:130]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    def get_remaining_quota(self):
        """Returns the number of hashes that could be queried within this run"""
        url = f"https://www.virustotal.com/api/v3/users/{self.api_key}/overall_quotas"
        headers = {"Accept": "application/json", "x-apikey": self.api_key}

        # Get the quotas, if response code != 200, return 0 so we don't query further
        response = requests.get(url, headers=headers)
        if response.status_code == 200:
            json_response = response.json()
        else:
            self.logger.warning(
                "Error retrieving VT Quota (HTTP Status code: %d)", response.status_code
            )
            return 0

        # Extract the hourly, daily and monthly remaining quotas
        remaining_hourly = get_value(
            "data.api_requests_hourly.user.allowed", json_response, 0
        ) - get_value("data.api_requests_hourly.user.used", json_response, 0)
        remaining_daily = get_value(
            "data.api_requests_daily.user.allowed", json_response, 0
        ) - get_value("data.api_requests_daily.user.used", json_response, 0)
        remaining_monthly = get_value(
            "data.api_requests_monthly.user.allowed", json_response, 0
        ) - get_value("data.api_requests_monthly.user.used", json_response, 0)

        self.logger.debug(
            "Remaining quotas: hourly(%d) / daily(%d) / monthly(%d)",
            remaining_hourly,
            remaining_daily,
            remaining_monthly,
        )

        # Get the smallest one and return it
        remaining_min = min(remaining_hourly, remaining_daily, remaining_monthly)

        return remaining_min
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



