Commit 8d3b1564 authored by Sam Maier's avatar Sam Maier Committed by Commit Bot

java_deobfuscate tool allowing whitespace and NullPtrExceptions

Bug: 833764, 891721
Change-Id: I0a8f06b391765bcd911a4ccb4e1f0ba1a312b0c2
Reviewed-on: https://chromium-review.googlesource.com/c/1269706
Commit-Queue: Sam Maier <smaier@chromium.org>
Reviewed-by: default avataragrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#598759}
parent 339739f6
......@@ -34,13 +34,17 @@ public class FlushingReTrace {
// Eagerly match logcat prefix to avoid conflicting with the patterns below.
LOGCAT_PREFIX
+ "(?:"
// Based on default ReTrace regex, but with "at" changed to to allow :
// E.g.: 06-22 13:58:02.895 4674 4674 E THREAD_STATE: bLA.a(PG:173)
// Based on default ReTrace regex, but with whitespaces allowed in file:line parentheses
// and "at" changed to to allow :
// E.g.: 06-22 13:58:02.895 4674 4674 E THREAD_STATE: bLA.a( PG : 173 )
// Normal stack trace lines look like:
// \tat org.chromium.chrome.browser.tab.Tab.handleJavaCrash(Tab.java:682)
+ "(?:.*?(?::|\\bat)\\s+%c\\.%m\\s*\\(%s(?::%l)?\\))|"
+ "(?:.*?(?::|\\bat)\\s+%c\\.%m\\s*\\(\\s*%s(?:\\s*:\\s*%l\\s*)?\\))|"
// E.g.: VFY: unable to resolve new-instance 3810 (LSome/Framework/Class;) in Lfoo/Bar;
+ "(?:.*L%C;.*)|"
// E.g.: Caused by: java.lang.NullPointerException: Attempt to read from field 'int bLA'
// on a null object reference
+ "(?:.*NullPointerException.*[\"']%t\\s*%c\\.(?:%f|%m\\(%a\\))[\"'].*)|"
// E.g.: END SomeTestClass#someMethod
+ "(?:.*?%c#%m.*?)|"
// E.g.: The member "Foo.bar"
......
......@@ -27,40 +27,56 @@ LINE_PREFIXES = [
TEST_MAP = """\
this.was.Deobfuscated -> FOO:
int[] FontFamily -> a
1:3:void someMethod(int,android.os.Bundle):65:65 -> bar
1:3:void someMethod(int,android.os.Bundle):65:67 -> bar
"""
TEST_DATA = """\
Here is a FOO
Here is a FOO baz
Here is a "FOO" baz
Here is a "FOO.bar" baz
Here it is: FOO
Here it is: FOO.bar
SomeError: SomeFrameworkClass in isTestClass for FOO
Here is a FOO.bar
Here is a FOO.bar baz
END FOO#bar
new-instance 3810 (LSome/Framework/Class;) in LFOO;
FOO: Error message
\tat FOO.bar(PG:1)
""".splitlines(True)
EXPECTED_OUTPUT = """\
Here is a this.was.Deobfuscated
Here is a FOO baz
Here is a "this.was.Deobfuscated" baz
Here is a "this.was.Deobfuscated.someMethod" baz
Here it is: this.was.Deobfuscated
Here it is: this.was.Deobfuscated.someMethod
SomeError: SomeFrameworkClass in isTestClass for this.was.Deobfuscated
Here is a this.was.Deobfuscated.someMethod
Here is a FOO.bar baz
END this.was.Deobfuscated#someMethod
new-instance 3810 (LSome/Framework/Class;) in Lthis/was/Deobfuscated;
this.was.Deobfuscated: Error message
\tat this.was.Deobfuscated.someMethod(Deobfuscated.java:65)
""".splitlines(True)
TEST_DATA = [
"Here is a FOO",
"Here is a FOO baz",
"Here is a \"FOO\" baz",
"Here is a \"FOO.bar\" baz",
"Here it is: FOO",
"Here it is: FOO.bar",
"SomeError: SomeFrameworkClass in isTestClass for FOO",
"Here is a FOO.bar",
"Here is a FOO.bar baz",
"END FOO#bar",
"new-instance 3810 (LSome/Framework/Class;) in LFOO;",
"FOO: Error message",
"\tat FOO.bar(PG:1)",
"\t at\t FOO.bar\t (\t PG:\t 1\t )",
("Unable to start activity ComponentInfo{garbage.in/here.test}:"
" java.lang.NullPointerException: Attempt to invoke interface method 'void"
" FOO.bar(int,android.os.Bundle)' on a null object reference"),
("Caused by: java.lang.NullPointerException: Attempt to read from field"
" 'int[] FOO.a' on a null object reference"),
]
EXPECTED_OUTPUT = [
"Here is a this.was.Deobfuscated",
"Here is a FOO baz",
"Here is a \"this.was.Deobfuscated\" baz",
"Here is a \"this.was.Deobfuscated.someMethod\" baz",
"Here it is: this.was.Deobfuscated",
"Here it is: this.was.Deobfuscated.someMethod",
"SomeError: SomeFrameworkClass in isTestClass for this.was.Deobfuscated",
"Here is a this.was.Deobfuscated.someMethod",
"Here is a FOO.bar baz",
"END this.was.Deobfuscated#someMethod",
"new-instance 3810 (LSome/Framework/Class;) in Lthis/was/Deobfuscated;",
"this.was.Deobfuscated: Error message",
"\tat this.was.Deobfuscated.someMethod(Deobfuscated.java:65)",
("\t at\t this.was.Deobfuscated.someMethod\t "
"(\t Deobfuscated.java:\t 65\t )"),
("Unable to start activity ComponentInfo{garbage.in/here.test}:"
" java.lang.NullPointerException: Attempt to invoke interface method"
" 'void this.was.Deobfuscated.someMethod(int,android.os.Bundle)' on a null"
" object reference"),
("Caused by: java.lang.NullPointerException: Attempt to read from field"
" 'int[] this.was.Deobfuscated.FontFamily' on a null object reference"),
]
TEST_DATA = [s + "\n" for s in TEST_DATA]
EXPECTED_OUTPUT = [s + "\n" for s in EXPECTED_OUTPUT]
class JavaDeobfuscateTest(unittest.TestCase):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment