[Soot-list] how to get all path values of write/read operations

Linghui Luo linghui.luo at uni-paderborn.de
Tue Mar 13 04:40:51 EDT 2018


Hi Jing,

You can call getArgs() method from InvokeExpr to get the arguments passing the constructor.

    Stmt stmt = (Stmt) unit;
    InvokeExpr invokeExpr = stmt.getInvokeExpr();
    if(invokeExpr instanceof SpecialInvokeExpr)//constructor is a specialInvoke
    {
          for (int i = 0; i < invokeExpr.getArgCount(); i++) {
            Value arg=invokeExpr.getArg(i);
            //Here you can find out which variable storing the file name is passed to the constructor, then you can do backward analysis to track the value of this variable or while forward analysis always track the value of String variables.
          }
}

To find out the value assigned to the variable filename you just need to look into the interface AssignStmt, you can get the left and right operand of the assignment by calling get getLeftOp()/getRightOp().
               if(unit instanceof AssignStmt)
               {
                              AssignStmt assignStmt=(AssignStmt)unit;
                              Value leftOp=assignStmt.getLeftOp();
                              ….
}

Best,
Linghui Luo

_________________________________
M. Sc. Linghui Luo

Wissenschaftliche Mitarbeiterin/Research assistant

Fachgruppe Softwaretechnik
Heinz Nixdorf Institut
Universität Paderborn
Fürstenallee 11
33102 Paderborn

E-Mail: linghui.luo at uni-paderborn.de<mailto:linghui.luo at uni-paderborn.de>
Telefon: +49 5251 606568
Raum: F1.119

_________________________________

Von: Soot-list <soot-list-bounces at CS.McGill.CA> Im Auftrag von Jing Zhang
Gesendet: Montag, 5. März 2018 05:04
An: soot-list at cs.mcgill.ca
Betreff: [Soot-list] how to get all path values of write/read operations

Hi  All,

I want to get value of filename of write/read operations from code like:

(1) String filename = "**/**/**/**.txt" ;
BufferedWriter bfw = new BufferedWriter(new FileWriter(filename, true));

(2) filename = Environment.getExternalStorageDirectory().getCanonicalPath() + "/" + filename;
   FileOutputStream output = new FileOutputStream(filename);

(3) String filename = "123"+"**.txt" ;
outputStream = openFileOutput(filename, Context.MODE_APPEND);

Is there any helper methods inside Soot that can help me?


Thanks a lot

Jing



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20180313/d3020ec0/attachment-0001.html>


More information about the Soot-list mailing list