common

package
v0.0.0-...-ac8a210 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ONE_ETHER uint64 = 1000000000000000000

Variables

View Source
var (
	Uint8T      = reflect.TypeOf(uint8(0))
	Uint16T     = reflect.TypeOf(uint16(0))
	Uint32T     = reflect.TypeOf(uint32(0))
	Uint64T     = reflect.TypeOf(uint64(0))
	Int8T       = reflect.TypeOf(int8(0))
	Int16T      = reflect.TypeOf(int16(0))
	Int32T      = reflect.TypeOf(int32(0))
	Int64T      = reflect.TypeOf(int64(0))
	BigIntT     = reflect.TypeOf(&big.Int{})
	BoolT       = reflect.TypeOf(false)
	StringT     = reflect.TypeOf("")
	AddressT    = reflect.TypeOf(common.Address{})
	SliceT      = func(typ reflect.Type) reflect.Type { return reflect.SliceOf(typ) }
	ArrayT      = func(size int, typ reflect.Type) reflect.Type { return reflect.ArrayOf(size, typ) }
	FixedBytesT = func(size int) reflect.Type { return reflect.ArrayOf(size, reflect.TypeOf(byte(0))) }
	BytesT      = reflect.SliceOf(reflect.TypeOf(byte(0)))
)
View Source
var ErrInvalidHexadecimal = errors.New("the provided string is not a valid hexadecimal")

Functions

func Contains

func Contains[T comparable](s []T, target T) bool

func ConvertHexadecimalToInt

func ConvertHexadecimalToInt(hexadecimal string) (*big.Int, error)

func ConvertStringArrayToInterfaceArray

func ConvertStringArrayToInterfaceArray(arr []string) []interface{}

func GetFirstStringKeyFromMap

func GetFirstStringKeyFromMap[V any](input map[string]V) string

func GetLastStringKeyFromMap

func GetLastStringKeyFromMap[V any](input map[string]V) string

func GetUniqueSlice

func GetUniqueSlice[T comparable](slice []T) []T

func JoinOracleTypeList

func JoinOracleTypeList(types []OracleType) string

func MergeSortedSlices

func MergeSortedSlices(a []string, b []string) []string

func MustConvertHexadecimalToInt

func MustConvertHexadecimalToInt(hexadecimal string) *big.Int

func NewSet

func NewSet[T comparable](args ...T) *set[T]

func Now

func Now() time.Time

func RandomChoice

func RandomChoice[T any](slice []T) T

func RandomSubSlice

func RandomSubSlice[T any](s []T) []T

func SumOccurrencesOfStringList

func SumOccurrencesOfStringList(targetGroup []string, source []string) uint64

func Swap

func Swap[T any](s []T, i, j int)

Types

type Block

type Block struct {
	PC               string                 `json:"pc"`
	Range            BlockRange             `json:"range"`
	Predecessors     []string               `json:"predecessors"`
	Successors       []string               `json:"successors"`
	EntryStack       []string               `json:"entryStack"`
	StackPops        uint64                 `json:"stackPops"`
	StackAdditions   []string               `json:"stackAdditions"`
	ExitStack        []string               `json:"exitStack"`
	Instructions     map[string]Instruction `json:"instructions"`
	InstructionOrder []string               `json:"instructionOrder"`
}

type BlockRange

type BlockRange struct {
	From string `json:"from"`
	To   string `json:"to"`
}

type CFG

type CFG struct {
	Graph        map[string][]string `json:"graph"`
	Blocks       map[string]CFGBlock `json:"blocks"`
	Instructions map[string]string   `json:"instructions"`
}

func (CFG) GetEdgesPCs

func (g CFG) GetEdgesPCs() []string

func (CFG) GetReverseGraph

func (g CFG) GetReverseGraph() map[string][]string

type CFGBlock

type CFGBlock struct {
	InitialPC       string            `json:"initialPC"`
	Instructions    map[string]string `json:"instructions"`
	InstructionsPCs []string          `json:"instructionsPCs"`
}

type ConcurrentMap

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

func (*ConcurrentMap) Add

func (d *ConcurrentMap) Add(key IKey, value IValue)

func (*ConcurrentMap) Clear

func (d *ConcurrentMap) Clear()

func (*ConcurrentMap) Exist

func (d *ConcurrentMap) Exist(key IKey) bool

func (*ConcurrentMap) Get

func (d *ConcurrentMap) Get(key IKey) IValue

func (*ConcurrentMap) GetKeys

func (d *ConcurrentMap) GetKeys() []IKey

func (*ConcurrentMap) GetValues

func (d *ConcurrentMap) GetValues() []IValue

func (*ConcurrentMap) Remove

func (d *ConcurrentMap) Remove(key IKey) bool

func (*ConcurrentMap) Size

func (d *ConcurrentMap) Size() int

type Contract

type Contract struct {
	Name               string
	AbiDefinition      string
	DeploymentBytecode string
	RuntimeBytecode    string
	Address            string
}

