Repository: mvt-project/mvt (language: python)

Issue:
Error when serializing data from module SMS: Circular reference detected
When running:
`mvt-ios check-backup --output ./check_backup decrypted_backup/`

I am getting the error:
```
14:27:50 ERROR    [mvt.ios.modules.mixed.sms] Error when serializing data from module SMS: Circular reference detected                                                                                                                                                         
                  Traceback (most recent call last):                                                                                                                                                                                                                           
                    File "/home/user/miniconda3/lib/python3.11/site-packages/mvt/common/module.py", line 217, in run_module                                                                                                                                                      
                      module.to_timeline()                                                                                                                                                                                                                                     
                    File "/home/user/miniconda3/lib/python3.11/site-packages/mvt/common/module.py", line 155, in to_timeline                                                                                                                                                     
                      self.timeline = self._deduplicate_timeline(self.timeline)                                                                                                                                                                                                
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                                                
                    File "/home/user/miniconda3/lib/python3.11/site-packages/mvt/common/module.py", line 133, in _deduplicate_timeline                                                                                                                                           
                      timeline_set.add(json.dumps(record, sort_keys=True))                                                                                                                                                                                                     
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                                                      
                    File "/home/user/miniconda3/lib/python3.11/json/__init__.py", line 238, in dumps                                                                                                                                                                             
                      **kw).encode(obj)                                                                                                                                                                                                                                        
                            ^^^^^^^^^^^                                                                                                                                                                                                                                        
                    File "/home/user/miniconda3/lib/python3.11/json/encoder.py", line 200, in encode                                                                                                                                                                             
                      chunks = self.iterencode(o, _one_shot=True)                                                                                                                                                                                                              
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                                                              
                    File "/home/user/miniconda3/lib/python3.11/json/encoder.py", line 258, in iterencode                                                                                                                                                                         
                      return _iterencode(o, 0)                                                                                                                                                                                                                                 
                             ^^^^^^^^^^^^^^^^^                                                                                                                                                                                                                                 
                  ValueError: Circular reference detected
```
I'm running python 3.11.5 and MVT==2.4.5 after cloning the repo. I encountered this error after pulling in the `uri=True` fix from #434.


Discussion / hints:
@Shellcat-Zero Can you confirm if the same error occurs with `mvt==2.4.3` from PyPI? It looks like another bug, but I would be quite surprised if the change introduced in #442 caused this.
SMS module had recent changes in #438 that are not yet in a PyPI release but are in `main` - seems related.

Fix patch:
diff --git a/mvt/ios/modules/mixed/sms.py b/mvt/ios/modules/mixed/sms.py
index eecc1c478..649134300 100644
--- a/mvt/ios/modules/mixed/sms.py
+++ b/mvt/ios/modules/mixed/sms.py
@@ -44,7 +44,7 @@ def __init__(
     def serialize(self, record: dict) -> Union[dict, list]:
         text = record["text"].replace("\n", "\\n")
         sms_data = f"{record['service']}: {record['guid']} \"{text}\" from {record['phone_number']} ({record['account']})"
-        sms_data = [
+        records = [
             {
                 "timestamp": record["isodate"],
                 "module": self.__class__.__name__,
@@ -54,7 +54,7 @@ def serialize(self, record: dict) -> Union[dict, list]:
         ]
         # If the message was read, we add an extra event.
         if record["isodate_read"]:
-            sms_data.append(
+            records.append(
                 {
                     "timestamp": record["isodate_read"],
                     "module": self.__class__.__name__,
@@ -62,7 +62,7 @@ def serialize(self, record: dict) -> Union[dict, list]:
                     "data": sms_data,
                 }
             )
-        return sms_data
+        return records
 
     def check_indicators(self) -> None:
         for message in self.results:


Test patch:
diff --git a/tests/artifacts/ios_backup/3d/3d0d7e5fb2ce288813306e4d4636395e047a3d28 b/tests/artifacts/ios_backup/3d/3d0d7e5fb2ce288813306e4d4636395e047a3d28
index b067ce7ca..f18450e30 100644
Binary files a/tests/artifacts/ios_backup/3d/3d0d7e5fb2ce288813306e4d4636395e047a3d28 and b/tests/artifacts/ios_backup/3d/3d0d7e5fb2ce288813306e4d4636395e047a3d28 differ
diff --git a/tests/ios_backup/test_sms.py b/tests/ios_backup/test_sms.py
index 84ac0b535..243f6306c 100644
--- a/tests/ios_backup/test_sms.py
+++ b/tests/ios_backup/test_sms.py
@@ -17,7 +17,7 @@ def test_sms(self):
         m = SMS(target_path=get_ios_backup_folder())
         run_module(m)
         assert len(m.results) == 1
-        assert len(m.timeline) == 1
+        assert len(m.timeline) == 2
         assert len(m.detected) == 0
 
     def test_detection(self, indicator_file):