ssaapi

package
v1.3.5-beta2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: AGPL-3.0 Imports: 41 Imported by: 0

README

SSA API

do ssa api can do anything?

the ssa api is designed for auditing and analysis, not for optimization.

optimization should be handled in Lower-IR.

Verify Case Suite

the cases for verifying ssa api should be careful code.

u can test any language feature in ssa api;

  1. rename test
  2. scope test
  3. if statement test
  4. if statement test: phi
  5. switch statement test
  6. switch statement test: phi
  7. loop statement test
  8. loop statement test: phi
  9. loop statement test: phi t2=phi(t1, t2)
  10. function test
  11. function test: formal parameter analysis
  12. function test: the N-th formal parameter analysis
  13. function test: return value analysis
  14. function test: closure
  15. function test: free-value
  16. function test: cross
  17. function test: recursive
  18. function test: recursive loop phi
  19. function test: maskable free-value
  20. classless test: static member call
  21. classless test: dynamic member call
  22. classless test: static member call: phi
  23. classless test: dynamic member call: phi
  24. dynamic member convert to static member: collapsed literal
  25. classless test and closure: multi-returns value to static member
  26. function test: maskable membered free-value
  27. function test: multi-returns value to value in function defs
  28. classless test: container assigned in closure

Documentation

Index

Constants

View Source
const (
	Yak  = consts.Yak
	JS   = consts.JS
	PHP  = consts.PHP
	JAVA = consts.JAVA
	GO   = consts.GO
)
View Source
const (
	// NativeCall_GetReturns is used to get the returns of a value
	NativeCall_GetReturns = "getReturns"

	// NativeCall_GetFormalParams is used to get the formal params of a value
	NativeCall_GetFormalParams = "getFormalParams"

	// NativeCall_GetFunc is used to get the function of a value
	// find current function instruction which contains the value
	NativeCall_GetFunc = "getFunc"

	// NativeCall_GetCall is used to get the call of a value, generally used to get the call of an opcode
	NativeCall_GetCall = "getCall"

	// NativeCall_GetCaller is used to get the caller of a value
	// find the caller instruction which contains the value
	NativeCall_GetCaller = "getCaller"

	// NativeCall_SearchFunc is used to search the call of a value, generally used to search the call of a function
	// if the input is a call already, check the 'call' 's method(function) 's other call(search mode)
	//
	// searchCall is not like getCall, search call will search all function name(from call) in the program
	NativeCall_SearchFunc = "searchFunc"

	// NativeCall_GetObject is used to get the object of a value
	NativeCall_GetObject = "getObject"

	// NativeCall_GetMembers is used to get the members of a value
	NativeCall_GetMembers = "getMembers"

	// NativeCall_GetSiblings is used to get the siblings of a value
	NativeCall_GetSiblings = "getSiblings"

	// NativeCall_TypeName is used to get the type name of a value
	NativeCall_TypeName = "typeName"

	// NativeCall_FullTypeName is used to get the full type name of a value
	NativeCall_FullTypeName = "fullTypeName"

	// NativeCall_Name is used to get the function name of a value
	NativeCall_Name = "name"

	// NativeCall_String is used to get the function name of a value
	NativeCall_String = "string"

	// NativeCall_Include is used to include a syntaxflow-rule
	NativeCall_Include = "include"

	// NativeCall_Eval is used to eval a new syntaxflow rule
	NativeCall_Eval = "eval"

	// NativeCall_Fuzztag is used to eval a new yaklang fuzztag template, the variables is in SFFrameResult
	NativeCall_Fuzztag = "fuzztag"

	// NativeCall_Show just show the value, do nothing
	NativeCall_Show = "show"

	// NativeCall_Slice just show the value, do nothing
	NativeCall_Slice = "slice"
)

Variables

View Source
var Exports = map[string]any{
	"Parse": Parse,

	"withLanguage":            WithLanguage,
	"withExternLib":           WithExternLib,
	"withExternValue":         WithExternValue,
	"withDatabaseProgramName": WithDatabaseProgramName,

	"Javascript": JS,
	"Yak":        Yak,
	"PHP":        PHP,
	"Java":       JAVA,
}
View Source
var NativeCallDocuments = make(map[string]*NativeCallDocument)
View Source
var SkippedError = ssareducer.SkippedError

Functions

func ClearCache added in v1.3.3

func ClearCache()

func ConvertSyntaxFlowResultToSarif

func ConvertSyntaxFlowResultToSarif(r ...*sfvm.SFFrameResult) (*sarif.Report, error)

func CreateDotGraph

func CreateDotGraph(i ...sfvm.ValueOperator) (string, error)

func GetBareNode added in v1.2.9

func GetBareNode(v *Value) ssa.Value

GetBareNode get ssa.Value from ssaapi.Value only use this function in golang

func GetBareType added in v1.2.9

func GetBareType(typ *Type) ssa.Type

func GetFreeValue added in v1.3.3

func GetFreeValue(v *Value) *ssa.Parameter

func TypeCompare added in v1.2.9

func TypeCompare(t1, t2 *Type) bool

func ValidSyntaxFlowRule

func ValidSyntaxFlowRule(s *schema.SyntaxFlowRule) error

func ValueCompare added in v1.2.9

func ValueCompare(v1, v2 *Value) bool

func ValueContain

