All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.joern.jimple2cpg.passes.SootAstCreationPass.scala Maven / Gradle / Ivy

There is a newer version: 4.0.77
Show newest version
package io.joern.jimple2cpg.passes

import io.joern.jimple2cpg.Config
import io.joern.jimple2cpg.astcreation.AstCreator
import io.joern.x2cpg.datastructures.Global
import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.passes.ForkJoinParallelCpgPass
import org.slf4j.LoggerFactory
import soot.{Scene, SootClass, SourceLocator}

/** Creates the AST layer from the given class file and stores all types in the given global parameter.
  */
class SootAstCreationPass(cpg: Cpg, config: Config) extends ForkJoinParallelCpgPass[SootClass](cpg) {

  val global: Global = new Global()
  private val logger = LoggerFactory.getLogger(classOf[AstCreationPass])

  override def generateParts(): Array[? <: AnyRef] = Scene.v().getApplicationClasses.toArray()

  override def runOnPart(builder: DiffGraphBuilder, part: SootClass): Unit = {
    val jimpleFile = SourceLocator.v().getSourceForClass(part.getName)
    try {
      // sootClass.setApplicationClass()
      val localDiff = new AstCreator(jimpleFile, part, global)(config.schemaValidation).createAst()
      builder.absorb(localDiff)
    } catch {
      case e: Exception =>
        logger.warn(s"Cannot parse: $part", e)
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy