From 8e51b6e016e5fdb7373c0d45726863c747509fc1 Mon Sep 17 00:00:00 2001 From: Francesco Vigliaturo Date: Mon, 13 Nov 2023 17:01:08 +0100 Subject: [PATCH] ref: refactor rust bindings to support optional parameters for StackFrame (#820) * Refactor rust bindings to support optional parameters for StackFrame --- CHANGELOG.md | 8 ++++++ Cargo.lock | 46 ++++++++++++++++---------------- py/symbolic/proguard.py | 13 +++++++-- symbolic-cabi/Cargo.toml | 2 +- symbolic-cabi/include/symbolic.h | 6 +++-- symbolic-cabi/src/proguard.rs | 10 ++++++- 6 files changed, 56 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 833eca5b..cd880c77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +**Internal** + +**Features** + +- Add support for `parameters` param in the `remap_frame` to allow deobfuscation when line is not available ([#820](https://github.com/getsentry/symbolic/pull/820)) + +**Fixes** + ## 12.5.0 **Internal** diff --git a/Cargo.lock b/Cargo.lock index 0168869e..8e1192d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,7 +23,7 @@ dependencies = [ [[package]] name = "addr2line" -version = "12.4.1" +version = "12.5.0" dependencies = [ "anyhow", "clap", @@ -519,7 +519,7 @@ dependencies = [ [[package]] name = "debuginfo_debug" -version = "12.4.1" +version = "12.5.0" dependencies = [ "anyhow", "clap", @@ -543,7 +543,7 @@ checksum = "f0bc8fbe9441c17c9f46f75dfe27fa1ddb6c68a461ccaed0481419219d4f10d3" [[package]] name = "dump_cfi" -version = "12.4.1" +version = "12.5.0" dependencies = [ "anyhow", "clap", @@ -552,7 +552,7 @@ dependencies = [ [[package]] name = "dump_sources" -version = "12.4.1" +version = "12.5.0" dependencies = [ "clap", "symbolic", @@ -1080,7 +1080,7 @@ dependencies = [ [[package]] name = "minidump_stackwalk" -version = "12.4.1" +version = "12.5.0" dependencies = [ "async-trait", "clap", @@ -1242,7 +1242,7 @@ dependencies = [ [[package]] name = "object_debug" -version = "12.4.1" +version = "12.5.0" dependencies = [ "clap", "symbolic", @@ -1450,9 +1450,9 @@ dependencies = [ [[package]] name = "proguard" -version = "5.1.0" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1766d401c716ab2d5ddc832468b420e4c51e37c4491ea94fd856ef652664a8d3" +checksum = "c0a4fc2794b6ee3ae207c36fb970a591e590dc6e1d36444f1de135529b285d88" dependencies = [ "lazy_static", "uuid", @@ -1857,7 +1857,7 @@ dependencies = [ [[package]] name = "sourcemapcache_debug" -version = "12.4.1" +version = "12.5.0" dependencies = [ "anyhow", "clap", @@ -2076,7 +2076,7 @@ dependencies = [ [[package]] name = "symbolic" -version = "12.4.1" +version = "12.5.0" dependencies = [ "symbolic-cfi", "symbolic-common", @@ -2091,7 +2091,7 @@ dependencies = [ [[package]] name = "symbolic-cabi" -version = "12.4.1" +version = "12.5.0" dependencies = [ "proguard", "sourcemap", @@ -2101,7 +2101,7 @@ dependencies = [ [[package]] name = "symbolic-cfi" -version = "12.4.1" +version = "12.5.0" dependencies = [ "insta", "similar-asserts", @@ -2113,7 +2113,7 @@ dependencies = [ [[package]] name = "symbolic-common" -version = "12.4.1" +version = "12.5.0" dependencies = [ "debugid", "memmap2 0.8.0", @@ -2127,7 +2127,7 @@ dependencies = [ [[package]] name = "symbolic-debuginfo" -version = "12.4.1" +version = "12.5.0" dependencies = [ "criterion", "debugid", @@ -2162,7 +2162,7 @@ dependencies = [ [[package]] name = "symbolic-demangle" -version = "12.4.1" +version = "12.5.0" dependencies = [ "cc", "cpp_demangle", @@ -2174,7 +2174,7 @@ dependencies = [ [[package]] name = "symbolic-il2cpp" -version = "12.4.1" +version = "12.5.0" dependencies = [ "indexmap", "serde_json", @@ -2184,7 +2184,7 @@ dependencies = [ [[package]] name = "symbolic-ppdb" -version = "12.4.1" +version = "12.5.0" dependencies = [ "flate2", "indexmap", @@ -2200,7 +2200,7 @@ dependencies = [ [[package]] name = "symbolic-sourcemapcache" -version = "12.4.1" +version = "12.5.0" dependencies = [ "itertools 0.11.0", "js-source-scopes", @@ -2214,7 +2214,7 @@ dependencies = [ [[package]] name = "symbolic-symcache" -version = "12.4.1" +version = "12.5.0" dependencies = [ "criterion", "indexmap", @@ -2231,11 +2231,11 @@ dependencies = [ [[package]] name = "symbolic-testutils" -version = "12.4.1" +version = "12.5.0" [[package]] name = "symbolic-unreal" -version = "12.4.1" +version = "12.5.0" dependencies = [ "anylog", "bytes", @@ -2255,7 +2255,7 @@ dependencies = [ [[package]] name = "symcache_debug" -version = "12.4.1" +version = "12.5.0" dependencies = [ "anyhow", "clap", @@ -2511,7 +2511,7 @@ checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "unreal_engine_crash" -version = "12.4.1" +version = "12.5.0" dependencies = [ "clap", "symbolic", diff --git a/py/symbolic/proguard.py b/py/symbolic/proguard.py index a2c04fb3..0ab5d1ed 100644 --- a/py/symbolic/proguard.py +++ b/py/symbolic/proguard.py @@ -19,12 +19,18 @@ class JavaStackFrame: def __init__( - self, class_name: str, method: str, line: int, file: str | None = None + self, + class_name: str, + method: str, + line: int, + file: str | None = None, + parameters: str | None = None, ) -> None: self.class_name = class_name self.method = method self.file = file or None self.line = line + self.parameters = parameters class ProguardMapper(RustObject): @@ -74,13 +80,16 @@ def remap_method(self, klass: str, method: str) -> Tuple[str, str] | None: return output if len(output[0]) > 0 and len(output[1]) > 0 else None - def remap_frame(self, klass: str, method: str, line: int) -> list[JavaStackFrame]: + def remap_frame( + self, klass: str, method: str, line: int, parameters: str = "" + ) -> list[JavaStackFrame]: """Remaps the stackframe, given its class, method and line.""" result = self._methodcall( lib.symbolic_proguardmapper_remap_frame, encode_str(klass), encode_str(method), line, + encode_str(parameters), ) frames = [] diff --git a/symbolic-cabi/Cargo.toml b/symbolic-cabi/Cargo.toml index 8ea5437e..56cdbc6a 100644 --- a/symbolic-cabi/Cargo.toml +++ b/symbolic-cabi/Cargo.toml @@ -20,7 +20,7 @@ publish = false crate-type = ["cdylib"] [dependencies] -proguard = { version = "5.1.0", features = ["uuid"] } +proguard = { version = "5.3.0", features = ["uuid"] } sourcemap = "7.0.0" symbolic = { version = "12.5.0", path = "../symbolic", features = ["cfi", "debuginfo", "sourcemapcache", "symcache"] } tempfile = "3.4.0" diff --git a/symbolic-cabi/include/symbolic.h b/symbolic-cabi/include/symbolic.h index fa739693..87506e8a 100644 --- a/symbolic-cabi/include/symbolic.h +++ b/symbolic-cabi/include/symbolic.h @@ -3,7 +3,7 @@ #ifndef SYMBOLIC_H_INCLUDED #define SYMBOLIC_H_INCLUDED -/* Generated with cbindgen:0.24.5 */ +/* Generated with cbindgen:0.26.0 */ /* Warning, this file is autogenerated. Do not modify this manually. */ @@ -167,6 +167,7 @@ typedef struct SymbolicJavaStackFrame { struct SymbolicStr method; struct SymbolicStr file; uintptr_t line; + struct SymbolicStr parameters; } SymbolicJavaStackFrame; /** @@ -512,7 +513,8 @@ void symbolic_proguardmapper_free(struct SymbolicProguardMapper *mapper); struct SymbolicProguardRemapResult symbolic_proguardmapper_remap_frame(const struct SymbolicProguardMapper *mapper, const struct SymbolicStr *class_, const struct SymbolicStr *method, - uintptr_t line); + uintptr_t line, + const struct SymbolicStr *parameters); /** * Remaps a class name. diff --git a/symbolic-cabi/src/proguard.rs b/symbolic-cabi/src/proguard.rs index 3d3b627f..bc46db07 100644 --- a/symbolic-cabi/src/proguard.rs +++ b/symbolic-cabi/src/proguard.rs @@ -15,6 +15,7 @@ pub struct SymbolicJavaStackFrame { pub method: SymbolicStr, pub file: SymbolicStr, pub line: usize, + pub parameters: SymbolicStr, } /// The result of remapping a Stack Frame. @@ -80,9 +81,14 @@ ffi_fn! { class: *const SymbolicStr, method: *const SymbolicStr, line: usize, + parameters: *const SymbolicStr, ) -> Result { let mapper = &SymbolicProguardMapper::as_rust(mapper).inner.get().mapper; - let frame = StackFrame::new((*class).as_str(), (*method).as_str(), line); + let frame = if (*parameters).len > 0 { + StackFrame::with_parameters((*class).as_str(), (*method).as_str(), (*parameters).as_str()) + } else { + StackFrame::new((*class).as_str(), (*method).as_str(), line) + }; let mut frames: Vec<_> = mapper.remap_frame(&frame).map(|frame| { SymbolicJavaStackFrame { @@ -90,6 +96,7 @@ ffi_fn! { method: frame.method().to_owned().into(), file: frame.file().unwrap_or("").to_owned().into(), line: frame.line(), + parameters: frame.parameters().unwrap_or("").to_owned().into(), } }).collect(); @@ -137,6 +144,7 @@ ffi_fn! { method: remapped_method.to_owned().into(), file: "".to_owned().into(), line: 0, + parameters: "".to_owned().into(), }]; frames.shrink_to_fit();