Skip to content

Commit defb594

Browse files
[CPG] Add JumpArgument Edge (#1853)
1 parent 3fb94a7 commit defb594

43 files changed

Lines changed: 2626 additions & 29 deletions

Some content is hidden

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

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/EdgeTypes.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ other words, there is a (name, signature) pair that can be resolved for the type
9494
 | */
9595
public static final String IS_CALL_FOR_IMPORT = "IS_CALL_FOR_IMPORT";
9696

97+
/** The edge connects jump-like control structures to the node encoding their jump target. */
98+
public static final String JUMP_ARGUMENT = "JUMP_ARGUMENT";
99+
97100
/** This edge connects a method input parameter to the corresponding
98101
method output parameter. */
99102
public static final String PARAMETER_LINK = "PARAMETER_LINK";
@@ -156,6 +159,7 @@ other words, there is a (name, signature) pair that can be resolved for the type
156159
add(IMPORTS);
157160
add(INHERITS_FROM);
158161
add(IS_CALL_FOR_IMPORT);
162+
add(JUMP_ARGUMENT);
159163
add(PARAMETER_LINK);
160164
add(POST_DOMINATE);
161165
add(REACHING_DEF);

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/GraphSchema.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ object GraphSchema extends flatgraph.Schema {
7474
"IMPORTS",
7575
"INHERITS_FROM",
7676
"IS_CALL_FOR_IMPORT",
77+
"JUMP_ARGUMENT",
7778
"PARAMETER_LINK",
7879
"POST_DOMINATE",
7980
"REACHING_DEF",
@@ -112,7 +113,8 @@ object GraphSchema extends flatgraph.Schema {
112113
size => null,
113114
size => null,
114115
size => null,
115-
size => Array.fill(size)("<empty>") /* label = REACHING_DEF, id = 26 */,
116+
size => null,
117+
size => Array.fill(size)("<empty>") /* label = REACHING_DEF, id = 27 */,
116118
size => null,
117119
size => null,
118120
size => null,
@@ -190,6 +192,7 @@ object GraphSchema extends flatgraph.Schema {
190192
(s, d, subseq, p) => new edges.Imports(s, d, subseq, p),
191193
(s, d, subseq, p) => new edges.InheritsFrom(s, d, subseq, p),
192194
(s, d, subseq, p) => new edges.IsCallForImport(s, d, subseq, p),
195+
(s, d, subseq, p) => new edges.JumpArgument(s, d, subseq, p),
193196
(s, d, subseq, p) => new edges.ParameterLink(s, d, subseq, p),
194197
(s, d, subseq, p) => new edges.PostDominate(s, d, subseq, p),
195198
(s, d, subseq, p) => new edges.ReachingDef(s, d, subseq, p),
@@ -1477,7 +1480,7 @@ object GraphSchema extends flatgraph.Schema {
14771480
_newNodeInserters
14781481
}
14791482
override def getNumberOfNodeKinds: Int = 43
1480-
override def getNumberOfEdgeKinds: Int = 33
1483+
override def getNumberOfEdgeKinds: Int = 34
14811484
override def getNodeLabel(nodeKind: Int): String = nodeLabels(nodeKind)
14821485
override def getNodeKindByLabel(label: String): Int = nodeKindByLabel.getOrElse(label, flatgraph.Schema.UndefinedKind)
14831486
override def getEdgeLabel(nodeKind: Int, edgeKind: Int): String = edgeLabels(edgeKind)

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/edges/EdgeTypes.scala

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,29 +192,37 @@ object IsCallForImport {
192192
class IsCallForImport(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
193193
extends flatgraph.Edge(src_4762, dst_4762, 23, subSeq_4862, property_4862) {}
194194

195+
object JumpArgument {
196+
val Label = "JUMP_ARGUMENT"
197+
198+
}
199+
200+
class JumpArgument(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
201+
extends flatgraph.Edge(src_4762, dst_4762, 24, subSeq_4862, property_4862) {}
202+
195203
object ParameterLink {
196204
val Label = "PARAMETER_LINK"
197205

198206
}
199207

200208
class ParameterLink(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
201-
extends flatgraph.Edge(src_4762, dst_4762, 24, subSeq_4862, property_4862) {}
209+
extends flatgraph.Edge(src_4762, dst_4762, 25, subSeq_4862, property_4862) {}
202210

203211
object PostDominate {
204212
val Label = "POST_DOMINATE"
205213

206214
}
207215

208216
class PostDominate(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
209-
extends flatgraph.Edge(src_4762, dst_4762, 25, subSeq_4862, property_4862) {}
217+
extends flatgraph.Edge(src_4762, dst_4762, 26, subSeq_4862, property_4862) {}
210218

211219
object ReachingDef {
212220
val Label = "REACHING_DEF"
213221
val propertyName: Option[String] = Some("VARIABLE")
214222
}
215223

216224
class ReachingDef(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
217-
extends flatgraph.Edge(src_4762, dst_4762, 26, subSeq_4862, property_4862) {
225+
extends flatgraph.Edge(src_4762, dst_4762, 27, subSeq_4862, property_4862) {
218226
override def propertyName: Option[String] = ReachingDef.propertyName
219227
}
220228

@@ -224,44 +232,44 @@ object Receiver {
224232
}
225233

226234
class Receiver(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
227-
extends flatgraph.Edge(src_4762, dst_4762, 27, subSeq_4862, property_4862) {}
235+
extends flatgraph.Edge(src_4762, dst_4762, 28, subSeq_4862, property_4862) {}
228236

229237
object Ref {
230238
val Label = "REF"
231239

232240
}
233241

234242
class Ref(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
235-
extends flatgraph.Edge(src_4762, dst_4762, 28, subSeq_4862, property_4862) {}
243+
extends flatgraph.Edge(src_4762, dst_4762, 29, subSeq_4862, property_4862) {}
236244

237245
object SourceFile {
238246
val Label = "SOURCE_FILE"
239247

240248
}
241249

242250
class SourceFile(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
243-
extends flatgraph.Edge(src_4762, dst_4762, 29, subSeq_4862, property_4862) {}
251+
extends flatgraph.Edge(src_4762, dst_4762, 30, subSeq_4862, property_4862) {}
244252

245253
object TaggedBy {
246254
val Label = "TAGGED_BY"
247255

248256
}
249257

250258
class TaggedBy(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
251-
extends flatgraph.Edge(src_4762, dst_4762, 30, subSeq_4862, property_4862) {}
259+
extends flatgraph.Edge(src_4762, dst_4762, 31, subSeq_4862, property_4862) {}
252260

253261
object TrueBody {
254262
val Label = "TRUE_BODY"
255263

256264
}
257265

258266
class TrueBody(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
259-
extends flatgraph.Edge(src_4762, dst_4762, 31, subSeq_4862, property_4862) {}
267+
extends flatgraph.Edge(src_4762, dst_4762, 32, subSeq_4862, property_4862) {}
260268

261269
object TryBody {
262270
val Label = "TRY_BODY"
263271

264272
}
265273

266274
class TryBody(src_4762: flatgraph.GNode, dst_4762: flatgraph.GNode, subSeq_4862: Int, property_4862: Any)
267-
extends flatgraph.Edge(src_4762, dst_4762, 32, subSeq_4862, property_4862) {}
275+
extends flatgraph.Edge(src_4762, dst_4762, 33, subSeq_4862, property_4862) {}

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/neighboraccessors/ControlStructure.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,10 @@ final class AccessNeighborsForControlStructure(val node: nodes.ControlStructure)
387387
*/
388388
def _jumpLabelViaAstOut: Iterator[nodes.JumpLabel] = astOut.collectAll[nodes.JumpLabel]
389389

390+
/** Traverse to JUMP_LABEL via JUMP_ARGUMENT OUT edge.
391+
*/
392+
def _jumpLabelViaJumpArgumentOut: Iterator[nodes.JumpLabel] = jumpArgumentOut.collectAll[nodes.JumpLabel]
393+
390394
/** Traverse to JUMP_TARGET via AST OUT edge.
391395
*/
392396
def _jumpTargetViaAstOut: Iterator[nodes.JumpTarget] = astOut.collectAll[nodes.JumpTarget]
@@ -507,6 +511,10 @@ final class AccessNeighborsForControlStructure(val node: nodes.ControlStructure)
507511
*/
508512
def _literalViaForUpdateOut: Iterator[nodes.Literal] = forUpdateOut.collectAll[nodes.Literal]
509513

514+
/** Traverse to LITERAL via JUMP_ARGUMENT OUT edge.
515+
*/
516+
def _literalViaJumpArgumentOut: Iterator[nodes.Literal] = jumpArgumentOut.collectAll[nodes.Literal]
517+
510518
/** Traverse to LITERAL via POST_DOMINATE IN edge.
511519
*/
512520
def _literalViaPostDominateIn: Iterator[nodes.Literal] = postDominateIn.collectAll[nodes.Literal]
@@ -912,6 +920,8 @@ final class AccessNeighborsForControlStructure(val node: nodes.ControlStructure)
912920

913921
def forUpdateOut: Iterator[nodes.CfgNode] = node._forUpdateOut.cast[nodes.CfgNode]
914922

923+
def jumpArgumentOut: Iterator[nodes.AstNode] = node._jumpArgumentOut.cast[nodes.AstNode]
924+
915925
def postDominateIn: Iterator[nodes.CfgNode] = node._postDominateIn.cast[nodes.CfgNode]
916926

917927
def postDominateOut: Iterator[nodes.CfgNode] = node._postDominateOut.cast[nodes.CfgNode]
@@ -1333,6 +1343,10 @@ final class AccessNeighborsForControlStructureTraversal(val traversal: Iterator[
13331343
*/
13341344
def _jumpLabelViaAstOut: Iterator[nodes.JumpLabel] = traversal.flatMap(_._jumpLabelViaAstOut)
13351345

1346+
/** Traverse to JUMP_LABEL via JUMP_ARGUMENT OUT edge.
1347+
*/
1348+
def _jumpLabelViaJumpArgumentOut: Iterator[nodes.JumpLabel] = traversal.flatMap(_._jumpLabelViaJumpArgumentOut)
1349+
13361350
/** Traverse to JUMP_TARGET via AST OUT edge.
13371351
*/
13381352
def _jumpTargetViaAstOut: Iterator[nodes.JumpTarget] = traversal.flatMap(_._jumpTargetViaAstOut)
@@ -1453,6 +1467,10 @@ final class AccessNeighborsForControlStructureTraversal(val traversal: Iterator[
14531467
*/
14541468
def _literalViaForUpdateOut: Iterator[nodes.Literal] = traversal.flatMap(_._literalViaForUpdateOut)
14551469

1470+
/** Traverse to LITERAL via JUMP_ARGUMENT OUT edge.
1471+
*/
1472+
def _literalViaJumpArgumentOut: Iterator[nodes.Literal] = traversal.flatMap(_._literalViaJumpArgumentOut)
1473+
14561474
/** Traverse to LITERAL via POST_DOMINATE IN edge.
14571475
*/
14581476
def _literalViaPostDominateIn: Iterator[nodes.Literal] = traversal.flatMap(_._literalViaPostDominateIn)
@@ -1858,6 +1876,8 @@ final class AccessNeighborsForControlStructureTraversal(val traversal: Iterator[
18581876

18591877
def forUpdateOut: Iterator[nodes.CfgNode] = traversal.flatMap(_.forUpdateOut)
18601878

1879+
def jumpArgumentOut: Iterator[nodes.AstNode] = traversal.flatMap(_.jumpArgumentOut)
1880+
18611881
def postDominateIn: Iterator[nodes.CfgNode] = traversal.flatMap(_.postDominateIn)
18621882

18631883
def postDominateOut: Iterator[nodes.CfgNode] = traversal.flatMap(_.postDominateOut)

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/neighboraccessors/JumpLabel.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ final class AccessNeighborsForJumpLabel(val node: nodes.JumpLabel) extends AnyVa
99
*/
1010
def _controlStructureViaAstIn: Iterator[nodes.ControlStructure] = astIn.collectAll[nodes.ControlStructure]
1111

12+
/** Traverse to CONTROL_STRUCTURE via JUMP_ARGUMENT IN edge.
13+
*/
14+
def _controlStructureViaJumpArgumentIn: Iterator[nodes.ControlStructure] =
15+
jumpArgumentIn.collectAll[nodes.ControlStructure]
16+
1217
def astIn: Iterator[nodes.ControlStructure] = node._astIn.cast[nodes.ControlStructure]
18+
19+
def jumpArgumentIn: Iterator[nodes.ControlStructure] = node._jumpArgumentIn.cast[nodes.ControlStructure]
1320
}
1421

1522
final class AccessNeighborsForJumpLabelTraversal(val traversal: Iterator[nodes.JumpLabel]) extends AnyVal {
@@ -18,5 +25,12 @@ final class AccessNeighborsForJumpLabelTraversal(val traversal: Iterator[nodes.J
1825
*/
1926
def _controlStructureViaAstIn: Iterator[nodes.ControlStructure] = traversal.flatMap(_._controlStructureViaAstIn)
2027

28+
/** Traverse to CONTROL_STRUCTURE via JUMP_ARGUMENT IN edge.
29+
*/
30+
def _controlStructureViaJumpArgumentIn: Iterator[nodes.ControlStructure] =
31+
traversal.flatMap(_._controlStructureViaJumpArgumentIn)
32+
2133
def astIn: Iterator[nodes.ControlStructure] = traversal.flatMap(_.astIn)
34+
35+
def jumpArgumentIn: Iterator[nodes.ControlStructure] = traversal.flatMap(_.jumpArgumentIn)
2236
}

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/neighboraccessors/Literal.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ final class AccessNeighborsForLiteral(val node: nodes.Literal) extends AnyVal {
156156
*/
157157
def _controlStructureViaForUpdateIn: Iterator[nodes.ControlStructure] = forUpdateIn.collectAll[nodes.ControlStructure]
158158

159+
/** Traverse to CONTROL_STRUCTURE via JUMP_ARGUMENT IN edge.
160+
*/
161+
def _controlStructureViaJumpArgumentIn: Iterator[nodes.ControlStructure] =
162+
jumpArgumentIn.collectAll[nodes.ControlStructure]
163+
159164
/** Traverse to CONTROL_STRUCTURE via POST_DOMINATE IN edge.
160165
*/
161166
def _controlStructureViaPostDominateIn: Iterator[nodes.ControlStructure] =
@@ -508,6 +513,8 @@ final class AccessNeighborsForLiteral(val node: nodes.Literal) extends AnyVal {
508513

509514
def forUpdateIn: Iterator[nodes.ControlStructure] = node._forUpdateIn.cast[nodes.ControlStructure]
510515

516+
def jumpArgumentIn: Iterator[nodes.ControlStructure] = node._jumpArgumentIn.cast[nodes.ControlStructure]
517+
511518
def postDominateIn: Iterator[nodes.CfgNode] = node._postDominateIn.cast[nodes.CfgNode]
512519

513520
def postDominateOut: Iterator[nodes.CfgNode] = node._postDominateOut.cast[nodes.CfgNode]
@@ -676,6 +683,11 @@ final class AccessNeighborsForLiteralTraversal(val traversal: Iterator[nodes.Lit
676683
def _controlStructureViaForUpdateIn: Iterator[nodes.ControlStructure] =
677684
traversal.flatMap(_._controlStructureViaForUpdateIn)
678685

686+
/** Traverse to CONTROL_STRUCTURE via JUMP_ARGUMENT IN edge.
687+
*/
688+
def _controlStructureViaJumpArgumentIn: Iterator[nodes.ControlStructure] =
689+
traversal.flatMap(_._controlStructureViaJumpArgumentIn)
690+
679691
/** Traverse to CONTROL_STRUCTURE via POST_DOMINATE IN edge.
680692
*/
681693
def _controlStructureViaPostDominateIn: Iterator[nodes.ControlStructure] =
@@ -1032,6 +1044,8 @@ final class AccessNeighborsForLiteralTraversal(val traversal: Iterator[nodes.Lit
10321044

10331045
def forUpdateIn: Iterator[nodes.ControlStructure] = traversal.flatMap(_.forUpdateIn)
10341046

1047+
def jumpArgumentIn: Iterator[nodes.ControlStructure] = traversal.flatMap(_.jumpArgumentIn)
1048+
10351049
def postDominateIn: Iterator[nodes.CfgNode] = traversal.flatMap(_.postDominateIn)
10361050

10371051
def postDominateOut: Iterator[nodes.CfgNode] = traversal.flatMap(_.postDominateOut)

domainClasses/src/main/generated/io/shiftleft/codepropertygraph/generated/nodes/NewAnnotation.scala

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,44 @@ object NewAnnotation {
660660
"TYPE_REF",
661661
"UNKNOWN"
662662
),
663+
"JUMP_ARGUMENT" -> Set(
664+
"ANNOTATION",
665+
"ANNOTATION_LITERAL",
666+
"ANNOTATION_PARAMETER",
667+
"ANNOTATION_PARAMETER_ASSIGN",
668+
"ARRAY_INITIALIZER",
669+
"BLOCK",
670+
"CALL",
671+
"CALL_REPR",
672+
"CFG_NODE",
673+
"COMMENT",
674+
"CONTROL_STRUCTURE",
675+
"EXPRESSION",
676+
"FIELD_IDENTIFIER",
677+
"FILE",
678+
"IDENTIFIER",
679+
"IMPORT",
680+
"JUMP_LABEL",
681+
"JUMP_TARGET",
682+
"LITERAL",
683+
"LOCAL",
684+
"MEMBER",
685+
"METHOD",
686+
"METHOD_PARAMETER_IN",
687+
"METHOD_PARAMETER_OUT",
688+
"METHOD_REF",
689+
"METHOD_RETURN",
690+
"MODIFIER",
691+
"NAMESPACE",
692+
"NAMESPACE_BLOCK",
693+
"RETURN",
694+
"TEMPLATE_DOM",
695+
"TYPE_ARGUMENT",
696+
"TYPE_DECL",
697+
"TYPE_PARAMETER",
698+
"TYPE_REF",
699+
"UNKNOWN"
700+
),
663701
"PARAMETER_LINK" -> Set(
664702
"ANNOTATION",
665703
"ANNOTATION_LITERAL",
@@ -1615,6 +1653,44 @@ object NewAnnotation {
16151653
"TYPE_REF",
16161654
"UNKNOWN"
16171655
),
1656+
"JUMP_ARGUMENT" -> Set(
1657+
"ANNOTATION",
1658+
"ANNOTATION_LITERAL",
1659+
"ANNOTATION_PARAMETER",
1660+
"ANNOTATION_PARAMETER_ASSIGN",
1661+
"ARRAY_INITIALIZER",
1662+
"BLOCK",
1663+
"CALL",
1664+
"CALL_REPR",
1665+
"CFG_NODE",
1666+
"COMMENT",
1667+
"CONTROL_STRUCTURE",
1668+
"EXPRESSION",
1669+
"FIELD_IDENTIFIER",
1670+
"FILE",
1671+
"IDENTIFIER",
1672+
"IMPORT",
1673+
"JUMP_LABEL",
1674+
"JUMP_TARGET",
1675+
"LITERAL",
1676+
"LOCAL",
1677+
"MEMBER",
1678+
"METHOD",
1679+
"METHOD_PARAMETER_IN",
1680+
"METHOD_PARAMETER_OUT",
1681+
"METHOD_REF",
1682+
"METHOD_RETURN",
1683+
"MODIFIER",
1684+
"NAMESPACE",
1685+
"NAMESPACE_BLOCK",
1686+
"RETURN",
1687+
"TEMPLATE_DOM",
1688+
"TYPE_ARGUMENT",
1689+
"TYPE_DECL",
1690+
"TYPE_PARAMETER",
1691+
"TYPE_REF",
1692+
"UNKNOWN"
1693+
),
16181694
"PARAMETER_LINK" -> Set(
16191695
"ANNOTATION",
16201696
"ANNOTATION_LITERAL",

0 commit comments

Comments
 (0)