MarkGaox / soot-skeleton

Automatically enumerates some options in a Soot based on user determined example output and input and generates a starter script.
2 stars 2 forks source link

User Input Example When "if statement" involves #12

Open MarkGaox opened 4 years ago

MarkGaox commented 4 years ago

Code: String a = "abc"; String x = ""; if (x.equals("")) { a = "cba"; } System.out.println(a);

Output: virtualinvoke r1.<java.lang.String: boolean equals(java.lang.Object)>("") virtualinvoke $r2.<java.io.PrintStream: void println(java.lang.String)>(r3)

Question: How can users actually find r3?

Solution So Far: What I can think of is to let the user indicate a local variable in their example. ie,

<java.io.PrintStream: void println(java.lang.String)>(r)

Then we handle that case manually.

izgzhen commented 4 years ago

You can either use a named variable or an actual wildcard (e.g. _) for this purpose

izgzhen commented 4 years ago

Then, in your validate procedure, you can check based on this type of pattern that contains named or unnamed wildcard variable

izgzhen commented 4 years ago

e.g. if the actual output is:

virtualinvoke $r2.<java.io.PrintStream: void println(java.lang.String)>(r3)

it can match with user provided output:

virtualinvoke _.<java.io.PrintStream: void println(java.lang.String)>(_)
izgzhen commented 4 years ago

You might need to parse jimple statement somehow