Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ trait AstC2CpgFrontend extends LanguageFrontend {
override type ConfigType = Config

def execute(sourceCodePath: java.io.File): Cpg = {
val cpgOutFile = FileUtil.newTemporaryFile(suffix = "cpg.bin")
FileUtil.deleteOnExit(cpgOutFile)
val cpg = newEmptyCpg(Option(cpgOutFile.toString))
val cpg = newEmptyCpg()
val pathAsString = sourceCodePath.getAbsolutePath
val config = getConfig()
.fold(Config())(_.asInstanceOf[Config])
.withInputPath(pathAsString)
.withOutputPath(pathAsString)
.withSchemaValidation(ValidationMode.Enabled)
val global = new CGlobal()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ trait C2CpgFrontend extends LanguageFrontend {
override type ConfigType = Config

def execute(sourceCodePath: java.io.File): Cpg = {
val cpgOutFile = FileUtil.newTemporaryFile(suffix = "cpg.bin")
FileUtil.deleteOnExit(cpgOutFile)
val c2cpg = new C2Cpg()
val config = getConfig()
.fold(Config())(_.asInstanceOf[Config])
.withInputPath(sourceCodePath.getAbsolutePath)
.withOutputPath(cpgOutFile.toString)
val res = c2cpg.createCpg(config).get
new PostFrontendValidator(res, false).run()
res
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ trait CSharpFrontend extends LanguageFrontend {
.getOrElse(Config().withSchemaValidation(ValidationMode.Enabled))

override def execute(sourceCodeFile: File): Cpg = {
val cpgOutFile = FileUtil.newTemporaryFile(suffix = "cpg.bin")
FileUtil.deleteOnExit(cpgOutFile)
val config = defaultConfig.withInputPath(sourceCodeFile.getAbsolutePath).withOutputPath(cpgOutFile.toString)
val config = defaultConfig.withInputPath(sourceCodeFile.getAbsolutePath)
val tmp = new CSharpSrc2Cpg().createCpg(config).get
new PostFrontendValidator(tmp, false).createAndApply()
tmp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,11 @@ class DefaultTestCpgWithGo(val fileSuffix: String) extends DefaultTestCpg with S
}

def execute(sourceCodePath: java.io.File): Cpg = {
val cpgOutFile = FileUtil.newTemporaryFile("go2cpg.bin")
FileUtil.deleteOnExit(cpgOutFile)
goSrc2Cpg = Some(new GoSrc2Cpg(this.goGlobal))
val config = getConfig()
.collectFirst { case x: Config => x }
.getOrElse(Config())
.withInputPath(sourceCodePath.getAbsolutePath)
.withOutputPath(cpgOutFile.toString)
val res = goSrc2Cpg.get.createCpg(config).get
new PostFrontendValidator(res, false).run()
res
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@ trait AstJsSrc2CpgFrontend extends LanguageFrontend {
override type ConfigType = Config

def execute(sourceCodePath: java.io.File): Cpg = {
val cpgOutFile = FileUtil.newTemporaryFile(suffix = "cpg.bin")
FileUtil.deleteOnExit(cpgOutFile)
val cpg = newEmptyCpg(Option(cpgOutFile.toString))
val cpg = newEmptyCpg()
val pathAsString = sourceCodePath.getAbsolutePath
val config = getConfig()
.fold(Config())(_.asInstanceOf[Config])
.withInputPath(pathAsString)
.withOutputPath(pathAsString)
val hash = HashUtil.sha256(pathAsString)

new JavaScriptMetaDataPass(cpg, hash, pathAsString).createAndApply()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ class Py2CpgTestContext {

def buildCpg: Cpg = {
val cpgOutFile = FileUtil.newTemporaryFile(suffix = "cpg.bin")
FileUtil.deleteOnExit(cpgOutFile)
val config = Py2CpgOnFileSystemConfig()
.withInputPath(absTestFilePath)
.withOutputPath(cpgOutFile.toString)
.withSchemaValidation(ValidationMode.Enabled)
.withDisableFileContent(!enableFileContent)
if (buildResult.isEmpty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ trait AstSwiftSrc2CpgFrontend extends LanguageFrontend {
final override type ConfigType = Config

def execute(sourceCodePath: java.io.File): Cpg = {
val cpgOutFile = FileUtil.newTemporaryFile(suffix = "cpg.bin")
FileUtil.deleteOnExit(cpgOutFile)
val cpg = newEmptyCpg(Option(cpgOutFile.toString))
val cpg = newEmptyCpg()
val pathAsString = sourceCodePath.getAbsolutePath
var config = Config()
.withInputPath(pathAsString)
.withOutputPath(cpgOutFile.toString)
getConfig().foreach(c => config = config.withDefines(c.defines))
val astGenResult = new AstGenRunner(config).execute(Paths.get(pathAsString))
val astCreationPass = new AstCreationPass(cpg, astGenResult, config)(ValidationMode.Enabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ trait SwiftCompilerSrc2CpgFrontend extends LanguageFrontend {
final override type ConfigType = Config

def execute(sourceCodePath: java.io.File): Cpg = {
val cpgOutFile = FileUtil.newTemporaryFile(suffix = "cpg.bin")
FileUtil.deleteOnExit(cpgOutFile)

val pathAsString = sourceCodePath.toPath.resolve("SwiftTest").toAbsolutePath.toString
var config = Config()
.withInputPath(pathAsString)
.withOutputPath(cpgOutFile.toString)
getConfig().foreach(c => config = config.withDefines(c.defines).withSwiftBuild(c.swiftBuild))

val cpg = new SwiftSrc2Cpg().createCpg(config).get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import scala.util.matching.Regex
import scala.util.{Failure, Success, Try}

object X2CpgConfig {
def defaultOutputPath: String = "cpg.bin"
def defaultOutputPath: String = ""

final case class GenericConfig(
inputPath: String = "",
Expand Down
Loading