func ValueContain(v1 *Value, v2 ...*Value) bool

func WithSyntaxFlowResult added in v1.3.3

func WithSyntaxFlowResult(expected string, handler func(*Value) error) sfvm.Option

func WithSyntaxFlowStrictMatch

func WithSyntaxFlowStrictMatch(stricts ...bool) sfvm.Option

Types

type AnalyzeContext added in v1.3.0

type AnalyzeContext struct {
	// Self
	Self *Value
	// contains filtered or unexported fields
}

func NewAnalyzeContext added in v1.3.0

func NewAnalyzeContext(opt ...OperationOption) *AnalyzeContext

func (*AnalyzeContext) EnterRecursive

func (a *AnalyzeContext) EnterRecursive()

func (*AnalyzeContext) ExitRecursive

func (a *AnalyzeContext) ExitRecursive()

func (*AnalyzeContext) GetCurrentCall added in v1.3.0

func (g *AnalyzeContext) GetCurrentCall() *Value

func (*AnalyzeContext) GetCurrentObject added in v1.3.2

func (g *AnalyzeContext) GetCurrentObject() (*Value, *Value, *Value)

func (*AnalyzeContext) GetRecursiveCounter

func (a *AnalyzeContext) GetRecursiveCounter() int64

func (*AnalyzeContext) IsExistedInCallStack added in v1.3.0

func (a *AnalyzeContext) IsExistedInCallStack(i *Value) bool

func (*AnalyzeContext) PopCall added in v1.3.0

func (a *AnalyzeContext) PopCall() *Value

func (*AnalyzeContext) PopObject added in v1.3.2

func (g *AnalyzeContext) PopObject() (*Value, *Value, *Value)

func (*AnalyzeContext) PushCall added in v1.3.0

func (a *AnalyzeContext) PushCall(i *Value) error

func (*AnalyzeContext) PushObject added in v1.3.2

func (g *AnalyzeContext) PushObject(obj, key, member *Value) error

func (*AnalyzeContext) TheCallShouldBeVisited added in v1.3.0

func (a *AnalyzeContext) TheCallShouldBeVisited(i *ssa.Call) bool

func (*AnalyzeContext) TheDefaultShouldBeVisited

func (a *AnalyzeContext) TheDefaultShouldBeVisited(i *Value) bool

func (*AnalyzeContext) TheMemberShouldBeVisited added in v1.3.2

func (a *AnalyzeContext) TheMemberShouldBeVisited(i *Value) bool

func (*AnalyzeContext) ThePhiShouldBeVisited added in v1.3.0

func (a *AnalyzeContext) ThePhiShouldBeVisited(i *Value) bool

========================================== PHI STACK ========================================== ThePhiShouldBeVisited is used to check whether the phi should be visited

type CallVisited

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

CallVisited is used to record the visited phi\object\default, and only used in the single call

func NewCallVisited

func NewCallVisited() *CallVisited

type ContextID added in v1.3.2

type ContextID string
var (
	ANALYZE_RUNTIME_CTX_TOPDEF_CALL_ENTRY             ContextID = "call_entry"
	ANALYZE_RUNTIME_CTX_TOPDEF_CALL_ENTRY_TRACE_INDEX ContextID = "call_entry_trace_idx"
)

type DominatorForest added in v1.3.1

type DominatorForest struct {
	Trees []*DominatorTree
}

type DominatorTree added in v1.3.1

type DominatorTree *omap.OrderedMap[int, *Value]

type NativeCallDocument

type NativeCallDocument struct {
	Name        string
	Description string
	Function    sfvm.NativeCallFunc
}

type OperationConfig added in v1.3.1

type OperationConfig struct {
	// 限制递归深度,每一次递归核心函数,计数器都会加一
	// 上下文计数器受到这个限制
	MaxDepth int
	MinDepth int

	// Hook
	HookEveryNode        []func(*Value) error
	AllowIgnoreCallStack bool
}

func NewOperations added in v1.3.1

func NewOperations(opt ...OperationOption) *OperationConfig

type OperationOption added in v1.3.1

type OperationOption func(*OperationConfig)

func WithAllowCallStack added in v1.3.3

func WithAllowCallStack(allowCallStack bool) OperationOption

func WithDepthLimit added in v1.3.1

func WithDepthLimit(depth int) OperationOption

func WithHookEveryNode added in v1.3.1

func WithHookEveryNode(hookNode func(*Value) error) OperationOption

func WithMaxDepth added in v1.3.1

func WithMaxDepth(maxDepth int) OperationOption

func WithMinDepth added in v1.3.1

func WithMinDepth(minDepth int) OperationOption

type Option

type Option func(*config)

func WithDatabaseProgramCacheHitter added in v1.3.3

func WithDatabaseProgramCacheHitter(h func(i any)) Option

func WithDatabaseProgramName added in v1.3.3

func WithDatabaseProgramName(name string) Option

save to database, please set the program name

func WithDefineFunc added in v1.3.1

func WithDefineFunc(table map[string]any) Option

func WithEnableCache

func WithEnableCache(b ...bool) Option

func WithExternBuildValueHandler

func WithExternBuildValueHandler(id string, callback func(b *ssa.FunctionBuilder, id string, v any) ssa.Value) Option

func WithExternInfo added in v1.3.0

func WithExternInfo(info string) Option

