Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(proguard): add support for frame signature #1425

Merged
merged 5 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- proguard: Added a mandatory `index` field to `JvmFrame` (#1411) by @loewenheim
- proguard: Support for source contex (#1414) by @loewenheim
- proguard: Field `lineno` on `JvmFrame` is now optional (#1417) by @loewenheim
- proguard: support method deobfuscation based on parameters mapping (#1418) by @viglia
- proguard: add support for frame signature (#1425 )by @viglia

### Dependencies

Expand Down
52 changes: 28 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/symbolicator-proguard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "MIT"

[dependencies]
futures = "0.3.12"
proguard = "5.4.0"
proguard = "5.4.1"
serde = { version = "1.0.137", features = ["derive", "rc"] }
serde_json = "1.0.81"
symbolic = "12.8.0"
Expand Down
6 changes: 2 additions & 4 deletions crates/symbolicator-proguard/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,12 @@ pub struct JvmFrame {
/// expanded from the frame with index `i` will also have index `i`.
pub index: usize,

/// Comma separated list of method's parameters.
/// Method signature.
///
/// This has to be set when we want to deobfuscate based on the function parameters
/// instead of using line numbers.
///
/// example of parameters list: `okio.Buffer,long`
#[serde(skip_serializing_if = "Option::is_none")]
pub parameters: Option<String>,
pub signature: Option<String>,
}

/// An exception in a JVM event.
Expand Down
30 changes: 26 additions & 4 deletions crates/symbolicator-proguard/src/symbolication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,35 @@ impl ProguardService {
frame: &JvmFrame,
release_package: Option<&str>,
) -> Vec<JvmFrame> {
let deobfuscated_signature: Option<proguard::DeobfuscatedSignature> =
frame.signature.as_ref().and_then(|signature| {
for mapper in mappers {
if let Some(deobfuscated_signature) = mapper.deobfuscate_signature(signature) {
return Some(deobfuscated_signature);
}
}
None
});
let params = deobfuscated_signature
.as_ref()
.map_or(String::new(), |sig| {
String::from_iter(sig.parameters_types().map(|param| format!("{},", param)))
});
viglia marked this conversation as resolved.
Show resolved Hide resolved
let stack_frame = frame
.lineno
.map(|lineno| {
proguard::StackFrame::new(&frame.module, &frame.function, lineno as usize)
})
.or_else(|| {
frame.parameters.as_ref().map(|params| {
proguard::StackFrame::with_parameters(
if deobfuscated_signature.as_ref().is_some() {
viglia marked this conversation as resolved.
Show resolved Hide resolved
Some(proguard::StackFrame::with_parameters(
&frame.module,
&frame.function,
params.as_str(),
)
})
))
} else {
None
}
});

// First, try to remap the whole frame.
Expand Down Expand Up @@ -241,6 +257,12 @@ impl ProguardService {
mapped_frame.in_app = Some(true);
}
}
// if there is a signature that has been deobfuscated,
// add it to the mapped frame
if deobfuscated_signature.is_some() {
mapped_frame.signature =
Some(deobfuscated_signature.as_ref().unwrap().format_signature());
}
viglia marked this conversation as resolved.
Show resolved Hide resolved
mapped_frame
})
.collect();
Expand Down