dfd

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2018 License: MIT Imports: 17 Imported by: 1

Documentation

Overview

Package uid implements unique ID provision for graphs.

Index

Constants

View Source
const Circle = "circle"
View Source
const Cylinder = "cylinder"
View Source
const Diamond = "diamond"
View Source
const Max = int64(^uint64(0) >> 1)

Max is the maximum value of int64.

Variables

This section is empty.

Functions

func Int64sEqual

func Int64sEqual(a, b Int64s) bool

Int64sEqual reports set equality between the parameters. Sets are equal if and only if they have the same elements.

func NewDfdGraph

func NewDfdGraph() *dfdGraph

Types

type Client

type Client struct {
	Config Config
	DFD    *DataFlowDiagram
}

func NewClient

func NewClient(dot_path string) *Client

func (*Client) DFDFromDOT

func (client *Client) DFDFromDOT() (encoding.Builder, error)

func (*Client) DFDToDOT

func (client *Client) DFDToDOT(dfd encoding.Builder) (string, error)

type Config

type Config struct {
	DFDName string
	DOTPath string
}

type DataFlowDiagram

type DataFlowDiagram struct {
	Name string

	Processes        map[string]*Process
	ExternalServices map[string]*ExternalService
	DataStores       map[string]*DataStore
	TrustBoundaries  map[string]*TrustBoundary
	Flows            map[string]*Flow
	// contains filtered or unexported fields
}

Graph

func DeserializeDFD

func DeserializeDFD(id string) *DataFlowDiagram

DeserializeDFD is used when loading a DFD from a DOT file, where an ID is already given

func InitializeDFD

func InitializeDFD(name string) *DataFlowDiagram

func (*DataFlowDiagram) AddFlow

func (g *DataFlowDiagram) AddFlow(f graph.Node, t graph.Node, name string) *Flow

func (DataFlowDiagram) AddNode

func (g DataFlowDiagram) AddNode(n graph.Node)

AddNode adds n to the graph. It panics if the added node ID matches an existing node ID.

func (*DataFlowDiagram) AddNodeElem

func (g *DataFlowDiagram) AddNodeElem(n graph.Node)

func (*DataFlowDiagram) AddTrustBoundary

func (dfd *DataFlowDiagram) AddTrustBoundary(name string) (*TrustBoundary, error)

func (DataFlowDiagram) DOTAttributeSetters

func (g DataFlowDiagram) DOTAttributeSetters() (graph, node, edge encoding.AttributeSetter)

DOTAttributeSetters implements the dot.AttributeSetters interface.

func (DataFlowDiagram) DOTAttributers

func (g DataFlowDiagram) DOTAttributers() (graph, node, edge encoding.Attributer)

DOTAttributers implements the dot.Attributers interface.

func (*DataFlowDiagram) DOTID

func (g *DataFlowDiagram) DOTID() string

func (DataFlowDiagram) Edge

func (g DataFlowDiagram) Edge(uid, vid int64) graph.Edge

Edge returns the edge from u to v if such an edge exists and nil otherwise. The node v must be directly reachable from u as defined by the From method.

func (DataFlowDiagram) Edges

func (g DataFlowDiagram) Edges() graph.Edges

Edges returns all the edges in the graph.

func (*DataFlowDiagram) ExternalID

func (dfd *DataFlowDiagram) ExternalID() string

func (*DataFlowDiagram) FindNode

func (g *DataFlowDiagram) FindNode(id string) graph.Node

FindNode looks for a node with a given id in either the top level graph or a subgraph. It assumes that all Nodes have unique IDs. This *should* be true, but further testing is required to really make this claim.

func (DataFlowDiagram) From

func (g DataFlowDiagram) From(id int64) graph.Nodes

From returns all nodes in g that can be reached directly from n.

func (*DataFlowDiagram) GetTrustBoundary

func (dfd *DataFlowDiagram) GetTrustBoundary(id string) *TrustBoundary

func (DataFlowDiagram) HasEdgeBetween

func (g DataFlowDiagram) HasEdgeBetween(xid, yid int64) bool

HasEdgeBetween returns whether an edge exists between nodes x and y without considering direction.

