Skip to content

Commit

Permalink
fix(proguard): Don't set in_app if frame wasn't mapped (#1440)
Browse files Browse the repository at this point in the history
  • Loading branch information
loewenheim committed Apr 17, 2024
1 parent 39fb6c8 commit 4acad52
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions crates/symbolicator-proguard/src/symbolication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,19 +248,25 @@ impl ProguardService {
mappers
.iter()
.find_map(|mapper| Self::map_class(mapper, frame))
})
// If all else fails, just return the original frame.
.unwrap_or_else(|| vec![frame.clone()]);
});

// Fix up the frames
for frame in &mut frames {
// mark the frame as in_app after deobfuscation based on the release package name
// only if it's not present
if let Some(package) = release_package {
if frame.module.starts_with(package) && frame.in_app.is_none() {
frame.in_app = Some(true);
// Fix up the frames' in-app fields only if they were actually mapped
if let Some(frames) = frames.as_mut() {
for frame in frames {
// mark the frame as in_app after deobfuscation based on the release package name
// only if it's not present
if let Some(package) = release_package {
if frame.module.starts_with(package) && frame.in_app.is_none() {
frame.in_app = Some(true);
}
}
}
}

// If all else fails, just return the original frame.
let mut frames = frames.unwrap_or_else(|| vec![frame.clone()]);

for frame in &mut frames {
// add the signature if we received one and we were
// able to translate/deobfuscate it
if let Some(signature) = &deobfuscated_signature {
Expand Down Expand Up @@ -638,6 +644,23 @@ org.slf4j.helpers.Util$ClassContext -> org.a.b.g$b:
assert_eq!(mapped_frames[4].in_app, Some(true));
}

#[test]
fn doesnt_set_in_app_if_not_resolved() {
let frame = JvmFrame {
function: "main".into(),
module: "android.app.ActivityThread".into(),
lineno: Some(8918),
..Default::default()
};

let remapped = ProguardService::map_frame(&[], &frame, Some("android"));

assert_eq!(remapped.len(), 1);
// The frame didn't get mapped, so we shouldn't set `in_app` even though
// the condition is satisfied.
assert!(remapped[0].in_app.is_none());
}

#[test]
fn line_0_1() {
let proguard_source = br#"com.example.App -> com.example.App:
Expand Down

0 comments on commit 4acad52

Please sign in to comment.