netmap

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: Apache-2.0 Imports: 17 Imported by: 53

README

netmap

GitHub Test Status GoDoc License Go Report CodeFactor Codecov Follow on Twitter

Graphing package for mapping and visualizing the Internet.

Installation Go Version

go get -v -u github.com/caffix/netmap

This package is currently in development.

Documentation

Index

Constants

View Source
const (
	IN int = iota
	OUT
	BOTH
)

Constant values that represent the direction of edges during graph queries.

View Source
const TypeAS string = "as"

TypeAS is the type for an autonomous system in the graph database.

View Source
const TypeAddr string = "ipaddr"
View Source
const TypeEvent string = "event"

TypeEvent is the type that represents an event over a range of time that extended the graph.

View Source
const TypeFQDN string = "fqdn"
View Source
const TypeNetblock string = "netblock"
View Source
const TypeSource string = "source"

TypeSource is the type representing a data source that has contributed findings to the graph.

Variables

This section is empty.

Functions

This section is empty.

Types

type CayleyGraph

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

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

func NewCayleyGraph

func NewCayleyGraph(system, path string, options string) *CayleyGraph

NewCayleyGraph returns an intialized CayleyGraph object.

func NewCayleyGraphMemory

func NewCayleyGraphMemory() *CayleyGraph

NewCayleyGraphMemory creates a temporary graph in memory.

func (*CayleyGraph) Close

func (g *CayleyGraph) Close()

Close implements the GraphDatabase interface.

func (*CayleyGraph) DumpGraph

func (g *CayleyGraph) DumpGraph(ctx context.Context) string

DumpGraph prints all data currently in the graph.

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 Graph

type Graph struct {
	// contains filtered or unexported fields
}

Graph implements the network infrastructure data model.

func NewGraph

func NewGraph(database *CayleyGraph) *Graph

NewGraph accepts a graph database that stores the Graph created and maintained by the data model.

func (*Graph) AddNodeToEvent

func (g *Graph) AddNodeToEvent(ctx context.Context, node Node, source, eventID string) error

AddNodeToEvent creates associations between a node in the graph, a data source and a discovery task.

func (*Graph) AllNodesOfType

func (g *Graph) AllNodesOfType(ctx context.Context, ntype string, uuids ...string) ([]Node, error)

AllNodesOfType provides all nodes in the graph of the identified type within the optionally identified events.

func (*Graph) AllOutNodes

func (g *Graph) AllOutNodes(ctx context.Context, node Node) ([]Node, error)

AllOutNodes returns all the nodes that the parameter node has out edges to.

func (*Graph) CacheSourceData

func (g *Graph) CacheSourceData(ctx context.Context, source, query, resp string) error

CacheSourceData inserts an updated response from the source/tag for the query.

func (*Graph) Close

func (g *Graph) Close()

Close will close the graph database being used by the Graph receiver.

func (*Graph) CountEdges

func (g *Graph) CountEdges(ctx context.Context, node Node, predicates ...string) (int, error)

CountEdges counts the total number of edges to a node.

func (*Graph) CountInEdges

func (g *Graph) CountInEdges(ctx context.Context, node Node, predicates ...string) (int, error)

CountInEdges implements the GraphDatabase interface.

func (*Graph) CountOutEdges

func (g *Graph) CountOutEdges(ctx context.Context, node Node, predicates ...string) (int, error)

CountOutEdges implements the GraphDatabase interface.

func (*Graph) CountProperties

func (g *Graph) CountProperties(ctx context.Context, node Node, predicates ...string) (int, error)

CountProperties implements the GraphDatabase interface.

func (*Graph) DeleteEdge

func (g *Graph) DeleteEdge(ctx context.Context, edge *Edge) error

DeleteEdge implements the GraphDatabase interface.

func (*Graph) DeleteNode

func (g *Graph) DeleteNode(ctx context.Context, node Node) error

DeleteNode implements the GraphDatabase interface.

func (*Graph) DeleteProperty

func (g *Graph) DeleteProperty(ctx context.Context, node Node, predicate string, value interface{}) error

DeleteProperty implements the GraphDatabase interface.

func (*Graph) DumpGraph

func (g *Graph) DumpGraph(ctx context.Context) string

DumpGraph prints all data currently in the graph.

func (*Graph) EventDateRange

func (g *Graph) EventDateRange(ctx context.Context, uuid string) (time.Time, time.Time)

EventDateRange returns the date range associated with the provided event UUID.

func (*Graph) EventDomains

func (g *Graph) EventDomains(ctx context.Context, uuid string) []string

EventDomains returns the domains that were involved in the event.