func (DataFlowDiagram) HasEdgeFromTo

func (g DataFlowDiagram) HasEdgeFromTo(uid, vid int64) bool

HasEdgeFromTo returns whether an edge exists in the graph from u to v.

func (DataFlowDiagram) NewEdge

func (g DataFlowDiagram) NewEdge(from, to graph.Node) graph.Edge

NewEdge returns a new Edge from the source to the destination node.

func (DataFlowDiagram) NewNode

func (g DataFlowDiagram) NewNode() graph.Node

func (DataFlowDiagram) Node

func (g DataFlowDiagram) Node(id int64) graph.Node

Node returns the node with the given ID if it exists in the graph, and nil otherwise.

func (DataFlowDiagram) Nodes

func (g DataFlowDiagram) Nodes() graph.Nodes

Nodes returns all the nodes in the graph.

func (*DataFlowDiagram) RemoveDataStore

func (g *DataFlowDiagram) RemoveDataStore(id string)

func (DataFlowDiagram) RemoveEdge

func (g DataFlowDiagram) RemoveEdge(fid, tid int64)

RemoveEdge removes the edge with the given end point IDs from the graph, leaving the terminal nodes. If the edge does not exist it is a no-op.

func (*DataFlowDiagram) RemoveExternalService

func (g *DataFlowDiagram) RemoveExternalService(id string)

func (*DataFlowDiagram) RemoveFlow

func (g *DataFlowDiagram) RemoveFlow(src_id, dest_id string)

func (DataFlowDiagram) RemoveNode

func (g DataFlowDiagram) RemoveNode(id int64)

RemoveNode removes the node with the given ID from the graph, as well as any edges attached to it. If the node is not in the graph it is a no-op.

func (*DataFlowDiagram) RemoveProcess

func (g *DataFlowDiagram) RemoveProcess(id string)

func (*DataFlowDiagram) RemoveTrustBoundary

func (g *DataFlowDiagram) RemoveTrustBoundary(id string)

func (DataFlowDiagram) SetDOTID

func (g DataFlowDiagram) SetDOTID(id string)

SetDOTID sets the DOT ID of the graph.

func (DataFlowDiagram) SetEdge

func (g DataFlowDiagram) SetEdge(e graph.Edge)

SetEdge adds e, an edge from one node to another. If the nodes do not exist, they are added and are set to the nodes of the edge otherwise. It will panic if the IDs of the e.From and e.To are equal.

func (*DataFlowDiagram) Structure

func (g *DataFlowDiagram) Structure() []dot.Graph

func (DataFlowDiagram) To

func (g DataFlowDiagram) To(id int64) graph.Nodes

To returns all nodes in g that can reach directly to n.

func (*DataFlowDiagram) ToDOT

func (dfd *DataFlowDiagram) ToDOT() error

func (*DataFlowDiagram) UpdateName

func (dfd *DataFlowDiagram) UpdateName(new_name string)

type DataStore

type DataStore struct {
	Name string
	// contains filtered or unexported fields
}

Node cylinder

func DeserializeDataStore

func DeserializeDataStore(id string) *DataStore

func NewDataStore

func NewDataStore(name string) *DataStore

func (DataStore) Attributes

func (n DataStore) Attributes() []encoding.Attribute

Attributes returns the DOT attributes of the node.

func (*DataStore) DOTID

func (n *DataStore) DOTID() string

func (*DataStore) ExternalID

func (n *DataStore) ExternalID() string

func (DataStore) SetAttribute

func (n DataStore) SetAttribute(attr encoding.Attribute) error

SetAttribute sets a DOT attribute.

func (DataStore) SetDOTID

func (n DataStore) SetDOTID(id string)

SetDOTID sets a DOT ID.

func (*DataStore) UpdateName

func (n *DataStore) UpdateName(new_name string)

type DfdGraph

type DfdGraph interface {
	AddNodeElem(graph.Node)

	RemoveProcess(string)
	RemoveExternalService(string)
	RemoveDataStore(string)
	// contains filtered or unexported methods
}

type DfdNode

type DfdNode interface {
	ExternalID() string
	UpdateName(string)
	DOTID() string
}

