analysis

package
v0.0.0-...-bcfd2cf Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package analysis applicability vs reliability: applicability describes in a deterministic way if an heuristic is applicable to a transaction based on its conditions while reliability is the degree of reliability the heuristic provides whether it is applicable to the transaction.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnfeasibleAnalysis = errors.New("Analysis not feasible")

ErrUnfeasibleAnalysis analysis not feasible error

View Source
var ErrUnfeasibleTx = errors.New("Transaction not feasible for analysis")

ErrUnfeasibleTx transaction not feasible for analysis error

Functions

func ExtractLikelihoodOutput

func ExtractLikelihoodOutput(analyzed heuristics.Map) (vout uint32, err error)

ExtractLikelihoodOutput function to return most probable output between applied heuristics results

func MajorityLikelihood

func MajorityLikelihood(v heuristics.Map) (likelihood map[uint32]map[heuristics.Mask]float64)

MajorityLikelihood extract majority output sets with likelihood percentages

func MajorityVotingOutput

func MajorityVotingOutput(analyzed heuristics.Map) (likelihood map[uint32]map[heuristics.Mask]float64, err error)

MajorityVotingOutput return map with probability of change output for each output

func NewService

func NewService(k kv.DB, c *cache.Cache) *service

NewService instantiates a new Service layer for customer

func PlotHeuristicsTimeline

func PlotHeuristicsTimeline(data map[int32][]float64, min int32, heuristicsList heuristics.Mask) (err error)

PlotHeuristicsTimeline plots timeseries of heuristics percentage effectiveness for each block representing time series

func Routes

func Routes(g *echo.Group, s Service)

Routes mounts /analysis based routes on the main group

Types

type AnalysisSet

type AnalysisSet struct {
	LocalPercentages map[byte]float64
	Percentages      map[byte]float64
	LocalCounters    map[byte]float64
	Counters         map[byte]float64
	Combinations     map[byte]float64
}

type ApplicabilityWorker

type ApplicabilityWorker struct {
	Worker
	// contains filtered or unexported fields
}

ApplicabilityWorker wrapper to partecipate in task pool

func (*ApplicabilityWorker) Work

func (w *ApplicabilityWorker) Work() (err error)

Work method to make ApplicabilityWorker compatible with task pool worker interface

type Chunk

type Chunk struct {
	Range          `json:"range,omitempty"`
	Vulnerabilites Graph `json:"vulnerabilities,omitempty"`
}

Chunk struct with info on previous analyzed blocks slice

type Graph

type Graph interface {
	ExtractPercentages(heuristics.Mask, int32, int32) map[int32][]float64
	ExtractGlobalPercentages(heuristics.Mask, int32, int32) []float64
	ExtractOffByOneBug(heuristics.Mask, int32, int32) map[int32][]float64
	ExtractGlobalOffByOneBug(heuristics.Mask, int32, int32) []float64
	ExtractGlobalSecureBasisPerc(heuristics.Mask, int32, int32) []float64
	ExtractCombinationPercentages(heuristics.Mask, int32, int32) map[string]float64
	ExtractGlobalFullMajorityVotingPerc(heuristics.Mask, int32, int32) map[string]float64
	ExtractGlobalMajorityVotingPerc(heuristics.Mask, int32, int32) map[string]float64
	ExtractGlobalStricMajorityVotingPerc(heuristics.Mask, int32, int32) map[string]float64
	MajorityFullAnalysis(heuristics.Mask, int32, int32, ...heuristics.Heuristic) AnalysisSet
	// contains filtered or unexported methods
}

Graph interface to manage analysis result

type MaskGraph

type MaskGraph map[int32]map[string]heuristics.Mask

MaskGraph alias for struct describing blockchain graph based on vulnerabilities mask

func (MaskGraph) ExtractCombinationPercentages

func (g MaskGraph) ExtractCombinationPercentages(heuristicsList heuristics.Mask, from, to int32) (perc map[string]float64)

ExtractCombinationPercentages extraction based on output graph mock

func (MaskGraph) ExtractGlobalFullMajorityVotingPerc

func (g MaskGraph) ExtractGlobalFullMajorityVotingPerc(heuristicsList heuristics.Mask, from, to int32) (perc map[string]float64)

ExtractGlobalFullMajorityVotingPerc extraction based on output graph mock

func (MaskGraph) ExtractGlobalMajorityVotingPerc

func (g MaskGraph) ExtractGlobalMajorityVotingPerc(heuristicsList heuristics.Mask, from, to int32) (perc map[string]float64)

ExtractGlobalMajorityVotingPerc extraction based on output graph mock

func (MaskGraph) ExtractGlobalOffByOneBug

func (g MaskGraph) ExtractGlobalOffByOneBug(heuristicsList heuristics.Mask, from, to int32) (perc []float64)

ExtractGlobalOffByOneBug extraction based on output graph mock

func (MaskGraph) ExtractGlobalPercentages

func (g MaskGraph) ExtractGlobalPercentages(heuristicsList heuristics.Mask, from, to int32) (perc []float64)

ExtractGlobalPercentages returns the corresponding map with global heuristic percentages for each heuristic

func (MaskGraph) ExtractGlobalSecureBasisPerc

func (g MaskGraph) ExtractGlobalSecureBasisPerc(heuristicsList heuristics.Mask, from, to int32) (perc []float64)

ExtractGlobalSecureBasisPerc extraction based on output graph mock

func (MaskGraph) ExtractGlobalStricMajorityVotingPerc