func WithExternLib

func WithExternLib(name string, table map[string]any) Option

func WithExternMethod added in v1.2.9

func WithExternMethod(b ssa.MethodBuilder) Option

func WithExternValue

func WithExternValue(table map[string]any) Option

func WithFeedCode added in v1.3.1

func WithFeedCode(b ...bool) Option

func WithFileSystemEntry added in v1.3.3

func WithFileSystemEntry(files ...string) Option

func WithIgnoreSyntaxError added in v1.3.0

func WithIgnoreSyntaxError(b ...bool) Option

func WithIncludePath

func WithIncludePath(path ...string) Option

func WithLanguage

func WithLanguage(language consts.Language) Option

func WithProgramPath

func WithProgramPath(path string) Option

type PredecessorValue

type PredecessorValue struct {
	Node *Value
	Info *sfvm.AnalysisContext
}

type Program

type Program struct {
	// TODO: one program may have multiple program,
	// 	 	 only one Application and multiple Library
	Program *ssa.Program
	// contains filtered or unexported fields
}

func FromDatabase added in v1.3.3

func FromDatabase(programName string, opts ...Option) (*Program, error)

func NewProgram

func NewProgram(prog *ssa.Program, config *config) *Program

func Parse

func Parse(code string, opts ...Option) (*Program, error)

Parse parse code to ssa.Program

func ParseFromReader added in v1.3.3

func ParseFromReader(input io.Reader, opts ...Option) (*Program, error)

ParseFromReader parse simple file to ssa.Program

func (*Program) AppendPredecessor

func (p *Program) AppendPredecessor(sfvm.ValueOperator, ...sfvm.AnalysisContextOption) error

func (*Program) DBDebug

func (p *Program) DBDebug()

func (*Program) ExactMatch added in v1.3.3

func (p *Program) ExactMatch(mod int, s string) (bool, sfvm.ValueOperator, error)

func (*Program) Feed added in v1.3.1

func (p *Program) Feed(code io.Reader) error

func (*Program) FileFilter

func (p *Program) FileFilter(path string, match string, rule map[string]string, rule2 []string) (sfvm.ValueOperator, error)

func (*Program) GetAllCallActualParams added in v1.3.3

func (p *Program) GetAllCallActualParams() (sfvm.ValueOperator, error)

func (*Program) GetAllOffsetItemsBefore added in v1.3.3

func (p *Program) GetAllOffsetItemsBefore(offset int) []*ssa.OffsetItem

func (*Program) GetCallActualParams added in v1.3.3

func (p *Program) GetCallActualParams(int) (sfvm.ValueOperator, error)

func (*Program) GetCalled added in v1.3.3

func (p *Program) GetCalled() (sfvm.ValueOperator, error)

func (*Program) GetErrors added in v1.3.0

func (p *Program) GetErrors() ssa.SSAErrors

func (*Program) GetFields

func (p *Program) GetFields() (sfvm.ValueOperator, error)

func (*Program) GetInstructionById added in v1.3.0

func (p *Program) GetInstructionById(id int64) ssa.Instruction

func (*Program) GetLanguage

func (p *Program) GetLanguage() string

func (*Program) GetNames added in v1.3.3

func (p *Program) GetNames() []string

func (*Program) GetOpcode

func (p *Program) GetOpcode() string

func (*Program) GetProgramKind

func (p *Program) GetProgramKind() ssa.ProgramKind

func (*Program) GetSyntaxFlowBottomUse added in v1.3.3

func (p *Program) GetSyntaxFlowBottomUse(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, config ...*sfvm.RecursiveConfigItem) (sfvm.ValueOperator, error)

func (*Program) GetSyntaxFlowDef added in v1.3.3

func (p *Program) GetSyntaxFlowDef() (sfvm.ValueOperator, error)

func (*Program) GetSyntaxFlowTopDef added in v1.3.3

func (p *Program) GetSyntaxFlowTopDef(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, config ...*sfvm.RecursiveConfigItem) (sfvm.ValueOperator, error)

func (*Program) GetSyntaxFlowUse added in v1.3.3

func (p *Program) GetSyntaxFlowUse() (sfvm.ValueOperator, error)

func (*Program) GetValueById added in v1.3.0

func (p *Program) GetValueById(id int64) (*Value, error)

func (*Program) GetValueByIdMust added in v1.3.0

func (p *Program) GetValueByIdMust(id int64) *Value

func (*Program) GlobMatch added in v1.3.3

func (p *Program) GlobMatch(mod int, g string) (bool, sfvm.ValueOperator, error)

func (*Program) IsList added in v1.3.3

func (p *Program) IsList() bool

func (*Program) IsMap added in v1.3.3

func (p *Program) IsMap() bool

func (*Program) IsNil added in v1.2.9

func (p *Program) IsNil() bool

func (*Program) ListIndex added in v1.3.3

func (p *Program) ListIndex(i int) (sfvm.ValueOperator, error)

func (*Program) Merge

func (*Program) NewValue added in v1.3.3

func (p *Program) NewValue(n ssa.Value) *Value

func (*Program) Recursive added in v1.3.3

func (p *Program) Recursive(f func(operator sfvm.ValueOperator) error) error

func (*Program) Ref

func (p *Program) Ref(name string) Values

func (*Program) RegexpMatch added in v1.3.3

