Skip to content

Commit

Permalink
Merge branch 'master' into revert/sync_1_6_16
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxology authored Jul 30, 2024
2 parents 11cef55 + 41b751e commit e27fef8
Show file tree
Hide file tree
Showing 95 changed files with 2,536 additions and 2,384 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ You can run `./regenerate-test-cpgs.sh` to update them, but this requires the pr
sbt semanticcpg/console
```
```scala
import io.shiftleft.codepropertygraph.Cpg
import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.semanticcpg.language._
val cpg = io.shiftleft.codepropertygraph.cpgloading.CpgLoader.load("./resources/testcode/cpgs/hello-shiftleft-0.0.5/cpg.bin.zip")
```
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name := "codepropertygraph"

// parsed by project/Versions.scala, updated by updateDependencies.sh
val overflowdbVersion = "0.1.4"
val overflowdbCodegenVersion = "2.107"
val overflowdbCodegenVersion = "2.110"

inThisBuild(
List(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.shiftleft

import io.shiftleft.codepropertygraph.Cpg
import io.shiftleft.codepropertygraph.generated.Cpg
import overflowdb.Graph

object OverflowDbTestInstance {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.shiftleft.codepropertygraph.cpgloading

import better.files.File
import io.shiftleft.codepropertygraph.Cpg
import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.codepropertygraph.generated.PropertyNames
import org.slf4j.{Logger, LoggerFactory}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.shiftleft.codepropertygraph.cpgloading

import com.google.protobuf.GeneratedMessageV3
import io.shiftleft.codepropertygraph.Cpg
import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.proto.cpg.Cpg.CpgStruct.Edge
import io.shiftleft.proto.cpg.Cpg.CpgStruct.Edge.EdgeType
import io.shiftleft.proto.cpg.Cpg.{CpgOverlay, CpgStruct}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.shiftleft.codepropertygraph.cpgloading

import io.shiftleft.codepropertygraph.Cpg
import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.proto.cpg.Cpg.CpgStruct.Edge.EdgeType
import io.shiftleft.proto.cpg.Cpg.CpgStruct.{Edge, Node}
import io.shiftleft.proto.cpg.Cpg.PropertyValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ abstract class ForkJoinParallelCpgPass[T <: AnyRef](
var nDiff = -1
var nDiffT = -1
try {
val diffGraph = new DiffGraphBuilder
val diffGraph = Cpg.newDiffGraphBuilder
nParts = runWithBuilder(diffGraph)
nanosBuilt = System.nanoTime()
nDiff = diffGraph.size()
Expand Down Expand Up @@ -200,7 +200,7 @@ abstract class NewStyleCpgPassBase[T <: AnyRef] extends CpgPassBase {
val diff = stream.collect(
new Supplier[DiffGraphBuilder] {
override def get(): DiffGraphBuilder =
new DiffGraphBuilder
Cpg.newDiffGraphBuilder
},
new BiConsumer[DiffGraphBuilder, AnyRef] {
override def accept(builder: DiffGraphBuilder, part: AnyRef): Unit =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ abstract class ConcurrentWriterCpgPass[T <: AnyRef](
// todo: Verify that we get FIFO scheduling; otherwise, do something about it.
// if this e.g. used LIFO with 4 cores and 18 size of ringbuffer, then 3 cores may idle while we block on the front item.
completionQueue.append(Future.apply {
val builder = new DiffGraphBuilder
val builder = Cpg.newDiffGraphBuilder
runOnPart(builder, next.asInstanceOf[T])
builder.build()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.shiftleft.passes

import better.files.File
import io.shiftleft.SerializedCpg
import io.shiftleft.codepropertygraph.Cpg
import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.codepropertygraph.generated.nodes.NewFile
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
Expand All @@ -14,10 +14,10 @@ class CpgPassNewTests extends AnyWordSpec with Matchers {

private object Fixture {
def apply(keyPool: Option[KeyPool] = None)(f: (Cpg, CpgPassBase) => Unit): Unit = {
val cpg = Cpg.emptyCpg
val cpg = Cpg.empty
class MyPass(cpg: Cpg) extends SimpleCpgPass(cpg, "MyPass", keyPool) {
override def run(builder: DiffGraphBuilder): Unit = {
val builder2 = new DiffGraphBuilder
val builder2 = Cpg.newDiffGraphBuilder
builder.addNode(NewFile().name("foo"))
builder2.addNode(NewFile().name("bar"))
builder.absorb(builder2)
Expand Down Expand Up @@ -52,7 +52,7 @@ class CpgPassNewTests extends AnyWordSpec with Matchers {
}

"fail for schema violations" in {
val cpg = Cpg.emptyCpg
val cpg = Cpg.empty
val pass = new SimpleCpgPass(cpg, "pass1") {
override def run(dst: DiffGraphBuilder): Unit = {
val file1 = NewFile().name("foo")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.shiftleft.passes

import better.files.File
import io.shiftleft.SerializedCpg
import io.shiftleft.codepropertygraph.Cpg
import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.codepropertygraph.generated.Properties
import io.shiftleft.codepropertygraph.generated.nodes.{NewCall, NewFile}
import org.scalatest.matchers.should.Matchers
Expand All @@ -16,7 +16,7 @@ class ParallelCpgPassNewTests extends AnyWordSpec with Matchers {

private object Fixture {
def apply(keyPools: Option[Iterator[KeyPool]] = None)(f: (Cpg, CpgPassBase) => Unit): Unit = {
val cpg = Cpg.emptyCpg
val cpg = Cpg.empty
val pool = keyPools.flatMap(_.nextOption())
class MyPass(cpg: Cpg) extends ConcurrentWriterCpgPass[String](cpg, "MyPass", pool) {
override def generateParts(): Array[String] = Array("foo", "bar")
Expand All @@ -33,7 +33,7 @@ class ParallelCpgPassNewTests extends AnyWordSpec with Matchers {
"ConcurrentWriterCpgPass" should {
"allow creating and applying result of pass" in Fixture() { (cpg, pass) =>
pass.createAndApply()
cpg.graph.nodes.map(_.property(Properties.NAME)).toSetMutable shouldBe Set("foo", "bar")
cpg.graph.nodes.map(_.property(Properties.Name)).toSetMutable shouldBe Set("foo", "bar")
}

"produce a serialized CPG file" in Fixture() { (_, pass) =>
Expand All @@ -56,7 +56,7 @@ class ParallelCpgPassNewTests extends AnyWordSpec with Matchers {
}

"fail for schema violations" in {
val cpg = Cpg.emptyCpg
val cpg = Cpg.empty
val pass = new ConcurrentWriterCpgPass[String](cpg, "pass2") {
override def generateParts() = Array("a", "b")
override def runOnPart(diffGraph: DiffGraphBuilder, part: String): Unit =
Expand All @@ -83,7 +83,7 @@ class ParallelCpgPassNewTests extends AnyWordSpec with Matchers {
}

"add NewNodes that are referenced in different parts only once" in {
val cpg = Cpg.emptyCpg
val cpg = Cpg.empty
val pass = new ConcurrentWriterCpgPass[String](cpg, "pass2") {
val call1 = NewCall().name("call1")
val call2 = NewCall().name("call2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ object Cpg {
case other => other
}

def newDiffGraphBuilder: DiffGraphBuilder = new DiffGraphBuilder
}

/** Domain-specific wrapper for graph, starting point for traversals.
Expand Down
Loading

0 comments on commit e27fef8

Please sign in to comment.