Skip to content

Commit

Permalink
update.
Browse files Browse the repository at this point in the history
  • Loading branch information
hac425xxx committed Nov 7, 2024
1 parent 6c4fca3 commit ad35d65
Show file tree
Hide file tree
Showing 22 changed files with 4,173 additions and 53 deletions.
2 changes: 2 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ lazy val ghidra2cpg = Projects.ghidra2cpg
lazy val x2cpg = Projects.x2cpg
lazy val pysrc2cpg = Projects.pysrc2cpg
lazy val php2cpg = Projects.php2cpg
lazy val ida2cpg = Projects.ida2cpg
lazy val jssrc2cpg = Projects.jssrc2cpg
lazy val javasrc2cpg = Projects.javasrc2cpg
lazy val jimple2cpg = Projects.jimple2cpg
Expand All @@ -36,6 +37,7 @@ lazy val aggregatedProjects: Seq[ProjectReference] = Seq(
x2cpg,
pysrc2cpg,
php2cpg,
ida2cpg,
ghidra2cpg,
jssrc2cpg,
javasrc2cpg,
Expand Down
1 change: 1 addition & 0 deletions console/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependsOn(
Projects.javasrc2cpg,
Projects.jssrc2cpg,
Projects.php2cpg,
Projects.ida2cpg,
Projects.pysrc2cpg,
Projects.rubysrc2cpg,
Projects.swiftsrc2cpg,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.joern.console.cpgcreation

import io.joern.console.FrontendConfig
import io.joern.php2cpg.{Config, Frontend, Php2Cpg}
import io.joern.x2cpg.X2Cpg
import io.joern.x2cpg.passes.frontend.XTypeRecoveryConfig
import io.shiftleft.codepropertygraph.Cpg

import java.nio.file.Path
import scala.util.Try

case class IdaCpgGenerator(config: FrontendConfig, rootPath: Path) extends CpgGenerator {
private lazy val command: Path = if (isWin) rootPath.resolve("ida2cpg.bat") else rootPath.resolve("ida2cpg")
private var phpConfig: Option[Config] = None

override def generate(inputPath: String, outputPath: String): Try[String] = {
val arguments = List(inputPath) ++ Seq("-o", outputPath) ++ config.cmdLineParams
phpConfig = X2Cpg.parseCommandLine(arguments.toArray, Frontend.cmdLineParser, Config())
runShellCommand(command.toString, arguments).map(_ => outputPath)
}

override def isAvailable: Boolean =
command.toFile.exists

override def isJvmBased = true

override def applyPostProcessingPasses(cpg: Cpg): Cpg = {
cpg
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class ImportCode[T <: Project](console: io.joern.console.Console[T]) extends Rep
def csharp: Frontend = new BinaryFrontend("csharp", Languages.CSHARP, "C# Source Frontend (Roslyn)")
def llvm: Frontend = new BinaryFrontend("llvm", Languages.LLVM, "LLVM Bitcode Frontend")
def php: SourceBasedFrontend = new SourceBasedFrontend("php", Languages.PHP, "PHP source frontend", "php")
def ida: SourceBasedFrontend = new SourceBasedFrontend("ida", "IDA", "IDA Hexray AST frontend", "json")
def ruby: SourceBasedFrontend = new RubyFrontend("Ruby source frontend", false)
def rubyDeprecated: SourceBasedFrontend = new RubyFrontend("Ruby source deprecated frontend", true)

Expand All @@ -79,6 +80,7 @@ class ImportCode[T <: Project](console: io.joern.console.Console[T]) extends Rep
golang,
llvm,
php,
ida,
python,
csharp,
ruby,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ package object cpgcreation {
case Languages.KOTLIN => Some(KotlinCpgGenerator(conf, rootPath))
case Languages.RUBYSRC => Some(RubyCpgGenerator(conf, rootPath))
case Languages.SWIFTSRC => Some(SwiftSrcCpgGenerator(conf, rootPath))
case "IDA" => Some(IdaCpgGenerator(conf, rootPath))
case _ => None
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ class DdgGenerator {
val ddgNodes = visibleNodes
.filter(node => allIdsReferencedByEdges.contains(node.id))
.map(surroundingCall)
.filterNot(node => node.isInstanceOf[Call] && isGenericMemberAccessName(node.asInstanceOf[Call].name))
// .filterNot(node => node.isInstanceOf[Call] && isGenericMemberAccessName(node.asInstanceOf[Call].name))

val ddgEdges = edges.flatten
.map { edge =>
edge.copy(src = surroundingCall(edge.src), dst = surroundingCall(edge.dst))
}
.filter(e => e.src != e.dst)
.filterNot(e => e.dst.isInstanceOf[Call] && isGenericMemberAccessName(e.dst.asInstanceOf[Call].name))
.filterNot(e => e.src.isInstanceOf[Call] && isGenericMemberAccessName(e.src.asInstanceOf[Call].name))
// .filterNot(e => e.dst.isInstanceOf[Call] && isGenericMemberAccessName(e.dst.asInstanceOf[Call].name))
// .filterNot(e => e.src.isInstanceOf[Call] && isGenericMemberAccessName(e.src.asInstanceOf[Call].name))
.distinct

edgeCache.clear()
Expand Down
Loading

0 comments on commit ad35d65

Please sign in to comment.