@@ -30,15 +30,14 @@ import io.shiftleft.semanticcpg.language.types.expressions.generalizations.CfgNo
30
30
import io .shiftleft .codepropertygraph .generated .EdgeTypes
31
31
import io .shiftleft .codepropertygraph .generated .NodeTypes
32
32
import io .shiftleft .codepropertygraph .generated .nodes
33
- import io .shiftleft .dataflowengine .language ._
33
+ import io .shiftleft .dataflowengineoss .language ._
34
34
import io .shiftleft .semanticcpg .language ._
35
35
import io .shiftleft .semanticcpg .language .types .expressions .Call
36
36
import io .shiftleft .semanticcpg .language .types .structure .Local
37
37
import io .shiftleft .codepropertygraph .generated .nodes .MethodParameterIn
38
38
39
- import gremlin .scala ._
40
- import org .apache .tinkerpop .gremlin .structure .Edge
41
- import org .apache .tinkerpop .gremlin .structure .VertexProperty
39
+ import overflowdb ._
40
+ import overflowdb .traversal ._
42
41
43
42
final case class GraphForFuncsFunction (function : String ,
44
43
file : String ,
@@ -48,12 +47,12 @@ final case class GraphForFuncsFunction(function: String,
48
47
PDG : List [nodes.AstNode ])
49
48
final case class GraphForFuncsResult (functions : List [GraphForFuncsFunction ])
50
49
51
- implicit val encodeEdge : Encoder [Edge ] =
52
- (edge : Edge ) =>
50
+ implicit val encodeEdge : Encoder [OdbEdge ] =
51
+ (edge : OdbEdge ) =>
53
52
Json .obj(
54
53
(" id" , Json .fromString(edge.toString)),
55
- (" in" , Json .fromString(edge.inVertex() .toString)),
56
- (" out" , Json .fromString(edge.outVertex() .toString))
54
+ (" in" , Json .fromString(edge.inNode .toString)),
55
+ (" out" , Json .fromString(edge.outNode .toString))
57
56
)
58
57
59
58
implicit val encodeNode : Encoder [nodes.AstNode ] =
@@ -62,10 +61,10 @@ implicit val encodeNode: Encoder[nodes.AstNode] =
62
61
(" id" , Json .fromString(node.toString)),
63
62
(" edges" ,
64
63
Json .fromValues((node.inE(" AST" , " CFG" ).l ++ node.outE(" AST" , " CFG" ).l).map(_.asJson))),
65
- (" properties" , Json .fromValues(node.properties() .asScala.toList.map { p : VertexProperty [_] =>
64
+ (" properties" , Json .fromValues(node.propertyMap .asScala.toList.map { case (key, value) =>
66
65
Json .obj(
67
- (" key" , Json .fromString(p. key() )),
68
- (" value" , Json .fromString(p. value() .toString))
66
+ (" key" , Json .fromString(key)),
67
+ (" value" , Json .fromString(value.toString))
69
68
)
70
69
}))
71
70
)
@@ -77,24 +76,22 @@ implicit val encodeFuncResult: Encoder[GraphForFuncsResult] = deriveEncoder
77
76
GraphForFuncsResult (
78
77
cpg.method.map { method =>
79
78
val methodName = method.fullName
80
- val methodFile = method.location.filename
81
79
val methodId = method.toString
80
+ val methodFile = method.location.filename
81
+ val methodVertex : Vertex = method // TODO MP drop as soon as we have the remainder of the below in ODB graph api
82
82
83
83
val astChildren = method.astMinusRoot.l
84
-
85
- val cfgChildren = new NodeSteps (
86
- method.out(EdgeTypes .CONTAINS ).filterOnEnd(_.isInstanceOf [nodes.CfgNode ]).cast[nodes.CfgNode ]
87
- ).l
84
+ val cfgChildren = method.out(EdgeTypes .CONTAINS ).asScala.collect { case node : nodes.CfgNode => node }.toList
88
85
89
86
val local = new NodeSteps (
90
- method
87
+ methodVertex
91
88
.out(EdgeTypes .CONTAINS )
92
89
.hasLabel(NodeTypes .BLOCK )
93
90
.out(EdgeTypes .AST )
94
91
.hasLabel(NodeTypes .LOCAL )
95
92
.cast[nodes.Local ])
96
93
val sink = local.evalType(" .*" ).referencingIdentifiers.dedup
97
- val source = new NodeSteps (method .out(EdgeTypes .CONTAINS ).hasLabel(NodeTypes .CALL ).cast[nodes.Call ]).nameNot(" <operator>.*" ).dedup
94
+ val source = new NodeSteps (methodVertex .out(EdgeTypes .CONTAINS ).hasLabel(NodeTypes .CALL ).cast[nodes.Call ]).nameNot(" <operator>.*" ).dedup
98
95
99
96
val pdgChildren = sink
100
97
.reachableByFlows(source)
0 commit comments