From df31c002ca3a4f56b978433e9a7ca5ea30de7641 Mon Sep 17 00:00:00 2001 From: Mika Ayenson Date: Tue, 17 Sep 2024 13:25:17 -0500 Subject: [PATCH] [Bug] Handle formatting empty list (#4086) --- detection_rules/rule_formatter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/detection_rules/rule_formatter.py b/detection_rules/rule_formatter.py index e7c84611d..e4b4d704b 100644 --- a/detection_rules/rule_formatter.py +++ b/detection_rules/rule_formatter.py @@ -161,7 +161,7 @@ class RuleTomlEncoder(toml.TomlEncoder): dump.append(' ' * 4 + self.dump_value(item)) return '[\n{},\n]'.format(',\n'.join(dump)) - if all(isinstance(i, dict) for i in v): + if v and all(isinstance(i, dict) for i in v): # Compact inline format for lists of dictionaries with proper indentation retval = "\n" + ' ' * 2 + "[\n" retval += ",\n".join([' ' * 4 + self.dump_inline_table(u).strip() for u in v])