Skip to content

Commit

Permalink
feat(proguard): Remap additional class names (#1496)
Browse files Browse the repository at this point in the history
This allows sending an additional list of class names not attached to any stack frame or exception with a proguard request. These classes will be deobfuscated and returned in the form of a map from obfuscated to deobfuscated names.

The intended use case is deobfuscating view hierarchies.
  • Loading branch information
loewenheim authored Jul 15, 2024
1 parent 042f98e commit ea02eb1
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#076)
- [diff](https://github.com/getsentry/sentry-native/compare/0.7.5...0.7.6)

### Various fixes & improvements

- The `symbolicate-jvm` endpoint now additionally accepts a list
`classes` of class names to deobfuscate. ([#1496](https://github.com/getsentry/symbolicator/pull/1496))
## 24.6.0

### Dependencies
Expand Down
7 changes: 5 additions & 2 deletions crates/symbolicator-proguard/src/interface.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::fmt;
use std::sync::Arc;
use std::{collections::HashMap, fmt};

use serde::{Deserialize, Serialize};
use symbolic::common::DebugId;
Expand All @@ -25,6 +25,8 @@ pub struct SymbolicateJvmStacktraces {
///
/// This is used to set a remapped frame's `in_app` field.
pub release_package: Option<String>,
/// An list of additional class names that should be remapped.
pub classes: Vec<Arc<str>>,
}

/// A stack frame in a JVM stacktrace.
Expand Down Expand Up @@ -159,14 +161,15 @@ pub struct ProguardError {
pub kind: ProguardErrorKind,
}

// TODO: Expand this
/// The symbolicated/remapped event data.
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
pub struct CompletedJvmSymbolicationResponse {
/// The exceptions after remapping.
pub exceptions: Vec<JvmException>,
/// The stacktraces after remapping.
pub stacktraces: Vec<JvmStacktrace>,
/// A mapping from obfuscated to remapped classes.
pub classes: HashMap<Arc<str>, Arc<str>>,
/// Errors that occurred during symbolication.
pub errors: Vec<ProguardError>,
}
14 changes: 14 additions & 0 deletions crates/symbolicator-proguard/src/symbolication.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::sync::Arc;

use crate::interface::{
CompletedJvmSymbolicationResponse, JvmException, JvmFrame, JvmModuleType, JvmStacktrace,
ProguardError, ProguardErrorKind, SymbolicateJvmStacktraces,
Expand Down Expand Up @@ -33,6 +35,7 @@ impl ProguardService {
modules,
release_package,
apply_source_context,
classes,
} = request;

let maybe_mappers = future::join_all(
Expand Down Expand Up @@ -141,9 +144,20 @@ impl ProguardService {
}
}

let remapped_classes = classes
.into_iter()
.filter_map(|class| {
let remapped = mappers
.iter()
.find_map(|mapper| mapper.remap_class(&class))?;
Some((class, Arc::from(remapped)))
})
.collect();

CompletedJvmSymbolicationResponse {
exceptions: remapped_exceptions,
stacktraces: remapped_stacktraces,
classes: remapped_classes,
errors,
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/symbolicator-proguard/tests/integration/proguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fn make_jvm_request(
exceptions,
stacktraces,
modules,
classes: Vec::new(),
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/symbolicator-proguard/tests/integration/proguard.rs
assertion_line: 517
expression: response
---
exceptions:
Expand Down Expand Up @@ -110,4 +109,5 @@ stacktraces:
- "}"
- ""
index: 6
classes: {}
errors: []
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
source: crates/symbolicator-proguard/tests/integration/proguard.rs
assertion_line: 122
expression: response
---
exceptions:
- type: Util$ClassContextSecurityManager
module: org.slf4j.helpers
stacktraces:
- frames: []
classes: {}
errors: []
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/symbolicator-proguard/tests/integration/proguard.rs
assertion_line: 232
expression: response
---
exceptions:
Expand All @@ -27,4 +26,5 @@ stacktraces:
module: io.sentry.sample.MainActivity
lineno: 54
index: 1
classes: {}
errors: []
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/symbolicator-proguard/tests/integration/proguard.rs
assertion_line: 474
expression: response
---
exceptions:
Expand Down Expand Up @@ -172,6 +171,7 @@ stacktraces:
lineno: 26
in_app: true
index: 18
classes: {}
errors:
- uuid: 8236f5cf-52c8-4e35-a7cf-01421e4c2c88
type: missing
4 changes: 4 additions & 0 deletions crates/symbolicator/src/endpoints/symbolicate_jvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pub struct JvmSymbolicationRequestBody {
#[serde(default)]
pub release_package: Option<String>,
#[serde(default)]
pub classes: Vec<Arc<str>>,
#[serde(default)]
pub options: JvmRequestOptions,
}

Expand Down Expand Up @@ -62,6 +64,7 @@ pub async fn handle_symbolication_request(
stacktraces,
modules,
release_package,
classes,
options,
} = body;

Expand All @@ -72,6 +75,7 @@ pub async fn handle_symbolication_request(
stacktraces,
modules,
release_package,
classes,
apply_source_context: options.apply_source_context,
})?;

Expand Down

0 comments on commit ea02eb1

Please sign in to comment.