func (p *Program) RegexpMatch(mod int, re string) (bool, sfvm.ValueOperator, error)

func (*Program) Remove

func (p *Program) Remove(...sfvm.ValueOperator) (sfvm.ValueOperator, error)

func (*Program) Show added in v1.3.0

func (p *Program) Show() *Program

func (*Program) String added in v1.3.3

func (p *Program) String() string

func (*Program) SyntaxFlow added in v1.3.3

func (p *Program) SyntaxFlow(i string, opts ...sfvm.Option) *SyntaxFlowResult

func (*Program) SyntaxFlowChain added in v1.3.3

func (p *Program) SyntaxFlowChain(i string, opts ...sfvm.Option) Values

func (*Program) SyntaxFlowWithError added in v1.3.3

func (p *Program) SyntaxFlowWithError(i string, opts ...sfvm.Option) (*SyntaxFlowResult, error)

type Programs

type Programs []*Program

func ParseProject added in v1.3.3

func ParseProject(fs fi.FileSystem, opts ...Option) (Programs, error)

func ParseProjectFromPath added in v1.3.3

func ParseProjectFromPath(path string, opts ...Option) (Programs, error)

func (Programs) SyntaxFlowWithError

func (ps Programs) SyntaxFlowWithError(i string, opts ...sfvm.Option) (*SyntaxFlowResult, error)

type SarifContext

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

func NewSarifContext

func NewSarifContext() *SarifContext

func (*SarifContext) AddSSAValue

func (s *SarifContext) AddSSAValue(v *Value, extraMsg ...string)

func (*SarifContext) ArtifactsExisted

func (s *SarifContext) ArtifactsExisted(hash string) (int, bool)

func (*SarifContext) CreateCodeFlowsFromPredecessor

func (s *SarifContext) CreateCodeFlowsFromPredecessor(v *Value) []*sarif.CodeFlow

func (*SarifContext) CreateLocation

func (s *SarifContext) CreateLocation(artifactId int, rg *ssa.Range) *sarif.Location

func (*SarifContext) CreateSubSarifContext

func (s *SarifContext) CreateSubSarifContext() *SarifContext

func (*SarifContext) GetArtifactIdFromEditor

func (s *SarifContext) GetArtifactIdFromEditor(editor *memedit.MemEditor) int

type SyntaxFlowResult

type SyntaxFlowResult struct {
	*sfvm.SFFrameResult
	// contains filtered or unexported fields
}

func SyntaxFlowWithError

func SyntaxFlowWithError(p sfvm.ValueOperator, sfCode string, opts ...sfvm.Option) (*SyntaxFlowResult, error)

func SyntaxFlowWithVMContext

func SyntaxFlowWithVMContext(p sfvm.ValueOperator, sfCode string, sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config) (*SyntaxFlowResult, error)

func (*SyntaxFlowResult) GetAllValues

func (r *SyntaxFlowResult) GetAllValues() map[string]Values

func (*SyntaxFlowResult) GetAllValuesChain

func (r *SyntaxFlowResult) GetAllValuesChain() Values

func (*SyntaxFlowResult) GetValues

func (r *SyntaxFlowResult) GetValues(name string) Values

type Type added in v1.2.9

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

func FuncOf added in v1.2.9

func FuncOf(name string, args, ret []*Type, isVariadic bool) *Type

func MapOf added in v1.2.9

func MapOf(key, value *Type) *Type

func NewType added in v1.2.9

func NewType(t ssa.Type) *Type

func SliceOf added in v1.2.9

func SliceOf(t *Type) *Type

func (*Type) Compare added in v1.2.9

func (t *Type) Compare(t2 *Type) bool

func (*Type) IsAny

func (t *Type) IsAny() bool

func (*Type) String added in v1.2.9

func (t *Type) String() string

type Value

type Value struct {
	ParentProgram *Program
	EffectOn      Values
	DependOn      Values

	// for syntaxflow vm
	Predecessors []*PredecessorValue
	// contains filtered or unexported fields
}

func FullUseDefChain added in v1.3.1

func FullUseDefChain(value *Value, opts ...OperationOption) *Value

func (*Value) AnalyzeDepth added in v1.3.1

func (v *Value) AnalyzeDepth() int

func (*Value) AppendDependOn added in v1.3.1

func (v *Value) AppendDependOn(i *Value) *Value

func (*Value) AppendEffectOn added in v1.3.1

func (v *Value) AppendEffectOn(i *Value) *Value

func (*Value) AppendPredecessor

func (v *Value) AppendPredecessor(operator sfvm.ValueOperator, opts ...sfvm.AnalysisContextOption) error

func (*Value) Backtrack added in v1.3.1

func (v *Value) Backtrack() *omap.OrderedMap[string, *Value]

func (*Value) Compare added in v1.2.9

func (v *Value) Compare(other *Value) bool

func (*Value) DotGraph

func (v *Value) DotGraph() string

func (*Value) ExactMatch added in v1.3.3

func (v *Value) ExactMatch(mod int, want string) (bool, sfvm.ValueOperator, error)

func (*Value) FileFilter

func (v *Value) FileFilter(string, string, map[string]string, []string) (sfvm.ValueOperator, error)

func (*Value) FlexibleDepends added in v1.3.1

func (v *Value) FlexibleDepends() *Value

