Skip to content

Commit

Permalink
OverflowDB graphs now generated from `io.shiftleft.codepropertygraph.…
Browse files Browse the repository at this point in the history
…generated.Cpg` (#207)
  • Loading branch information
DavidBakerEffendi authored Sep 8, 2021
1 parent 5896bfb commit 714e096
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 21 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added

- `Extractor::project` now generated overloaded methods for Java

### Changed

- OverflowDB graphs now generated from `io.shiftleft.codepropertygraph.generated.Cpg`

## [0.5.13] - 2021-09-07

### Changed
Expand Down
1 change: 1 addition & 0 deletions plume/src/main/kotlin/io/github/plume/oss/Extractor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class Extractor(val driver: IDriver) {
* @param includeReachingDefs if true, will include calculating REACHING_DEF chains. If false, will keep method CPGs
* in memory storage.
*/
@JvmOverloads
fun project(includeReachingDefs: Boolean = true): Extractor {
/*
Load and compile files then feed them into Soot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import io.github.plume.oss.domain.mappers.VertexMapper.checkSchemaConstraints
import io.github.plume.oss.domain.model.DeltaGraph
import io.github.plume.oss.metrics.DriverTimeKey
import io.github.plume.oss.metrics.PlumeTimer
import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.codepropertygraph.generated.EdgeTypes.AST
import io.shiftleft.codepropertygraph.generated.NodeTypes.*
import io.shiftleft.codepropertygraph.generated.PropertyNames.FULL_NAME
Expand Down Expand Up @@ -481,10 +482,6 @@ abstract class GremlinDriver : IDriver {
}
}

protected fun newOverflowGraph(): overflowdb.Graph = overflowdb.Graph.open(
Config.withDefaults(),
NodeFactories.allAsJava(),
EdgeFactories.allAsJava()
)
protected fun newOverflowGraph(): overflowdb.Graph = Cpg.emptyGraph()

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import io.github.plume.oss.domain.mappers.VertexMapper.mapToVertex
import io.github.plume.oss.domain.model.DeltaGraph
import io.github.plume.oss.metrics.DriverTimeKey
import io.github.plume.oss.metrics.PlumeTimer
import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.codepropertygraph.generated.EdgeTypes.AST
import io.shiftleft.codepropertygraph.generated.EdgeTypes.SOURCE_FILE
import io.shiftleft.codepropertygraph.generated.NodeTypes.*
Expand Down Expand Up @@ -645,11 +646,7 @@ class Neo4jDriver internal constructor() : IDriver {
return l
}

private fun newOverflowGraph(): Graph = Graph.open(
Config.withDefaults(),
NodeFactories.allAsJava(),
EdgeFactories.allAsJava()
)
private fun newOverflowGraph(): Graph = Cpg.emptyGraph()

companion object {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import io.github.plume.oss.domain.mappers.VertexMapper.checkSchemaConstraints
import io.github.plume.oss.domain.model.DeltaGraph
import io.github.plume.oss.metrics.DriverTimeKey
import io.github.plume.oss.metrics.PlumeTimer
import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.codepropertygraph.generated.nodes.*
import org.apache.logging.log4j.LogManager
import overflowdb.*
Expand Down Expand Up @@ -317,10 +318,6 @@ class OverflowDbDriver internal constructor() : IDriver {
}
}

private fun newOverflowGraph(odbConfig: Config = Config.withDefaults()): Graph = Graph.open(
odbConfig,
NodeFactories.allAsJava(),
EdgeFactories.allAsJava()
)
private fun newOverflowGraph(odbConfig: Config = Config.withDefaults()): Graph = Cpg.withConfig(odbConfig).graph()

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import io.github.plume.oss.util.ExtractorConst
import io.github.plume.oss.util.ExtractorConst.BOOLEAN_TYPES
import io.github.plume.oss.util.ExtractorConst.INT_TYPES
import io.github.plume.oss.util.PlumeKeyProvider
import io.shiftleft.codepropertygraph.generated.Cpg
import io.shiftleft.codepropertygraph.generated.EdgeTypes
import io.shiftleft.codepropertygraph.generated.NodeTypes
import io.shiftleft.codepropertygraph.generated.NodeTypes.*
Expand Down Expand Up @@ -686,11 +687,7 @@ class TigerGraphDriver internal constructor() : IOverridenIdDriver, ISchemaSafeD
return out.toString()
}

private fun newOverflowGraph(): Graph = Graph.open(
Config.withDefaults(),
NodeFactories.allAsJava(),
EdgeFactories.allAsJava()
)
private fun newOverflowGraph(): Graph = Cpg.emptyGraph()

/**
* Uses the generated schema from [TigerGraphDriver.buildSchemaPayload] and remotely executes it on the database.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PlumeFrontend extends LanguageFrontend {
Using(DriverFactory.invoke(GraphDatabase.OVERFLOWDB).asInstanceOf[OverflowDbDriver]) { driver =>
driver.storageLocation(cpgFile.getAbsolutePath)
val extractor = new Extractor(driver)
extractor.load(sourceCodeFile).project(true)
extractor.load(sourceCodeFile).project()
LocalCache.INSTANCE.clear()
}
val odbConfig = overflowdb.Config.withDefaults().withStorageLocation(cpgFile.getAbsolutePath)
Expand Down

0 comments on commit 714e096

Please sign in to comment.