Skip to content

Commit 58ae896

Browse files
getsentry-botphacops
authored andcommitted
Revert "feat(profiling): Deobfuscate Android methods' signature (#53427)"
This reverts commit 6584123. Co-authored-by: phacops <[email protected]>
1 parent e73144d commit 58ae896

File tree

4 files changed

+25
-197
lines changed

4 files changed

+25
-197
lines changed

Diff for: src/sentry/profiles/java.py

-97
This file was deleted.

Diff for: src/sentry/profiles/task.py

+16-34
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from sentry.lang.native.symbolicator import RetrySymbolication, Symbolicator, SymbolicatorTaskKind
1919
from sentry.models import EventError, Organization, Project, ProjectDebugFile
2020
from sentry.profiles.device import classify_device
21-
from sentry.profiles.java import deobfuscate_signature
2221
from sentry.profiles.utils import get_from_profiling_service
2322
from sentry.signals import first_profile_received
2423
from sentry.tasks.base import instrumented_task
@@ -619,52 +618,35 @@ def _deobfuscate(profile: Profile, project: Project) -> None:
619618

620619
with sentry_sdk.start_span(op="proguard.remap"):
621620
for method in profile["profile"]["methods"]:
622-
method.setdefault("data", {})
623-
624621
mapped = mapper.remap_frame(
625622
method["class_name"], method["name"], method["source_line"] or 0
626623
)
627-
628-
if "signature" in method and method["signature"]:
629-
method["signature"] = deobfuscate_signature(mapper, method["signature"])
630-
631-
if len(mapped) >= 1:
632-
new_frame = mapped[-1]
633-
method["class_name"] = new_frame.class_name
634-
method["name"] = new_frame.method
635-
method["data"] = {
636-
"deobfuscation_status": "deobfuscated"
637-
if method.get("signature", None)
638-
else "partial"
639-
}
640-
641-
if new_frame.file:
642-
method["source_file"] = new_frame.file
643-
644-
if new_frame.line:
645-
method["source_line"] = new_frame.line
646-
624+
method.setdefault("data", {})
625+
if len(mapped) == 1:
626+
new_frame = mapped[0]
627+
method.update(
628+
{
629+
"class_name": new_frame.class_name,
630+
"name": new_frame.method,
631+
"source_file": new_frame.file,
632+
"source_line": new_frame.line,
633+
}
634+
)
635+
method["data"]["deobfuscation_status"] = "deobfuscated"
636+
elif len(mapped) > 1:
647637
bottom_class = mapped[-1].class_name
648638
method["inline_frames"] = [
649639
{
650640
"class_name": new_frame.class_name,
651-
"data": {"deobfuscation_status": "deobfuscated"},
652641
"name": new_frame.method,
653642
"source_file": method["source_file"]
654643
if bottom_class == new_frame.class_name
655-
else "",
644+
else None,
656645
"source_line": new_frame.line,
646+
"data": {"deobfuscation_status": "deobfuscated"},
657647
}
658-
for new_frame in reversed(mapped)
648+
for new_frame in mapped
659649
]
660-
661-
# vroom will only take into account frames in this list
662-
# if it exists. since symbolic does not return a signature for
663-
# the frame we deobfuscated, we update it to set
664-
# the deobfuscated signature.
665-
if len(method["inline_frames"]) > 0:
666-
method["inline_frames"][0]["data"] = method["data"]
667-
method["inline_frames"][0]["signature"] = method.get("signature", "")
668650
else:
669651
mapped_class = mapper.remap_class(method["class_name"])
670652
if mapped_class:

Diff for: tests/sentry/profiles/test_java.py

-50
This file was deleted.

Diff for: tests/sentry/profiles/test_task.py

+9-16
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,16 @@ def test_basic_deobfuscation(self):
127127
"profile": {
128128
"methods": [
129129
{
130+
"name": "a",
130131
"abs_path": None,
131132
"class_name": "org.a.b.g$a",
132-
"name": "a",
133-
"signature": "()V",
134133
"source_file": None,
135134
"source_line": 67,
136135
},
137136
{
137+
"name": "a",
138138
"abs_path": None,
139139
"class_name": "org.a.b.g$a",
140-
"name": "a",
141-
"signature": "()V",
142140
"source_file": None,
143141
"source_line": 69,
144142
},
@@ -180,18 +178,16 @@ def test_inline_deobfuscation(self):
180178
"profile": {
181179
"methods": [
182180
{
181+
"name": "onClick",
183182
"abs_path": None,
184183
"class_name": "e.a.c.a",
185-
"name": "onClick",
186-
"signature": "()V",
187184
"source_file": None,
188185
"source_line": 2,
189186
},
190187
{
188+
"name": "t",
191189
"abs_path": None,
192190
"class_name": "io.sentry.sample.MainActivity",
193-
"name": "t",
194-
"signature": "()V",
195191
"source_file": "MainActivity.java",
196192
"source_line": 1,
197193
},
@@ -204,24 +200,21 @@ def test_inline_deobfuscation(self):
204200
_deobfuscate(profile, project)
205201
frames = profile["profile"]["methods"]
206202

207-
assert sum(len(f.get("inline_frames", [])) for f in frames) == 3
203+
assert sum(len(f.get("inline_frames", [{}])) for f in frames) == 4
208204

209205
assert frames[0]["name"] == "onClick"
210206
assert frames[0]["class_name"] == "io.sentry.sample.-$$Lambda$r3Avcbztes2hicEObh02jjhQqd4"
211207

212-
assert frames[1]["inline_frames"][0]["name"] == "onClickHandler"
213-
assert frames[1]["inline_frames"][0]["source_line"] == 40
214208
assert frames[1]["inline_frames"][0]["source_file"] == "MainActivity.java"
215209
assert frames[1]["inline_frames"][0]["class_name"] == "io.sentry.sample.MainActivity"
216-
assert frames[1]["inline_frames"][0]["signature"] == "()"
217-
210+
assert frames[1]["inline_frames"][0]["name"] == "bar"
211+
assert frames[1]["inline_frames"][0]["source_line"] == 54
218212
assert frames[1]["inline_frames"][1]["name"] == "foo"
219213
assert frames[1]["inline_frames"][1]["source_line"] == 44
220-
214+
assert frames[1]["inline_frames"][2]["name"] == "onClickHandler"
215+
assert frames[1]["inline_frames"][2]["source_line"] == 40
221216
assert frames[1]["inline_frames"][2]["source_file"] == "MainActivity.java"
222217
assert frames[1]["inline_frames"][2]["class_name"] == "io.sentry.sample.MainActivity"
223-
assert frames[1]["inline_frames"][2]["name"] == "bar"
224-
assert frames[1]["inline_frames"][2]["source_line"] == 54
225218

226219
def test_error_on_resolving(self):
227220
out = BytesIO()

0 commit comments

Comments
 (0)