Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with upstream v1.6.16 #4

Merged
merged 5 commits into from
Jul 1, 2024
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
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 @@ -2,7 +2,7 @@ package io.shiftleft.passes

import com.google.protobuf.GeneratedMessageV3
import io.shiftleft.SerializedCpg
import io.shiftleft.codepropertygraph.Cpg
import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.utils.StatsLogger
import org.slf4j.{Logger, LoggerFactory, MDC}
import overflowdb.BatchedUpdate
Expand Down Expand Up @@ -70,7 +70,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 @@ -148,7 +148,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
@@ -1,6 +1,6 @@
package io.shiftleft.passes
import io.shiftleft.SerializedCpg
import io.shiftleft.codepropertygraph.Cpg
import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.utils.{ExecutionContextProvider, StatsLogger}
import org.slf4j.MDC

Expand Down 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
Loading