Skip to content

Commit 2ad63cc

Browse files
committed
Fix issue in merging configs with same family name
1 parent d62aecc commit 2ad63cc

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

modules/processing/CAPE.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -391,18 +391,23 @@ def update_cape_configs(self, cape_name, config, file_obj):
391391
# look for an existing config matching this cape_name; merge them if found
392392
for existing_config in self.cape["configs"]:
393393
if cape_name in existing_config:
394-
log.debug("CAPE: data loss may occur, existing config found for: %s", cape_name)
394+
log.debug("CAPE: existing config found for: %s, merging - data loss may occur", cape_name)
395395
existing_config[cape_name].update(config[cape_name])
396396
config = existing_config
397-
break
398-
else:
399-
# first time a config for this cape_name was seen
400-
log.debug("CAPE: new config found for: %s", cape_name)
401-
self.cape["configs"].append(config)
397+
self.link_configs_to_hashes(config, file_obj)
398+
return
399+
400+
# first time a config for this cape_name was seen
401+
log.debug("CAPE: new config found for: %s", cape_name)
402+
self.cape["configs"].append(config)
403+
self.link_configs_to_hashes(config, file_obj)
402404

403-
# Link the config to the hashes it was generated from.
404-
# Store it in a list so that the keys of the dict are fixed and not dynamic, which, if
405-
# storing the report in ElasticSearch, could otherwise create tons of keys in the index.
405+
406+
def link_configs_to_hashes(self, config, file_obj):
407+
"""Link the config to the hashes it was generated from.
408+
Store it in a list so that the keys of the dict are fixed and not dynamic, which, if
409+
storing the report in ElasticSearch, could otherwise create tons of keys in the index.
410+
"""
406411
sha256 = file_obj.get("sha256", "")
407412
current_hashes = config.setdefault("_associated_config_hashes", [])
408413
for hashes in current_hashes:

0 commit comments

Comments
 (0)