FlexibleDepends is used to get all the dependencies of the value e.g: a = b + c; d = a + e; the e is not filled in the depends of a, but call FlexibleDepends will get it

func (*Value) GetAllCallActualParams added in v1.3.3

func (v *Value) GetAllCallActualParams() (sfvm.ValueOperator, error)

func (*Value) GetAllMember added in v1.3.1

func (v *Value) GetAllMember() Values

GetAllMember get all member of object

func (*Value) GetAllVariables added in v1.3.3

func (v *Value) GetAllVariables() map[string]*ssa.Variable

func (*Value) GetBlock

func (v *Value) GetBlock() *Value

func (*Value) GetBottomUses added in v1.3.0

func (v *Value) GetBottomUses(opt ...OperationOption) Values

func (*Value) GetCallActualParams added in v1.3.3

func (v *Value) GetCallActualParams(i int) (sfvm.ValueOperator, error)

func (*Value) GetCallArgs added in v1.3.0

func (v *Value) GetCallArgs() Values

func (*Value) GetCallReturns added in v1.3.0

func (v *Value) GetCallReturns() Values

func (*Value) GetCalled added in v1.3.3

func (v *Value) GetCalled() (sfvm.ValueOperator, error)

func (*Value) GetCalledBy added in v1.3.0

func (v *Value) GetCalledBy() Values

GetCalledBy desc all of 'Users' is Call

func (*Value) GetCallee added in v1.3.0

func (v *Value) GetCallee() *Value

GetCallee desc any of 'Users' is Call return the first Call, if `risk.New()`, GetCallee will return `risk.New`.

func (*Value) GetConst added in v1.2.9

func (v *Value) GetConst() *ssa.Const

func (*Value) GetConstValue added in v1.2.9

func (v *Value) GetConstValue() any

for const instruction

func (*Value) GetContextValue added in v1.3.0

func (v *Value) GetContextValue(i ContextID) (*Value, bool)

GetContextValue can handle context

func (*Value) GetDepth added in v1.3.1

func (v *Value) GetDepth() int

func (*Value) GetFields

func (v *Value) GetFields() (sfvm.ValueOperator, error)

func (*Value) GetFreeValue

func (v *Value) GetFreeValue(name string) *Value

func (*Value) GetFunction

func (v *Value) GetFunction() *Value

func (*Value) GetFunctionObjectType added in v1.3.3

func (v *Value) GetFunctionObjectType() ssa.Type

func (*Value) GetId added in v1.3.0

func (v *Value) GetId() int64

func (*Value) GetKey added in v1.3.1

func (v *Value) GetKey() *Value

GetKey get key of member

func (*Value) GetMask

func (v *Value) GetMask() Values

func (*Value) GetMember added in v1.3.1

func (v *Value) GetMember(value *Value) *Value

GetMember get member of object by key

func (*Value) GetMembers

func (v *Value) GetMembers() [][]*Value

GetAllMember get member keys and values

func (*Value) GetMembersByString added in v1.3.3

func (v *Value) GetMembersByString(key string) (sfvm.ValueOperator, error)

func (*Value) GetName added in v1.3.0

func (v *Value) GetName() string

func (*Value) GetObject added in v1.3.1

func (v *Value) GetObject() *Value

GetObject get object of member

func (*Value) GetOpcode added in v1.2.9

func (v *Value) GetOpcode() string

func (*Value) GetOperand

func (v *Value) GetOperand(index int) *Value

func (*Value) GetOperands

func (v *Value) GetOperands() Values

func (*Value) GetParameter

func (v *Value) GetParameter(i int) *Value

func (*Value) GetParameters added in v1.2.9

func (v *Value) GetParameters() Values

func (*Value) GetRange added in v1.3.1

func (v *Value) GetRange() *ssa.Range

func (*Value) GetReachable

func (v *Value) GetReachable() *Value

func (*Value) GetReferences

func (v *Value) GetReferences() Values

func (*Value) GetReturn

func (v *Value) GetReturn() Values

func (*Value) GetSSAValue

func (v *Value) GetSSAValue() ssa.Value

func (*Value) GetSelf added in v1.2.9

func (v *Value) GetSelf() *Value

func (*Value) GetSyntaxFlowBottomUse added in v1.3.3

func (v *Value) GetSyntaxFlowBottomUse(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, config ...*sfvm.RecursiveConfigItem) (sfvm.ValueOperator, error)

func (*Value) GetSyntaxFlowDef added in v1.3.3

func (v *Value) GetSyntaxFlowDef() (sfvm.ValueOperator, error)

func (*Value) GetSyntaxFlowTopDef added in v1.3.3

func (v *Value) GetSyntaxFlowTopDef(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, config ...*sfvm.RecursiveConfigItem) (sfvm.ValueOperator, error)

func (*Value) GetSyntaxFlowUse added in v1.3.3

func (v *Value) GetSyntaxFlowUse() (sfvm.ValueOperator, error)

func (*Value) GetTopDefs added in v1.3.0

func (i *Value) GetTopDefs(opt ...OperationOption) Values

GetTopDefs desc all of 'Defs' is not used by any other value

func (*Value) GetType added in v1.2.9

func (v *Value) GetType() *Type

func (*Value) GetTypeKind added in v1.2.9

func (v *Value) GetTypeKind() ssa.TypeKind