func (g MaskGraph) ExtractGlobalStricMajorityVotingPerc(heuristicsList heuristics.Mask, from, to int32) (perc map[string]float64)

ExtractGlobalStricMajorityVotingPerc extraction based on output graph mock

func (MaskGraph) ExtractOffByOneBug

func (g MaskGraph) ExtractOffByOneBug(heuristicsList heuristics.Mask, from, to int32) (perc map[int32][]float64)

ExtractOffByOneBug extraction based on output graph mock

func (MaskGraph) ExtractPercentages

func (g MaskGraph) ExtractPercentages(heuristicsList heuristics.Mask, from, to int32) (perc map[int32][]float64)

ExtractPercentages returns the corresponding map with heuristic percentages for each element in the map (in each block)

func (MaskGraph) MajorityFullAnalysis

func (g MaskGraph) MajorityFullAnalysis(heuristicsList heuristics.Mask, from, to int32, reducing ...heuristics.Heuristic) AnalysisSet

MajorityFullAnalysis extraction based on output graph mock

type Model

type Model struct {
	gorm.Model
	ID     uuid.UUID `json:"id" gorm:"primarykey;index;unique"`
	UserID uuid.UUID `json:"user_id" gorm:"index;not null"`
	Type   string    `json:"type" gorm:"index"`

} //@name Analysis

Model analysis struct

func (*Model) TableName

func (m *Model) TableName() string

TableName defines default table name

type OutputGraph

type OutputGraph map[int32]map[string]heuristics.Map

OutputGraph alias for struct describing blockchain graph based on heuristics

func (OutputGraph) ExtractCombinationPercentages

func (g OutputGraph) ExtractCombinationPercentages(heuristicsList heuristics.Mask, from, to int32) (perc map[string]float64)

ExtractCombinationPercentages returns the corresponding map with global heuristic percentages for each heuristic

func (OutputGraph) ExtractGlobalFullMajorityVotingPerc

func (g OutputGraph) ExtractGlobalFullMajorityVotingPerc(heuristicsList heuristics.Mask, from, to int32) (perc map[string]float64)

ExtractGlobalFullMajorityVotingPerc returns the corresponding map with global heuristic percentages for each heuristic

func (OutputGraph) ExtractGlobalMajorityVotingPerc

func (g OutputGraph) ExtractGlobalMajorityVotingPerc(heuristicsList heuristics.Mask, from, to int32) (perc map[string]float64)

ExtractGlobalMajorityVotingPerc returns the corresponding map with global heuristic percentages for each heuristic

func (OutputGraph) ExtractGlobalOffByOneBug

func (g OutputGraph) ExtractGlobalOffByOneBug(heuristicsList heuristics.Mask, from, to int32) (perc []float64)

ExtractGlobalOffByOneBug returns the corresponding map with global heuristic percentages for each heuristic

func (OutputGraph) ExtractGlobalPercentages

func (g OutputGraph) ExtractGlobalPercentages(heuristicsList heuristics.Mask, from, to int32) (perc []float64)

ExtractGlobalPercentages returns the corresponding map with global heuristic percentages for each heuristic

func (OutputGraph) ExtractGlobalSecureBasisPerc

func (g OutputGraph) ExtractGlobalSecureBasisPerc(heuristicsList heuristics.Mask, from, to int32) (perc []float64)

ExtractGlobalSecureBasisPerc returns the corresponding map with global heuristic percentages for each heuristic

func (OutputGraph) ExtractGlobalStricMajorityVotingPerc

func (g OutputGraph) ExtractGlobalStricMajorityVotingPerc(heuristicsList heuristics.Mask, from, to int32) (perc map[string]float64)

ExtractGlobalStricMajorityVotingPerc returns the corresponding map with global heuristic percentages for each heuristic

func (OutputGraph) ExtractOffByOneBug

func (g OutputGraph) ExtractOffByOneBug(heuristicsList heuristics.Mask, from, to int32) (perc map[int32][]float64)

ExtractOffByOneBug returns the corresponding map with heuristic percentages for each element in the map (in each block)

func (OutputGraph) ExtractPercentages

func (g OutputGraph) ExtractPercentages(heuristicsList heuristics.Mask, from, to int32) (perc map[int32][]float64)

ExtractPercentages returns the corresponding map with heuristic percentages for each element in the map (in each block)

func (OutputGraph) MajorityFullAnalysis

func (g OutputGraph) MajorityFullAnalysis(heuristicsList heuristics.Mask, from, to int32, reducing ...heuristics.Heuristic) AnalysisSet

MajorityFullAnalysis returns the corresponding map with global heuristic percentages for each heuristic

type Range

type Range struct {
	From int32 `json:"from,omitempty"`
	To   int32 `json:"to,omitempty"`
}

Range wrapper for blocks interval boundaries

type ReliabilityWorker

type ReliabilityWorker struct {
	Worker
	// contains filtered or unexported fields
}

ReliabilityWorker wrapper to partecipate in task pool

func (*ReliabilityWorker) Work

func (w *ReliabilityWorker) Work() (err error)

Work method to make ReliabilityWorker compatible with task pool worker interface

type Service

type Service interface {
	AnalyzeTx(txid string, heuristicsList heuristics.Mask, analysisType string) (vuln interface{}, err error)
	AnalyzeBlocks(from, to int32, heuristicsList heuristics.Mask, analysisType, criteria, chart string, force bool) (err error)
}

Service interface exports available methods for analysis service

type Worker

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

Worker basic worker to partecipate in task pool

Jump to

Keyboard shortcuts

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