Exemple #1
0
    def del_alert(self, id_alert):
        """Call API Onyphe https://www.onyphe.io/api/v2/alert/del

        :param id_alert: id of alert to delete
        :type id_alert: str
        :return: dict -- a dictionary with result
        """
        if id_alert:
            return self._prepare_request("/".join(
                [self.version, "alert/del", id_alert]),
                                         method="post")
        else:
            raise ParamError("Parameter Invalid")
Exemple #2
0
    def add_alert(self, query, name, email):
        """Call API Onyphe https://www.onyphe.io/api/v2/alert/add
         :param query: query language onyphe
         :type query: str
         :param name: name of alert
         :type name: str
         :param email: email to receive alerts
         :type email: str
        :return: dict -- a dictionary with result
        """
        if query and name and email:
            data = {"query": query, "name": name, "email": email}

            return self._prepare_request("/".join([self.version, "alert/add"]),
                                         method="post",
                                         json_data=data)
        else:
            raise ParamError("Parameters Invalid")
Exemple #3
0
    def bulk_simple_whois_ip(self, path):
        """Call API Onyphe https://www.onyphe.io/api/v2/bulk/simple/whois/ip

        :param path: path of the files with IPs
        :type path:str
        :return: dict -- a dictionary with result
        """
        if os.path.isfile(path):

            file_iocs = open(path, "rb")
            for line in self._prepare_request(
                    "/".join([self.version, "bulk/simple/whois/ip"]),
                    method="post",
                    files=file_iocs,
            ).iter_lines():
                yield json.loads(line.decode("utf-8"))

        else:
            raise ParamError("%s is no a file" % path)