type ExternalService

type ExternalService struct {
	Name string
	// contains filtered or unexported fields
}

Node diamond

func DeserializeExternalService

func DeserializeExternalService(id string) *ExternalService

func NewExternalService

func NewExternalService(name string) *ExternalService

func (ExternalService) Attributes

func (n ExternalService) Attributes() []encoding.Attribute

Attributes returns the DOT attributes of the node.

func (*ExternalService) DOTID

func (es *ExternalService) DOTID() string

func (ExternalService) ExternalID

func (n ExternalService) ExternalID() string

func (ExternalService) SetAttribute

func (n ExternalService) SetAttribute(attr encoding.Attribute) error

SetAttribute sets a DOT attribute.

func (ExternalService) SetDOTID

func (n ExternalService) SetDOTID(id string)

SetDOTID sets a DOT ID.

func (*ExternalService) UpdateName

func (n *ExternalService) UpdateName(new_name string)

type Flow

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

Edge

func (*Flow) Attributes

func (f *Flow) Attributes() []encoding.Attribute

func (Flow) FromPort

func (e Flow) FromPort() (port, compass string)

func (Flow) SetAttribute

func (e Flow) SetAttribute(attr encoding.Attribute) error

SetAttribute sets a DOT attribute.

func (Flow) SetFromPort

func (e Flow) SetFromPort(port, compass string) error

func (Flow) SetToPort

func (e Flow) SetToPort(port, compass string) error

func (Flow) ToPort

func (e Flow) ToPort() (port, compass string)

type Int64s

type Int64s map[int64]struct{}

func (Int64s) Add

func (s Int64s) Add(e int64)

Add inserts an element into the set.

func (Int64s) Count

func (s Int64s) Count() int

Count reports the number of elements stored in the set.

func (Int64s) Has

func (s Int64s) Has(e int64) bool

Has reports the existence of the element in the set.

func (Int64s) Remove

func (s Int64s) Remove(e int64)

Remove deletes the specified element from the set.

type Process

type Process struct {
	Name string
	// contains filtered or unexported fields
}

Node circle

func DeserializeProcess

func DeserializeProcess(id string) *Process

DeserializeProcess returns a pointer to a Process with a given id

func NewProcess

func NewProcess(name string) *Process

NewProcess returns a pointer to a Process with the given name and an autogenerated id

func (Process) Attributes

func (n Process) Attributes() []encoding.Attribute

Attributes returns the DOT attributes of the node.

func (*Process) DOTID

func (p *Process) DOTID() string

func (*Process) ExternalID

func (p *Process) ExternalID() string

func (Process) SetAttribute

func (n Process) SetAttribute(attr encoding.Attribute) error

SetAttribute sets a DOT attribute.

func (Process) SetDOTID

func (n Process) SetDOTID(id string)

SetDOTID sets a DOT ID.

func (*Process) UpdateName

func (n *Process) UpdateName(new_name string)

type Set

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

Set implements available ID storage.

func NewSet

func NewSet() Set

NewSet returns a new Set. The returned value should not be passed except by pointer.

func (*Set) NewID

func (s *Set) NewID() int64

NewID returns a new unique ID. The ID returned is not considered used until passed in a call to use.

func (*Set) Release

func (s *Set) Release(id int64)

Release frees the id for reuse.

func (*Set) Use

func (s *Set) Use(id int64)

Use adds the id to the used IDs in the Set.

type TrustBoundary

type TrustBoundary struct {
	Name string

	Processes        map[string]*Process
	ExternalServices map[string]*ExternalService
	DataStores       map[string]*DataStore
	// contains filtered or unexported fields
}

Subgraph

func DeserializeTrustBoundary

func DeserializeTrustBoundary(id string) *TrustBoundary

DeserializeTrustBoundary is used when loading a DFD from a DOT file, where an ID is already given

func InitializeTrustBoundary

func InitializeTrustBoundary(name string) *TrustBoundary

func (TrustBoundary) AddNode

func (g TrustBoundary) AddNode(n graph.Node)

AddNode adds n to the graph. It panics if the added node ID matches an existing node ID.