func (*Value) GetUser

func (v *Value) GetUser(index int) *Value

func (*Value) GetUsers

func (v *Value) GetUsers() Values

func (*Value) GetVariable added in v1.3.3

func (v *Value) GetVariable(name string) *ssa.Variable

for variable

func (*Value) GetVerboseName added in v1.3.1

func (v *Value) GetVerboseName() string

func (*Value) GlobMatch added in v1.3.3

func (v *Value) GlobMatch(mod int, g string) (bool, sfvm.ValueOperator, error)

func (*Value) HasOperands

func (v *Value) HasOperands() bool

func (*Value) HasUsers

func (v *Value) HasUsers() bool

func (*Value) InMainFunction

func (v *Value) InMainFunction() bool

func (*Value) IsAssert

func (v *Value) IsAssert() bool

func (*Value) IsBasicBlock

func (v *Value) IsBasicBlock() bool

func (*Value) IsBinOp

func (v *Value) IsBinOp() bool

func (*Value) IsCall

func (v *Value) IsCall() bool

func (*Value) IsCalled added in v1.3.0

func (v *Value) IsCalled() bool

IsCalled desc any of 'Users' is Call

func (*Value) IsConstInst

func (v *Value) IsConstInst() bool

func (*Value) IsErrorHandler

func (v *Value) IsErrorHandler() bool

func (*Value) IsExtern added in v1.2.9

func (v *Value) IsExtern() bool

func (*Value) IsExternLib added in v1.3.1

func (v *Value) IsExternLib() bool

IsExternLib desc if the value is extern lib

extern-lib is a special value that is used to represent the external library

code := `a = fmt.Println`
fmt := prog.Ref("fmt") // extern-lib
fmt.GetOperands() // Values // [Function-Println]

func (*Value) IsFreeValue added in v1.3.3

func (v *Value) IsFreeValue() bool

func (*Value) IsFunction

func (v *Value) IsFunction() bool

func (*Value) IsIf

func (v *Value) IsIf() bool

func (*Value) IsJump

func (v *Value) IsJump() bool

func (*Value) IsList added in v1.3.3

func (v *Value) IsList() bool

func (*Value) IsLoop

func (v *Value) IsLoop() bool

func (*Value) IsMake

func (v *Value) IsMake() bool

func (*Value) IsMap added in v1.3.3

func (v *Value) IsMap() bool

func (*Value) IsMember added in v1.3.1

func (v *Value) IsMember() bool

IsMember desc if the value is member of some object

func (*Value) IsMethod added in v1.3.3

func (v *Value) IsMethod() bool

func (*Value) IsModifySelf added in v1.2.9

func (v *Value) IsModifySelf() bool

func (*Value) IsNext

func (v *Value) IsNext() bool

func (*Value) IsNil added in v1.3.3

func (v *Value) IsNil() bool

func (*Value) IsObject added in v1.3.1

func (v *Value) IsObject() bool

IsObject desc if the value is object

func (*Value) IsPanic

func (v *Value) IsPanic() bool

func (*Value) IsParameter added in v1.2.9

func (v *Value) IsParameter() bool

func (*Value) IsParameterMember added in v1.3.3

func (v *Value) IsParameterMember() bool

func (*Value) IsPhi

func (v *Value) IsPhi() bool

func (*Value) IsReachable

func (v *Value) IsReachable() int

if condition is true : 1 reach if condition is false : -1 unreachable if condition need calc: 0 unknown

func (*Value) IsRecover

func (v *Value) IsRecover() bool

func (*Value) IsReturn

func (v *Value) IsReturn() bool

func (*Value) IsSwitch

func (v *Value) IsSwitch() bool

func (*Value) IsTypeCast

func (v *Value) IsTypeCast() bool

func (*Value) IsTypeValue

func (v *Value) IsTypeValue() bool

func (*Value) IsUnOp

func (v *Value) IsUnOp() bool

func (*Value) IsUndefined

func (v *Value) IsUndefined() bool

func (*Value) ListIndex added in v1.3.3

func (v *Value) ListIndex(i int) (sfvm.ValueOperator, error)

func (*Value) LoadFullUseDefChain added in v1.3.1

func (v *Value) LoadFullUseDefChain() *Value

func (*Value) Merge

func (v *Value) Merge(sf ...sfvm.ValueOperator) (sfvm.ValueOperator, error)

func (*Value) NewError added in v1.2.9

func (v *Value) NewError(tag, msg string)

func (*Value) NewValue added in v1.3.3

func (v *Value) NewValue(value ssa.Value) *Value

func (*Value) NewWarn added in v1.2.9

func (v *Value) NewWarn(tag, msg string)

func (*Value) Recursive added in v1.3.3

func (v *Value) Recursive(f func(operator sfvm.ValueOperator) error) error

func (*Value) RecursiveDepends added in v1.3.1

func (v *Value) RecursiveDepends(h func(value *Value) error)

RecursiveDepends is used to get all the dependencies of the value

func (*Value) RecursiveDependsAndEffects added in v1.3.1

func (v *Value) RecursiveDependsAndEffects(h func(value *Value) error)

func (*Value) RecursiveEffects added in v1.3.1

func (v *Value) RecursiveEffects(h func(value *Value) error)

RecursiveEffects is used to get all the effects of the value