func NewContract

func NewContract(name, abiDefinition, deploymentBytecode string, runtimeBytecode string) *Contract

type ContractStatus

type ContractStatus string
const (
	CONTRACT_CREATED  ContractStatus = "created"
	CONTRACT_DEPLOYED ContractStatus = "deployed"
)

type DistanceMap

type DistanceMap map[string]map[string]uint32 // blockPC => instruction => distance

type EventsSnapshot

type EventsSnapshot struct {
	CallFailed          bool
	Reentrancy          bool
	RepeatedCall        bool
	EtherTransfer       bool
	EtherTransferFailed bool
	CallEtherFailed     bool
	GaslessSend         bool
	Delegate            bool
	ExceptionDisorder   bool
	SendOp              bool
	CallOp              bool
	CallException       bool
	UnknowCall          bool
	StorageChanged      bool
	Timestamp           bool
	BlockHash           bool
	BlockNumber         bool
}

type Function

type Function struct {
	Signature  string   `json:"signature"`
	EntryBlock string   `json:"entryBlock"`
	ExitBlock  string   `json:"exitBlock"`
	Body       []string `json:"body"`
}

type FuzzingType

type FuzzingType string
const (
	BLACKBOX_FUZZING         FuzzingType = "blackbox"
	GREYBOX_FUZZING          FuzzingType = "greybox"
	DIRECTED_GREYBOX_FUZZING FuzzingType = "directed_greybox"
)

type IValue

type IValue = interface{}

type Instruction

type Instruction struct {
	Op      string   `json:"op"`
	Args    []string `json:"args"`
	StackOp string   `json:"stackOp"`
}

type MethodType

type MethodType string
const (
	CONSTRUCTOR MethodType = "constructor"
	FALLBACK    MethodType = "fallback"
	RECEIVE     MethodType = "receive"
	METHOD      MethodType = "method"
)

type OracleType

type OracleType string
const (
	DELEGATE_ORACLE             OracleType = "delegate"
	EXCEPTION_DISORDER_ORACLE   OracleType = "exception-disorder"
	GASLESS_SEND_ORACLE         OracleType = "gasless-send"
	NUMBER_DEPENDENCY_ORACLE    OracleType = "number-dependency"
	REENTRANCY_ORACLE           OracleType = "reentrancy"
	TIMESTAMP_DEPENDENCY_ORACLE OracleType = "timestamp-dependency"
)

func SplitOracleTypeString

func SplitOracleTypeString(input string) []OracleType

type PowerScheduleStrategy

type PowerScheduleStrategy string
const (
	DISTANCE_BASED_STRATEGY PowerScheduleStrategy = "distance_based"
	COVERAGE_BASED_STRATEGY PowerScheduleStrategy = "coverage_based"
)

type ReporterType

type ReporterType string
const (
	CONSOLE_REPORTER ReporterType = "console"
	WEBHOOK_REPOTER  ReporterType = "webhook"
	FILE_REPORTER    ReporterType = "file"
)

type Seeds

type Seeds = map[TypeIdentifier][]string

type TaskReport

type TaskReport struct {
	TaskId                   string            `json:"taskId"`
	TimeElapsed              time.Duration     `json:"timeElapsed"`
	ContractName             string            `json:"contractName"`
	TotalInstructions        uint64            `json:"totalInstructions"`
	Coverage                 uint64            `json:"coverage"`
	CoverageByTime           TimeSeriesData    `json:"coverageByTime"`
	MinDistance              uint64            `json:"minDistance"`
	MinDistanceByTime        TimeSeriesData    `json:"minDistanceByTime"`
	DetectedWeaknesses       []string          `json:"detectedWeaknesses"`
	CriticalInstructionsHits uint64            `json:"criticalInstructionsHits"`
	AverageCoverage          float64           `json:"averageCoverage"`
	Instructions             map[string]string `json:"instructions"`
	InstructionHitsHeatMap   map[string]uint64 `json:"instructionHitsHeatMap"`
}

type TaskStatus

type TaskStatus string
const (
	TASK_RUNNING TaskStatus = "running"
	TASK_DONE    TaskStatus = "done"
	TASK_REPORT  TaskStatus = "report"
)

type TimeSeriesData

type TimeSeriesData struct {
	X []time.Time `json:"x"`
	Y []uint64    `json:"y"`
}

type TransactionStatus

type TransactionStatus string
const (
	TRANSACTION_CREATED    TransactionStatus = "created"
	TRANSACTION_SEND_ERROR TransactionStatus = "send_error"
	TRANSACTION_RUNNING    TransactionStatus = "running"
	TRANSACTION_DONE       TransactionStatus = "done"
	TRANSACTION_TIMEOUT    TransactionStatus = "timeout"
)

type TypeIdentifier

type TypeIdentifier string

Jump to

Keyboard shortcuts

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