Skip to content

Commit 13a555e

Browse files
authored
Changes WebhookHandler shallow copy to deepcopy (#237)
* Changes shallow copy to deepcopy * Fixes dict * Adds comment
1 parent 86faeb8 commit 13a555e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

opencanary/logger.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from copy import deepcopy
12
import simplejson as json
23
import logging.config
34
import socket
@@ -334,8 +335,12 @@ def emit(self, record):
334335
if self.data is None:
335336
data = mapping
336337
else:
337-
# Due to the recursive function, sending a shallow copy of self.data here is fine.
338-
data = map_string(dict(self.data), mapping)
338+
if isinstance(self.data, dict):
339+
# Casting logging.config.ConvertingDict to a standard dict
340+
data = dict(self.data)
341+
else:
342+
data = self.data
343+
data = map_string(deepcopy(data), mapping)
339344

340345
if "application/json" in self.kwargs.get("headers", {}).values():
341346
response = requests.request(method=self.method, url=self.url, json=data, **self.kwargs)

0 commit comments

Comments
 (0)