func (*Value) RegexpMatch added in v1.3.3

func (v *Value) RegexpMatch(mod int, re string) (bool, sfvm.ValueOperator, error)

func (*Value) Remove

func (v *Value) Remove(sf ...sfvm.ValueOperator) (sfvm.ValueOperator, error)

func (*Value) SetContextValue added in v1.3.0

func (v *Value) SetContextValue(i ContextID, values *Value) *Value

func (*Value) SetDepth added in v1.3.1

func (v *Value) SetDepth(i int)

func (*Value) ShortString added in v1.3.1

func (v *Value) ShortString() string

func (*Value) Show

func (i *Value) Show() *Value

func (*Value) ShowBacktrack added in v1.3.1

func (v *Value) ShowBacktrack()

func (*Value) ShowDot added in v1.3.1

func (v *Value) ShowDot() *Value

func (*Value) ShowUseDefChain

func (v *Value) ShowUseDefChain()

func (*Value) ShowWithRange

func (i *Value) ShowWithRange() *Value

func (*Value) ShowWithSourceCode

func (i *Value) ShowWithSourceCode() *Value

func (*Value) String

func (v *Value) String() string

func (*Value) StringWithRange

func (v *Value) StringWithRange() string

func (*Value) StringWithSourceCode

func (v *Value) StringWithSourceCode(msg ...string) string

type ValueGraph

type ValueGraph struct {
	*dot.Graph

	RootValue map[*Value]int // root value to graph node id
	NodeInfo  map[int]*Value // graph node id to value
}

func NewValueGraph

func NewValueGraph(v ...*Value) *ValueGraph

type Values

type Values []*Value

func FindFlexibleCommonDepends added in v1.3.1

func FindFlexibleCommonDepends(val Values) Values

FindFlexibleCommonDepends 在给定的值集合中查找具有灵活共同依赖的值。

FindFlexibleCommonDepends searches for values with flexible common dependencies in the given collection of values.

它与 FindStrictCommonDepends 类似,但在查找共同依赖时,会尝试重新构建值的顶层定义。

It is similar to FindStrictCommonDepends, but when searching for common dependencies, it attempts to rebuild the top-level definition of values.

具有灵活共同依赖的值是指通过重新构建顶层定义,从而可能包括更多的依赖关系。

Values with flexible common dependencies are those that may include more dependencies by rebuilding the top-level definition.

func FindFlexibleDependsIntersection added in v1.3.3

func FindFlexibleDependsIntersection(root Values, element Values, opts ...OperationOption) Values

FindFlexibleDependsIntersection searches for intersections between flexible dependencies of the root collection and elements from the target collection, returning matched elements.

FindFlexibleDependsIntersection 搜索根集合中的灵活依赖与目标集合中元素的交集,并返回匹配的元素。

这个函数是 ExtractTopDefsIntersection 的一个封装,专门用于处理灵活依赖关系。 This function is a wrapper around ExtractTopDefsIntersection, specifically tailored for handling flexible dependencies.

它接收三个参数:root(根集合),element(目标集合),以及可选的 opts(操作选项)。 It takes three parameters: root (the root collection), element (the target collection), and optionally opts (operation options).

通过将灵活依赖的特定处理逻辑传递给 ExtractTopDefsIntersection,该函数利用已有的逻辑 来检查和返回交集元素。 By passing specific handling logic for flexible dependencies to ExtractTopDefsIntersection, this function leverages existing logic to check and return intersecting elements.

使用此函数可以灵活地处理不同类型的依赖关系,如在计算或数据分析场景中常见的依赖查找。 Using this function allows flexible handling of different types of dependencies, commonly seen in computing or data analysis scenarios.

func FindStrictCommonDepends added in v1.3.1

func FindStrictCommonDepends(val Values) Values

FindStrictCommonDepends 在给定的值集合中查找具有严格共同依赖的值。

FindStrictCommonDepends searches for values with strictly common dependencies in the given collection of values.

它遍历给定的值集合,比较每对值之间的依赖关系,并返回所有具有严格共同依赖的值的集合。

It iterates over the given collection of values, compares the dependencies between each pair of values, and returns a collection of all values with strictly common dependencies.

严格共同依赖是指只有当值 A 依赖于值 B,而值 B 也依赖于值 A 时,这两个值才被认为具有严格共同依赖。

Strict common dependencies refer to the scenario where value A depends on value B, and value B depends on value A for them to be considered to have strict common dependencies.

func GetValues added in v1.3.3

func GetValues(v *Value) Values

func SFValueListToValues added in v1.3.3

func SFValueListToValues(list *sfvm.ValueList) (Values, error)

func SyntaxFlowVariableToValues

func SyntaxFlowVariableToValues(v sfvm.ValueOperator) Values

func WithSyntaxFlowConfig added in v1.3.3

func WithSyntaxFlowConfig(
	sfResult *sf.SFFrameResult,
	config *sf.Config,
	cb func(...OperationOption) Values,
	opts ...*sf.RecursiveConfigItem,
) Values

func (Values) AppendDependOn added in v1.3.1

func (i Values) AppendDependOn(v *Value) Values

func (Values) AppendEffectOn added in v1.3.1

func (i Values) AppendEffectOn(v *Value) Values

func (Values) AppendPredecessor