func (*Graph) EventFQDNs

func (g *Graph) EventFQDNs(ctx context.Context, uuid string) []string

EventFQDNs returns the domains that were involved in the event.

func (*Graph) EventList

func (g *Graph) EventList(ctx context.Context) []string

EventList returns a list of event UUIDs found in the graph.

func (*Graph) EventSubdomains

func (g *Graph) EventSubdomains(ctx context.Context, events ...string) []string

EventSubdomains returns the subdomains discovered during the event(s).

func (*Graph) EventsInScope

func (g *Graph) EventsInScope(ctx context.Context, d ...string) []string

EventsInScope returns the events that include all of the domain arguments.

func (*Graph) GetSourceData

func (g *Graph) GetSourceData(ctx context.Context, source, query string, ttl int) (string, error)

GetSourceData returns the most recent response from the source/tag for the query within the time to live.

func (*Graph) InEventScope

func (g *Graph) InEventScope(ctx context.Context, node Node, uuid string, predicates ...string) bool

InEventScope checks if the Node parameter is within scope of the Event identified by the uuid parameter.

func (*Graph) IsCNAMENode

func (g *Graph) IsCNAMENode(ctx context.Context, fqdn string) bool

IsCNAMENode returns true if the FQDN has a CNAME edge to another FQDN in the graph.

func (*Graph) IsMXNode

func (g *Graph) IsMXNode(ctx context.Context, fqdn string) bool

IsMXNode returns true if the FQDN has a MX edge pointing to it in the graph.

func (*Graph) IsNSNode

func (g *Graph) IsNSNode(ctx context.Context, fqdn string) bool

IsNSNode returns true if the FQDN has a NS edge pointing to it in the graph.

func (*Graph) IsPTRNode

func (g *Graph) IsPTRNode(ctx context.Context, fqdn string) bool

IsPTRNode returns true if the FQDN has a PTR edge to another FQDN in the graph.

func (*Graph) IsRootDomainNode

func (g *Graph) IsRootDomainNode(ctx context.Context, fqdn string) bool

IsRootDomainNode returns true if the FQDN has a 'root' edge pointing to it in the graph.

func (*Graph) IsTLDNode

func (g *Graph) IsTLDNode(ctx context.Context, fqdn string) bool

IsTLDNode returns true if the FQDN has a 'tld' edge pointing to it in the graph.

func (*Graph) Migrate

func (g *Graph) Migrate(ctx context.Context, to *Graph) error

func (*Graph) MigrateEvents

func (g *Graph) MigrateEvents(ctx context.Context, to *Graph, uuids ...string) error

MigrateEvents copies the nodes and edges related to the Events identified by the uuids from the receiver Graph into another.

func (*Graph) MigrateEventsInScope

func (g *Graph) MigrateEventsInScope(ctx context.Context, to *Graph, d []string) error

MigrateEventsInScope copies the nodes and edges related to the Events identified by the uuids from the receiver Graph into another.

func (*Graph) NamesToAddrs

func (g *Graph) NamesToAddrs(ctx context.Context, uuid string, names ...string) ([]*NameAddrPair, error)

NamesToAddrs returns a NameAddrPair for each name / address combination discovered in the graph.

func (*Graph) NodeSources

func (g *Graph) NodeSources(ctx context.Context, node Node, events ...string) ([]string, error)

NodeSources returns the names of data sources that identified the Node parameter during the events.

func (*Graph) NodeToID

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

NodeToID implements the GraphDatabase interface.

func (*Graph) ReadASDescription

func (g *Graph) ReadASDescription(ctx context.Context, asn int) string

ReadASDescription the description property of an autonomous system in the graph.

func (*Graph) ReadASPrefixes

func (g *Graph) ReadASPrefixes(ctx context.Context, asn int) []string

func (*Graph) ReadEdges

func (g *Graph) ReadEdges(ctx context.Context, node Node, predicates ...string) ([]*Edge, error)

ReadEdges implements the GraphDatabase interface.

func (*Graph) ReadEventQuads

func (g *Graph) ReadEventQuads(ctx context.Context, uuids ...string) ([]quad.Quad, error)

ReadEventQuads returns all graph database quads associated with the provided events.

func (*Graph) ReadInEdges

func (g *Graph) ReadInEdges(ctx context.Context, node Node, predicates ...string) ([]*Edge, error)

ReadInEdges implements the GraphDatabase interface.

func (*Graph) ReadNode

func (g *Graph) ReadNode(ctx context.Context, id, ntype string) (Node, error)

ReadNode returns the node matching the id and type arguments.

