Documentation
¶
Index ¶
- Constants
- Variables
- func ClearCache()
- func ConvertSyntaxFlowResultToSarif(r ...*SyntaxFlowResult) (*sarif.Report, error)
- func DataFlowWithSFConfig(sfResult *sf.SFFrameResult, config *sf.Config, ...) sf.ValueOperator
- func GetBareNode(v *Value) ssa.Value
- func GetBareType(typ *Type) ssa.Type
- func GetFreeValue(v *Value) *ssa.Parameter
- func GetIncludeCacheValue(program *Program, ruleName string, inputValues Values) (hash string, value sfvm.ValueOperator, shouldCache bool)
- func GetSFIncludeCache() *utils.Cache[sfvm.ValueOperator]
- func MergeSFValueOperator(sfv ...sfvm.ValueOperator) sfvm.ValueOperator
- func SaveValue(value *Value, opts ...SaveValueOption) error
- func TypeCompare(t1, t2 *Type) bool
- func ValidSyntaxFlowRule(s *schema.SyntaxFlowRule) error
- func ValueCompare(v1raw, v2raw *Value) bool
- func ValueContain(v1 *Value, v2 ...*Value) bool
- func ValuesToSFValueList(values Values) sfvm.ValueOperator
- type AnalyzeContext
- type CodeRange
- type ContextID
- type DominatorForest
- type DominatorTree
- type NativeCallDocument
- type OperationConfig
- type OperationOption
- type Option
- func DefaultExcludeFunc(patterns []string) (Option, error)
- func WithCacheTTL(ttl time.Duration) Option
- func WithConfigInfo(input map[string]any) Option
- func WithConfigInfoRaw(info string) Option
- func WithContext(ctx context.Context) Option
- func WithDatabasePath(path string) Option
- func WithDatabaseProgramCacheHitter(h func(i any)) Option
- func WithDefineFunc(table map[string]any) Option
- func WithEnableCache(b ...bool) Option
- func WithExcludeFile(f func(path, filename string) bool) Option
- func WithExternBuildValueHandler(id string, callback func(b *ssa.FunctionBuilder, id string, v any) ssa.Value) Option
- func WithExternInfo(info string) Option
- func WithExternLib(name string, table map[string]any) Option
- func WithExternMethod(b ssa.MethodBuilder) Option
- func WithExternValue(table map[string]any) Option
- func WithFeedCode(b ...bool) Option
- func WithFileSystem(fs fi.FileSystem) Option
- func WithFileSystemEntry(files ...string) Option
- func WithIgnoreSyntaxError(b ...bool) Option
- func WithIncludePath(path ...string) Option
- func WithLanguage(language consts.Language) Option
- func WithLocalFs(path string) Option
- func WithPeepholeSize(size int) Option
- func WithProcess(process ProcessFunc) Option
- func WithProgramDescription(desc string) Option
- func WithProgramName(name string) Option
- func WithProgramPath(path string) Option
- func WithRawLanguage(input_language string) Option
- func WithReCompile(b bool) Option
- func WithSaveToProfile(b ...bool) Option
- func WithStrictMode(b bool) Option
- type PredecessorValue
- type ProcessFunc
- type Program
- func (p *Program) AppendPredecessor(sfvm.ValueOperator, ...sfvm.AnalysisContextOption) error
- func (p *Program) DBDebug()
- func (p *Program) ExactMatch(ctx context.Context, mod int, s string) (bool, sfvm.ValueOperator, error)
- func (p *Program) Feed(code io.Reader) error
- func (p *Program) FileFilter(path string, match string, rule map[string]string, rule2 []string) (sfvm.ValueOperator, error)
- func (p *Program) GetAllCallActualParams() (sfvm.ValueOperator, error)
- func (p *Program) GetAllOffsetItemsBefore(offset int) []*ssa.OffsetItem
- func (p *Program) GetBinaryOperator() string
- func (p *Program) GetCallActualParams(int) (sfvm.ValueOperator, error)
- func (p *Program) GetCalled() (sfvm.ValueOperator, error)
- func (p *Program) GetErrors() ssa.SSAErrors
- func (p *Program) GetFields() (sfvm.ValueOperator, error)
- func (p *Program) GetInstructionById(id int64) ssa.Instruction
- func (p *Program) GetLanguage() string
- func (p *Program) GetOpcode() string
- func (p *Program) GetProgramKind() ssa.ProgramKind
- func (p *Program) GetProgramName() string
- func (p *Program) GetSyntaxFlowBottomUse(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, ...) (sfvm.ValueOperator, error)
- func (p *Program) GetSyntaxFlowDef() (sfvm.ValueOperator, error)
- func (p *Program) GetSyntaxFlowTopDef(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, ...) (sfvm.ValueOperator, error)
- func (p *Program) GetSyntaxFlowUse() (sfvm.ValueOperator, error)
- func (p *Program) GetType(name string) *Type
- func (p *Program) GetUnaryOperator() string
- func (p *Program) GetValueById(id int64) (*Value, error)
- func (p *Program) GetValueByIdMust(id int64) *Value
- func (p *Program) GlobMatch(ctx context.Context, mod int, g string) (bool, sfvm.ValueOperator, error)
- func (p *Program) Hash() (string, bool)
- func (p *Program) IsEmpty() bool
- func (p *Program) IsFromDatabase() bool
- func (p *Program) IsList() bool
- func (p *Program) IsMap() bool
- func (p *Program) IsNil() bool
- func (p *Program) ListIndex(i int) (sfvm.ValueOperator, error)
- func (p *Program) Merge(sfv ...sfvm.ValueOperator) (sfvm.ValueOperator, error)
- func (p *Program) NewValue(n ssa.Value) *Value
- func (p *Program) NewValueFromAuditNode(nodeID uint) *Value
- func (prog *Program) Recompile(opts ...Option) error
- func (p *Program) Recursive(f func(operator sfvm.ValueOperator) error) error
- func (p *Program) Ref(name string) Values
- func (p *Program) RegexpMatch(ctx context.Context, mod int, re string) (bool, sfvm.ValueOperator, error)
- func (p *Program) Remove(...sfvm.ValueOperator) (sfvm.ValueOperator, error)
- func (p *Program) Show() *Program
- func (p *Program) String() string
- func (p *Program) SyntaxFlow(rule string, opts ...QueryOption) *SyntaxFlowResult
- func (p *Program) SyntaxFlowChain(i string, opts ...QueryOption) Values
- func (p *Program) SyntaxFlowRule(rule *schema.SyntaxFlowRule, opts ...QueryOption) (*SyntaxFlowResult, error)
- func (p *Program) SyntaxFlowRuleName(ruleName string, opts ...QueryOption) (*SyntaxFlowResult, error)
- func (p *Program) SyntaxFlowWithError(rule string, opts ...QueryOption) (*SyntaxFlowResult, error)
- type Programs
- func (p Programs) Show() Programs
- func (ps Programs) SyntaxFlowRule(rule *schema.SyntaxFlowRule, opts ...QueryOption) (*SyntaxFlowResult, error)
- func (ps Programs) SyntaxFlowRuleName(ruleName string, opts ...QueryOption) (*SyntaxFlowResult, error)
- func (ps Programs) SyntaxFlowWithError(i string, opts ...QueryOption) (*SyntaxFlowResult, error)
- type QueryOption
- func QueryWithContext(ctx context.Context) QueryOption
- func QueryWithEnableDebug(b ...bool) QueryOption
- func QueryWithFailFast(b ...bool) QueryOption
- func QueryWithInitInputVar(value sfvm.ValueOperator) QueryOption
- func QueryWithInitVar(result *omap.OrderedMap[string, sfvm.ValueOperator]) QueryOption
- func QueryWithProcessCallback(cb func(float64, string)) QueryOption
- func QueryWithProgram(program *Program) QueryOption
- func QueryWithPrograms(programs Programs) QueryOption
- func QueryWithResultCaptured(capture sfvm.ResultCapturedCallback) QueryOption
- func QueryWithRule(rule *schema.SyntaxFlowRule) QueryOption
- func QueryWithRuleContent(rule string) QueryOption
- func QueryWithRuleName(names string) QueryOption
- func QueryWithSFConfig(config *sfvm.Config) QueryOption
- func QueryWithSave(kind schema.SyntaxflowResultKind) QueryOption
- func QueryWithStrictMatch(b ...bool) QueryOption
- func QueryWithSyntaxFlowResult(expected string, handler func(*Value) error) QueryOption
- func QueryWithTaskID(taskID string) QueryOption
- func QueryWithVM(vm *sfvm.SyntaxFlowVirtualMachine) QueryOption
- func QueryWithValue(value sfvm.ValueOperator) QueryOption
- type RecursiveConfig
- type SarifContext
- func (s *SarifContext) AddSSAValue(v *Value, extraMsg ...string)
- func (s *SarifContext) ArtifactsExisted(hash string) (int, bool)
- func (s *SarifContext) CreateCodeFlowsFromPredecessor(v *Value) []*sarif.CodeFlow
- func (s *SarifContext) CreateLocation(artifactId int, rg memedit.RangeIf) *sarif.Location
- func (s *SarifContext) CreateSubSarifContext() *SarifContext
- func (s *SarifContext) GetArtifactIdFromEditor(editor *memedit.MemEditor) int
- type SaveValueOption
- func OptionSaveValue_ProgramName(name string) SaveValueOption
- func OptionSaveValue_ResultAlert(alertMsg string) SaveValueOption
- func OptionSaveValue_ResultID(resultID uint) SaveValueOption
- func OptionSaveValue_ResultVariable(variable string) SaveValueOption
- func OptionSaveValue_RuleName(i string) SaveValueOption
- func OptionSaveValue_RuleTitle(name string) SaveValueOption
- func OptionSaveValue_TaskID(taskID string) SaveValueOption
- type SyntaxFlowResult
- func (r *SyntaxFlowResult) Dump(showCode bool) string
- func (r *SyntaxFlowResult) DumpValuesJson(name string) string
- func (r *SyntaxFlowResult) GetAlertInfo(name string) (*schema.SyntaxFlowDescInfo, bool)
- func (r *SyntaxFlowResult) GetAlertMsg(name string) (string, bool)
- func (r *SyntaxFlowResult) GetAlertValue(name string) Values
- func (r *SyntaxFlowResult) GetAlertValues() *omap.OrderedMap[string, Values]
- func (r *SyntaxFlowResult) GetAlertVariables() []string
- func (r *SyntaxFlowResult) GetAllValuesChain() Values
- func (r *SyntaxFlowResult) GetAllVariable() *orderedmap.OrderedMap
- func (r *SyntaxFlowResult) GetCheckMsg() []string
- func (r *SyntaxFlowResult) GetErrors() []string
- func (r *SyntaxFlowResult) GetGRPCModelResult() *ypb.SyntaxFlowResult
- func (r *SyntaxFlowResult) GetGRPCModelRisk() []*ypb.SSARisk
- func (r *SyntaxFlowResult) GetProgramName() string
- func (r *SyntaxFlowResult) GetResultID() uint
- func (r *SyntaxFlowResult) GetRiskByValue(variable string, i int) *schema.SSARisk
- func (r *SyntaxFlowResult) GetRiskHash(variable string, i int) string
- func (r *SyntaxFlowResult) GetSFResult() *sfvm.SFFrameResult
- func (r *SyntaxFlowResult) GetUnNameValues() Values
- func (r *SyntaxFlowResult) GetValue(name string, index int64) (*Value, error)
- func (r *SyntaxFlowResult) GetValues(name string) Values
- func (r *SyntaxFlowResult) GetVariableNum() int
- func (r *SyntaxFlowResult) Name() string
- func (r *SyntaxFlowResult) Save(kind schema.SyntaxflowResultKind, TaskIDs ...string) (uint, error)
- func (r *SyntaxFlowResult) SaveRisk(variable string, result *ssadb.AuditResult)
- func (r *SyntaxFlowResult) Show(opts ...sfvm.ShowOption)
- func (r *SyntaxFlowResult) String(opts ...sfvm.ShowOption) string
- type Type
- type Value
- func (v *Value) AnalyzeDepth() int
- func (i *Value) AppendDependOn(vs ...*Value) *Value
- func (i *Value) AppendEffectOn(vs ...*Value) *Value
- func (v *Value) AppendPredecessor(operator sfvm.ValueOperator, opts ...sfvm.AnalysisContextOption) error
- func (v *Value) Backtrack() *omap.OrderedMap[string, *Value]
- func (v *Value) Compare(other *Value) bool
- func (v *Value) DotGraph() string
- func (v *Value) ExactMatch(ctx context.Context, mod int, want string) (bool, sfvm.ValueOperator, error)
- func (v *Value) FileFilter(path string, match string, rule map[string]string, rule2 []string) (sfvm.ValueOperator, error)
- func (v *Value) FlexibleDepends() *Value
- func (v *Value) GetAllCallActualParams() (sfvm.ValueOperator, error)
- func (v *Value) GetAllMember() Values
- func (v *Value) GetAllVariables() map[string]*ssa.Variable
- func (v *Value) GetAuditNodeId() uint
- func (v *Value) GetBinaryOperator() string
- func (v *Value) GetBlock() *Value
- func (v *Value) GetBottomUses(opt ...OperationOption) Values
- func (v *Value) GetCallActualParams(i int) (sfvm.ValueOperator, error)
- func (v *Value) GetCallArgs() Values
- func (v *Value) GetCallReturns() Values
- func (v *Value) GetCalled() (sfvm.ValueOperator, error)
- func (v *Value) GetCalledBy() Values
- func (v *Value) GetCallee() *Value
- func (v *Value) GetConst() *ssa.Const
- func (v *Value) GetConstValue() any
- func (v *Value) GetContextValue(i ContextID) (*Value, bool)
- func (v *Value) GetDataflowPath(end ...*Value) []Values
- func (v *Value) GetDependOn() Values
- func (v *Value) GetDependOnPath(end ...*Value) []Values
- func (v *Value) GetDepth() int
- func (v *Value) GetEffectOn() Values
- func (v *Value) GetEffectOnPath(end ...*Value) []Values
- func (v *Value) GetFields() (sfvm.ValueOperator, error)
- func (v *Value) GetFreeValue(name string) *Value
- func (v *Value) GetFunction() *Value
- func (v *Value) GetFunctionObjectType() ssa.Type
- func (v *Value) GetId() int64
- func (v *Value) GetKey() *Value
- func (v *Value) GetMask() Values
- func (v *Value) GetMember(value *Value) *Value
- func (v *Value) GetMembers() [][]*Value
- func (v *Value) GetMembersByString(key string) (sfvm.ValueOperator, error)
- func (v *Value) GetName() string
- func (v *Value) GetObject() *Value
- func (v *Value) GetOpcode() string
- func (v *Value) GetOperand(index int) *Value
- func (v *Value) GetOperands() Values
- func (v *Value) GetParameter(i int) *Value
- func (v *Value) GetParameters() Values
- func (v *Value) GetPointer() Values
- func (v *Value) GetPredecessors() []*PredecessorValue
- func (v *Value) GetProgramName() string
- func (v *Value) GetRange() memedit.RangeIf
- func (v *Value) GetReachable() *Value
- func (v *Value) GetReturn() Values
- func (v *Value) GetSSAValue() ssa.Value
- func (v *Value) GetSelf() *Value
- func (v *Value) GetSyntaxFlowBottomUse(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, ...) (sfvm.ValueOperator, error)
- func (v *Value) GetSyntaxFlowDef() (sfvm.ValueOperator, error)
- func (v *Value) GetSyntaxFlowTopDef(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, ...) (sfvm.ValueOperator, error)
- func (v *Value) GetSyntaxFlowUse() (sfvm.ValueOperator, error)
- func (i *Value) GetTopDefs(opt ...OperationOption) Values
- func (v *Value) GetType() *Type
- func (v *Value) GetTypeKind() ssa.TypeKind
- func (v *Value) GetUnaryOperator() string
- func (v *Value) GetUser(index int) *Value
- func (v *Value) GetUsers() Values
- func (v *Value) GetVariable(name string) *ssa.Variable
- func (v *Value) GetVerboseName() string
- func (v *Value) GlobMatch(ctx context.Context, mod int, g string) (bool, sfvm.ValueOperator, error)
- func (v *Value) HasOperands() bool
- func (v *Value) HasUsers() bool
- func (v *Value) Hash() (string, bool)
- func (v *Value) InMainFunction() bool
- func (v *Value) IsAssert() bool
- func (v *Value) IsBasicBlock() bool
- func (v *Value) IsBinOp() bool
- func (v *Value) IsCall() bool
- func (v *Value) IsCalled() bool
- func (v *Value) IsConstInst() bool
- func (v *Value) IsEmpty() bool
- func (v *Value) IsErrorHandler() bool
- func (v *Value) IsExtern() bool
- func (v *Value) IsExternLib() bool
- func (v *Value) IsFreeValue() bool
- func (v *Value) IsFromDataBase() bool
- func (v *Value) IsFunction() bool
- func (v *Value) IsIf() bool
- func (v *Value) IsJump() bool
- func (v *Value) IsLazy() bool
- func (v *Value) IsList() bool
- func (v *Value) IsLoop() bool
- func (v *Value) IsMake() bool
- func (v *Value) IsMap() bool
- func (v *Value) IsMember() bool
- func (v *Value) IsMethod() bool
- func (v *Value) IsModifySelf() bool
- func (v *Value) IsNext() bool
- func (v *Value) IsNil() bool
- func (v *Value) IsObject() bool
- func (v *Value) IsPanic() bool
- func (v *Value) IsParameter() bool
- func (v *Value) IsParameterMember() bool
- func (v *Value) IsPhi() bool
- func (v *Value) IsReachable() int
- func (v *Value) IsRecover() bool
- func (v *Value) IsReturn() bool
- func (v *Value) IsSideEffect() bool
- func (v *Value) IsSwitch() bool
- func (v *Value) IsTypeCast() bool
- func (v *Value) IsTypeValue() bool
- func (v *Value) IsUnOp() bool
- func (v *Value) IsUndefined() bool
- func (v *Value) ListIndex(i int) (sfvm.ValueOperator, error)
- func (v *Value) LoadFullUseDefChain() *Value
- func (v *Value) Merge(sf ...sfvm.ValueOperator) (sfvm.ValueOperator, error)
- func (v *Value) NewBottomUseValue(value ssa.Value) *Value
- func (v *Value) NewError(tag, msg string)
- func (v *Value) NewTopDefValue(value ssa.Value) *Value
- func (v *Value) NewValue(value ssa.Value) *Value
- func (v *Value) NewValueFromAuditNode(nodeID uint) *Value
- func (v *Value) NewWarn(tag, msg string)
- func (v *Value) Recursive(f func(operator sfvm.ValueOperator) error) error
- func (v *Value) RecursiveDepends(h func(value *Value) error)
- func (v *Value) RecursiveDependsAndEffects(h func(value *Value) error)
- func (v *Value) RecursiveEffects(h func(value *Value) error)
- func (v *Value) RegexpMatch(ctx context.Context, mod int, re string) (bool, sfvm.ValueOperator, error)
- func (v *Value) Remove(sf ...sfvm.ValueOperator) (sfvm.ValueOperator, error)
- func (v *Value) SetContextValue(i ContextID, values *Value) *Value
- func (v *Value) SetDepth(i int)
- func (v *Value) ShortString() string
- func (i *Value) Show() *Value
- func (v *Value) ShowBacktrack()
- func (v *Value) ShowDot() *Value
- func (v *Value) ShowUseDefChain()
- func (i *Value) ShowWithRange() *Value
- func (i *Value) ShowWithSourceCode() *Value
- func (v *Value) String() string
- func (v *Value) StringWithRange() string
- func (v *Value) StringWithSourceCode(msg ...string) string
- type ValueGraph
- type Values
- func FindFlexibleCommonDepends(val Values) Values
- func FindFlexibleDependsIntersection(root Values, element Values, opts ...OperationOption) Values
- func FindStrictCommonDepends(val Values) Values
- func GetValues(v *Value) Values
- func MergeValues(vs ...Values) Values
- func SFValueListToValues(list *sfvm.ValueList) (Values, error)
- func SyntaxFlowVariableToValues(vs ...sfvm.ValueOperator) Values
- func (i Values) AppendDependOn(vs ...*Value) Values
- func (i Values) AppendEffectOn(vs ...*Value) Values
- func (value Values) AppendPredecessor(operator sfvm.ValueOperator, opts ...sfvm.AnalysisContextOption) error
- func (v Values) DotGraph() string
- func (v Values) DotGraphs() []string
- func (values Values) ExactMatch(ctx context.Context, mod int, want string) (bool, sfvm.ValueOperator, error)
- func (value Values) ExtractTopDefsIntersection(targets Values, opts ...OperationOption) Values
- func (vs Values) FileFilter(path string, match string, rule map[string]string, rule2 []string) (sfvm.ValueOperator, error)
- func (v Values) Filter(f func(*Value) bool) Values
- func (v Values) Flat(f func(*Value) Values) Values
- func (v Values) FlexibleDepends() Values
- func (v Values) ForEach(f func(*Value)) Values
- func (v Values) FullUseDefChain(h func(*Value))
- func (v Values) Get(i int) *Value
- func (value Values) GetAllCallActualParams() (sfvm.ValueOperator, error)
- func (Values) GetBinaryOperator() string
- func (v Values) GetBottomUses(opts ...OperationOption) Values
- func (v Values) GetBySyntaxFlowName(name string) Values
- func (value Values) GetCallActualParams(index int) (sfvm.ValueOperator, error)
- func (value Values) GetCalled() (sfvm.ValueOperator, error)
- func (vs Values) GetDataflowPath(end ...*Value) []Values
- func (value Values) GetFields() (sfvm.ValueOperator, error)
- func (value Values) GetMembersByString(key string) (sfvm.ValueOperator, error)
- func (p Values) GetOpcode() string
- func (v Values) GetOperands() Values
- func (value Values) GetSyntaxFlowBottomUse(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, ...) (sfvm.ValueOperator, error)
- func (value Values) GetSyntaxFlowDef() (sfvm.ValueOperator, error)
- func (value Values) GetSyntaxFlowTopDef(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, ...) (sfvm.ValueOperator, error)
- func (value Values) GetSyntaxFlowUse() (sfvm.ValueOperator, error)
- func (v Values) GetTopDefs(opts ...OperationOption) Values
- func (Values) GetUnaryOperator() string
- func (v Values) GetUsers() Values
- func (values Values) GlobMatch(ctx context.Context, mod int, g string) (bool, sfvm.ValueOperator, error)
- func (value Values) Hash() (string, bool)
- func (vs Values) IsEmpty() bool
- func (value Values) IsList() bool
- func (value Values) IsMap() bool
- func (value Values) Len() int
- func (value Values) ListIndex(i int) (sfvm.ValueOperator, error)
- func (vs Values) Merge(sf ...sfvm.ValueOperator) (sfvm.ValueOperator, error)
- func (v Values) NewValue(ssaVal ssa.Value) *Value
- func (value Values) Recursive(f func(operator sfvm.ValueOperator) error) error
- func (value Values) Ref(name string) Values
- func (values Values) RegexpMatch(ctx context.Context, mod int, re string) (bool, sfvm.ValueOperator, error)
- func (value Values) Remove(values ...sfvm.ValueOperator) (sfvm.ValueOperator, error)
- func (v Values) Show(b ...bool) Values
- func (V Values) ShowDot() Values
- func (v Values) ShowWithSource(b ...bool) Values
- func (v Values) String() string
- func (v Values) StringEx(flag int) string
Constants ¶
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 // example:NativeCall_Slice = "slice" // NativeCall_Regexp is used to regexp, group is available // you can use to extract NativeCall_Regexp = "regexp" // NativeCall_StrLower is used to convert a string to lower case NativeCall_StrLower = "strlower" // NativeCall_StrUpper is used to convert a string to upper case NativeCall_StrUpper = "strupper" // NativeCall_Var is used to put vars to variables NativeCall_Var = "var" // NativeCall_MyBatisSink is used to find MyBatis Sink for default searching NativeCall_MyBatisSink = "mybatisSink" // NativeCall_FreeMarkerSink is used to find FreeMarker Sink for default searching NativeCall_FreeMarkerSink = "freeMarkerSink" // NativeCall_OpCodes is used to get the opcodes of a value NativeCall_OpCodes = "opcodes" // NativeCall_SourceCode is used to get the source code of a value NativeCall_SourceCode = "sourceCode" // NativeCall_ScanPrevious is used to scan previous opcode of a value NativeCall_ScanPrevious = "scanPrevious" // NativeCall_ScanNext is used to scan next NativeCall_ScanNext = "scanNext" //NatiCall_ScanCurrent is used to scan current block NatiCall_ScanCurrent = "scanCurrent" //NativeCall_DeleteVariable is used to delete a variable NativeCall_DeleteVariable = "delete" // NativeCall_Forbid is used to forbid a value, if values existed, report critical error. NativeCall_Forbid = "forbid" // NativeCall_Self is used to get self value NativeCall_Self = "self" // NativeCall_DataFlow is used to get data flow // if u want to fetch dataflow, callafter --> or #-> // use it like: $data// *?{opcode: call && // CODE)> NativeCall_DataFlow = "dataflow" // NativeCall_Const is used to search const value NativeCall_Const = "const" // NativeCall_VersionIn is used to get the version in NativeCall_VersionIn = "versionIn" // NativeCall_IsSanitizeName checks for potential sanitization function names NativeCall_IsSanitizeName = "isSanitizeName" // NativeCall_Java_UnEscape_Output is used to show output in java template languages that has not been escape, // and is generally used to audit XSS vulnerabilities NativeCall_Java_UnEscape_Output = "javaUnescapeOutput" NativeCall_Foeach_Func_Inst = "foreach_function_inst" NativeCall_GetFilenameByContent = "FilenameByContent" NativeCall_GetFullFileName = "getFullFileName" NativeCall_GetUsers = "getUsers" NativeCall_GetActualParams = "getActualParams" NativeCall_GetActualParamLen = "getActualParamLen" ) ?{name} }
const ( Previous direction = "previous" Current direction = "current" Next direction = "next" )
const ( Yak = consts.Yak JS = consts.JS PHP = consts.PHP JAVA = consts.JAVA GO = consts.GO )
const CodeContextLine = 3
const SSADBProto = "ssadb://"
Variables ¶
var ( ErrContextCancel error = errors.New("context cancel") ErrNoFoundCompiledFile error = errors.New("not found can compiled file") )
var ( Number = NewType(ssa.BasicTypes[ssa.NumberTypeKind]) String = NewType(ssa.BasicTypes[ssa.StringTypeKind]) Bytes = NewType(ssa.BasicTypes[ssa.BytesTypeKind]) Boolean = NewType(ssa.BasicTypes[ssa.BooleanTypeKind]) UndefinedType = NewType(ssa.BasicTypes[ssa.UndefinedTypeKind]) Null = NewType(ssa.BasicTypes[ssa.NullTypeKind]) Any = NewType(ssa.BasicTypes[ssa.AnyTypeKind]) ErrorType = NewType(ssa.BasicTypes[ssa.ErrorTypeKind]) )
var AllLanguageBuilders = []ssa.Builder{ php2ssa.Builder, java2ssa.Builder, yak2ssa.Builder, js2ssa.Builder, go2ssa.Builder, }
var DefaultInputVar = "input"
var Exports = map[string]any{ "Parse": Parse, "ParseLocalProject": ParseProjectFromPath, "ParseProject": ParseProject, "NewFromProgramName": FromDatabase, "NewProgramFromDB": FromDatabase, "withLanguage": WithRawLanguage, "withConfigInfo": WithConfigInfo, "withExternLib": WithExternLib, "withExternValue": WithExternValue, "withProgramName": WithProgramName, "withDatabasePath": WithDatabasePath, "withDescription": WithProgramDescription, "withProcess": WithProcess, "withEntryFile": WithFileSystemEntry, "withReCompile": WithReCompile, "withStrictMode": WithStrictMode, "withSaveToProfile": WithSaveToProfile, "withContext": WithContext, "withPeepholeSize": WithPeepholeSize, "withExcludeFile": WithExcludeFile, "withDefaultExcludeFunc": DefaultExcludeFunc, "Javascript": JS, "Yak": Yak, "PHP": PHP, "Java": JAVA, }
var LanguageBuilders = map[consts.Language]ssa.Builder{ Yak: yak2ssa.Builder, JS: js2ssa.Builder, PHP: php2ssa.Builder, JAVA: java2ssa.Builder, GO: go2ssa.Builder, }
var NativeCallDocuments = make(map[string]*NativeCallDocument)
var SkippedError = ssareducer.SkippedError
Functions ¶
func ClearCache ¶
func ClearCache()
func ConvertSyntaxFlowResultToSarif ¶
func ConvertSyntaxFlowResultToSarif(r ...*SyntaxFlowResult) (*sarif.Report, error)
func DataFlowWithSFConfig ¶
func DataFlowWithSFConfig( sfResult *sf.SFFrameResult, config *sf.Config, dataflowRecursiveFunc func(...OperationOption) Values, opts ...*sf.RecursiveConfigItem, ) sf.ValueOperator
func GetBareNode ¶
GetBareNode get ssa.Value from ssaapi.Value only use this function in golang
func GetBareType ¶
func GetFreeValue ¶
func GetIncludeCacheValue ¶
func GetSFIncludeCache ¶
func GetSFIncludeCache() *utils.Cache[sfvm.ValueOperator]
func MergeSFValueOperator ¶
func MergeSFValueOperator(sfv ...sfvm.ValueOperator) sfvm.ValueOperator
func SaveValue ¶
func SaveValue(value *Value, opts ...SaveValueOption) error
func TypeCompare ¶
func ValidSyntaxFlowRule ¶
func ValidSyntaxFlowRule(s *schema.SyntaxFlowRule) error
func ValueCompare ¶
func ValueContain ¶
func ValuesToSFValueList ¶
func ValuesToSFValueList(values Values) sfvm.ValueOperator
Types ¶
type AnalyzeContext ¶
type AnalyzeContext struct {
// Self
Self *Value
// contains filtered or unexported fields
}
func NewAnalyzeContext ¶
func NewAnalyzeContext(opt ...OperationOption) *AnalyzeContext
type CodeRange ¶
type CodeRange struct {
URL string `json:"url"`
StartLine int64 `json:"start_line"`
StartColumn int64 `json:"start_column"`
EndLine int64 `json:"end_line"`
EndColumn int64 `json:"end_column"`
SourceCodeLine int64 `json:"source_code_line"`
}
func CoverCodeRange ¶
func (*CodeRange) JsonString ¶
type DominatorForest ¶
type DominatorForest struct {
Trees []*DominatorTree
}
type DominatorTree ¶
type DominatorTree *omap.OrderedMap[int, *Value]
type NativeCallDocument ¶
type NativeCallDocument struct {
Name string
Description string
Function sfvm.NativeCallFunc
}
type OperationConfig ¶
type OperationConfig struct {
// 限制递归深度,每一次递归核心函数,计数器都会加一
// 上下文计数器受到这个限制
MaxDepth int
MinDepth int
// Hook
HookEveryNode []func(*Value) error
AllowIgnoreCallStack bool
}
func NewOperations ¶
func NewOperations(opt ...OperationOption) *OperationConfig
type OperationOption ¶
type OperationOption func(*OperationConfig)
func WithAllowCallStack ¶
func WithAllowCallStack(allowCallStack bool) OperationOption
func WithDepthLimit ¶
func WithDepthLimit(depth int) OperationOption
func WithHookEveryNode ¶
func WithHookEveryNode(hookNode func(*Value) error) OperationOption
func WithMaxDepth ¶
func WithMaxDepth(maxDepth int) OperationOption
func WithMinDepth ¶
func WithMinDepth(minDepth int) OperationOption
type Option ¶
type Option func(*config) error
func DefaultExcludeFunc ¶
func WithCacheTTL ¶
func WithConfigInfo ¶
func WithConfigInfoRaw ¶
func WithContext ¶
func WithDatabasePath ¶
func WithDefineFunc ¶
func WithEnableCache ¶
func WithExcludeFile ¶
func WithExternInfo ¶
func WithExternMethod ¶
func WithExternMethod(b ssa.MethodBuilder) Option
func WithExternValue ¶
func WithFeedCode ¶
func WithFileSystem ¶
func WithFileSystem(fs fi.FileSystem) Option
func WithFileSystemEntry ¶
func WithIgnoreSyntaxError ¶
func WithIncludePath ¶
func WithLanguage ¶
func WithLocalFs ¶
func WithPeepholeSize ¶
func WithProcess ¶
func WithProcess(process ProcessFunc) Option
func WithProgramDescription ¶
func WithProgramName ¶
save to database, please set the program name
func WithProgramPath ¶
func WithRawLanguage ¶
func WithReCompile ¶
func WithSaveToProfile ¶
func WithStrictMode ¶
type PredecessorValue ¶
type PredecessorValue struct {
Node *Value
Info *sfvm.AnalysisContext
}
type ProcessFunc ¶
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 ¶
FromDatabase get program from database by program name
func NewProgram ¶
func ParseFromReader ¶
ParseFromReader parse simple file to ssa.Program
func (*Program) AppendPredecessor ¶
func (p *Program) AppendPredecessor(sfvm.ValueOperator, ...sfvm.AnalysisContextOption) error
func (*Program) ExactMatch ¶
func (*Program) FileFilter ¶
func (*Program) GetAllCallActualParams ¶
func (p *Program) GetAllCallActualParams() (sfvm.ValueOperator, error)
func (*Program) GetAllOffsetItemsBefore ¶
func (p *Program) GetAllOffsetItemsBefore(offset int) []*ssa.OffsetItem
func (*Program) GetBinaryOperator ¶
func (*Program) GetCallActualParams ¶
func (p *Program) GetCallActualParams(int) (sfvm.ValueOperator, error)
func (*Program) GetInstructionById ¶
func (p *Program) GetInstructionById(id int64) ssa.Instruction
func (*Program) GetLanguage ¶
func (*Program) GetProgramKind ¶
func (p *Program) GetProgramKind() ssa.ProgramKind
func (*Program) GetProgramName ¶
func (*Program) GetSyntaxFlowBottomUse ¶
func (p *Program) GetSyntaxFlowBottomUse(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, config ...*sfvm.RecursiveConfigItem) (sfvm.ValueOperator, error)
func (*Program) GetSyntaxFlowDef ¶
func (p *Program) GetSyntaxFlowDef() (sfvm.ValueOperator, error)
func (*Program) GetSyntaxFlowTopDef ¶
func (p *Program) GetSyntaxFlowTopDef(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, config ...*sfvm.RecursiveConfigItem) (sfvm.ValueOperator, error)
func (*Program) GetSyntaxFlowUse ¶
func (p *Program) GetSyntaxFlowUse() (sfvm.ValueOperator, error)
func (*Program) GetUnaryOperator ¶
func (*Program) GetValueById ¶
from ssa id (IrCode)
func (*Program) GetValueByIdMust ¶
func (*Program) IsFromDatabase ¶
func (*Program) Merge ¶
func (p *Program) Merge(sfv ...sfvm.ValueOperator) (sfvm.ValueOperator, error)
func (*Program) NewValueFromAuditNode ¶
func (*Program) Recursive ¶
func (p *Program) Recursive(f func(operator sfvm.ValueOperator) error) error
func (*Program) RegexpMatch ¶
func (*Program) Remove ¶
func (p *Program) Remove(...sfvm.ValueOperator) (sfvm.ValueOperator, error)
func (*Program) SyntaxFlow ¶
func (p *Program) SyntaxFlow(rule string, opts ...QueryOption) *SyntaxFlowResult
func (*Program) SyntaxFlowChain ¶
func (p *Program) SyntaxFlowChain(i string, opts ...QueryOption) Values
func (*Program) SyntaxFlowRule ¶
func (p *Program) SyntaxFlowRule(rule *schema.SyntaxFlowRule, opts ...QueryOption) (*SyntaxFlowResult, error)
func (*Program) SyntaxFlowRuleName ¶
func (p *Program) SyntaxFlowRuleName(ruleName string, opts ...QueryOption) (*SyntaxFlowResult, error)
func (*Program) SyntaxFlowWithError ¶
func (p *Program) SyntaxFlowWithError(rule string, opts ...QueryOption) (*SyntaxFlowResult, error)
type Programs ¶
type Programs []*Program
func ParseProject ¶
func ParseProjectFromPath ¶
func ParseProjectWithFS ¶
func ParseProjectWithFS(fs fi.FileSystem, opts ...Option) (Programs, error)
func PeepholeCompile ¶
func (Programs) SyntaxFlowRule ¶
func (ps Programs) SyntaxFlowRule(rule *schema.SyntaxFlowRule, opts ...QueryOption) (*SyntaxFlowResult, error)
func (Programs) SyntaxFlowRuleName ¶
func (ps Programs) SyntaxFlowRuleName(ruleName string, opts ...QueryOption) (*SyntaxFlowResult, error)
func (Programs) SyntaxFlowWithError ¶
func (ps Programs) SyntaxFlowWithError(i string, opts ...QueryOption) (*SyntaxFlowResult, error)
type QueryOption ¶
type QueryOption func(*queryConfig)
func QueryWithContext ¶
func QueryWithContext(ctx context.Context) QueryOption
func QueryWithEnableDebug ¶
func QueryWithEnableDebug(b ...bool) QueryOption
func QueryWithFailFast ¶
func QueryWithFailFast(b ...bool) QueryOption
func QueryWithInitInputVar ¶
func QueryWithInitInputVar(value sfvm.ValueOperator) QueryOption
func QueryWithInitVar ¶
func QueryWithInitVar(result *omap.OrderedMap[string, sfvm.ValueOperator]) QueryOption
func QueryWithProcessCallback ¶
func QueryWithProcessCallback(cb func(float64, string)) QueryOption
func QueryWithProgram ¶
func QueryWithProgram(program *Program) QueryOption
func QueryWithPrograms ¶
func QueryWithPrograms(programs Programs) QueryOption
func QueryWithResultCaptured ¶
func QueryWithResultCaptured(capture sfvm.ResultCapturedCallback) QueryOption
func QueryWithRule ¶
func QueryWithRule(rule *schema.SyntaxFlowRule) QueryOption
func QueryWithRuleContent ¶
func QueryWithRuleContent(rule string) QueryOption
func QueryWithRuleName ¶
func QueryWithRuleName(names string) QueryOption
func QueryWithSFConfig ¶
func QueryWithSFConfig(config *sfvm.Config) QueryOption
func QueryWithSave ¶
func QueryWithSave(kind schema.SyntaxflowResultKind) QueryOption
func QueryWithStrictMatch ¶
func QueryWithStrictMatch(b ...bool) QueryOption
func QueryWithSyntaxFlowResult ¶
func QueryWithSyntaxFlowResult(expected string, handler func(*Value) error) QueryOption
func QueryWithTaskID ¶
func QueryWithTaskID(taskID string) QueryOption
func QueryWithVM ¶
func QueryWithVM(vm *sfvm.SyntaxFlowVirtualMachine) QueryOption
func QueryWithValue ¶
func QueryWithValue(value sfvm.ValueOperator) QueryOption
type RecursiveConfig ¶
type RecursiveConfig struct {
// contains filtered or unexported fields
}
func CreateRecursiveConfigFromItems ¶
func CreateRecursiveConfigFromItems( contextResult *sf.SFFrameResult, config *sf.Config, configItems ...*sf.RecursiveConfigItem, ) *RecursiveConfig
func CreateRecursiveConfigFromNativeCallParams ¶
func CreateRecursiveConfigFromNativeCallParams( sfResult *sf.SFFrameResult, config *sf.Config, params *sf.NativeCallActualParams, ) (*RecursiveConfig, bool)
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 (*SarifContext) CreateSubSarifContext ¶
func (s *SarifContext) CreateSubSarifContext() *SarifContext
func (*SarifContext) GetArtifactIdFromEditor ¶
func (s *SarifContext) GetArtifactIdFromEditor(editor *memedit.MemEditor) int
type SaveValueOption ¶
type SaveValueOption func(c *saveValueCtx)
func OptionSaveValue_ProgramName ¶
func OptionSaveValue_ProgramName(name string) SaveValueOption
func OptionSaveValue_ResultAlert ¶
func OptionSaveValue_ResultAlert(alertMsg string) SaveValueOption
func OptionSaveValue_ResultID ¶
func OptionSaveValue_ResultID(resultID uint) SaveValueOption
func OptionSaveValue_ResultVariable ¶
func OptionSaveValue_ResultVariable(variable string) SaveValueOption
func OptionSaveValue_RuleName ¶
func OptionSaveValue_RuleName(i string) SaveValueOption
func OptionSaveValue_RuleTitle ¶
func OptionSaveValue_RuleTitle(name string) SaveValueOption
func OptionSaveValue_TaskID ¶
func OptionSaveValue_TaskID(taskID string) SaveValueOption
type SyntaxFlowResult ¶
type SyntaxFlowResult struct {
// contains filtered or unexported fields
}
func CreateResultFromQuery ¶
func CreateResultFromQuery(res *sfvm.SFFrameResult) *SyntaxFlowResult
func CreateResultWithProg ¶
func CreateResultWithProg(prog *Program, res *sfvm.SFFrameResult) *SyntaxFlowResult
func LoadResultByID ¶
func LoadResultByID(resultID uint) (*SyntaxFlowResult, error)
func QuerySyntaxflow ¶
func QuerySyntaxflow(opt ...QueryOption) (*SyntaxFlowResult, error)
func (*SyntaxFlowResult) Dump ¶
func (r *SyntaxFlowResult) Dump(showCode bool) string
func (*SyntaxFlowResult) DumpValuesJson ¶
func (r *SyntaxFlowResult) DumpValuesJson(name string) string
func (*SyntaxFlowResult) GetAlertInfo ¶
func (r *SyntaxFlowResult) GetAlertInfo(name string) (*schema.SyntaxFlowDescInfo, bool)
func (*SyntaxFlowResult) GetAlertMsg ¶
func (r *SyntaxFlowResult) GetAlertMsg(name string) (string, bool)
func (*SyntaxFlowResult) GetAlertValue ¶
func (r *SyntaxFlowResult) GetAlertValue(name string) Values
func (*SyntaxFlowResult) GetAlertValues ¶
func (r *SyntaxFlowResult) GetAlertValues() *omap.OrderedMap[string, Values]
func (*SyntaxFlowResult) GetAlertVariables ¶
func (r *SyntaxFlowResult) GetAlertVariables() []string
Alert value
func (*SyntaxFlowResult) GetAllValuesChain ¶
func (r *SyntaxFlowResult) GetAllValuesChain() Values
func (*SyntaxFlowResult) GetAllVariable ¶
func (r *SyntaxFlowResult) GetAllVariable() *orderedmap.OrderedMap
func (*SyntaxFlowResult) GetCheckMsg ¶
func (r *SyntaxFlowResult) GetCheckMsg() []string
func (*SyntaxFlowResult) GetErrors ¶
func (r *SyntaxFlowResult) GetErrors() []string
func (*SyntaxFlowResult) GetGRPCModelResult ¶
func (r *SyntaxFlowResult) GetGRPCModelResult() *ypb.SyntaxFlowResult
func (*SyntaxFlowResult) GetGRPCModelRisk ¶
func (r *SyntaxFlowResult) GetGRPCModelRisk() []*ypb.SSARisk
func (*SyntaxFlowResult) GetProgramName ¶
func (r *SyntaxFlowResult) GetProgramName() string
func (*SyntaxFlowResult) GetResultID ¶
func (r *SyntaxFlowResult) GetResultID() uint
func (*SyntaxFlowResult) GetRiskByValue ¶
func (r *SyntaxFlowResult) GetRiskByValue(variable string, i int) *schema.SSARisk
func (*SyntaxFlowResult) GetRiskHash ¶
func (r *SyntaxFlowResult) GetRiskHash(variable string, i int) string
func (*SyntaxFlowResult) GetSFResult ¶
func (r *SyntaxFlowResult) GetSFResult() *sfvm.SFFrameResult
func (*SyntaxFlowResult) GetUnNameValues ¶
func (r *SyntaxFlowResult) GetUnNameValues() Values
UnName value
func (*SyntaxFlowResult) GetValue ¶
func (r *SyntaxFlowResult) GetValue(name string, index int64) (*Value, error)
func (*SyntaxFlowResult) GetValues ¶
func (r *SyntaxFlowResult) GetValues(name string) Values
Normal value
func (*SyntaxFlowResult) GetVariableNum ¶
func (r *SyntaxFlowResult) GetVariableNum() int
func (*SyntaxFlowResult) Name ¶
func (r *SyntaxFlowResult) Name() string
func (*SyntaxFlowResult) Save ¶
func (r *SyntaxFlowResult) Save(kind schema.SyntaxflowResultKind, TaskIDs ...string) (uint, error)
func (*SyntaxFlowResult) SaveRisk ¶
func (r *SyntaxFlowResult) SaveRisk(variable string, result *ssadb.AuditResult)
func (*SyntaxFlowResult) Show ¶
func (r *SyntaxFlowResult) Show(opts ...sfvm.ShowOption)
func (*SyntaxFlowResult) String ¶
func (r *SyntaxFlowResult) String(opts ...sfvm.ShowOption) string
type Value ¶
type Value struct {
ParentProgram *Program
EffectOn Values // this value effect current value [effectOn -> self]
DependOn Values // this value depend on current value [self -> dependOn]
// for syntaxflow vm
Predecessors []*PredecessorValue
DescInfo map[string]string
// contains filtered or unexported fields
}
func FullUseDefChain ¶
func FullUseDefChain(value *Value, opts ...OperationOption) *Value
func (*Value) AnalyzeDepth ¶
func (*Value) AppendDependOn ¶
func (*Value) AppendEffectOn ¶
func (*Value) AppendPredecessor ¶
func (v *Value) AppendPredecessor(operator sfvm.ValueOperator, opts ...sfvm.AnalysisContextOption) error
func (*Value) ExactMatch ¶
func (*Value) FileFilter ¶
func (*Value) FlexibleDepends ¶
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 ¶
func (v *Value) GetAllCallActualParams() (sfvm.ValueOperator, error)
func (*Value) GetAllMember ¶
GetAllMember get all member of object
func (*Value) GetAuditNodeId ¶
func (*Value) GetBinaryOperator ¶
func (*Value) GetBottomUses ¶
func (v *Value) GetBottomUses(opt ...OperationOption) Values
func (*Value) GetCallActualParams ¶
func (v *Value) GetCallActualParams(i int) (sfvm.ValueOperator, error)
func (*Value) GetCallArgs ¶
func (*Value) GetCallReturns ¶
func (*Value) GetCalledBy ¶
GetCalledBy desc all of 'Users' is Call
func (*Value) GetCallee ¶
GetCallee desc any of 'Users' is Call return the first Call, if `risk.New()`, GetCallee will return `risk.New`.
func (*Value) GetContextValue ¶
GetContextValue can handle context
func (*Value) GetDataflowPath ¶
func (*Value) GetDependOn ¶
func (*Value) GetDependOnPath ¶
func (*Value) GetEffectOn ¶
func (*Value) GetEffectOnPath ¶
func (*Value) GetFreeValue ¶
func (*Value) GetFunction ¶
func (*Value) GetFunctionObjectType ¶
func (*Value) GetMembers ¶
GetAllMember get member keys and values
func (*Value) GetMembersByString ¶
func (v *Value) GetMembersByString(key string) (sfvm.ValueOperator, error)
func (*Value) GetOperand ¶
func (*Value) GetOperands ¶
func (*Value) GetParameter ¶
func (*Value) GetParameters ¶
func (*Value) GetPointer ¶
func (*Value) GetPredecessors ¶
func (v *Value) GetPredecessors() []*PredecessorValue
func (*Value) GetProgramName ¶
func (*Value) GetReachable ¶
func (*Value) GetSSAValue ¶
func (*Value) GetSyntaxFlowBottomUse ¶
func (v *Value) GetSyntaxFlowBottomUse(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, config ...*sfvm.RecursiveConfigItem) (sfvm.ValueOperator, error)
func (*Value) GetSyntaxFlowDef ¶
func (v *Value) GetSyntaxFlowDef() (sfvm.ValueOperator, error)
func (*Value) GetSyntaxFlowTopDef ¶
func (v *Value) GetSyntaxFlowTopDef(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, config ...*sfvm.RecursiveConfigItem) (sfvm.ValueOperator, error)
func (*Value) GetSyntaxFlowUse ¶
func (v *Value) GetSyntaxFlowUse() (sfvm.ValueOperator, error)
func (*Value) GetTopDefs ¶
func (i *Value) GetTopDefs(opt ...OperationOption) Values
GetTopDefs desc all of 'Defs' is not used by any other value
func (*Value) GetTypeKind ¶
func (*Value) GetUnaryOperator ¶
func (*Value) GetVerboseName ¶
func (*Value) HasOperands ¶
func (*Value) InMainFunction ¶
func (*Value) IsBasicBlock ¶
func (*Value) IsConstInst ¶
func (*Value) IsErrorHandler ¶
func (*Value) IsExternLib ¶
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 ¶
func (*Value) IsFromDataBase ¶
func (*Value) IsFunction ¶
func (*Value) IsModifySelf ¶
func (*Value) IsParameter ¶
func (*Value) IsParameterMember ¶
func (*Value) IsReachable ¶
if condition is true : 1 reach if condition is false : -1 unreachable if condition need calc: 0 unknown
func (*Value) IsSideEffect ¶
func (*Value) IsTypeCast ¶
func (*Value) IsTypeValue ¶
func (*Value) IsUndefined ¶
func (*Value) LoadFullUseDefChain ¶
func (*Value) Merge ¶
func (v *Value) Merge(sf ...sfvm.ValueOperator) (sfvm.ValueOperator, error)
func (*Value) NewValueFromAuditNode ¶
from audit node id
func (*Value) Recursive ¶
func (v *Value) Recursive(f func(operator sfvm.ValueOperator) error) error
func (*Value) RecursiveDepends ¶
RecursiveDepends is used to get all the dependencies of the value
func (*Value) RecursiveDependsAndEffects ¶
func (*Value) RecursiveEffects ¶
RecursiveEffects is used to get all the effects of the value
func (*Value) RegexpMatch ¶
func (*Value) Remove ¶
func (v *Value) Remove(sf ...sfvm.ValueOperator) (sfvm.ValueOperator, error)
func (*Value) ShortString ¶
func (*Value) ShowBacktrack ¶
func (v *Value) ShowBacktrack()
func (*Value) ShowUseDefChain ¶
func (v *Value) ShowUseDefChain()
func (*Value) ShowWithRange ¶
func (*Value) ShowWithSourceCode ¶
func (*Value) StringWithRange ¶
func (*Value) StringWithSourceCode ¶
type ValueGraph ¶
type ValueGraph struct {
*dot.Graph
// one ssa.value can be create many ssaapi.Value,
// so we use SSA-ID(int64) to graph node-id
Value2Node map[int64]int
// graph node id to value, this value just use bare ssa.value
Node2Value map[int]*Value
// contains filtered or unexported fields
}
func NewValueGraph ¶
func NewValueGraph(v ...*Value) *ValueGraph
func (*ValueGraph) CreateNode ¶
func (g *ValueGraph) CreateNode(value *Value) int
func (*ValueGraph) DeepFirstGraph ¶
func (g *ValueGraph) DeepFirstGraph(valueID int64) [][]string
func (*ValueGraph) Dot ¶
func (g *ValueGraph) Dot() string
type Values ¶
type Values []*Value
func FindFlexibleCommonDepends ¶
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 ¶
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 ¶
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 MergeValues ¶
func SyntaxFlowVariableToValues ¶
func SyntaxFlowVariableToValues(vs ...sfvm.ValueOperator) Values
func (Values) AppendDependOn ¶
func (Values) AppendEffectOn ¶
func (Values) AppendPredecessor ¶
func (value Values) AppendPredecessor(operator sfvm.ValueOperator, opts ...sfvm.AnalysisContextOption) error
func (Values) ExactMatch ¶
func (Values) ExtractTopDefsIntersection ¶
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 (vs Values) FileFilter(path string, match string, rule map[string]string, rule2 []string) (sfvm.ValueOperator, error)
func (value Values) FileFilter(string, string, map[string]string, []string) (sfvm.ValueOperator, error) {
func (Values) FlexibleDepends ¶
func (Values) FullUseDefChain ¶
func (Values) GetAllCallActualParams ¶
func (value Values) GetAllCallActualParams() (sfvm.ValueOperator, error)
func (Values) GetBinaryOperator ¶
func (Values) GetBottomUses ¶
func (v Values) GetBottomUses(opts ...OperationOption) Values
func (Values) GetBySyntaxFlowName ¶
func (Values) GetCallActualParams ¶
func (value Values) GetCallActualParams(index int) (sfvm.ValueOperator, error)
func (Values) GetDataflowPath ¶
func (Values) GetMembersByString ¶
func (value Values) GetMembersByString(key string) (sfvm.ValueOperator, error)
func (Values) GetOperands ¶
func (Values) GetSyntaxFlowBottomUse ¶
func (value Values) GetSyntaxFlowBottomUse(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, config ...*sfvm.RecursiveConfigItem) (sfvm.ValueOperator, error)
func (Values) GetSyntaxFlowDef ¶
func (value Values) GetSyntaxFlowDef() (sfvm.ValueOperator, error)
func (Values) GetSyntaxFlowTopDef ¶
func (value Values) GetSyntaxFlowTopDef(sfResult *sfvm.SFFrameResult, sfConfig *sfvm.Config, config ...*sfvm.RecursiveConfigItem) (sfvm.ValueOperator, error)
func (Values) GetSyntaxFlowUse ¶
func (value Values) GetSyntaxFlowUse() (sfvm.ValueOperator, error)
func (Values) GetTopDefs ¶
func (v Values) GetTopDefs(opts ...OperationOption) Values
func (Values) GetUnaryOperator ¶
func (Values) Merge ¶
func (vs Values) Merge(sf ...sfvm.ValueOperator) (sfvm.ValueOperator, error)
func (Values) Recursive ¶
func (value Values) Recursive(f func(operator sfvm.ValueOperator) error) error
func (Values) RegexpMatch ¶
func (Values) Remove ¶
func (value Values) Remove(values ...sfvm.ValueOperator) (sfvm.ValueOperator, error)
func (Values) ShowWithSource ¶
Source Files
¶
- analyze_context.go
- analyze_cross_process.go
- doc.go
- dominator_tree.go
- exclusive_config.go
- exclusive_z_bottom_use.go
- exclusive_z_misc.go
- exclusive_z_top_defs.go
- misc.go
- position.go
- program.go
- sf_config.go
- sf_dataflow.go
- sf_native_call.go
- sf_native_call_code.go
- sf_native_call_doc.go
- sf_native_call_eval.go
- sf_native_call_freeMarker.go
- sf_native_call_include.go
- sf_native_call_name.go
- sf_native_call_sanitize_names.go
- sf_native_call_scan.go
- sf_native_call_util.go
- sf_native_call_xml.go
- sf_prog.go
- sf_query.go
- sf_result.go
- sf_result_risk.go
- sf_result_save.go
- sf_result_value.go
- sf_result_verbose.go
- sf_sarif.go
- sf_utils.go
- sf_value.go
- sf_values.go
- ssa_compile.go
- ssa_compile_fs.go
- ssa_compile_info.go
- ssa_compile_init.go
- ssa_compile_project.go
- ssa_compile_utils.go
- ssa_exports.go
- ssa_load_program.go
- ssa_recompile.go
- type.go
- use_def_chain.go
- values.go
- values_contains.go
- values_db.go
- values_graph_backtrack.go
- values_graph_dot.go
- values_graph_path.go