From 7d8239d7803519d0bc6724f535d8c584a526be5c Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Thu, 14 Aug 2025 23:26:22 +0530 Subject: [PATCH 01/26] replaced type by isinstance in intelmqdump.py --- intelmq/bin/intelmqdump.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intelmq/bin/intelmqdump.py b/intelmq/bin/intelmqdump.py index eb254d166d..ecdc7b1b15 100644 --- a/intelmq/bin/intelmqdump.py +++ b/intelmq/bin/intelmqdump.py @@ -131,7 +131,7 @@ def save_file(handle, content): def load_meta(dump): retval = [] for key, value in dump.items(): - if type(value['traceback']) is not list: + if not isinstance(value['traceback'], list): error = value['traceback'].splitlines()[-1] else: error = value['traceback'][-1].strip() @@ -410,7 +410,7 @@ def main(argv=None): len(value['message']['raw']) > args.truncate): value['message']['raw'] = value['message'][ 'raw'][:args.truncate] + '...[truncated]' - if type(value['traceback']) is not list: + if not isinstance(value['traceback'], list): value['traceback'] = value['traceback'].splitlines() pprint.pprint(value) elif answer[0] == 'e': From 6f178e0bf53de7c01e94349373fff34765f5b60a Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Thu, 14 Aug 2025 23:30:46 +0530 Subject: [PATCH 02/26] replaced type to isinstance in intelmqctl.py --- intelmq/bin/intelmqctl.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/intelmq/bin/intelmqctl.py b/intelmq/bin/intelmqctl.py index 91a0ec9420..048766121d 100644 --- a/intelmq/bin/intelmqctl.py +++ b/intelmq/bin/intelmqctl.py @@ -799,7 +799,7 @@ def read_bot_log(self, bot_id, log_level, number_of_lines): if self._parameters.logging_handler == 'syslog': log_message = utils.parse_logline(line, regex=utils.SYSLOG_REGEX) - if type(log_message) is not dict: + if not isinstance(log_message, dict): if self._parameters.logging_handler == 'file': message_overflow = '\n'.join([line, message_overflow]) continue @@ -1084,7 +1084,7 @@ def upgrade_conf(self, previous=None, dry_run=None, function=None, result['traceback'] = traceback.format_exc() result['success'] = False else: - if type(retval) is str: + if isinstance(retval, str): self._logger.error('Upgrade %r failed: %s', function, retval) result['message'] = retval result['success'] = False @@ -1176,7 +1176,7 @@ def upgrade_conf(self, previous=None, dry_run=None, function=None, result['traceback'] = traceback.format_exc() result['success'] = False else: - if type(retval) is str: + if isinstance(retval, str): self._logger.error('%s: Upgrade failed: %s', docstring, retval) result['message'] = retval result['success'] = False From 6af9ee510f28b6ae2bc86490e2b8ea90fa247e6b Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Thu, 14 Aug 2025 23:34:30 +0530 Subject: [PATCH 03/26] replaced type with isinstance in expert.py --- intelmq/bots/experts/filter/expert.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/intelmq/bots/experts/filter/expert.py b/intelmq/bots/experts/filter/expert.py index d42f6721a3..9f988aae8f 100644 --- a/intelmq/bots/experts/filter/expert.py +++ b/intelmq/bots/experts/filter/expert.py @@ -82,21 +82,21 @@ def process(self): except ValueError: self.logger.error("Could not parse time.source %s.", event.get('time.source')) else: - if type(self.not_after) is datetime and event_time > self.not_after: + if isinstance(self.not_after, datetime) and event_time > self.not_after: self.acknowledge_message() self.logger.debug("Filtered out event with time.source %s.", event.get('time.source')) return - if type(self.not_before) is datetime and event_time < self.not_before: + if isinstance(self,not_before, datetime) and event_time < self.not_before: self.acknowledge_message() self.logger.debug("Filtered out event with time.source %r.", event.get('time.source')) return now = datetime.now(tz=timezone.utc) - if type(self.not_after) is timedelta and event_time > (now - self.not_after): + if isinstance(self.not_after, timedelta and event_time > (now - self.not_after): self.acknowledge_message() self.logger.debug("Filtered out event with time.source %r.", event.get('time.source')) return - if type(self.not_before) is timedelta and event_time < (now - self.not_before): + if isinstance(self.not_before, timedelta) and event_time < (now - self.not_before): self.acknowledge_message() self.logger.debug("Filtered out event with time.source %r.", event.get('time.source')) return From 1c276ed16934db3dad75952b92242b4cd974136f Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Thu, 14 Aug 2025 23:35:50 +0530 Subject: [PATCH 04/26] replaced type with isinstance in expert.py --- intelmq/bots/experts/format_field/expert.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intelmq/bots/experts/format_field/expert.py b/intelmq/bots/experts/format_field/expert.py index bc2a6a8b11..55198076b7 100644 --- a/intelmq/bots/experts/format_field/expert.py +++ b/intelmq/bots/experts/format_field/expert.py @@ -18,7 +18,7 @@ class FormatFieldExpertBot(ExpertBot): split_column = None def init(self): - if type(self.strip_columns) is str: + if isinstance(self.strip_columns, str): self.strip_columns = [column.strip() for column in self.strip_columns.split(",")] def process(self): From cf3add785acfb70f1f0488009b84709328696a23 Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Thu, 14 Aug 2025 23:39:07 +0530 Subject: [PATCH 05/26] replaced type with isinstance in expert.py --- intelmq/bots/experts/rdap/expert.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/intelmq/bots/experts/rdap/expert.py b/intelmq/bots/experts/rdap/expert.py index a786b87f8e..89d8f1953a 100644 --- a/intelmq/bots/experts/rdap/expert.py +++ b/intelmq/bots/experts/rdap/expert.py @@ -47,14 +47,15 @@ def init(self): # get bootstrapped servers for service in self.rdap_bootstrapped_servers: if type(self.rdap_bootstrapped_servers[service]) is str: + if isinstance(self.rdap_bootstrapped_servers[service], str): self.__rdap_directory[service] = {"url": self.rdap_bootstrapped_servers[service]} - elif type(self.rdap_bootstrapped_servers) is dict: + elif isinstance(self.rdap_bootstrapped_servers, dict): self.__rdap_directory[service] = self.rdap_bootstrapped_servers[service] def parse_entities(self, vcardArray) -> list: vcard = [] for vcardentry in vcardArray: - if type(vcardentry) is str: + if isinstance(vcardentry, str): continue for vcarddata in vcardentry: From 9cab0883949bc4408d4429a935d28086bb446c61 Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Thu, 14 Aug 2025 23:41:52 +0530 Subject: [PATCH 06/26] replaced type with isinstance in parser_csv.py --- intelmq/bots/parsers/generic/parser_csv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intelmq/bots/parsers/generic/parser_csv.py b/intelmq/bots/parsers/generic/parser_csv.py index c77cee1e61..e3bfa65939 100644 --- a/intelmq/bots/parsers/generic/parser_csv.py +++ b/intelmq/bots/parsers/generic/parser_csv.py @@ -50,7 +50,7 @@ class GenericCsvParserBot(ParserBot): def init(self): # convert columns to an array - if type(self.columns) is str: + if isinstance(self.columns, str): self.columns = [column.strip() for column in self.columns.split(",")] if self.type_translation and isinstance(self.type_translation, str): # not-empty string From 7a430505a6c0cf19180115d79d64004488bff3bb Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Thu, 14 Aug 2025 23:43:37 +0530 Subject: [PATCH 07/26] replaced type with isinstance in parser.py --- intelmq/bots/parsers/html_table/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intelmq/bots/parsers/html_table/parser.py b/intelmq/bots/parsers/html_table/parser.py index cfb7e39819..fcac998cb1 100644 --- a/intelmq/bots/parsers/html_table/parser.py +++ b/intelmq/bots/parsers/html_table/parser.py @@ -55,11 +55,11 @@ def init(self): raise MissingDependencyError("beautifulsoup4") # convert columns to an array - if type(self.columns) is str: + if isinstance(self.columns, str): self.columns = [column.strip() for column in self.columns.split(",")] if self.ignore_values is None: self.ignore_values = len(self.columns) * [''] - if type(self.ignore_values) is str: + if isinstance(self.ignore_values, str): self.ignore_values = [value.strip() for value in self.ignore_values.split(",")] if len(self.columns) != len(self.ignore_values): From fa3e58cf15cffa92baf3905484aee5573b47f9bd Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Thu, 14 Aug 2025 23:45:33 +0530 Subject: [PATCH 08/26] replaced type with isinstance in harmonization.py --- intelmq/lib/harmonization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intelmq/lib/harmonization.py b/intelmq/lib/harmonization.py index 130acbaba1..0354c74079 100644 --- a/intelmq/lib/harmonization.py +++ b/intelmq/lib/harmonization.py @@ -101,7 +101,7 @@ def is_valid(value: str, sanitize: bool = False) -> bool: if not GenericType.is_valid(value): return False - if type(value) is not str: + if not isinstace(value, str): return False if len(value) == 0: From 6e3ac7070a83d74ff5d892f62cd45be9a94bc663 Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Thu, 14 Aug 2025 23:50:12 +0530 Subject: [PATCH 09/26] replaced type with isinstance in bot.py --- intelmq/lib/bot.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/intelmq/lib/bot.py b/intelmq/lib/bot.py index 638d68677e..eb23184cf6 100644 --- a/intelmq/lib/bot.py +++ b/intelmq/lib/bot.py @@ -528,8 +528,7 @@ def __reset_total_path_stats(self): """Initially set destination paths to 0 to reset them in stats cache""" if not self.destination_queues: return - queues_type = type(self.destination_queues) - if queues_type is dict: + if isinstance(self.destination_queues, dict): for path in self.destination_queues.keys(): self.__message_counter["path_total"][path] = 0 else: @@ -1240,7 +1239,7 @@ def process(self): value = self.parse_line(line, report) if value is None: continue - elif type(value) is list or isinstance(value, types.GeneratorType): + elif isinstace(value, list) or isinstance(value, types.GeneratorType): # filter out None events: list[libmessage.Event] = list(filter(bool, value)) else: From 4436e98de06806ac4c80148c5ae0199f0446fe53 Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Thu, 14 Aug 2025 23:52:38 +0530 Subject: [PATCH 10/26] replaced type with isinstance in pipeline.py --- intelmq/lib/pipeline.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/intelmq/lib/pipeline.py b/intelmq/lib/pipeline.py index f439a20537..57dae3b565 100644 --- a/intelmq/lib/pipeline.py +++ b/intelmq/lib/pipeline.py @@ -116,10 +116,9 @@ def set_queues(self, queues: Optional[str], queues_type: str): self.internal_queue = None if queues is None else f'{queues}-internal' elif queues_type == "destination": - type_ = type(queues) - if type_ is list: + if isinstace(queues, list): q = {"_default": queues} - elif type_ is str: + elif isinstance(queues, str): q = {"_default": queues.split()} elif isinstance(queues, dict): q = queues From 6e8d78c5ff54102b06db3a14dcf1515e03eb29c7 Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Thu, 14 Aug 2025 23:56:02 +0530 Subject: [PATCH 11/26] replaced type with isinstance in test.py --- intelmq/lib/test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intelmq/lib/test.py b/intelmq/lib/test.py index f49821eff2..239760162c 100644 --- a/intelmq/lib/test.py +++ b/intelmq/lib/test.py @@ -171,7 +171,7 @@ def setUpClass(cls): 'time.observation': '2016-01-01T00:00:00+00:00'} elif cls.bot_type != 'collector' and cls.default_input_message == '': cls.default_input_message = {'__type': 'Event'} - if type(cls.default_input_message) is dict: + if isinstance(cls.default_input_message, dict): cls.default_input_message = \ utils.decode(json.dumps(cls.default_input_message)) @@ -268,7 +268,7 @@ def prepare_source_queue(self): self.input_message = [self.input_message] self.input_queue = [] for msg in self.input_message: - if type(msg) is dict: + if isinstance(msg, dict): self.input_queue.append(json.dumps(msg)) elif issubclass(type(msg), message.Message): self.input_queue.append(msg.serialize()) From 65ce94e6d0b263e5a91325a08810e477bcfc2522 Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Thu, 14 Aug 2025 23:58:17 +0530 Subject: [PATCH 12/26] replaced type with isinstance in upgrades.py --- intelmq/lib/upgrades.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intelmq/lib/upgrades.py b/intelmq/lib/upgrades.py index ee22b60a69..40bc3331a4 100644 --- a/intelmq/lib/upgrades.py +++ b/intelmq/lib/upgrades.py @@ -200,7 +200,7 @@ def v100_dev7_modify_syntax(configuration, harmonization, dry_run, **kwargs): if bot["module"] == "intelmq.bots.experts.modify.expert": if "configuration_path" in bot["parameters"]: config = load_configuration(bot["parameters"]["configuration_path"]) - if type(config) is dict: + if isinstace(config, dict): new_config = modify_expert_convert_config(config) if len(config) != len(new_config): return 'Error converting modify expert syntax. Different size of configurations. Please report this.' @@ -527,7 +527,7 @@ def v221_feed_changes(configuration, harmonization, dry_run, **kwargs): continue columns = bot["parameters"]["columns"] # convert columns to an array - if type(columns) is str: + if isinstance(columns, str): columns = [column.strip() for column in columns.split(",")] if columns == ULRHAUS_OLD: changed = True From ef8f00fe2e0cff82c0eddd7ef7b3f2a5941db130 Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Fri, 15 Aug 2025 00:03:50 +0530 Subject: [PATCH 13/26] replaced type with isinstance in utils.py --- intelmq/lib/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/intelmq/lib/utils.py b/intelmq/lib/utils.py index 0a4922d703..f269737533 100644 --- a/intelmq/lib/utils.py +++ b/intelmq/lib/utils.py @@ -199,8 +199,8 @@ def flatten_queues(queues: Union[list, dict]) -> Iterator[str]: Returns: flattened_queues: queues without dictionaries as values, just lists with the values """ - return (item for sublist in (queues.values() if type(queues) is dict else queues) for item in - (sublist if type(sublist) is list else [sublist])) + return (item for sublist in (queues.values() if isinstance(queues, dict) else queues) for item in + (sublist if isinstance(sublist, list) else [sublist])) def load_configuration(configuration_filepath: str) -> dict: @@ -395,7 +395,7 @@ def log(name: str, log_path: Union[str, bool] = intelmq.DEFAULT_LOGGING_PATH, handler.setLevel(log_level) handler.setFormatter(logging.Formatter(LOG_FORMAT)) elif syslog: - if type(syslog) is tuple or type(syslog) is list: + if isinstance(syslog, tuple) or isinstance(syslog, list): handler = logging.handlers.SysLogHandler(address=tuple(syslog)) else: handler = logging.handlers.SysLogHandler(address=syslog) From 552728d845c3b3a9ee888e1e8e37cfc3d83de514 Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Fri, 15 Aug 2025 00:23:18 +0530 Subject: [PATCH 14/26] replaced type by isinstance in message.py --- intelmq/lib/message.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/intelmq/lib/message.py b/intelmq/lib/message.py index 627ebbb671..ab2f8a1396 100644 --- a/intelmq/lib/message.py +++ b/intelmq/lib/message.py @@ -498,9 +498,8 @@ def __eq__(self, other: dict) -> bool: """ dict_eq = super().__eq__(other) if dict_eq and issubclass(type(other), Message): - type_eq = type(self) is type(other) harm_eq = self.harmonization_config == other.harmonization_config if hasattr(other, 'harmonization_config') else False - if type_eq and harm_eq: + if isinstance(type_eq, harm_eq): return True elif dict_eq: return True From 4dbcb081cc97c0732fb699689ff73a2df3e684ea Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Fri, 15 Aug 2025 00:33:03 +0530 Subject: [PATCH 15/26] replaced type by isinstance in test_message.py --- intelmq/tests/lib/test_message.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/intelmq/tests/lib/test_message.py b/intelmq/tests/lib/test_message.py index ac1e1cbcdd..2c372b5c11 100644 --- a/intelmq/tests/lib/test_message.py +++ b/intelmq/tests/lib/test_message.py @@ -90,14 +90,12 @@ def add_event_examples(self, event): def test_report_type(self): """ Test if MessageFactory returns a Report. """ report = self.new_report() - self.assertEqual(type(report), - message.Report) + self.assertTrue(isinstance(report, message.Report)) def test_event_type(self): """ Test if MessageFactory returns a Event. """ event = self.new_event() - self.assertEqual(type(event), - message.Event) + self.assertTrue(isinstance(event, message.Event)) def test_report_init_auto(self): """ Test if serialize does pass auto=True """ @@ -584,7 +582,8 @@ def test_message_from_dict_return_type(self): event = {'__type': 'Event'} event_type = type(message.MessageFactory.from_dict(event, harmonization=HARM)) - self.assertTrue(event_type is message.Event, + + self.assertTrue(isinstance(message.MessageFactory.from_dict(event, harmonization=HARM), message.Event), msg=f'Type is {event_type} instead of Event.') def test_event_init_check(self): From f8b695deafa20b7c69e2f62a7ff117dfa2e1d197 Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Fri, 15 Aug 2025 00:40:15 +0530 Subject: [PATCH 16/26] replaced type with isinstance in bot.py --- intelmq/lib/bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intelmq/lib/bot.py b/intelmq/lib/bot.py index eb23184cf6..b5fb577c71 100644 --- a/intelmq/lib/bot.py +++ b/intelmq/lib/bot.py @@ -1239,7 +1239,7 @@ def process(self): value = self.parse_line(line, report) if value is None: continue - elif isinstace(value, list) or isinstance(value, types.GeneratorType): + elif isinstance(value, list) or isinstance(value, types.GeneratorType): # filter out None events: list[libmessage.Event] = list(filter(bool, value)) else: From 800907659fe87b33569512d9926888af99e6238a Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Fri, 15 Aug 2025 00:42:28 +0530 Subject: [PATCH 17/26] replaced files with isinstance in harmonization.py --- intelmq/lib/harmonization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intelmq/lib/harmonization.py b/intelmq/lib/harmonization.py index 0354c74079..05444e5659 100644 --- a/intelmq/lib/harmonization.py +++ b/intelmq/lib/harmonization.py @@ -101,7 +101,7 @@ def is_valid(value: str, sanitize: bool = False) -> bool: if not GenericType.is_valid(value): return False - if not isinstace(value, str): + if not isinstance(value, str): return False if len(value) == 0: From 158be13e4a494e55abd350c1eb56afc40fd57812 Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Fri, 15 Aug 2025 00:43:39 +0530 Subject: [PATCH 18/26] replaced type with isinstance in upgrades.py --- intelmq/lib/upgrades.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intelmq/lib/upgrades.py b/intelmq/lib/upgrades.py index 40bc3331a4..712f34951b 100644 --- a/intelmq/lib/upgrades.py +++ b/intelmq/lib/upgrades.py @@ -200,7 +200,7 @@ def v100_dev7_modify_syntax(configuration, harmonization, dry_run, **kwargs): if bot["module"] == "intelmq.bots.experts.modify.expert": if "configuration_path" in bot["parameters"]: config = load_configuration(bot["parameters"]["configuration_path"]) - if isinstace(config, dict): + if isinstance(config, dict): new_config = modify_expert_convert_config(config) if len(config) != len(new_config): return 'Error converting modify expert syntax. Different size of configurations. Please report this.' From cafbf3f6e79d1dbd1acc59aaf2c97ddbb0203d16 Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Fri, 15 Aug 2025 00:45:24 +0530 Subject: [PATCH 19/26] replaced type with isinstance in pipeline.py --- intelmq/lib/pipeline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intelmq/lib/pipeline.py b/intelmq/lib/pipeline.py index 57dae3b565..4ba7465f3a 100644 --- a/intelmq/lib/pipeline.py +++ b/intelmq/lib/pipeline.py @@ -116,7 +116,7 @@ def set_queues(self, queues: Optional[str], queues_type: str): self.internal_queue = None if queues is None else f'{queues}-internal' elif queues_type == "destination": - if isinstace(queues, list): + if isinstance(queues, list): q = {"_default": queues} elif isinstance(queues, str): q = {"_default": queues.split()} From 26ceba7452e31f2e14d1293320849d528df0cf4c Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Fri, 15 Aug 2025 11:05:43 +0530 Subject: [PATCH 20/26] Updated expert.py --- intelmq/bots/experts/filter/expert.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intelmq/bots/experts/filter/expert.py b/intelmq/bots/experts/filter/expert.py index 9f988aae8f..eeabe4a16b 100644 --- a/intelmq/bots/experts/filter/expert.py +++ b/intelmq/bots/experts/filter/expert.py @@ -86,13 +86,13 @@ def process(self): self.acknowledge_message() self.logger.debug("Filtered out event with time.source %s.", event.get('time.source')) return - if isinstance(self,not_before, datetime) and event_time < self.not_before: + if isinstance(self.not_before, datetime) and event_time < self.not_before: self.acknowledge_message() self.logger.debug("Filtered out event with time.source %r.", event.get('time.source')) return now = datetime.now(tz=timezone.utc) - if isinstance(self.not_after, timedelta and event_time > (now - self.not_after): + if isinstance(self.not_after, timedelta) and event_time > (now - self.not_after): self.acknowledge_message() self.logger.debug("Filtered out event with time.source %r.", event.get('time.source')) return From c2d0ae5f6dbebffd2dcbc822f22be7b24df52416 Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Fri, 15 Aug 2025 11:08:18 +0530 Subject: [PATCH 21/26] Update expert.py --- intelmq/bots/experts/rdap/expert.py | 1 - 1 file changed, 1 deletion(-) diff --git a/intelmq/bots/experts/rdap/expert.py b/intelmq/bots/experts/rdap/expert.py index 89d8f1953a..b8658fe003 100644 --- a/intelmq/bots/experts/rdap/expert.py +++ b/intelmq/bots/experts/rdap/expert.py @@ -46,7 +46,6 @@ def init(self): # get bootstrapped servers for service in self.rdap_bootstrapped_servers: - if type(self.rdap_bootstrapped_servers[service]) is str: if isinstance(self.rdap_bootstrapped_servers[service], str): self.__rdap_directory[service] = {"url": self.rdap_bootstrapped_servers[service]} elif isinstance(self.rdap_bootstrapped_servers, dict): From 2449d854ae56624cf57d4184c1eea6fc1d926abd Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Fri, 15 Aug 2025 11:10:15 +0530 Subject: [PATCH 22/26] Update expert.py --- intelmq/bots/experts/filter/expert.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intelmq/bots/experts/filter/expert.py b/intelmq/bots/experts/filter/expert.py index eeabe4a16b..3ea8da74be 100644 --- a/intelmq/bots/experts/filter/expert.py +++ b/intelmq/bots/experts/filter/expert.py @@ -86,7 +86,7 @@ def process(self): self.acknowledge_message() self.logger.debug("Filtered out event with time.source %s.", event.get('time.source')) return - if isinstance(self.not_before, datetime) and event_time < self.not_before: + if isinstance(self.not_before, datetime) and event_time < self.not_before: self.acknowledge_message() self.logger.debug("Filtered out event with time.source %r.", event.get('time.source')) return From 9a5f8fdc3f542eec7c41da2b3cfe957e2f9f3890 Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Fri, 15 Aug 2025 11:14:28 +0530 Subject: [PATCH 23/26] Update bot.py --- intelmq/lib/bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intelmq/lib/bot.py b/intelmq/lib/bot.py index b5fb577c71..5de756e884 100644 --- a/intelmq/lib/bot.py +++ b/intelmq/lib/bot.py @@ -1239,7 +1239,7 @@ def process(self): value = self.parse_line(line, report) if value is None: continue - elif isinstance(value, list) or isinstance(value, types.GeneratorType): + elif isinstance(value, list) or isinstance(value, types.GeneratorType): # filter out None events: list[libmessage.Event] = list(filter(bool, value)) else: From 7e1b5559f2ebc2d01d11d6b0f4f88f873854865f Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Fri, 15 Aug 2025 12:43:15 +0530 Subject: [PATCH 24/26] Update test.py --- intelmq/lib/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intelmq/lib/test.py b/intelmq/lib/test.py index 239760162c..03b0963325 100644 --- a/intelmq/lib/test.py +++ b/intelmq/lib/test.py @@ -270,7 +270,7 @@ def prepare_source_queue(self): for msg in self.input_message: if isinstance(msg, dict): self.input_queue.append(json.dumps(msg)) - elif issubclass(type(msg), message.Message): + elif isinstance(msg, message.Message): self.input_queue.append(msg.serialize()) else: self.input_queue.append(msg) From 23f58e7b795310b7370abc8ca6997d1ee013e90c Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Fri, 15 Aug 2025 12:57:17 +0530 Subject: [PATCH 25/26] Update test_message.py --- intelmq/tests/lib/test_message.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/intelmq/tests/lib/test_message.py b/intelmq/tests/lib/test_message.py index 2c372b5c11..38b00af266 100644 --- a/intelmq/tests/lib/test_message.py +++ b/intelmq/tests/lib/test_message.py @@ -580,10 +580,9 @@ def test_protocol_length(self): def test_message_from_dict_return_type(self): """ Test if from_dict() returns the correct class. """ event = {'__type': 'Event'} - event_type = type(message.MessageFactory.from_dict(event, - harmonization=HARM)) - - self.assertTrue(isinstance(message.MessageFactory.from_dict(event, harmonization=HARM), message.Event), + event_message = message.MessageFactory.from_dict(event,harmonization=HARM) + event_type = type(event_message) + self.assertTrue(isinstance(event_message, message.Event), msg=f'Type is {event_type} instead of Event.') def test_event_init_check(self): From db2ac4e9476d4e4e9372d7353e3b8323c5dc7145 Mon Sep 17 00:00:00 2001 From: Aman Chandra Kumar <115037337+Spiritedswordsman@users.noreply.github.com> Date: Fri, 15 Aug 2025 13:04:43 +0530 Subject: [PATCH 26/26] Update message.py --- intelmq/lib/message.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/intelmq/lib/message.py b/intelmq/lib/message.py index ab2f8a1396..651b95fa21 100644 --- a/intelmq/lib/message.py +++ b/intelmq/lib/message.py @@ -497,9 +497,10 @@ def __eq__(self, other: dict) -> bool: Comparison with other types e.g. dicts does not check the harmonization_config. """ dict_eq = super().__eq__(other) - if dict_eq and issubclass(type(other), Message): + if dict_eq and isinstance(other, Message): + type_eq = isinstance(self, other) harm_eq = self.harmonization_config == other.harmonization_config if hasattr(other, 'harmonization_config') else False - if isinstance(type_eq, harm_eq): + if type_eq and harm_eq: return True elif dict_eq: return True