Skip to content

Commit

Permalink
🐛 Corrected Identifier's code for Static Field Access (#195)
Browse files Browse the repository at this point in the history
- Corrected Identifier's code for Static Field Access
  • Loading branch information
popthink authored Apr 27, 2021
1 parent 2c764e5 commit 90f405e
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import io.shiftleft.codepropertygraph.generated.nodes.*
import org.apache.logging.log4j.LogManager
import scala.Option
import soot.Local
import soot.SootClass
import soot.Unit
import soot.Value
import soot.jimple.*
Expand Down Expand Up @@ -787,7 +788,7 @@ class BaseCPGPass(private val g: BriefUnitGraph) {
when (fieldRef) {
is StaticFieldRef -> {
Pair( // TODO: Making this use an Identifier is a temporary fix for data flow passes to work
createIdentifierVertex(fieldRef, currentLine, currentCol, 1),
createIdentifierVertex(fieldRef.field.declaringClass, currentLine, currentCol, 1),
createFieldIdentifierVertex(fieldRef, currentLine, currentCol, 2)
)
}
Expand Down Expand Up @@ -878,6 +879,28 @@ class BaseCPGPass(private val g: BriefUnitGraph) {
LocalCache.getType(local.type.toQuotedString())?.let { t -> builder.addEdge(this, t, EVAL_TYPE) }
}

/**
* Creates a [NewIdentifier] from a [SootClass].
*/
private fun createIdentifierVertex(
clazz: SootClass,
currentLine: Int,
currentCol: Int,
childIdx: Int = 1
): NewIdentifierBuilder =
NewIdentifierBuilder()
.code(clazz.toString())
.name(clazz.toString())
.order(childIdx)
.argumentIndex(childIdx)
.typeFullName(clazz.type.toQuotedString())
.lineNumber(Option.apply(currentLine))
.columnNumber(Option.apply(currentCol))
.apply {
// LocalCache.getType(clazz.type.toQuotedString())?.let { t -> builder.addEdge(this, t, EVAL_TYPE) }
}


private fun projectInstanceOfExpr(expr: InstanceOfExpr, childIdx: Int): Pair<NewNodeBuilder, NewNodeBuilder> {
val (instanceOf, op1) = projectUnaryCall(expr, expr.op, childIdx)
instanceOf.name(Operators.instanceOf)
Expand Down

0 comments on commit 90f405e

Please sign in to comment.