func (value Values) AppendPredecessor(operator sfvm.ValueOperator, opts ...sfvm.AnalysisContextOption) error

func (Values) DotGraph

func (v Values) DotGraph() string

func (Values) DotGraphs

func (v Values) DotGraphs() []string

func (Values) ExactMatch added in v1.3.3

func (values Values) ExactMatch(mod int, want string) (bool, sfvm.ValueOperator, error)

func (Values) ExtractTopDefsIntersection added in v1.3.3

func (value Values) ExtractTopDefsIntersection(targets Values, opts ...OperationOption) Values

ExtractTopDefsIntersection explores the possibility of top-level definitions in the caller's elements including elements from the target collection and returns them if found.

ExtractTopDefsIntersection 寻找调用者中的顶级定义过程包含目标元素的可能性,如果找到则直接返回。

该函数通过遍历调用者集合中的每一个元素,检查其顶级定义是否与目标集合中的某个元素匹配。 This function iterates through each element in the caller's collection to check if its top-level definitions match any of the elements in the target collection.

func (Values) FileFilter

func (value Values) FileFilter(string, string, map[string]string, []string) (sfvm.ValueOperator, error)

func (Values) Filter added in v1.2.9

func (v Values) Filter(f func(*Value) bool) Values

func (Values) Flat added in v1.3.0

func (v Values) Flat(f func(*Value) Values) Values

func (Values) FlexibleDepends added in v1.3.1

func (v Values) FlexibleDepends() Values

func (Values) ForEach

func (v Values) ForEach(f func(*Value)) Values

func (Values) FullUseDefChain added in v1.3.1

func (v Values) FullUseDefChain(h func(*Value))

func (Values) Get

func (v Values) Get(i int) *Value

func (Values) GetAllCallActualParams added in v1.3.3

func (value Values) GetAllCallActualParams() (sfvm.ValueOperator, error)

func (Values) GetBottomUses added in v1.3.1

func (v Values) GetBottomUses(opts ...OperationOption) Values

func (Values) GetBySyntaxFlowName

func (v Values) GetBySyntaxFlowName(name string) Values

func (Values) GetCallActualParams added in v1.3.3

func (value Values) GetCallActualParams(index int) (sfvm.ValueOperator, error)

func (Values) GetCalled added in v1.3.3

func (value Values) GetCalled() (sfvm.ValueOperator, error)

func (Values) GetFields

func (value Values) GetFields() (sfvm.ValueOperator, error)

func (Values) GetMembersByString added in v1.3.3

func (value Values) GetMembersByString(key string) (sfvm.ValueOperator, error)

func (Values) GetOpcode

func (p Values) GetOpcode() string

func (Values) GetOperands added in v1.3.1

func (v Values) GetOperands() Values

func (Values) GetSyntaxFlowBottomUse added in v1.3.3

func (value Values) GetSyntaxFlowBottomUse(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, config ...*sfvm.RecursiveConfigItem) (sfvm.ValueOperator, error)

func (Values) GetSyntaxFlowDef added in v1.3.3

func (value Values) GetSyntaxFlowDef() (sfvm.ValueOperator, error)

func (Values) GetSyntaxFlowTopDef added in v1.3.3

func (value Values) GetSyntaxFlowTopDef(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, config ...*sfvm.RecursiveConfigItem) (sfvm.ValueOperator, error)

func (Values) GetSyntaxFlowUse added in v1.3.3

func (value Values) GetSyntaxFlowUse() (sfvm.ValueOperator, error)

func (Values) GetTopDefs added in v1.3.0

func (v Values) GetTopDefs(opts ...OperationOption) Values

func (Values) GetUsers added in v1.2.9

func (v Values) GetUsers() Values

func (Values) GlobMatch added in v1.3.3

func (values Values) GlobMatch(mod int, g string) (bool, sfvm.ValueOperator, error)

func (Values) IsList added in v1.3.3

func (value Values) IsList() bool

func (Values) IsMap added in v1.3.3

func (value Values) IsMap() bool

func (Values) Len added in v1.3.3

func (value Values) Len() int

func (Values) ListIndex added in v1.3.3

func (value Values) ListIndex(i int) (sfvm.ValueOperator, error)

func (Values) Merge

func (value Values) Merge(values ...sfvm.ValueOperator) (sfvm.ValueOperator, error)

func (Values) NewValue added in v1.3.3

func (v Values) NewValue(ssaVal ssa.Value) *Value

func (Values) Recursive added in v1.3.3

func (value Values) Recursive(f func(operator sfvm.ValueOperator) error) error

func (Values) Ref

func (value Values) Ref(name string) Values

func (Values) RegexpMatch added in v1.3.3

func (values Values) RegexpMatch(mod int, re string) (bool, sfvm.ValueOperator, error)

func (Values) Remove

func (value Values) Remove(values ...sfvm.ValueOperator) (sfvm.ValueOperator, error)

func (Values) Show

func (v Values) Show(b ...bool) Values

func (Values) ShowDot added in v1.3.1

func (V Values) ShowDot() Values

func (Values) ShowWithSource

func (v Values) ShowWithSource(b ...bool) Values

func (Values) String added in v1.3.0

func (v Values) String() string

func (Values) StringEx

func (v Values) StringEx(flag int) string

Directories

Path Synopsis
test

Jump to

Keyboard shortcuts

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