func (*Graph) ReadOutEdges

func (g *Graph) ReadOutEdges(ctx context.Context, node Node, predicates ...string) ([]*Edge, error)

ReadOutEdges implements the GraphDatabase interface.

func (*Graph) ReadProperties

func (g *Graph) ReadProperties(ctx context.Context, node Node, predicates ...string) ([]*Property, error)

ReadProperties implements the GraphDatabase interface.

func (*Graph) String

func (g *Graph) String() string

String returns the name of the graph database used by the Graph.

func (*Graph) UpsertA

func (g *Graph) UpsertA(ctx context.Context, fqdn, addr, source, eventID string) error

UpsertA creates FQDN, IP address and A record edge in the graph and associates them with a source and event.

func (*Graph) UpsertAAAA

func (g *Graph) UpsertAAAA(ctx context.Context, fqdn, addr, source, eventID string) error

UpsertAAAA creates FQDN, IP address and AAAA record edge in the graph and associates them with a source and event.

func (*Graph) UpsertAS

func (g *Graph) UpsertAS(ctx context.Context, asn, desc, source, eventID string) (Node, error)

UpsertAS adds/updates an autonomous system in the graph.

func (*Graph) UpsertAddress

func (g *Graph) UpsertAddress(ctx context.Context, addr, source, eventID string) (Node, error)

UpsertAddress creates an IP address in the graph and associates it with a source and event.

func (*Graph) UpsertCNAME

func (g *Graph) UpsertCNAME(ctx context.Context, fqdn, target, source, eventID string) error

UpsertCNAME adds the FQDNs and CNAME record between them to the graph.

func (*Graph) UpsertEdge

func (g *Graph) UpsertEdge(ctx context.Context, edge *Edge) error

UpsertEdge will create an edge in the database if it does not already exist.

func (*Graph) UpsertEvent

func (g *Graph) UpsertEvent(ctx context.Context, eventID string) (Node, error)

UpsertEvent create an event node in the graph that represents a discovery task.

func (*Graph) UpsertFQDN

func (g *Graph) UpsertFQDN(ctx context.Context, name, source, eventID string) (Node, error)

UpsertFQDN adds a fully qualified domain name to the graph.

func (*Graph) UpsertInfrastructure

func (g *Graph) UpsertInfrastructure(ctx context.Context, asn int, desc, addr, cidr, source, eventID string) error

UpsertInfrastructure adds/updates an associated IP address, netblock and autonomous system in the graph.

func (*Graph) UpsertMX

func (g *Graph) UpsertMX(ctx context.Context, fqdn, target, source, eventID string) error

UpsertMX adds the FQDNs and MX record between them to the graph.

func (*Graph) UpsertNS

func (g *Graph) UpsertNS(ctx context.Context, fqdn, target, source, eventID string) error

UpsertNS adds the FQDNs and NS record between them to the graph.

func (*Graph) UpsertNetblock

func (g *Graph) UpsertNetblock(ctx context.Context, cidr, source, eventID string) (Node, error)

UpsertNetblock adds a netblock/CIDR to the graph.

func (*Graph) UpsertNode

func (g *Graph) UpsertNode(ctx context.Context, id, ntype string) (Node, error)

UpsertNode will create a node in the database.

func (*Graph) UpsertPTR

func (g *Graph) UpsertPTR(ctx context.Context, fqdn, target, source, eventID string) error

UpsertPTR adds the FQDNs and PTR record between them to the graph.

func (*Graph) UpsertProperty

func (g *Graph) UpsertProperty(ctx context.Context, node Node, predicate, value string) error

UpsertProperty implements the GraphDatabase interface.

func (*Graph) UpsertSRV

func (g *Graph) UpsertSRV(ctx context.Context, fqdn, service, target, source, eventID string) error

UpsertSRV adds the FQDNs and SRV record between them to the graph.

func (*Graph) UpsertSource

func (g *Graph) UpsertSource(ctx context.Context, source string) (Node, error)

UpsertSource creates a data source node in the graph.

func (*Graph) WriteNodeQuads

func (g *Graph) WriteNodeQuads(ctx context.Context, cg *Graph, nodes []Node) error

WriteNodeQuads replicates nodes from the cg parameter to the receiver Graph.

type NameAddrPair

type NameAddrPair struct {
	Name string
	Addr string
}

NameAddrPair represents a relationship between a DNS name and an IP address it eventually resolves to.

type Node

type Node interface{}

Node represents a node in the graph.

type Property

type Property struct {
	Predicate string
	Value     quad.Value
}

Property represents a node property.

Jump to

Keyboard shortcuts

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