@@ -391,18 +391,23 @@ def update_cape_configs(self, cape_name, config, file_obj):
391
391
# look for an existing config matching this cape_name; merge them if found
392
392
for existing_config in self .cape ["configs" ]:
393
393
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 )
395
395
existing_config [cape_name ].update (config [cape_name ])
396
396
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 )
402
404
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
+ """
406
411
sha256 = file_obj .get ("sha256" , "" )
407
412
current_hashes = config .setdefault ("_associated_config_hashes" , [])
408
413
for hashes in current_hashes :
0 commit comments