Ejemplo n.º 1
0
    @classmethod
    def node_schema(cls) -> "Schema":
        return ProcessInboundConnectionSchema()


from grapl_analyzerlib.nodes.ip_port import IpPortSchema, IpPortQuery, IpPortView

ProcessInboundConnectionSchema().init_reverse()


class ProcessInboundConnectionExtendsIpPortQuery(IpPortQuery):
    def with_bound_port(self, *bound_ports):
        self.with_to_neighbor(ProcessInboundConnectionQuery, "bound_port",
                              "bound_by", bound_ports)


class ProcessInboundConnectionExtendsIpPortView(IpPortView):
    def get_bound_port(self, *bound_ports, cached=False):
        self.get_neighbor(
            ProcessInboundConnectionQuery,
            "bound_port",
            "bound_by",
            bound_ports,
            cached=cached,
        )


IpPortQuery = IpPortQuery.extend_self(
    ProcessInboundConnectionExtendsIpPortQuery)
IpPortView = IpPortView.extend_self(ProcessInboundConnectionExtendsIpPortView)
Ejemplo n.º 2
0
NetworkConnectionSchema().init_reverse()


class NetworkConnectionExtendsIpPortQuery(IpPortQuery):
    def with_inbound_network_connections_from(
            self, *inbound_network_connections_from):
        return self.with_to_neighbor(
            NetworkConnectionQuery,
            "inbound_network_connections_from",
            "inbound_network_connection_to",
            inbound_network_connections_from,
        )


class NetworkConnectionExtendsIpPortView(IpPortQuery):
    def get_inbound_network_connections_from(self,
                                             *inbound_network_connections_from,
                                             cached=False):
        return self.get_neighbor(
            NetworkConnectionQuery,
            "inbound_network_connections_from",
            "inbound_network_connection_to",
            inbound_network_connections_from,
            cached=cached,
        )


IpPortQuery = IpPortQuery.extend_self(NetworkConnectionExtendsIpPortQuery)
IpPortView = IpPortView.extend_self(NetworkConnectionExtendsIpPortView)