db

package
v3.4.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CayleyGraph

type CayleyGraph struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

CayleyGraph is the object for managing a network infrastructure link graph.

func NewCayleyGraph

func NewCayleyGraph(path string) *CayleyGraph

NewCayleyGraph returns an intialized CayleyGraph object.

func NewCayleyGraphMemory

func NewCayleyGraphMemory() *CayleyGraph

NewCayleyGraphMemory creates a temporary graph in memory.

func (*CayleyGraph) AllNodesOfType

func (g *CayleyGraph) AllNodesOfType(ntype string, events ...string) ([]Node, error)

AllNodesOfType implements the GraphDatabase interface.

func (*CayleyGraph) Close

func (g *CayleyGraph) Close()

Close implements the GraphDatabase interface.

func (*CayleyGraph) CountInEdges

func (g *CayleyGraph) CountInEdges(node Node, predicates ...string) (int, error)

CountInEdges implements the GraphDatabase interface.

func (*CayleyGraph) CountOutEdges

func (g *CayleyGraph) CountOutEdges(node Node, predicates ...string) (int, error)

CountOutEdges implements the GraphDatabase interface.

func (*CayleyGraph) CountProperties

func (g *CayleyGraph) CountProperties(node Node, predicates ...string) (int, error)

CountProperties implements the GraphDatabase interface.

func (*CayleyGraph) DeleteEdge

func (g *CayleyGraph) DeleteEdge(edge *Edge) error

DeleteEdge implements the GraphDatabase interface.

func (*CayleyGraph) DeleteNode

func (g *CayleyGraph) DeleteNode(node Node) error

DeleteNode implements the GraphDatabase interface.

func (*CayleyGraph) DeleteProperty

func (g *CayleyGraph) DeleteProperty(node Node, predicate, value string) error

DeleteProperty implements the GraphDatabase interface.

func (*CayleyGraph) DumpGraph

func (g *CayleyGraph) DumpGraph() string

DumpGraph returns a string containing all data currently in the graph.

func (*CayleyGraph) InsertEdge

func (g *CayleyGraph) InsertEdge(edge *Edge) error

InsertEdge implements the GraphDatabase interface.

func (*CayleyGraph) InsertNode

func (g *CayleyGraph) InsertNode(id, ntype string) (Node, error)

InsertNode implements the GraphDatabase interface.

func (*CayleyGraph) InsertProperty

func (g *CayleyGraph) InsertProperty(node Node, predicate, value string) error

InsertProperty implements the GraphDatabase interface.

func (*CayleyGraph) NameToIPAddrs

func (g *CayleyGraph) NameToIPAddrs(node Node) ([]Node, error)

NameToIPAddrs implements the GraphDatabase interface.

func (*CayleyGraph) NodeSources

func (g *CayleyGraph) NodeSources(node Node, events ...string) ([]string, error)

NodeSources implements the GraphDatabase interface.

func (*CayleyGraph) NodeToID

func (g *CayleyGraph) NodeToID(n Node) string

NodeToID implements the GraphDatabase interface.

func (*CayleyGraph) ReadEdges

func (g *CayleyGraph) ReadEdges(node Node, predicates ...string) ([]*Edge, error)

ReadEdges implements the GraphDatabase interface.

func (*CayleyGraph) ReadInEdges

func (g *CayleyGraph) ReadInEdges(node Node, predicates ...string) ([]*Edge, error)

ReadInEdges implements the GraphDatabase interface.

func (*CayleyGraph) ReadNode

func (g *CayleyGraph) ReadNode(id string) (Node, error)

ReadNode implements the GraphDatabase interface.

func (*CayleyGraph) ReadOutEdges

func (g *CayleyGraph) ReadOutEdges(node Node, predicates ...string) ([]*Edge, error)

ReadOutEdges implements the GraphDatabase interface.

func (*CayleyGraph) ReadProperties

func (g *CayleyGraph) ReadProperties(node Node, predicates ...string) ([]*Property, error)

ReadProperties implements the GraphDatabase interface.

func (*CayleyGraph) String

func (g *CayleyGraph) String() string

String returns a description for the CayleyGraph object.

type Edge

type Edge struct {
	Predicate string
	From, To  Node
}

Edge represents an edge in the graph.

type GraphDatabase

type GraphDatabase interface {
	fmt.Stringer

	// Graph operations for adding and removing nodes
	NodeToID(n Node) string
	InsertNode(id, ntype string) (Node, error)
	ReadNode(name string) (Node, error)
	DeleteNode(node Node) error

	// Graph operations for querying for nodes using search criteria
	AllNodesOfType(ntype string, events ...string) ([]Node, error)
	NameToIPAddrs(node Node) ([]Node, error)

	// NodeSources returns the names of data sources that identified node during the events
	NodeSources(node Node, events ...string) ([]string, error)

	// Graph operations for manipulating property values of a node
	InsertProperty(node Node, predicate, value string) error
	// Returns a slice of predicate names and slice of the associated values
	ReadProperties(node Node, predicates ...string) ([]*Property, error)
	// Returns the number of values for the node that match the optional predicate names
	CountProperties(node Node, predicates ...string) (int, error)
	DeleteProperty(node Node, predicate, value string) error

	// Graph operations for adding and removing edges
	InsertEdge(edge *Edge) error
	ReadEdges(node Node, predicates ...string) ([]*Edge, error)
	ReadInEdges(node Node, predicates ...string) ([]*Edge, error)
	CountInEdges(node Node, predicates ...string) (int, error)
	ReadOutEdges(node Node, predicates ...string) ([]*Edge, error)
	CountOutEdges(node Node, predicates ...string) (int, error)
	DeleteEdge(edge *Edge) error

	// Signals for the database to close
	Close()
}

GraphDatabase is the interface for storage of Amass data.

type Node

type Node interface{}

Node represents a node in the graph.

type Property

type Property struct {
	Predicate string
	Value     string
}

Property represents a node property.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL