analyzers

package
v0.0.0-...-ac32242 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SeverityInfo represents informational severity
	SeverityInfo int = iota
	// SeverityLow represents low severity
	SeverityLow
	// SeverityMed represents medium severity
	SeverityMed
	// SeverityHigh represents high severity
	SeverityHigh
)
View Source
const (
	// CallGraphCallInternal represents an internal function call.
	CallGraphCallInternal = iota
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Analyzer

type Analyzer interface {
	Name() string
	ID() string
	Execute(*sources.Source) ([]*Issue, error)
}

Analyzer is an interface for all analyzers.

type CallGraph

type CallGraph struct {
	SubGraphs    []*CallGraphSubGraph
	SubGraphsMap map[string]*CallGraphSubGraph
	Edges        []*CallGraphEdge
	EdgesMap     map[string]*CallGraphEdge
	DotAttrs     *DotAttrs
	NodeDotAttrs *DotAttrs
	EdgeDotAttrs *DotAttrs
}

CallGraph is the root of a call graph that only has subgraphs and edges.

func NewCallGraph

func NewCallGraph() *CallGraph

NewCallGraph returns a new instance of CallGraph.

func (*CallGraph) AddEdge

func (cg *CallGraph) AddEdge(from *CallGraphNode, to *CallGraphNode, subType int)

AddEdge adds a new edge to the graph.

func (*CallGraph) String

func (cg *CallGraph) String() string

func (*CallGraph) SubGraph

func (cg *CallGraph) SubGraph(id string) *CallGraphSubGraph

SubGraph creates a new graph or returns an existing one.

type CallGraphAnalyzer

type CallGraphAnalyzer struct{}

CallGraphAnalyzer is an analyzer that reports issues related to function calls.

func (*CallGraphAnalyzer) Execute

func (cga *CallGraphAnalyzer) Execute(source *sources.Source) ([]*Issue, error)

Execute runs the analyzer on a given source.

func (*CallGraphAnalyzer) ID

func (cga *CallGraphAnalyzer) ID() string

ID returns the unique ID of the analyzer.

func (*CallGraphAnalyzer) Name

func (cga *CallGraphAnalyzer) Name() string

Name returns the name of the analyzer.

type CallGraphEdge

type CallGraphEdge struct {
	From     *CallGraphNode
	To       *CallGraphNode
	SubType  int
	DotAttrs *DotAttrs
}

CallGraphEdge is a call graph edge.

func NewCallGraphEdge

func NewCallGraphEdge(from *CallGraphNode, to *CallGraphNode, subType int) *CallGraphEdge

NewCallGraphEdge returns a new instance of CallGraphEdge.

type CallGraphNode

type CallGraphNode struct {
	ID       string
	Function *sources.Function
	DotAttrs *DotAttrs
}

CallGraphNode is a call graph node.

func NewCallGraphNode

func NewCallGraphNode(id string, fn *sources.Function) *CallGraphNode

NewCallGraphNode returns a new instance of CallGraphNode.

type CallGraphSubGraph

type CallGraphSubGraph struct {
	ID       string
	Nodes    []*CallGraphNode
	NodesMap map[string]*CallGraphNode
	Edges    []*CallGraphEdge
	EdgesMap map[string]*CallGraphEdge
	DotAttrs *DotAttrs
}

CallGraphSubGraph is a subgraph of a call graph.

func NewCallGraphSubGraph

func NewCallGraphSubGraph(id string) *CallGraphSubGraph

NewCallGraphSubGraph returns a new instance of CallGraphSubGraph.

func (*CallGraphSubGraph) AddEdge

func (sg *CallGraphSubGraph) AddEdge(from *CallGraphNode, to *CallGraphNode, subType int)

AddEdge adds a new edge to a subgraph.

func (*CallGraphSubGraph) Node

Node creates a new node or returns an existing one.

type CompilerBug

type CompilerBug struct {
	Name        string `json:"name"`
	Summary     string `json:"summary"`
	Description string `json:"description"`
	Introduced  string `json:"introduced"`
	Fixed       string `json:"fixed"`
	Severity    string `json:"severity"`
	URL         string `json:"url"`
}

CompilerBug represents a known bug affecting a version of the Solidity compiler.

type CompilerVersionAnalyzer

type CompilerVersionAnalyzer struct {
	LatestVersion    string
	KnownBugs        []*CompilerBug
	KnownBugVersions map[string]*KnownBugVersion
	AffectedBugs     map[string]bool
}

CompilerVersionAnalyzer is an analyzer that reports issues related to the version of the Solidity compiler declared in a source's solidity pragma.

func NewCompilerVersionAnalyzer

func NewCompilerVersionAnalyzer() (*CompilerVersionAnalyzer, error)

NewCompilerVersionAnalyzer returns a new instance of the analyzer.

func (*CompilerVersionAnalyzer) Execute

func (cva *CompilerVersionAnalyzer) Execute(source *sources.Source) ([]*Issue, error)

Execute runs the analyzer on a given source.

func (*CompilerVersionAnalyzer) ID

func (cva *CompilerVersionAnalyzer) ID() string

ID returns the unique ID of the analyzer.

func (*CompilerVersionAnalyzer) Name

func (cva *CompilerVersionAnalyzer) Name() string

Name returns the name of the analyzer.

type DotAttrs

type DotAttrs map[string]string

DotAttrs is a map of attributes for dot templates.

func (*DotAttrs) AsProps

func (da *DotAttrs) AsProps() []string

AsProps returns a string of attributes in property list format.

func (*DotAttrs) Inline

func (da *DotAttrs) Inline() string

Inline returns a string of attributes in in-line format.

func (*DotAttrs) String

func (da *DotAttrs) String() string

type FunctionVisibilityAnalyzer

type FunctionVisibilityAnalyzer struct{}

FunctionVisibilityAnalyzer is an analyzer that reports issues related to function visibility.

func (*FunctionVisibilityAnalyzer) Execute

func (fva *FunctionVisibilityAnalyzer) Execute(source *sources.Source) ([]*Issue, error)

Execute runs the analyzer on a given source.

func (*FunctionVisibilityAnalyzer) ID

ID returns the unique ID of the analyzer.

func (*FunctionVisibilityAnalyzer) Name

func (fva *FunctionVisibilityAnalyzer) Name() string

Name returns the name of the analyzer.

type Issue

type Issue struct {
	Severity int
	Title    string
	Format   string
	Message  string
	// contains filtered or unexported fields
}

Issue contains output generated by an analyzer.

func (*Issue) AnalyzerID

func (i *Issue) AnalyzerID() string

AnalyzerID returns the ID of an analyzer associated with an issue.

func (*Issue) ID

func (i *Issue) ID() string

ID returns the ID associated with an issue.

func (*Issue) Source

func (i *Issue) Source() string

Source returns the source location of an issue.

type KnownBugVersion

type KnownBugVersion struct {
	Bugs []string `json:"bugs"`
}

KnownBugVersion represents a version of the Solidity compiler with one or more known bugs.

Jump to

Keyboard shortcuts

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