Skip to content
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -169,114 +169,119 @@ object Properties {
*/
val IsExternal = flatgraph.SinglePropertyKey[Boolean](kind = 29, name = "IS_EXTERNAL", default = false)

/** Specifies whether this is a module import. This is used for languages like Java >= 25 where packages exported by a
* module can be imported via the module name (which does not need to match the package names in any way).
*/
val IsModuleImport = flatgraph.OptionalPropertyKey[Boolean](kind = 30, name = "IS_MODULE_IMPORT")

/** Specifies whether a parameter is the variadic argument handling parameter of a variadic method. Only one parameter
* of a method is allowed to have this property set to true.
*/
val IsVariadic = flatgraph.SinglePropertyKey[Boolean](kind = 30, name = "IS_VARIADIC", default = false)
val IsVariadic = flatgraph.SinglePropertyKey[Boolean](kind = 31, name = "IS_VARIADIC", default = false)

/** Specifies whether this is a wildcard import. For a Java import like "import java.nio.*;" IS_WILDCARD would be
* "true" and IMPORTED_ENTITY would be "java.nio". For wildcard imports the IMPORTED_AS property is ignored.
*/
val IsWildcard = flatgraph.OptionalPropertyKey[Boolean](kind = 31, name = "IS_WILDCARD")
val IsWildcard = flatgraph.OptionalPropertyKey[Boolean](kind = 32, name = "IS_WILDCARD")

/** This property denotes a key of a key-value pair. */
val Key = flatgraph.SinglePropertyKey[String](kind = 32, name = "KEY", default = "<empty>")
val Key = flatgraph.SinglePropertyKey[String](kind = 33, name = "KEY", default = "<empty>")

/** This field indicates which CPG language frontend generated the CPG. Frontend developers may freely choose a value
* that describes their frontend so long as it is not used by an existing frontend. Reserved values are to date: C,
* LLVM, GHIDRA, PHP.
*/
val Language = flatgraph.SinglePropertyKey[String](kind = 33, name = "LANGUAGE", default = "<empty>")
val Language = flatgraph.SinglePropertyKey[String](kind = 34, name = "LANGUAGE", default = "<empty>")

/** This optional field provides the line number of the program construct represented by the node.
*/
val LineNumber = flatgraph.OptionalPropertyKey[Int](kind = 34, name = "LINE_NUMBER")
val LineNumber = flatgraph.OptionalPropertyKey[Int](kind = 35, name = "LINE_NUMBER")

/** This optional fields provides the line number at which the program construct represented by the node ends.
*/
val LineNumberEnd = flatgraph.OptionalPropertyKey[Int](kind = 35, name = "LINE_NUMBER_END")
val LineNumberEnd = flatgraph.OptionalPropertyKey[Int](kind = 36, name = "LINE_NUMBER_END")

/** The FULL_NAME of a method. Used to link CALL and METHOD nodes. It is required to have exactly one METHOD node for
* each METHOD_FULL_NAME
*/
val MethodFullName = flatgraph.SinglePropertyKey[String](kind = 36, name = "METHOD_FULL_NAME", default = "<empty>")
val MethodFullName = flatgraph.SinglePropertyKey[String](kind = 37, name = "METHOD_FULL_NAME", default = "<empty>")

/** The modifier type is a free-form string. The following are known modifier types: `STATIC`, `PUBLIC`, `PROTECTED`,
* `PRIVATE`, `ABSTRACT`, `NATIVE`, `CONSTRUCTOR`, `VIRTUAL`.
*/
val ModifierType = flatgraph.SinglePropertyKey[String](kind = 37, name = "MODIFIER_TYPE", default = "<empty>")
val ModifierType = flatgraph.SinglePropertyKey[String](kind = 38, name = "MODIFIER_TYPE", default = "<empty>")

/** Name of represented object, e.g., method name (e.g. "run") */
val Name = flatgraph.SinglePropertyKey[String](kind = 38, name = "NAME", default = "<empty>")
val Name = flatgraph.SinglePropertyKey[String](kind = 39, name = "NAME", default = "<empty>")

/** Start offset into the CONTENT property of the corresponding FILE node. The offset is such that parts of the
* content can easily be accessed via `content.substring(offset, offsetEnd)`. This means that the offset must be
* measured in utf16 encoding (i.e. neither in characters/codeunits nor in byte-offsets into a utf8 encoding). E.g.
* for METHOD nodes this start offset points to the start of the methods source code in the string holding the source
* code of the entire file.
*/
val Offset = flatgraph.OptionalPropertyKey[Int](kind = 39, name = "OFFSET")
val Offset = flatgraph.OptionalPropertyKey[Int](kind = 40, name = "OFFSET")

/** End offset (exclusive) into the CONTENT property of the corresponding FILE node. See OFFSET documentation for
* finer details. E.g. for METHOD nodes this end offset points to the first code position which is not part of the
* method.
*/
val OffsetEnd = flatgraph.OptionalPropertyKey[Int](kind = 40, name = "OFFSET_END")
val OffsetEnd = flatgraph.OptionalPropertyKey[Int](kind = 41, name = "OFFSET_END")

/** This integer indicates the position of the node among its siblings in the AST. The left-most child has an order of
* 0.
*/
val Order = flatgraph.SinglePropertyKey[Int](kind = 41, name = "ORDER", default = -1: Int)
val Order = flatgraph.SinglePropertyKey[Int](kind = 42, name = "ORDER", default = -1: Int)

/** The field contains the names of the overlays applied to this CPG, in order of their application. Names are
* free-form strings, that is, this specification does not dictate them but rather requires tool producers and
* consumers to communicate them between each other.
*/
val Overlays = flatgraph.MultiPropertyKey[String](kind = 42, name = "OVERLAYS")
val Overlays = flatgraph.MultiPropertyKey[String](kind = 43, name = "OVERLAYS")

/** AST node type name emitted by parser. */
val ParserTypeName = flatgraph.SinglePropertyKey[String](kind = 43, name = "PARSER_TYPE_NAME", default = "<empty>")
val ParserTypeName = flatgraph.SinglePropertyKey[String](kind = 44, name = "PARSER_TYPE_NAME", default = "<empty>")

/** Similar to `DYNAMIC_TYPE_HINT_FULL_NAME`, but that this makes no guarantee that types within this property are
* correct. This property is used to capture observations between node interactions during a 'may-analysis'.
*/
val PossibleTypes = flatgraph.MultiPropertyKey[String](kind = 44, name = "POSSIBLE_TYPES")
val PossibleTypes = flatgraph.MultiPropertyKey[String](kind = 45, name = "POSSIBLE_TYPES")

/** The path to the root directory of the source/binary this CPG is generated from. */
val Root = flatgraph.SinglePropertyKey[String](kind = 45, name = "ROOT", default = "<empty>")
val Root = flatgraph.SinglePropertyKey[String](kind = 46, name = "ROOT", default = "<empty>")

/** The method signature encodes the types of parameters in a string. The string SHOULD be human readable and suitable
* for differentiating methods with different parameter types sufficiently to allow for resolving of function
* overloading. The present specification does not enforce a strict format for the signature, that is, it can be
* chosen by the frontend implementor to fit the source language.
*/
val Signature = flatgraph.SinglePropertyKey[String](kind = 46, name = "SIGNATURE", default = "")
val Signature = flatgraph.SinglePropertyKey[String](kind = 47, name = "SIGNATURE", default = "")

/** The `STATIC_RECEIVER` field is used to keep track of the type on which a static method is called for static
* methods which may be inherited. This information can then be used to find the true `METHOD_FULL_NAME` of the
* method being called during call linking. For example, if a class `Foo` defines a static method `foo` and a class
* `Bar extends Foo`, then the `STATIC_RECEIVER` of a`Bar.foo()` call is `Bar` and the `METHOD_FULL_NAME` of the
* `foo` call is rewritten to `Foo.foo:<signature>`.
*/
val StaticReceiver = flatgraph.OptionalPropertyKey[String](kind = 47, name = "STATIC_RECEIVER")
val StaticReceiver = flatgraph.OptionalPropertyKey[String](kind = 48, name = "STATIC_RECEIVER")

/** The static type decl of a TYPE. This property is matched against the FULL_NAME of TYPE_DECL nodes. It is required
* to have exactly one TYPE_DECL for each different TYPE_DECL_FULL_NAME
*/
val TypeDeclFullName =
flatgraph.SinglePropertyKey[String](kind = 48, name = "TYPE_DECL_FULL_NAME", default = "<empty>")
flatgraph.SinglePropertyKey[String](kind = 49, name = "TYPE_DECL_FULL_NAME", default = "<empty>")

/** This field contains the fully-qualified static type name of the program construct represented by a node. It is the
* name of an instantiated type, e.g., `java.util.List<Integer>`, rather than `java.util.List[T]`. If the type cannot
* be determined, this field should be set to the empty string.
*/
val TypeFullName = flatgraph.SinglePropertyKey[String](kind = 49, name = "TYPE_FULL_NAME", default = "<empty>")
val TypeFullName = flatgraph.SinglePropertyKey[String](kind = 50, name = "TYPE_FULL_NAME", default = "<empty>")

/** This property denotes a string value as used in a key-value pair. */
val Value = flatgraph.SinglePropertyKey[String](kind = 50, name = "VALUE", default = "")
val Value = flatgraph.SinglePropertyKey[String](kind = 51, name = "VALUE", default = "")

/** A version, given as a string. Used, for example, in the META_DATA node to indicate which version of the CPG spec
* this CPG conforms to
*/
val Version = flatgraph.SinglePropertyKey[String](kind = 51, name = "VERSION", default = "<empty>")
val Version = flatgraph.SinglePropertyKey[String](kind = 52, name = "VERSION", default = "<empty>")
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ object PropertyNames {
*/
val IsExternal: String = "IS_EXTERNAL"

/** Specifies whether this is a module import. This is used for languages like Java >= 25 where packages exported by a
* module can be imported via the module name (which does not need to match the package names in any way).
*/
val IsModuleImport: String = "IS_MODULE_IMPORT"

/** Specifies whether a parameter is the variadic argument handling parameter of a variadic method. Only one parameter
* of a method is allowed to have this property set to true.
*/
Expand Down Expand Up @@ -331,6 +336,7 @@ object PropertyNames {
InheritsFromTypeFullName,
IsExplicit,
IsExternal,
IsModuleImport,
IsVariadic,
IsWildcard,
Key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,24 +202,28 @@ object Accessors {
default = false: Boolean
)
}
final class AccessPropertyIsModuleImport(val node: nodes.StoredNode) extends AnyVal {
def isModuleImport: Option[Boolean] = flatgraph.Accessors
.getNodePropertyOption[Boolean](node.graph, nodeKind = node.nodeKind, propertyKind = 30, seq = node.seq)
}
final class AccessPropertyIsVariadic(val node: nodes.StoredNode) extends AnyVal {
def isVariadic: Boolean = flatgraph.Accessors.getNodePropertySingle(
node.graph,
nodeKind = node.nodeKind,
propertyKind = 30,
propertyKind = 31,
seq = node.seq(),
default = false: Boolean
)
}
final class AccessPropertyIsWildcard(val node: nodes.StoredNode) extends AnyVal {
def isWildcard: Option[Boolean] = flatgraph.Accessors
.getNodePropertyOption[Boolean](node.graph, nodeKind = node.nodeKind, propertyKind = 31, seq = node.seq)
.getNodePropertyOption[Boolean](node.graph, nodeKind = node.nodeKind, propertyKind = 32, seq = node.seq)
}
final class AccessPropertyKey(val node: nodes.StoredNode) extends AnyVal {
def key: String = flatgraph.Accessors.getNodePropertySingle(
node.graph,
nodeKind = node.nodeKind,
propertyKind = 32,
propertyKind = 33,
seq = node.seq(),
default = "<empty>": String
)
Expand All @@ -228,24 +232,24 @@ object Accessors {
def language: String = flatgraph.Accessors.getNodePropertySingle(
node.graph,
nodeKind = node.nodeKind,
propertyKind = 33,
propertyKind = 34,
seq = node.seq(),
default = "<empty>": String
)
}
final class AccessPropertyLineNumber(val node: nodes.StoredNode) extends AnyVal {
def lineNumber: Option[Int] = flatgraph.Accessors
.getNodePropertyOption[Int](node.graph, nodeKind = node.nodeKind, propertyKind = 34, seq = node.seq)
.getNodePropertyOption[Int](node.graph, nodeKind = node.nodeKind, propertyKind = 35, seq = node.seq)
}
final class AccessPropertyLineNumberEnd(val node: nodes.StoredNode) extends AnyVal {
def lineNumberEnd: Option[Int] = flatgraph.Accessors
.getNodePropertyOption[Int](node.graph, nodeKind = node.nodeKind, propertyKind = 35, seq = node.seq)
.getNodePropertyOption[Int](node.graph, nodeKind = node.nodeKind, propertyKind = 36, seq = node.seq)
}
final class AccessPropertyMethodFullName(val node: nodes.StoredNode) extends AnyVal {
def methodFullName: String = flatgraph.Accessors.getNodePropertySingle(
node.graph,
nodeKind = node.nodeKind,
propertyKind = 36,
propertyKind = 37,
seq = node.seq(),
default = "<empty>": String
)
Expand All @@ -254,7 +258,7 @@ object Accessors {
def modifierType: String = flatgraph.Accessors.getNodePropertySingle(
node.graph,
nodeKind = node.nodeKind,
propertyKind = 37,
propertyKind = 38,
seq = node.seq(),
default = "<empty>": String
)
Expand All @@ -263,50 +267,50 @@ object Accessors {
def name: String = flatgraph.Accessors.getNodePropertySingle(
node.graph,
nodeKind = node.nodeKind,
propertyKind = 38,
propertyKind = 39,
seq = node.seq(),
default = "<empty>": String
)
}
final class AccessPropertyOffset(val node: nodes.StoredNode) extends AnyVal {
def offset: Option[Int] = flatgraph.Accessors
.getNodePropertyOption[Int](node.graph, nodeKind = node.nodeKind, propertyKind = 39, seq = node.seq)
.getNodePropertyOption[Int](node.graph, nodeKind = node.nodeKind, propertyKind = 40, seq = node.seq)
}
final class AccessPropertyOffsetEnd(val node: nodes.StoredNode) extends AnyVal {
def offsetEnd: Option[Int] = flatgraph.Accessors
.getNodePropertyOption[Int](node.graph, nodeKind = node.nodeKind, propertyKind = 40, seq = node.seq)
.getNodePropertyOption[Int](node.graph, nodeKind = node.nodeKind, propertyKind = 41, seq = node.seq)
}
final class AccessPropertyOrder(val node: nodes.StoredNode) extends AnyVal {
def order: Int = flatgraph.Accessors.getNodePropertySingle(
node.graph,
nodeKind = node.nodeKind,
propertyKind = 41,
propertyKind = 42,
seq = node.seq(),
default = -1: Int
)
}
final class AccessPropertyOverlays(val node: nodes.StoredNode) extends AnyVal {
def overlays: IndexedSeq[String] = flatgraph.Accessors
.getNodePropertyMulti[String](node.graph, nodeKind = node.nodeKind, propertyKind = 42, seq = node.seq)
.getNodePropertyMulti[String](node.graph, nodeKind = node.nodeKind, propertyKind = 43, seq = node.seq)
}
final class AccessPropertyParserTypeName(val node: nodes.StoredNode) extends AnyVal {
def parserTypeName: String = flatgraph.Accessors.getNodePropertySingle(
node.graph,
nodeKind = node.nodeKind,
propertyKind = 43,
propertyKind = 44,
seq = node.seq(),
default = "<empty>": String
)
}
final class AccessPropertyPossibleTypes(val node: nodes.StoredNode) extends AnyVal {
def possibleTypes: IndexedSeq[String] = flatgraph.Accessors
.getNodePropertyMulti[String](node.graph, nodeKind = node.nodeKind, propertyKind = 44, seq = node.seq)
.getNodePropertyMulti[String](node.graph, nodeKind = node.nodeKind, propertyKind = 45, seq = node.seq)
}
final class AccessPropertyRoot(val node: nodes.StoredNode) extends AnyVal {
def root: String = flatgraph.Accessors.getNodePropertySingle(
node.graph,
nodeKind = node.nodeKind,
propertyKind = 45,
propertyKind = 46,
seq = node.seq(),
default = "<empty>": String
)
Expand All @@ -315,20 +319,20 @@ object Accessors {
def signature: String = flatgraph.Accessors.getNodePropertySingle(
node.graph,
nodeKind = node.nodeKind,
propertyKind = 46,
propertyKind = 47,
seq = node.seq(),
default = "": String
)
}
final class AccessPropertyStaticReceiver(val node: nodes.StoredNode) extends AnyVal {
def staticReceiver: Option[String] = flatgraph.Accessors
.getNodePropertyOption[String](node.graph, nodeKind = node.nodeKind, propertyKind = 47, seq = node.seq)
.getNodePropertyOption[String](node.graph, nodeKind = node.nodeKind, propertyKind = 48, seq = node.seq)
}
final class AccessPropertyTypeDeclFullName(val node: nodes.StoredNode) extends AnyVal {
def typeDeclFullName: String = flatgraph.Accessors.getNodePropertySingle(
node.graph,
nodeKind = node.nodeKind,
propertyKind = 48,
propertyKind = 49,
seq = node.seq(),
default = "<empty>": String
)
Expand All @@ -337,7 +341,7 @@ object Accessors {
def typeFullName: String = flatgraph.Accessors.getNodePropertySingle(
node.graph,
nodeKind = node.nodeKind,
propertyKind = 49,
propertyKind = 50,
seq = node.seq(),
default = "<empty>": String
)
Expand All @@ -346,7 +350,7 @@ object Accessors {
def value: String = flatgraph.Accessors.getNodePropertySingle(
node.graph,
nodeKind = node.nodeKind,
propertyKind = 50,
propertyKind = 51,
seq = node.seq(),
default = "": String
)
Expand All @@ -355,7 +359,7 @@ object Accessors {
def version: String = flatgraph.Accessors.getNodePropertySingle(
node.graph,
nodeKind = node.nodeKind,
propertyKind = 51,
propertyKind = 52,
seq = node.seq(),
default = "<empty>": String
)
Expand Down Expand Up @@ -547,6 +551,10 @@ object Accessors {
case stored: nodes.StoredNode => new AccessPropertyIsExplicit(stored).isExplicit
case newNode: nodes.NewImport => newNode.isExplicit
}
def isModuleImport: Option[Boolean] = node match {
case stored: nodes.StoredNode => new AccessPropertyIsModuleImport(stored).isModuleImport
case newNode: nodes.NewImport => newNode.isModuleImport
}
def isWildcard: Option[Boolean] = node match {
case stored: nodes.StoredNode => new AccessPropertyIsWildcard(stored).isWildcard
case newNode: nodes.NewImport => newNode.isWildcard
Expand Down Expand Up @@ -1084,6 +1092,9 @@ trait ConcreteStoredConversions extends ConcreteBaseConversions {
implicit def accessPropertyIsExternal(
node: nodes.StoredNode & nodes.StaticType[nodes.HasIsExternalEMT]
): AccessPropertyIsExternal = new AccessPropertyIsExternal(node)
implicit def accessPropertyIsModuleImport(
node: nodes.StoredNode & nodes.StaticType[nodes.HasIsModuleImportEMT]
): AccessPropertyIsModuleImport = new AccessPropertyIsModuleImport(node)
implicit def accessPropertyIsVariadic(
node: nodes.StoredNode & nodes.StaticType[nodes.HasIsVariadicEMT]
): AccessPropertyIsVariadic = new AccessPropertyIsVariadic(node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ trait HasIsExplicitEMT
*/
trait HasIsExternalEMT

/** Node types with this marker trait are guaranteed to have the IS_MODULE_IMPORT property. EMT stands for: "erased
* marker trait", it exists only at compile time in order to improve type safety.
*/
trait HasIsModuleImportEMT

/** Node types with this marker trait are guaranteed to have the IS_VARIADIC property. EMT stands for: "erased marker
* trait", it exists only at compile time in order to improve type safety.
*/
Expand Down
Loading
Loading