Skip to content

Commit d336dc0

Browse files
author
Sebastian Wagner
committed
BUG: generic csv: fix time_format empty string handling
1 parent 64e1e31 commit d336dc0

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ Update allowed classification fields to 2020-01-28 version (#1409, #1476).
8282
- Added `intelmq.bots.parsers.fireeye`: A bot that parses hashes and URLs from Fireeye MAS indicators (PR#1745 by Christopher Schappelwein).
8383
- `intelmq.bots.parsers.shadowserver._config`:
8484
- Improved the feed-mapping and all conversion functions (PR#1971 by Mikk Margus Möll).
85+
- `intelmq.bots.parsers.generic.parser_csv`:
86+
- Fix handling of empty string values for parameter `time_format` (by Sebastian Wagner).
8587

8688
#### Experts
8789
- `intelmq.bots.experts.domain_suffix.expert`: Added `--update-database` option to update domain suffix database.

intelmq/bots/parsers/generic/parser_csv.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ def init(self):
6868
# prevents empty strings:
6969
self.column_regex_search = self.column_regex_search or {}
7070

71+
# handle empty strings, false etc.
72+
if not self.time_format:
73+
self.time_format = None
7174
if self.time_format not in TIME_CONVERSIONS.keys():
7275
raise InvalidArgument('time_format', got=self.time_format,
7376
expected=list(TIME_CONVERSIONS.keys()),

intelmq/tests/bots/parsers/generic/test_parser_csv.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ def test_event(self):
8080
self.assertMessageEqual(0, EXAMPLE_EVENT)
8181
self.assertMessageEqual(1, EXAMPLE_EVENT2)
8282

83+
def test_time_format_empty_string(self):
84+
""" Test if empty string value for parameter time_format is handled correctly. """
85+
self.run_bot(parameters={'time_format': ''})
86+
self.assertMessageEqual(0, EXAMPLE_EVENT)
87+
8388
def test_strcol(self):
8489
self.run_bot(parameters={"columns": "time.source, __IGNORE__,"
8590
"event_description.text, __IGNORE__,"

0 commit comments

Comments
 (0)