def run(self, params={}): base = self.connection.base endpoint = "report" url = f"{base}/{endpoint}" params = { "ip": params.get(Input.IP), "categories": params.get(Input.CATEGORIES), "comment": params.get(Input.COMMENT), } r = requests.post(url, params=params, headers=self.connection.headers) try: json_ = helper.get_json(r) out = json_["data"] except json.decoder.JSONDecodeError: raise PluginException( cause="Received an unexpected response from AbuseIPDB.", assistance= f"(non-JSON or no response was received). Response was: {r.text}", ) if len(out) > 0: out[Output.SUCCESS] = True else: out[Output.SUCCESS] = False return out
def run(self, params={}): base = self.connection.base endpoint = "blacklist" url = f"{base}/{endpoint}" params = {"confidenceMinimum": params.get(Input.CONFIDENCEMINIMUM)} if params.get(Input.LIMIT): params["limit"] = params.get(Input.LIMIT) r = requests.get(url, params=params, headers=self.connection.headers) try: json_ = helper.get_json(r) blacklist = json_["data"] out = {Output.BLACKLIST: blacklist} except json.decoder.JSONDecodeError: raise PluginException( cause="Received an unexpected response from AbuseIPDB.", assistance= f"(non-JSON or no response was received). Response was: {r.text}", ) if len(out) > 0: out[Output.SUCCESS] = True else: out[Output.SUCCESS] = False return out
def run(self, params={}): base = self.connection.base endpoint = 'check' url = f'{base}/{endpoint}' params = { 'ipAddress': params.get(Input.ADDRESS), 'maxAgeInDays': params.get(Input.DAYS), 'verbose': params.get(Input.VERBOSE) } r = requests.get(url, params=params, headers=self.connection.headers) try: json_ = helper.get_json(r) out = self.transform_output(json_["data"]) except json.decoder.JSONDecodeError: raise PluginException(cause='Received an unexpected response from AbuseIPDB.', assistance=f"(non-JSON or no response was received). Response was: {r.text}") if len(out) > 0: out[Output.FOUND] = True else: out[Output.FOUND] = False return out
def run(self, params={}): base = self.connection.base endpoint = 'check-block' url = f'{base}/{endpoint}' params = { 'network': params.get(Input.CIDR), 'maxAgeInDays': params.get(Input.DAYS), } r = requests.get(url, params=params, headers=self.connection.headers) try: json_ = helper.get_json(r) out = json_["data"] except json.decoder.JSONDecodeError: raise PluginException( cause='Received an unexpected response from AbuseIPDB.', assistance= f"(non-JSON or no response was received). Response was: {r.text}" ) if len(out) > 0: out[Output.FOUND] = True else: out[Output.FOUND] = False return insightconnect_plugin_runtime.helper.clean(out)