예제 #1
0
 class AnotherLocalisableEntity(neomodel.StructuredNode):
     """
     A very simple entity with an array of locations
     """
     identifier = neomodel.UniqueIdProperty()
     locations = neomodel.ArrayProperty(
         neomodel.contrib.spatial_properties.PointProperty(crs='cartesian'))
예제 #2
0
 class LocalisableEntity(neomodel.StructuredNode):
     """
     A very simple entity to try out the default value assignment.
     """
     identifier = neomodel.UniqueIdProperty()
     location = neomodel.contrib.spatial_properties.PointProperty(
         crs='cartesian', default=get_some_point)
예제 #3
0
class PipelineRunInfo(neomodel.StructuredNode):
    """
    Define a model for pipeline run information.
    """
    uid = neomodel.UniqueIdProperty()  # Unique ID for this database entry
    run_id = neomodel.StringProperty(
    )  # ID for this pipeline run, created with sentence IDs involved in this run
    timestamp = neomodel.StringProperty(
    )  # Timestamp for the current pipeline run
    article_ids = neomodel.ArrayProperty(
    )  # List of sentence IDs involved in this pipeline run
예제 #4
0
class Recipe(nm.StructuredNode):
    r_id = nm.UniqueIdProperty()
    title = nm.StringProperty()
    description = nm.StringProperty()
    requires = nm.RelationshipTo('Ingredient', 'REQUIRES', model=Requires)

    def to_dict(self):
        return {
            'r_id': self.r_id,
            'title': self.title,
            'description': self.description
        }
예제 #5
0
class Entity(neomodel.StructuredNode, EveCompatibilityMixin):
    """
    Node model for entities in the graph.
    """
    uid = neomodel.UniqueIdProperty()  # Unique ID for this database entry
    category = neomodel.StringProperty(
    )  # Category of this entity (Person, Organization...)
    label = neomodel.StringProperty(
    )  # Text that should be displayed about this node
    data = neomodel.JSONProperty(
    )  # Dictionary with more detailed data about this entity
    relations = neomodel.Relationship("Entity",
                                      "CONNECTED_WITH",
                                      model=Relation)
    weight = neomodel.IntegerProperty(default=1)
예제 #6
0
class DOMSnapshot(neomodel.StructuredNode):

    ## html path 		--> Location field
    ## html code 		--> Code field
    ## other properties are currently empty

    # properties
    Id = neomodel.UniqueIdProperty()
    Type = neomodel.StringProperty()
    Kind = neomodel.StringProperty()
    Code = neomodel.StringProperty()
    Range = neomodel.StringProperty()
    Location = neomodel.StringProperty()
    Value = neomodel.StringProperty()
    Raw = neomodel.StringProperty()
    Async = neomodel.StringProperty()
    SemanticType = neomodel.StringProperty()
예제 #7
0
class EventNode(neomodel.StructuredNode):

    ## event name --> Type field
    ## event target --> Value field
    ## other properties are currently empty

    # properties
    Id = neomodel.UniqueIdProperty()
    Type = neomodel.StringProperty()
    Kind = neomodel.StringProperty()
    Code = neomodel.StringProperty()
    Range = neomodel.StringProperty()
    Location = neomodel.StringProperty()
    Value = neomodel.StringProperty()
    Raw = neomodel.StringProperty()
    Async = neomodel.StringProperty()
    SemanticType = neomodel.StringProperty()
예제 #8
0
class CookieNode(neomodel.StructuredNode):

    ## cookie name 		--> Raw field
    ## cookie value 	--> Value field
    ## cookie httpOnly  --> Type field
    ## other properties are currently empty

    # properties
    Id = neomodel.UniqueIdProperty()
    Type = neomodel.StringProperty()
    Kind = neomodel.StringProperty()
    Code = neomodel.StringProperty()
    Range = neomodel.StringProperty()
    Location = neomodel.StringProperty()
    Value = neomodel.StringProperty()
    Raw = neomodel.StringProperty()
    Async = neomodel.StringProperty()
    SemanticType = neomodel.StringProperty()
예제 #9
0
class RequestNode(neomodel.StructuredNode):

    ## request method 					   --> Type field
    ## request kind (e.g., xmlhttprequest) --> Kind field
    ## request URL						   --> Value field
    ## request body						   --> Raw field
    ## request status code 				   --> Code field
    ## other properties are currently empty

    # properties
    Id = neomodel.UniqueIdProperty()
    Type = neomodel.StringProperty()
    Kind = neomodel.StringProperty()
    Code = neomodel.StringProperty()
    Range = neomodel.StringProperty()
    Location = neomodel.StringProperty()
    Value = neomodel.StringProperty()
    Raw = neomodel.StringProperty()
    Async = neomodel.StringProperty()
    SemanticType = neomodel.StringProperty()
예제 #10
0
class SomeEntity(neomodel.StructuredNode):
    """
        A bare minimum entity specified in neomodel to demonstrate the error condition and how to enter it.
    """
    serial_num = neomodel.UniqueIdProperty()
    payload = neomodel.StringProperty(unique_index=True)
