Skip to content

Commit a4d265d

Browse files
author
Tebogo Selahle
committed
Merge remote-tracking branch 'origin/master' into andrei/ruby-erb-support
2 parents 5710607 + 5c53497 commit a4d265d

File tree

93 files changed

+1177
-739
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1177
-739
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name := "joern"
22
ThisBuild / organization := "io.joern"
33
ThisBuild / scalaVersion := "3.6.4"
44

5-
val cpgVersion = "1.7.43"
5+
val cpgVersion = "1.7.46"
66

77
lazy val joerncli = Projects.joerncli
88
lazy val querydb = Projects.querydb

console/src/main/scala/io/joern/console/cpgcreation/CpgGenerator.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ abstract class CpgGenerator() {
4343
|""".stripMargin
4444
)
4545

46-
val exitValue = ExternalCommand.run(cmd).exitCode
47-
assert(exitValue == 0, s"Error running shell command: exitValue=$exitValue; $cmd")
46+
ExternalCommand.run(cmd, additionalContext = cmd.toString).logIfFailed().verifySuccess()
4847
}
4948

5049
protected lazy val maxMemoryParameter = {

joern-cli/frontends/c2cpg/src/main/scala/io/joern/c2cpg/C2Cpg.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ import scala.util.control.NonFatal
1919
import scala.util.Try
2020
import scala.util.matching.Regex
2121

22-
class C2Cpg extends X2CpgFrontend[Config] {
22+
class C2Cpg extends X2CpgFrontend {
23+
final override type ConfigType = Config
24+
override val defaultConfig = Config()
2325

2426
private val logger = LoggerFactory.getLogger(classOf[C2Cpg])
2527

joern-cli/frontends/c2cpg/src/main/scala/io/joern/c2cpg/Main.scala

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,46 +17,50 @@ final case class Config(
1717
includePathsAutoDiscovery: Boolean = false,
1818
skipFunctionBodies: Boolean = false,
1919
withPreprocessedFiles: Boolean = false,
20-
compilationDatabaseFilename: Option[String] = None
20+
compilationDatabaseFilename: Option[String] = None,
21+
override val genericConfig: X2CpgConfig.GenericConfig = X2CpgConfig.GenericConfig()
2122
) extends X2CpgConfig[Config] {
23+
24+
override def withGenericConfig(value: X2CpgConfig.GenericConfig): Config = copy(genericConfig = value)
25+
2226
def withIncludePaths(includePaths: Set[String]): Config = {
23-
this.copy(includePaths = includePaths).withInheritedFields(this)
27+
this.copy(includePaths = includePaths)
2428
}
2529

2630
def withDefines(defines: Set[String]): Config = {
27-
this.copy(defines = defines).withInheritedFields(this)
31+
this.copy(defines = defines)
2832
}
2933

3034
def withIncludeComments(value: Boolean): Config = {
31-
this.copy(includeComments = value).withInheritedFields(this)
35+
this.copy(includeComments = value)
3236
}
3337

3438
def withLogProblems(value: Boolean): Config = {
35-
this.copy(logProblems = value).withInheritedFields(this)
39+
this.copy(logProblems = value)
3640
}
3741

3842
def withLogPreprocessor(value: Boolean): Config = {
39-
this.copy(logPreprocessor = value).withInheritedFields(this)
43+
this.copy(logPreprocessor = value)
4044
}
4145

4246
def withPrintIfDefsOnly(value: Boolean): Config = {
43-
this.copy(printIfDefsOnly = value).withInheritedFields(this)
47+
this.copy(printIfDefsOnly = value)
4448
}
4549

4650
def withIncludePathsAutoDiscovery(value: Boolean): Config = {
47-
this.copy(includePathsAutoDiscovery = value).withInheritedFields(this)
51+
this.copy(includePathsAutoDiscovery = value)
4852
}
4953

5054
def withSkipFunctionBodies(value: Boolean): Config = {
51-
this.copy(skipFunctionBodies = value).withInheritedFields(this)
55+
this.copy(skipFunctionBodies = value)
5256
}
5357

5458
def withPreprocessedFiles(value: Boolean): Config = {
55-
this.copy(withPreprocessedFiles = value).withInheritedFields(this)
59+
this.copy(withPreprocessedFiles = value)
5660
}
5761

5862
def withCompilationDatabase(value: String): Config = {
59-
this.copy(compilationDatabaseFilename = Option(value)).withInheritedFields(this)
63+
this.copy(compilationDatabaseFilename = Option(value))
6064
}
6165
}
6266

@@ -116,16 +120,13 @@ private object Frontend {
116120

117121
}
118122

119-
object Main extends X2CpgMain(cmdLineParser, new C2Cpg()) with FrontendHTTPServer[Config, C2Cpg] {
123+
object Main extends X2CpgMain(new C2Cpg(), cmdLineParser) {
120124

121-
override def run(config: Config, c2cpg: C2Cpg): Unit = {
125+
override def run(config: frontend.ConfigType): Unit = {
122126
config match {
123-
case c if c.serverMode => startup(); config.serverTimeoutSeconds.foreach(serveUntilTimeout)
124-
case c if c.printIfDefsOnly => c2cpg.printIfDefsOnly(config)
125-
case _ => c2cpg.run(config)
127+
case c: Config if c.printIfDefsOnly => frontend.asInstanceOf[C2Cpg].printIfDefsOnly(c)
128+
case _ => super.run(config)
126129
}
127130
}
128131

129-
override protected def newDefaultConfig(): Config = Config()
130-
131132
}

joern-cli/frontends/c2cpg/src/test/scala/io/joern/c2cpg/config/ConfigTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ConfigTests extends AnyWordSpec with Matchers with Inside {
3939
s.takeRight(n)
4040
}
4141

42-
inside(X2Cpg.parseCommandLine(args, parser, Config())) { case Some(config) =>
42+
inside(X2Cpg.parseCommandLine(args, parser, Main.frontend.defaultConfig)) { case Some(config: Config) =>
4343
config.inputPath.endsWith("INPUT") shouldBe true
4444
config.outputPath shouldBe "OUTPUT"
4545
config.ignoredFiles.map(getSuffix(_, 13)).toSet shouldBe Set("1EXCLUDE_FILE", "2EXCLUDE_FILE")

joern-cli/frontends/c2cpg/src/test/scala/io/joern/c2cpg/io/C2CpgHTTPServerTests.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ class C2CpgHTTPServerTests extends AnyWordSpec with Matchers with BeforeAndAfter
3838
}
3939

4040
override def beforeAll(): Unit = {
41-
// Start server
42-
port = io.joern.c2cpg.Main.startup()
41+
port = io.joern.c2cpg.Main.server.startup()
4342
}
4443

4544
override def afterAll(): Unit = {
46-
// Stop server
47-
io.joern.c2cpg.Main.stop()
45+
io.joern.c2cpg.Main.server.stop()
4846
}
4947

5048
"Using c2cpg in server mode" should {

joern-cli/frontends/c2cpg/src/test/scala/io/joern/c2cpg/passes/FullNameUniquenessPassTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class FullNameUniquenessPassTests extends C2CpgSuite {
123123
)
124124
cpg.call
125125
.map(c =>
126-
s"${c.name} in ${c.file.map(_.name).head} -> CALL -> ${c.methodFullName} in ${c.callOut.filename.head}"
126+
s"${c.name} in ${c.file.map(_.name).head} -> CALL -> ${c.methodFullName} in ${c.staticCallOut.filename.head}"
127127
)
128128
.sorted
129129
.l shouldBe List(

joern-cli/frontends/c2cpg/src/test/scala/io/joern/c2cpg/testfixtures/AstC2CpgFrontend.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import io.shiftleft.codepropertygraph.generated.Cpg
1414
import io.shiftleft.semanticcpg.utils.FileUtil
1515

1616
trait AstC2CpgFrontend extends LanguageFrontend {
17+
override type ConfigType = Config
18+
1719
def execute(sourceCodePath: java.io.File): Cpg = {
1820
val cpgOutFile = FileUtil.newTemporaryFile(suffix = "cpg.bin")
1921
FileUtil.deleteOnExit(cpgOutFile)

joern-cli/frontends/c2cpg/src/test/scala/io/joern/c2cpg/testfixtures/C2CpgFrontend.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import io.shiftleft.codepropertygraph.generated.Cpg
77
import io.shiftleft.semanticcpg.utils.FileUtil
88

99
trait C2CpgFrontend extends LanguageFrontend {
10+
override type ConfigType = Config
11+
1012
def execute(sourceCodePath: java.io.File): Cpg = {
1113
val cpgOutFile = FileUtil.newTemporaryFile(suffix = "cpg.bin")
1214
FileUtil.deleteOnExit(cpgOutFile)

joern-cli/frontends/csharpsrc2cpg/src/main/scala/io/joern/csharpsrc2cpg/CSharpSrc2Cpg.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ import scala.concurrent.duration.Duration
3131
import scala.concurrent.{Await, Future}
3232
import scala.util.{Failure, Success, Try}
3333

34-
class CSharpSrc2Cpg extends X2CpgFrontend[Config] {
34+
class CSharpSrc2Cpg extends X2CpgFrontend {
35+
override type ConfigType = Config
36+
override val defaultConfig: Config = Config()
3537

36-
private val logger = LoggerFactory.getLogger(getClass)
38+
private val logger = LoggerFactory.getLogger(classOf[CSharpSrc2Cpg])
3739
private val report: Report = new Report()
3840

3941
override def createCpg(config: Config): Try[Cpg] = {

0 commit comments

Comments
 (0)