func (*TrustBoundary) AddNodeElem

func (g *TrustBoundary) AddNodeElem(n graph.Node)

func (TrustBoundary) DOTAttributeSetters

func (g TrustBoundary) DOTAttributeSetters() (graph, node, edge encoding.AttributeSetter)

DOTAttributeSetters implements the dot.AttributeSetters interface.

func (TrustBoundary) DOTAttributers

func (g TrustBoundary) DOTAttributers() (graph, node, edge encoding.Attributer)

DOTAttributers implements the dot.Attributers interface.

func (*TrustBoundary) DOTID

func (g *TrustBoundary) DOTID() string

func (TrustBoundary) Edge

func (g TrustBoundary) Edge(uid, vid int64) graph.Edge

Edge returns the edge from u to v if such an edge exists and nil otherwise. The node v must be directly reachable from u as defined by the From method.

func (TrustBoundary) Edges

func (g TrustBoundary) Edges() graph.Edges

Edges returns all the edges in the graph.

func (*TrustBoundary) ExternalID

func (sg *TrustBoundary) ExternalID() string

func (*TrustBoundary) FindNode

func (g *TrustBoundary) FindNode(id string) graph.Node

FindNode looks for a node with a given id It assumes that all Nodes have unique IDs. This *should* be true, but further testing is required to really make this claim.

func (TrustBoundary) From

func (g TrustBoundary) From(id int64) graph.Nodes

From returns all nodes in g that can be reached directly from n.

func (TrustBoundary) HasEdgeBetween

func (g TrustBoundary) HasEdgeBetween(xid, yid int64) bool

HasEdgeBetween returns whether an edge exists between nodes x and y without considering direction.

func (TrustBoundary) HasEdgeFromTo

func (g TrustBoundary) HasEdgeFromTo(uid, vid int64) bool

HasEdgeFromTo returns whether an edge exists in the graph from u to v.

func (TrustBoundary) NewEdge

func (g TrustBoundary) NewEdge(from, to graph.Node) graph.Edge

NewEdge returns a new Edge from the source to the destination node.

func (TrustBoundary) NewNode

func (g TrustBoundary) NewNode() graph.Node

func (TrustBoundary) Node

func (g TrustBoundary) Node(id int64) graph.Node

Node returns the node with the given ID if it exists in the graph, and nil otherwise.

func (TrustBoundary) Nodes

func (g TrustBoundary) Nodes() graph.Nodes

Nodes returns all the nodes in the graph.

func (*TrustBoundary) RemoveDataStore

func (g *TrustBoundary) RemoveDataStore(id string)

func (TrustBoundary) RemoveEdge

func (g TrustBoundary) RemoveEdge(fid, tid int64)

RemoveEdge removes the edge with the given end point IDs from the graph, leaving the terminal nodes. If the edge does not exist it is a no-op.

func (*TrustBoundary) RemoveExternalService

func (g *TrustBoundary) RemoveExternalService(id string)

func (TrustBoundary) RemoveNode

func (g TrustBoundary) RemoveNode(id int64)

RemoveNode removes the node with the given ID from the graph, as well as any edges attached to it. If the node is not in the graph it is a no-op.

func (*TrustBoundary) RemoveProcess

func (g *TrustBoundary) RemoveProcess(id string)

func (TrustBoundary) SetDOTID

func (g TrustBoundary) SetDOTID(id string)

SetDOTID sets the DOT ID of the graph.

func (TrustBoundary) SetEdge

func (g TrustBoundary) SetEdge(e graph.Edge)

SetEdge adds e, an edge from one node to another. If the nodes do not exist, they are added and are set to the nodes of the edge otherwise. It will panic if the IDs of the e.From and e.To are equal.

func (*TrustBoundary) Subgraph

func (g *TrustBoundary) Subgraph() graph.Graph

func (TrustBoundary) To

func (g TrustBoundary) To(id int64) graph.Nodes

To returns all nodes in g that can reach directly to n.

func (*TrustBoundary) UpdateName

func (sg *TrustBoundary) UpdateName(new_name string)

Jump to

Keyboard shortcuts

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