예제 #11
0
 class SomePerson(BaseOtherPerson):
     uid = neomodel.UniqueIdProperty()
예제 #12
0
class ASTNode(neomodel.StructuredNode):

    # properties
    Id = neomodel.UniqueIdProperty()
    Type = neomodel.StringProperty()
    Kind = neomodel.StringProperty()
    Code = neomodel.StringProperty()
    Range = neomodel.StringProperty()
    Location = neomodel.StringProperty()
    Value = neomodel.StringProperty()
    Raw = neomodel.StringProperty()
    Async = neomodel.StringProperty()
    SemanticType = neomodel.StringProperty()

    # Abstract Syntax Tree (AST) relationships
    ASTConnectionsTo = neomodel.RelationshipTo('ASTNode',
                                               'AST_parentOf',
                                               model=RelationshipSchema)
    ASTConnectionsFrom = neomodel.RelationshipFrom('ASTNode',
                                                   'AST_parentOf',
                                                   model=RelationshipSchema)
    ASTConnections = neomodel.Relationship('ASTNode',
                                           'AST_parentOf',
                                           model=RelationshipSchema)

    # Control Flow Graph (CFG) relationships
    CFGConnectionsTo = neomodel.RelationshipTo('ASTNode',
                                               'CFG_parentOf',
                                               model=RelationshipSchema)
    CFGConnectionsFrom = neomodel.RelationshipFrom('ASTNode',
                                                   'CFG_parentOf',
                                                   model=RelationshipSchema)
    CFGConnections = neomodel.Relationship('ASTNode',
                                           'CFG_parentOf',
                                           model=RelationshipSchema)

    # Program Dependence Graph (PDG) relationships
    PDGConnectionsTo = neomodel.RelationshipTo('ASTNode',
                                               'PDG_parentOf',
                                               model=RelationshipSchema)
    PDGConnectionsFrom = neomodel.RelationshipFrom('ASTNode',
                                                   'PDG_parentOf',
                                                   model=RelationshipSchema)
    PDGConnections = neomodel.Relationship('ASTNode',
                                           'PDG_parentOf',
                                           model=RelationshipSchema)

    # Inter-Procedural Call Graph (IPCG) relationships
    IPCGConnectionsTo = neomodel.RelationshipTo('ASTNode',
                                                'CG_parentOf',
                                                model=RelationshipSchema)
    IPCGConnectionsFrom = neomodel.RelationshipFrom('ASTNode',
                                                    'CG_parentOf',
                                                    model=RelationshipSchema)
    IPCGConnections = neomodel.Relationship('ASTNode',
                                            'CG_parentOf',
                                            model=RelationshipSchema)

    # Event Registration of ERDDG relationships
    ERDDGRegistrationConnectionsTo = neomodel.RelationshipTo(
        'ASTNode', 'ERDDG_Registration', model=RelationshipSchema)
    ERDDGRegistrationConnectionsFrom = neomodel.RelationshipFrom(
        'ASTNode', 'ERDDG_Registration', model=RelationshipSchema)
    ERDDGRegistrationConnections = neomodel.Relationship(
        'ASTNode', 'ERDDG_Registration', model=RelationshipSchema)

    # Event Dispatch of ERDDG relationships
    ERDDGDispatchConnectionsTo = neomodel.RelationshipTo(
        'ASTNode', 'ERDDG_Dispatch', model=RelationshipSchema)
    ERDDGDispatchConnectionsFrom = neomodel.RelationshipFrom(
        'ASTNode', 'ERDDG_Dispatch', model=RelationshipSchema)
    ERDDGRegistrationConnections = neomodel.Relationship(
        'ASTNode', 'ERDDG_Registration', model=RelationshipSchema)

    # Event Dependency of ERDDG relationships
    ERDDGDependencyConnectionsTo = neomodel.RelationshipTo(
        'ASTNode', 'ERDDG_Dependency', model=RelationshipSchema)
    ERDDGDependencyConnectionsFrom = neomodel.RelationshipFrom(
        'ASTNode', 'ERDDG_Dependency', model=RelationshipSchema)
    ERDDGDependencyConnections = neomodel.Relationship(
        'ASTNode', 'ERDDG_Dependency', model=RelationshipSchema)

    # ------------------------------------------------------------------------------------------------ #
    #					General Methods
    # ------------------------------------------------------------------------------------------------ #

    def get_line(self):
        """
		@return {list|None}: [(a, b)] where a, b are the start and end lines for the code of the AST node 
		
		"""
        if self.location is not None:
            loc = eval(self.location)
            return [loc.start.line, loc.end.line]

        return None

    def is_cfg_node(self):
        # TODO
        pass

    def has_cfg_edge(self):
        # TODO
        pass

    def has_pdg_edge(self):
        # TODO
        pass

    # ------------------------------------------------------------------------------------------------ #
    #					Edge Traversals
    # ------------------------------------------------------------------------------------------------ #

    def get_connections_by_ast(self,
                               direction=neomodel.match.OUTGOING,
                               **kwargs):
        """
		@param {string} direction: neomodel.match.OUTGOING / neomodel.match.INCOMING / neomodel.match.EITHER
		@param **kwargs: positional keyword arguments specifying the constraints on the edges for traversals
		@return {list}: related AST nodes
		"""

        if direction == neomodel.match.OUTGOING:
            return self.ASTConnectionsTo.match(**kwargs).all()
        elif direction == neomodel.match.INCOMING:
            return self.ASTConnectionsFrom.match(**kwargs).all()
        else:
            return self.ASTConnections.match(**kwargs).all()

    def get_connections_by_cfg(self,
                               direction=neomodel.match.OUTGOING,
                               **kwargs):
        """
		@param {string} direction: neomodel.match.OUTGOING / neomodel.match.INCOMING / neomodel.match.EITHER
		@param **kwargs: positional keyword arguments specifying the constraints on the edges for traversals
		@return {list} related CFG nodes
		"""

        if direction == neomodel.match.OUTGOING:
            return self.CFGConnectionsTo.match(**kwargs).all()
        elif direction == neomodel.match.INCOMING:
            return self.CFGConnectionsFrom.match(**kwargs).all()
        else:
            return self.CFGConnections.match(**kwargs).all()

    def get_connections_by_pdg(self,
                               direction=neomodel.match.OUTGOING,
                               **kwargs):
        """
		@param {string} direction: neomodel.match.OUTGOING / neomodel.match.INCOMING / neomodel.match.EITHER
		@param **kwargs: positional keyword arguments specifying the constraints on the edges for traversals
		@return {list} related PDG nodes
		"""

        if direction == neomodel.match.OUTGOING:
            return self.PDGConnectionsTo.match(**kwargs).all()
        elif direction == neomodel.match.INCOMING:
            return self.PDGConnectionsFrom.match(**kwargs).all()
        else:
            return self.PDGConnections.match(**kwargs).all()

    def get_connections_by_ipcg(self,
                                direction=neomodel.match.OUTGOING,
                                **kwargs):
        """
		@param {string} direction: neomodel.match.OUTGOING / neomodel.match.INCOMING / neomodel.match.EITHER
		@param **kwargs: positional keyword arguments specifying the constraints on the edges for traversals
		@return {list} related IPCG nodes
		"""

        if direction == neomodel.match.OUTGOING:
            return self.IPCGConnectionsTo.match(**kwargs).all()
        elif direction == neomodel.match.INCOMING:
            return self.IPCGConnectionsFrom.match(**kwargs).all()
        else:
            return self.IPCGConnections.match(**kwargs).all()

    def get_connections_by_erddg_dispatch(self,
                                          direction=neomodel.match.OUTGOING,
                                          **kwargs):
        """
		@param {string} direction: neomodel.match.OUTGOING / neomodel.match.INCOMING / neomodel.match.EITHER
		@param **kwargs: positional keyword arguments specifying the constraints on the edges for traversals
		@return {list} related nodes via ERDDG Dispatch edges
		"""

        if direction == neomodel.match.OUTGOING:
            return self.ERDDGDispatchConnectionsTo.match(**kwargs).all()
        elif direction == neomodel.match.INCOMING:
            return self.ERDDGDispatchConnectionsFrom.match(**kwargs).all()
        else:
            return self.ERDDGDispatchConnections.match(**kwargs).all()

    def get_connections_by_erddg_registration(self,
                                              direction=neomodel.match.
                                              OUTGOING,
                                              **kwargs):
        """
		@param {string} direction: neomodel.match.OUTGOING / neomodel.match.INCOMING / neomodel.match.EITHER
		@param **kwargs: positional keyword arguments specifying the constraints on the edges for traversals
		@return {list} related nodes via ERDDG Registration edges
		"""

        if direction == neomodel.match.OUTGOING:
            return self.ERDDGRegistrationConnectionsTo.match(**kwargs).all()
        elif direction == neomodel.match.INCOMING:
            return self.ERDDGRegistrationConnectionsFrom.match(**kwargs).all()
        else:
            return self.ERDDGRegistrationConnections.match(**kwargs).all()

    def get_connections_by_erddg_dependency(self,
                                            direction=neomodel.match.OUTGOING,
                                            **kwargs):
        """
		@param {string} direction: neomodel.match.OUTGOING / neomodel.match.INCOMING / neomodel.match.EITHER
		@param **kwargs: positional keyword arguments specifying the constraints on the edges for traversals
		@return {list} related nodes via ERDDG Dependency edges
		"""

        if direction == neomodel.match.OUTGOING:
            return self.ERDDGDependencyConnectionsTo.match(**kwargs).all()
        elif direction == neomodel.match.INCOMING:
            return self.ERDDGDependencyConnectionsFrom.match(**kwargs).all()
        else:
            return self.ERDDGDependencyConnections.match(**kwargs).all()
예제 #13
0
 class TestStorageRetrievalProperty(neomodel.StructuredNode):
     uid = neomodel.UniqueIdProperty()
     description = neomodel.StringProperty()
     location = neomodel.contrib.spatial_properties.PointProperty(
         crs="cartesian")