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

io.joern.console.Commit.scala Maven / Gradle / Ivy

There is a newer version: 4.0.131
Show newest version
package io.joern.console

import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.passes.CpgPass
import io.shiftleft.semanticcpg.layers.{LayerCreator, LayerCreatorContext, LayerCreatorOptions}
import io.shiftleft.codepropertygraph.generated.DiffGraphBuilder

object Commit {
  val overlayName: String = "commit"
  val description: String = "Apply current custom diffgraph"
  def defaultOpts         = new CommitOptions(Cpg.newDiffGraphBuilder)
}

class CommitOptions(var diffGraphBuilder: DiffGraphBuilder) extends LayerCreatorOptions

class Commit(opts: CommitOptions) extends LayerCreator {

  override val overlayName: String       = Commit.overlayName
  override val description: String       = Commit.description
  override val storeOverlayName: Boolean = false

  override def create(context: LayerCreatorContext): Unit = {
    val pass: CpgPass = new CpgPass(context.cpg) {
      override val name = "commit"
      override def run(builder: DiffGraphBuilder): Unit = {
        builder.absorb(opts.diffGraphBuilder)
      }
    }
    pass.createAndApply()
    opts.diffGraphBuilder = Cpg.newDiffGraphBuilder
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy