diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b31d7035..ab180890c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ - Refactored to utilize the type field returned by the API to match the requested types instead of a sub-string match on the filename. - Fixed timezone issue for collecting reports (PR#2506 by elsif2). - Fixed behaviour if parameter `reports` value is empty string, behave the same way as not set, not like no report (PR#2523 by Sebastian Wagner). + - Fixed behaviour if parameter `types` value is empty string, behave the same way as not set, not like no type. - `intelmq.bots.collectors.shodan.collector_stream` (PR#2492 by Mikk Margus Möll): - Add `alert` parameter to Shodan stream collector to allow fetching streams by configured alert ID - `intelmq.bots.collectors.mail._lib`: Remove deprecated parameter `attach_unzip` from default parameters (PR#2511 by Sebastian Wagner). diff --git a/intelmq/bots/collectors/shadowserver/collector_reports_api.py b/intelmq/bots/collectors/shadowserver/collector_reports_api.py index 3fc3d2f9f..2fa11a3c2 100644 --- a/intelmq/bots/collectors/shadowserver/collector_reports_api.py +++ b/intelmq/bots/collectors/shadowserver/collector_reports_api.py @@ -33,7 +33,7 @@ class ShadowServerAPICollectorBot(CollectorBot, HttpMixin, CacheMixin): reports (list): A list of strings or a comma-separated list of the mailing lists you want to process. types (list): - A list of strings or a string of comma-separated values with the names of reporttypes you want to process. If you leave this empty, all the available reports will be downloaded and processed (i.e. 'scan', 'drones', 'intel', 'sandbox_connection', 'sinkhole_combined'). + A list of strings or a string of comma-separated values with the names of report types you want to process. If you leave this empty, all the available reports will be downloaded and processed (i.e. 'scan', 'drones', 'intel', 'sandbox_connection', 'sinkhole_combined'). """ country = None @@ -48,6 +48,7 @@ class ShadowServerAPICollectorBot(CollectorBot, HttpMixin, CacheMixin): redis_cache_ttl: int = 864000 # 10 days redis_cache_password: Optional[str] = None _report_list = [] + _type_list = [] def init(self): if not self.api_key: @@ -62,7 +63,11 @@ def init(self): elif isinstance(self.reports, list): self._report_list = self.reports if isinstance(self.types, str): - self.types = self.types.split(',') + # if types is an empty string (or only contains whitespace), behave as if the parameter is not set and select all types + types = self.types.strip() + self._type_list = types.split(',') if types else [] + elif isinstance(self.types, list): + self._type_list = self.types if self.country and self.country not in self._report_list: self.logger.warn("Deprecated parameter 'country' found. Please use 'reports' instead. The backwards-compatibility will be removed in IntelMQ version 4.0.0.") self._report_list.append(self.country) @@ -111,8 +116,8 @@ def _reports_list(self, date=None): self.logger.debug('There was an error downloading the reports: %s', reports['error']) return None - if self.types: - reports = [report for report in reports if any(report['type'] == rtype for rtype in self.types)] + if self._type_list: + reports = [report for report in reports if any(report['type'] == rtype for rtype in self._type_list)] return reports def _report_download(self, reportid: str):