Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SVFA implementation #20

Open
wants to merge 46 commits into
base: develop
Choose a base branch
from

Conversation

galilasmb
Copy link

@galilasmb galilasmb commented Jun 22, 2023

In progress: should we add all assignments or only with new?

Fix:

  1. Create updateAllocationSites(): when we enter a new method, we update the allocationSites.
  2. When we visit a new method, we call updateAllocationSites()
  3. We create edges to the uses of an invoke statement
  4. We add the depth for the amount of visited methods
  5. Add Options.v().set_ignore_resolution_errors(true);

Comment on lines 200 to 201
val left = unit.asInstanceOf[soot.jimple.AssignStmt].getLeftOp
allocationSites += (left -> createNode(m, unit))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alterei somente estas duas linhas, caso remova-as, fica somente com o algoritmo de SVFA, funcionando somente com New, New Array e StringConstant

}

//add new allocation sites
updateAllocationSites(method)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modificação crucial, atualiza todos os allocationSites quando visita um novo método.

@@ -464,7 +467,10 @@ class Graph() {
sourceNodes.foreach(source => {
sinkNodes.foreach(sink => {
val paths = findPath(source, sink)
conflicts = conflicts ++ paths
val pathsHaveSameSourceAndSinkRootTraversedLine: Boolean = conflicts.exists(c => paths.exists(p => c.head.line() == p.head.line() && c.last.line() == p.last.line()))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignorar caminhos repetidos com mesma origem e destino.

@@ -275,7 +326,7 @@ abstract class JSVFA extends SVFA with Analysis with FieldSensitiveness with Obj

if(analyze(callStmt.base) == SinkNode) {
defsToCallOfSinkMethod(callStmt, exp, caller, defs)
return // TODO: we are not exploring the body of a sink method.
// return // TODO: we are not exploring the body of a sink method.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Não estava visitando métodos que eram sink. Removi o return.

@@ -285,6 +336,19 @@ abstract class JSVFA extends SVFA with Analysis with FieldSensitiveness with Obj
svg.addNode(source)
}

//Add edge from defs statements to invoke statement use
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Não estava adicionando arestas para invoke statements, por exemplo:

  1. stack1 = class...
  2. invoke stack1.m();

Não adicionava aresta de stack1 (linha 1) para o statement invoke (linha 2).

@@ -396,6 +466,11 @@ abstract class JSVFA extends SVFA with Analysis with FieldSensitiveness with Obj
allocationNodes = findFieldStores(base.asInstanceOf[Local], ref.getField)
}

//Search the defined allocationSites fields
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Procura por algum allocationSite de fields

@@ -699,6 +776,21 @@ abstract class JSVFA extends SVFA with Analysis with FieldSensitiveness with Obj
return res
}

// Search the defined allocationSites fields
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verifica se tem algum allocationSite de um de determinado field.

val right = unit.asInstanceOf[soot.jimple.AssignStmt].getRightOp
if (right.isInstanceOf[soot.jimple.InstanceInvokeExpr]){
val method = right.asInstanceOf[soot.jimple.InstanceInvokeExpr]
updateAllocationSites(method.getMethod)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se na direita também tiver uma chamada de método, atualiza os allocation sites. Por exemplo: stack0 = stack1.m()

}
}

if (unit.isInstanceOf[soot.jimple.InvokeStmt]){
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se for apenas uma chamada direta de método, atualiza os allocation sites. Por exemplo: stack1.m()


githubOwner := "rbonifacio"
githubOwner := "galilasmb"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alterar isso para o de Rodrigo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants