prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  SDK Crash Detection: Set in app
  Set all in app for all frames to `false` except for the SDK frames after stripping the event data. 
  
  https://github.com/getsentry/sentry/blob/95086b406dec79e6bcef45f299a3e92f727da2c0/src/sentry/utils/sdk_crashes/sdk_crash_detection.py#L58
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/sentry/utils/sdk_crashes/event_stripper.py`
  Content:
  ```
  1 from enum import Enum, auto
  2 from typing import Any, Dict, Mapping, Optional, Sequence
  3 
  4 from sentry.db.models import NodeData
  5 from sentry.utils.safe import get_path
  6 from sentry.utils.sdk_crashes.sdk_crash_detector import SDKCrashDetector
  7 
  8 
  9 class Allow(Enum):
  10     def __init__(self, explanation: str = "") -> None:
  11         self.explanation = explanation
  12 
  13     """Keeps the event data if it is of type str, int, float, bool."""
  14     SIMPLE_TYPE = auto()
  15 
  16     """
  17     Doesn't keep the event data no matter the type. This can be used to explicitly
  18     specify that data should be removed with an explanation.
  19     """
  20     NEVER = auto()
  21 
  22     def with_explanation(self, explanation: str) -> "Allow":
  23         self.explanation = explanation
  24         return self
  25 
  26 
  27 EVENT_DATA_ALLOWLIST = {
  28     "type": Allow.SIMPLE_TYPE,
  29     "datetime": Allow.SIMPLE_TYPE,
  30     "timestamp": Allow.SIMPLE_TYPE,
  31     "platform": Allow.SIMPLE_TYPE,
  32     "sdk": {
  33         "name": Allow.SIMPLE_TYPE,
  34         "version": Allow.SIMPLE_TYPE,
  35         "integrations": Allow.NEVER.with_explanation("Users can add their own integrations."),
  36     },
  37     "exception": {
  38         "values": {
  39             "stacktrace": {
  40                 "frames": {
  41                     "filename": Allow.SIMPLE_TYPE,
  42                     "function": Allow.SIMPLE_TYPE,
  43                     "raw_function": Allow.SIMPLE_TYPE,
  44                     "module": Allow.SIMPLE_TYPE,
  45                     "abs_path": Allow.SIMPLE_TYPE,
  46                     "in_app": Allow.SIMPLE_TYPE,
  47                     "instruction_addr": Allow.SIMPLE_TYPE,
  48                     "addr_mode": Allow.SIMPLE_TYPE,
  49                     "symbol": Allow.SIMPLE_TYPE,
  50                     "symbol_addr": Allow.SIMPLE_TYPE,
  51                     "image_addr": Allow.SIMPLE_TYPE,
  52                     "package": Allow.SIMPLE_TYPE,
  53                     "platform": Allow.SIMPLE_TYPE,
  54                 }
  55             },
  56             "value": Allow.NEVER.with_explanation("The exception value could contain PII."),
  57             "type": Allow.SIMPLE_TYPE,
  58             "mechanism": {
  59                 "handled": Allow.SIMPLE_TYPE,
  60                 "type": Allow.SIMPLE_TYPE,
  61                 "meta": {
  62                     "signal": {
  63                         "number": Allow.SIMPLE_TYPE,
  64                         "code": Allow.SIMPLE_TYPE,
  65                         "name": Allow.SIMPLE_TYPE,
  66                         "code_name": Allow.SIMPLE_TYPE,
  67                     },
  68                     "mach_exception": {
  69                         "exception": Allow.SIMPLE_TYPE,
  70                         "code": Allow.SIMPLE_TYPE,
  71                         "subcode": Allow.SIMPLE_TYPE,
  72                         "name": Allow.SIMPLE_TYPE,
  73                     },
  74                 },
  75             },
  76         }
  77     },
  78     "contexts": {
  79         "device": {
  80             "family": Allow.SIMPLE_TYPE,
  81             "model": Allow.SIMPLE_TYPE,
  82             "arch": Allow.SIMPLE_TYPE,
  83         },
  84         "os": {
  85             "name": Allow.SIMPLE_TYPE,
  86             "version": Allow.SIMPLE_TYPE,
  87             "build": Allow.SIMPLE_TYPE,
  88         },
  89     },
  90 }
  91 
  92 
  93 def strip_event_data(
  94     event_data: NodeData, sdk_crash_detector: SDKCrashDetector
  95 ) -> Mapping[str, Any]:
  96     new_event_data = _strip_event_data_with_allowlist(event_data, EVENT_DATA_ALLOWLIST)
  97 
  98     if (new_event_data is None) or (new_event_data == {}):
  99         return {}
  100 
  101     stripped_frames: Sequence[Mapping[str, Any]] = []
  102     frames = get_path(new_event_data, "exception", "values", -1, "stacktrace", "frames")
  103 
  104     if frames is not None:
  105         stripped_frames = _strip_frames(frames, sdk_crash_detector)
  106         new_event_data["exception"]["values"][0]["stacktrace"]["frames"] = stripped_frames
  107 
  108     return new_event_data
  109 
  110 
  111 def _strip_event_data_with_allowlist(
  112     data: Mapping[str, Any], allowlist: Optional[Mapping[str, Any]]
  113 ) -> Optional[Mapping[str, Any]]:
  114     """
  115     Recursively traverses the data and only keeps values based on the allowlist.
  116     """
  117     if allowlist is None:
  118         return None
  119 
  120     stripped_data: Dict[str, Any] = {}
  121     for data_key, data_value in data.items():
  122         allowlist_for_data = allowlist.get(data_key)
  123         if allowlist_for_data is None:
  124             continue
  125 
  126         if isinstance(allowlist_for_data, Allow):
  127             allowed = allowlist_for_data
  128 
  129             if allowed is Allow.SIMPLE_TYPE and isinstance(data_value, (str, int, float, bool)):
  130                 stripped_data[data_key] = data_value
  131             else:
  132                 continue
  133 
  134         elif isinstance(data_value, Mapping):
  135             stripped_data[data_key] = _strip_event_data_with_allowlist(
  136                 data_value, allowlist_for_data
  137             )
  138         elif isinstance(data_value, Sequence):
  139             stripped_data[data_key] = [
  140                 _strip_event_data_with_allowlist(item, allowlist_for_data) for item in data_value
  141             ]
  142 
  143     return stripped_data
  144 
  145 
  146 def _strip_frames(
  147     frames: Sequence[Mapping[str, Any]], sdk_crash_detector: SDKCrashDetector
  148 ) -> Sequence[Mapping[str, Any]]:
  149     """
  150     Only keep SDK frames or Apple system libraries.
  151     We need to adapt this logic once we support other platforms.
  152     """
  153 
  154     def is_system_library(frame: Mapping[str, Any]) -> bool:
  155         fields_containing_paths = {"package", "module", "abs_path"}
  156         system_library_paths = {"/System/Library/", "/usr/lib/system/"}
  157 
  158         for field in fields_containing_paths:
  159             for path in system_library_paths:
  160                 if frame.get(field, "").startswith(path):
  161                     return True
  162 
  163         return False
  164 
  165     return [
  166         frame
  167         for frame in frames
  168         if sdk_crash_detector.is_sdk_frame(frame) or is_system_library(frame)
  169     ]
  170
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/sentry/utils/sdk_crashes/event_stripper.py b/src/sentry/utils/sdk_crashes/event_stripper.py
  --- a/src/sentry/utils/sdk_crashes/event_stripper.py
  +++ b/src/sentry/utils/sdk_crashes/event_stripper.py
  @@ -1,5 +1,5 @@
   from enum import Enum, auto
  -from typing import Any, Dict, Mapping, Optional, Sequence
  +from typing import Any, Dict, Mapping, MutableMapping, Optional, Sequence
   
   from sentry.db.models import NodeData
   from sentry.utils.safe import get_path
  @@ -98,11 +98,11 @@
       if (new_event_data is None) or (new_event_data == {}):
           return {}
   
  -    stripped_frames: Sequence[Mapping[str, Any]] = []
       frames = get_path(new_event_data, "exception", "values", -1, "stacktrace", "frames")
   
       if frames is not None:
           stripped_frames = _strip_frames(frames, sdk_crash_detector)
  +
           new_event_data["exception"]["values"][0]["stacktrace"]["frames"] = stripped_frames
   
       return new_event_data
  @@ -144,7 +144,7 @@
   
   
   def _strip_frames(
  -    frames: Sequence[Mapping[str, Any]], sdk_crash_detector: SDKCrashDetector
  +    frames: Sequence[MutableMapping[str, Any]], sdk_crash_detector: SDKCrashDetector
   ) -> Sequence[Mapping[str, Any]]:
       """
       Only keep SDK frames or Apple system libraries.
  @@ -162,8 +162,15 @@
   
           return False
   
  +    def strip_frame(frame: MutableMapping[str, Any]) -> MutableMapping[str, Any]:
  +        if sdk_crash_detector.is_sdk_frame(frame):
  +            frame["in_app"] = True
  +        else:
  +            frame["in_app"] = False
  +        return frame
  +
       return [
  -        frame
  +        strip_frame(frame)
           for frame in frames
           if sdk_crash_detector.is_sdk_frame(frame) or is_system_library(frame)
       ]
  
verification_info: {"golden_diff": "diff --git a/src/sentry/utils/sdk_crashes/event_stripper.py b/src/sentry/utils/sdk_crashes/event_stripper.py\n--- a/src/sentry/utils/sdk_crashes/event_stripper.py\n+++ b/src/sentry/utils/sdk_crashes/event_stripper.py\n@@ -1,5 +1,5 @@\n from enum import Enum, auto\n-from typing import Any, Dict, Mapping, Optional, Sequence\n+from typing import Any, Dict, Mapping, MutableMapping, Optional, Sequence\n \n from sentry.db.models import NodeData\n from sentry.utils.safe import get_path\n@@ -98,11 +98,11 @@\n     if (new_event_data is None) or (new_event_data == {}):\n         return {}\n \n-    stripped_frames: Sequence[Mapping[str, Any]] = []\n     frames = get_path(new_event_data, \"exception\", \"values\", -1, \"stacktrace\", \"frames\")\n \n     if frames is not None:\n         stripped_frames = _strip_frames(frames, sdk_crash_detector)\n+\n         new_event_data[\"exception\"][\"values\"][0][\"stacktrace\"][\"frames\"] = stripped_frames\n \n     return new_event_data\n@@ -144,7 +144,7 @@\n \n \n def _strip_frames(\n-    frames: Sequence[Mapping[str, Any]], sdk_crash_detector: SDKCrashDetector\n+    frames: Sequence[MutableMapping[str, Any]], sdk_crash_detector: SDKCrashDetector\n ) -> Sequence[Mapping[str, Any]]:\n     \"\"\"\n     Only keep SDK frames or Apple system libraries.\n@@ -162,8 +162,15 @@\n \n         return False\n \n+    def strip_frame(frame: MutableMapping[str, Any]) -> MutableMapping[str, Any]:\n+        if sdk_crash_detector.is_sdk_frame(frame):\n+            frame[\"in_app\"] = True\n+        else:\n+            frame[\"in_app\"] = False\n+        return frame\n+\n     return [\n-        frame\n+        strip_frame(frame)\n         for frame in frames\n         if sdk_crash_detector.is_sdk_frame(frame) or is_system_library(frame)\n     ]\n", "issue": "SDK Crash Detection: Set in app\nSet all in app for all frames to `false` except for the SDK frames after stripping the event data. \r\n\r\nhttps://github.com/getsentry/sentry/blob/95086b406dec79e6bcef45f299a3e92f727da2c0/src/sentry/utils/sdk_crashes/sdk_crash_detection.py#L58\n", "before_files": [{"content": "from enum import Enum, auto\nfrom typing import Any, Dict, Mapping, Optional, Sequence\n\nfrom sentry.db.models import NodeData\nfrom sentry.utils.safe import get_path\nfrom sentry.utils.sdk_crashes.sdk_crash_detector import SDKCrashDetector\n\n\nclass Allow(Enum):\n    def __init__(self, explanation: str = \"\") -> None:\n        self.explanation = explanation\n\n    \"\"\"Keeps the event data if it is of type str, int, float, bool.\"\"\"\n    SIMPLE_TYPE = auto()\n\n    \"\"\"\n    Doesn't keep the event data no matter the type. This can be used to explicitly\n    specify that data should be removed with an explanation.\n    \"\"\"\n    NEVER = auto()\n\n    def with_explanation(self, explanation: str) -> \"Allow\":\n        self.explanation = explanation\n        return self\n\n\nEVENT_DATA_ALLOWLIST = {\n    \"type\": Allow.SIMPLE_TYPE,\n    \"datetime\": Allow.SIMPLE_TYPE,\n    \"timestamp\": Allow.SIMPLE_TYPE,\n    \"platform\": Allow.SIMPLE_TYPE,\n    \"sdk\": {\n        \"name\": Allow.SIMPLE_TYPE,\n        \"version\": Allow.SIMPLE_TYPE,\n        \"integrations\": Allow.NEVER.with_explanation(\"Users can add their own integrations.\"),\n    },\n    \"exception\": {\n        \"values\": {\n            \"stacktrace\": {\n                \"frames\": {\n                    \"filename\": Allow.SIMPLE_TYPE,\n                    \"function\": Allow.SIMPLE_TYPE,\n                    \"raw_function\": Allow.SIMPLE_TYPE,\n                    \"module\": Allow.SIMPLE_TYPE,\n                    \"abs_path\": Allow.SIMPLE_TYPE,\n                    \"in_app\": Allow.SIMPLE_TYPE,\n                    \"instruction_addr\": Allow.SIMPLE_TYPE,\n                    \"addr_mode\": Allow.SIMPLE_TYPE,\n                    \"symbol\": Allow.SIMPLE_TYPE,\n                    \"symbol_addr\": Allow.SIMPLE_TYPE,\n                    \"image_addr\": Allow.SIMPLE_TYPE,\n                    \"package\": Allow.SIMPLE_TYPE,\n                    \"platform\": Allow.SIMPLE_TYPE,\n                }\n            },\n            \"value\": Allow.NEVER.with_explanation(\"The exception value could contain PII.\"),\n            \"type\": Allow.SIMPLE_TYPE,\n            \"mechanism\": {\n                \"handled\": Allow.SIMPLE_TYPE,\n                \"type\": Allow.SIMPLE_TYPE,\n                \"meta\": {\n                    \"signal\": {\n                        \"number\": Allow.SIMPLE_TYPE,\n                        \"code\": Allow.SIMPLE_TYPE,\n                        \"name\": Allow.SIMPLE_TYPE,\n                        \"code_name\": Allow.SIMPLE_TYPE,\n                    },\n                    \"mach_exception\": {\n                        \"exception\": Allow.SIMPLE_TYPE,\n                        \"code\": Allow.SIMPLE_TYPE,\n                        \"subcode\": Allow.SIMPLE_TYPE,\n                        \"name\": Allow.SIMPLE_TYPE,\n                    },\n                },\n            },\n        }\n    },\n    \"contexts\": {\n        \"device\": {\n            \"family\": Allow.SIMPLE_TYPE,\n            \"model\": Allow.SIMPLE_TYPE,\n            \"arch\": Allow.SIMPLE_TYPE,\n        },\n        \"os\": {\n            \"name\": Allow.SIMPLE_TYPE,\n            \"version\": Allow.SIMPLE_TYPE,\n            \"build\": Allow.SIMPLE_TYPE,\n        },\n    },\n}\n\n\ndef strip_event_data(\n    event_data: NodeData, sdk_crash_detector: SDKCrashDetector\n) -> Mapping[str, Any]:\n    new_event_data = _strip_event_data_with_allowlist(event_data, EVENT_DATA_ALLOWLIST)\n\n    if (new_event_data is None) or (new_event_data == {}):\n        return {}\n\n    stripped_frames: Sequence[Mapping[str, Any]] = []\n    frames = get_path(new_event_data, \"exception\", \"values\", -1, \"stacktrace\", \"frames\")\n\n    if frames is not None:\n        stripped_frames = _strip_frames(frames, sdk_crash_detector)\n        new_event_data[\"exception\"][\"values\"][0][\"stacktrace\"][\"frames\"] = stripped_frames\n\n    return new_event_data\n\n\ndef _strip_event_data_with_allowlist(\n    data: Mapping[str, Any], allowlist: Optional[Mapping[str, Any]]\n) -> Optional[Mapping[str, Any]]:\n    \"\"\"\n    Recursively traverses the data and only keeps values based on the allowlist.\n    \"\"\"\n    if allowlist is None:\n        return None\n\n    stripped_data: Dict[str, Any] = {}\n    for data_key, data_value in data.items():\n        allowlist_for_data = allowlist.get(data_key)\n        if allowlist_for_data is None:\n            continue\n\n        if isinstance(allowlist_for_data, Allow):\n            allowed = allowlist_for_data\n\n            if allowed is Allow.SIMPLE_TYPE and isinstance(data_value, (str, int, float, bool)):\n                stripped_data[data_key] = data_value\n            else:\n                continue\n\n        elif isinstance(data_value, Mapping):\n            stripped_data[data_key] = _strip_event_data_with_allowlist(\n                data_value, allowlist_for_data\n            )\n        elif isinstance(data_value, Sequence):\n            stripped_data[data_key] = [\n                _strip_event_data_with_allowlist(item, allowlist_for_data) for item in data_value\n            ]\n\n    return stripped_data\n\n\ndef _strip_frames(\n    frames: Sequence[Mapping[str, Any]], sdk_crash_detector: SDKCrashDetector\n) -> Sequence[Mapping[str, Any]]:\n    \"\"\"\n    Only keep SDK frames or Apple system libraries.\n    We need to adapt this logic once we support other platforms.\n    \"\"\"\n\n    def is_system_library(frame: Mapping[str, Any]) -> bool:\n        fields_containing_paths = {\"package\", \"module\", \"abs_path\"}\n        system_library_paths = {\"/System/Library/\", \"/usr/lib/system/\"}\n\n        for field in fields_containing_paths:\n            for path in system_library_paths:\n                if frame.get(field, \"\").startswith(path):\n                    return True\n\n        return False\n\n    return [\n        frame\n        for frame in frames\n        if sdk_crash_detector.is_sdk_frame(frame) or is_system_library(frame)\n    ]\n", "path": "src/sentry/utils/sdk_crashes/event_stripper.py"}], "after_files": [{"content": "from enum import Enum, auto\nfrom typing import Any, Dict, Mapping, MutableMapping, Optional, Sequence\n\nfrom sentry.db.models import NodeData\nfrom sentry.utils.safe import get_path\nfrom sentry.utils.sdk_crashes.sdk_crash_detector import SDKCrashDetector\n\n\nclass Allow(Enum):\n    def __init__(self, explanation: str = \"\") -> None:\n        self.explanation = explanation\n\n    \"\"\"Keeps the event data if it is of type str, int, float, bool.\"\"\"\n    SIMPLE_TYPE = auto()\n\n    \"\"\"\n    Doesn't keep the event data no matter the type. This can be used to explicitly\n    specify that data should be removed with an explanation.\n    \"\"\"\n    NEVER = auto()\n\n    def with_explanation(self, explanation: str) -> \"Allow\":\n        self.explanation = explanation\n        return self\n\n\nEVENT_DATA_ALLOWLIST = {\n    \"type\": Allow.SIMPLE_TYPE,\n    \"datetime\": Allow.SIMPLE_TYPE,\n    \"timestamp\": Allow.SIMPLE_TYPE,\n    \"platform\": Allow.SIMPLE_TYPE,\n    \"sdk\": {\n        \"name\": Allow.SIMPLE_TYPE,\n        \"version\": Allow.SIMPLE_TYPE,\n        \"integrations\": Allow.NEVER.with_explanation(\"Users can add their own integrations.\"),\n    },\n    \"exception\": {\n        \"values\": {\n            \"stacktrace\": {\n                \"frames\": {\n                    \"filename\": Allow.SIMPLE_TYPE,\n                    \"function\": Allow.SIMPLE_TYPE,\n                    \"raw_function\": Allow.SIMPLE_TYPE,\n                    \"module\": Allow.SIMPLE_TYPE,\n                    \"abs_path\": Allow.SIMPLE_TYPE,\n                    \"in_app\": Allow.SIMPLE_TYPE,\n                    \"instruction_addr\": Allow.SIMPLE_TYPE,\n                    \"addr_mode\": Allow.SIMPLE_TYPE,\n                    \"symbol\": Allow.SIMPLE_TYPE,\n                    \"symbol_addr\": Allow.SIMPLE_TYPE,\n                    \"image_addr\": Allow.SIMPLE_TYPE,\n                    \"package\": Allow.SIMPLE_TYPE,\n                    \"platform\": Allow.SIMPLE_TYPE,\n                }\n            },\n            \"value\": Allow.NEVER.with_explanation(\"The exception value could contain PII.\"),\n            \"type\": Allow.SIMPLE_TYPE,\n            \"mechanism\": {\n                \"handled\": Allow.SIMPLE_TYPE,\n                \"type\": Allow.SIMPLE_TYPE,\n                \"meta\": {\n                    \"signal\": {\n                        \"number\": Allow.SIMPLE_TYPE,\n                        \"code\": Allow.SIMPLE_TYPE,\n                        \"name\": Allow.SIMPLE_TYPE,\n                        \"code_name\": Allow.SIMPLE_TYPE,\n                    },\n                    \"mach_exception\": {\n                        \"exception\": Allow.SIMPLE_TYPE,\n                        \"code\": Allow.SIMPLE_TYPE,\n                        \"subcode\": Allow.SIMPLE_TYPE,\n                        \"name\": Allow.SIMPLE_TYPE,\n                    },\n                },\n            },\n        }\n    },\n    \"contexts\": {\n        \"device\": {\n            \"family\": Allow.SIMPLE_TYPE,\n            \"model\": Allow.SIMPLE_TYPE,\n            \"arch\": Allow.SIMPLE_TYPE,\n        },\n        \"os\": {\n            \"name\": Allow.SIMPLE_TYPE,\n            \"version\": Allow.SIMPLE_TYPE,\n            \"build\": Allow.SIMPLE_TYPE,\n        },\n    },\n}\n\n\ndef strip_event_data(\n    event_data: NodeData, sdk_crash_detector: SDKCrashDetector\n) -> Mapping[str, Any]:\n    new_event_data = _strip_event_data_with_allowlist(event_data, EVENT_DATA_ALLOWLIST)\n\n    if (new_event_data is None) or (new_event_data == {}):\n        return {}\n\n    frames = get_path(new_event_data, \"exception\", \"values\", -1, \"stacktrace\", \"frames\")\n\n    if frames is not None:\n        stripped_frames = _strip_frames(frames, sdk_crash_detector)\n\n        new_event_data[\"exception\"][\"values\"][0][\"stacktrace\"][\"frames\"] = stripped_frames\n\n    return new_event_data\n\n\ndef _strip_event_data_with_allowlist(\n    data: Mapping[str, Any], allowlist: Optional[Mapping[str, Any]]\n) -> Optional[Mapping[str, Any]]:\n    \"\"\"\n    Recursively traverses the data and only keeps values based on the allowlist.\n    \"\"\"\n    if allowlist is None:\n        return None\n\n    stripped_data: Dict[str, Any] = {}\n    for data_key, data_value in data.items():\n        allowlist_for_data = allowlist.get(data_key)\n        if allowlist_for_data is None:\n            continue\n\n        if isinstance(allowlist_for_data, Allow):\n            allowed = allowlist_for_data\n\n            if allowed is Allow.SIMPLE_TYPE and isinstance(data_value, (str, int, float, bool)):\n                stripped_data[data_key] = data_value\n            else:\n                continue\n\n        elif isinstance(data_value, Mapping):\n            stripped_data[data_key] = _strip_event_data_with_allowlist(\n                data_value, allowlist_for_data\n            )\n        elif isinstance(data_value, Sequence):\n            stripped_data[data_key] = [\n                _strip_event_data_with_allowlist(item, allowlist_for_data) for item in data_value\n            ]\n\n    return stripped_data\n\n\ndef _strip_frames(\n    frames: Sequence[MutableMapping[str, Any]], sdk_crash_detector: SDKCrashDetector\n) -> Sequence[Mapping[str, Any]]:\n    \"\"\"\n    Only keep SDK frames or Apple system libraries.\n    We need to adapt this logic once we support other platforms.\n    \"\"\"\n\n    def is_system_library(frame: Mapping[str, Any]) -> bool:\n        fields_containing_paths = {\"package\", \"module\", \"abs_path\"}\n        system_library_paths = {\"/System/Library/\", \"/usr/lib/system/\"}\n\n        for field in fields_containing_paths:\n            for path in system_library_paths:\n                if frame.get(field, \"\").startswith(path):\n                    return True\n\n        return False\n\n    def strip_frame(frame: MutableMapping[str, Any]) -> MutableMapping[str, Any]:\n        if sdk_crash_detector.is_sdk_frame(frame):\n            frame[\"in_app\"] = True\n        else:\n            frame[\"in_app\"] = False\n        return frame\n\n    return [\n        strip_frame(frame)\n        for frame in frames\n        if sdk_crash_detector.is_sdk_frame(frame) or is_system_library(frame)\n    ]\n", "path": "src/sentry/utils/sdk_crashes/event_stripper.py"}]}