Skip to content

Commit

Permalink
Revert "feat(profiling): Deobfuscate Android methods' signature (#53427
Browse files Browse the repository at this point in the history
…)"

This reverts commit 6584123.

Co-authored-by: phacops <336345+phacops@users.noreply.github.com>
  • Loading branch information
getsentry-bot and phacops committed Jul 25, 2023
1 parent 75d6446 commit af3ae3b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 197 deletions.
97 changes: 0 additions & 97 deletions src/sentry/profiles/java.py

This file was deleted.

50 changes: 16 additions & 34 deletions src/sentry/profiles/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from sentry.lang.native.symbolicator import RetrySymbolication, Symbolicator, SymbolicatorTaskKind
from sentry.models import EventError, Organization, Project, ProjectDebugFile
from sentry.profiles.device import classify_device
from sentry.profiles.java import deobfuscate_signature
from sentry.profiles.utils import get_from_profiling_service
from sentry.signals import first_profile_received
from sentry.tasks.base import instrumented_task
Expand Down Expand Up @@ -619,52 +618,35 @@ def _deobfuscate(profile: Profile, project: Project) -> None:

with sentry_sdk.start_span(op="proguard.remap"):
for method in profile["profile"]["methods"]:
method.setdefault("data", {})

mapped = mapper.remap_frame(
method["class_name"], method["name"], method["source_line"] or 0
)

if "signature" in method and method["signature"]:
method["signature"] = deobfuscate_signature(mapper, method["signature"])

if len(mapped) >= 1:
new_frame = mapped[-1]
method["class_name"] = new_frame.class_name
method["name"] = new_frame.method
method["data"] = {
"deobfuscation_status": "deobfuscated"
if method.get("signature", None)
else "partial"
}

if new_frame.file:
method["source_file"] = new_frame.file

if new_frame.line:
method["source_line"] = new_frame.line

method.setdefault("data", {})
if len(mapped) == 1:
new_frame = mapped[0]
method.update(
{
"class_name": new_frame.class_name,
"name": new_frame.method,
"source_file": new_frame.file,
"source_line": new_frame.line,
}
)
method["data"]["deobfuscation_status"] = "deobfuscated"
elif len(mapped) > 1:
bottom_class = mapped[-1].class_name
method["inline_frames"] = [
{
"class_name": new_frame.class_name,
"data": {"deobfuscation_status": "deobfuscated"},
"name": new_frame.method,
"source_file": method["source_file"]
if bottom_class == new_frame.class_name
else "",
else None,
"source_line": new_frame.line,
"data": {"deobfuscation_status": "deobfuscated"},
}
for new_frame in reversed(mapped)
for new_frame in mapped
]

# vroom will only take into account frames in this list
# if it exists. since symbolic does not return a signature for
# the frame we deobfuscated, we update it to set
# the deobfuscated signature.
if len(method["inline_frames"]) > 0:
method["inline_frames"][0]["data"] = method["data"]
method["inline_frames"][0]["signature"] = method.get("signature", "")
else:
mapped_class = mapper.remap_class(method["class_name"])
if mapped_class:
Expand Down
50 changes: 0 additions & 50 deletions tests/sentry/profiles/test_java.py

This file was deleted.

25 changes: 9 additions & 16 deletions tests/sentry/profiles/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,16 @@ def test_basic_deobfuscation(self):
"profile": {
"methods": [
{
"name": "a",
"abs_path": None,
"class_name": "org.a.b.g$a",
"name": "a",
"signature": "()V",
"source_file": None,
"source_line": 67,
},
{
"name": "a",
"abs_path": None,
"class_name": "org.a.b.g$a",
"name": "a",
"signature": "()V",
"source_file": None,
"source_line": 69,
},
Expand Down Expand Up @@ -180,18 +178,16 @@ def test_inline_deobfuscation(self):
"profile": {
"methods": [
{
"name": "onClick",
"abs_path": None,
"class_name": "e.a.c.a",
"name": "onClick",
"signature": "()V",
"source_file": None,
"source_line": 2,
},
{
"name": "t",
"abs_path": None,
"class_name": "io.sentry.sample.MainActivity",
"name": "t",
"signature": "()V",
"source_file": "MainActivity.java",
"source_line": 1,
},
Expand All @@ -204,24 +200,21 @@ def test_inline_deobfuscation(self):
_deobfuscate(profile, project)
frames = profile["profile"]["methods"]

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

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

assert frames[1]["inline_frames"][0]["name"] == "onClickHandler"
assert frames[1]["inline_frames"][0]["source_line"] == 40
assert frames[1]["inline_frames"][0]["source_file"] == "MainActivity.java"
assert frames[1]["inline_frames"][0]["class_name"] == "io.sentry.sample.MainActivity"
assert frames[1]["inline_frames"][0]["signature"] == "()"

assert frames[1]["inline_frames"][0]["name"] == "bar"
assert frames[1]["inline_frames"][0]["source_line"] == 54
assert frames[1]["inline_frames"][1]["name"] == "foo"
assert frames[1]["inline_frames"][1]["source_line"] == 44

assert frames[1]["inline_frames"][2]["name"] == "onClickHandler"
assert frames[1]["inline_frames"][2]["source_line"] == 40
assert frames[1]["inline_frames"][2]["source_file"] == "MainActivity.java"
assert frames[1]["inline_frames"][2]["class_name"] == "io.sentry.sample.MainActivity"
assert frames[1]["inline_frames"][2]["name"] == "bar"
assert frames[1]["inline_frames"][2]["source_line"] == 54

def test_error_on_resolving(self):
out = BytesIO()
Expand Down

0 comments on commit af3ae3b

Please sign in to comment.