duan5858
duan5858

Reputation: 11

How can I get a precise callgraph for a web Application using spring FrameWork by soot SPARK?

I want to get a precise callgraph (using soot SPARK) when analysising a web Application using spring FrameWork, but I have one big problem to solve: Spring use DI (Dependency Injection) to manage beans , which means we don't need to create an Object. For this instance, I can't get precise callgraph (using SPARK) for some interface.

Example: When I use soot to get the call graph by SPARK( mainClass = AnimalMain.main(String[] args)), it can't find the implement class of "Animal pig" and "Animal human", so the result don't contains any edge about "pig.eat()". So it is not practical for Web Applications using Spring FrameWork。

How can I get a precise callgraph ?

public class AnimalMain {
@Autowired
Animal pig;

@Autowired
Animal human;

Tree pineTree = new PineTree();

public static void main(String[] args) {
    AnimalMain animalMain = new AnimalMain();
    animalMain.eat();
}

void eat() {
    pig.eat();
    pineTree.grow();
}
}

public interface Animal {
void eat();
}
@component(value = "pig")
public class Pig implements Animal {

@Override
public void eat() {
    System.out.println(doEat());
}

private String doEat() {
    return "pig eat";
}
}

@component(value = "human")
public class Human implements Animal {
@override
public void eat() {
System.out.println("human eat ……");
}
}

Upvotes: 1

Views: 323

Answers (1)

Eric
Eric

Reputation: 1393

We (the Soot team) do not have a well working solution for this yet, but we are working on this at the moment.

Upvotes: 1

Related Questions