setup

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

* Copyright 2022 ByteDance Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright 2022 ByteDance Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright 2022 ByteDance Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConstructors

func GetConstructors(pkg *packages.Package) (constructorMap map[types.Type][]*ssa.Function)

Get all constructor for each type by SSA We consider the constructor to satisfy such characteristics: 1. Return at least one value 2. Not a method 3. The return value contains a structure we need

func GetConstructorsByFunc

func GetConstructorsByFunc(function Functions) (constructorMap map[string][]*ssa.Function)

func GetConstructorsByType

func GetConstructorsByType(pkg *packages.Package, typeList []types.Type) (constructorMap map[string][]*ssa.Function)

Get all constructor for certain type by SSA We consider the constructor to satisfy such characteristics: 1. Return at least one value 2. Not a method 3. The return value contains a structure we need TODO: support pointer

func GetLiteralFromFile

func GetLiteralFromFile(SRCFile string, FunctionName string) (map[reflect.Type][]reflect.Value, error)

func GetTypeByAnalysisBlock

func GetTypeByAnalysisBlock(instr ssa.Instruction, reference map[interface{}]struct{})

Types

type CallGraph

type CallGraph struct {
	RootFunc          *FuncDesc
	CallerRelationMap map[string]*CallerRelation
}

type CalleeRelation

type CalleeRelation struct {
	Callee []FuncDesc
	CanFix bool // 该调用关系能反向找到gin.Context即可以自动修复
}

描述关键函数的一条反向调用关系

type CallerRelation

type CallerRelation struct {
	Caller  FuncDesc
	Callees []FuncDesc
	// contains filtered or unexported fields
}

描述一个函数调用N个函数的一对多关系

type FileVisitor

type FileVisitor struct {
	LiteralMap map[reflect.Type][]reflect.Value
	// contains filtered or unexported fields
}

func NewFileVisitor

func NewFileVisitor(functionName string) (v *FileVisitor)

func (*FileVisitor) Visit

func (v *FileVisitor) Visit(node ast.Node) ast.Visitor

This is used to parse the content in the target function.

type FuncDesc

type FuncDesc struct {
	Path    string
	Package string
	Name    string
}

函数描述

type Functions

type Functions struct {
	TestFunction      *parsermodel.ProjectFunction
	DateSteam         map[interface{}]struct{}
	TestFuncCallGraph *callgraph.Graph
	SRCFile           string
	FunctionName      string
}

Todo: init 在一个包或者一个项目里可能有多个,这里我们先不去管它,在之后要加上。

func GetFunctions

func GetFunctions(option atgconstant.Options) (Functions, error)

GetFunctions gets the functions from tested function.

type HeaderVisitor

type HeaderVisitor struct {
	LiteralMap map[reflect.Type][]reflect.Value
}

func NewHeaderVisitor

func NewHeaderVisitor() (v *HeaderVisitor)

func (*HeaderVisitor) Visit

func (v *HeaderVisitor) Visit(node ast.Node) ast.Visitor

This is used to parse the struct, interface, constant in the head of the file.

type LiteralVisitor

type LiteralVisitor struct {
	LiteralMap map[reflect.Type][]reflect.Value
}

func NewLiteralVisitor

func NewLiteralVisitor() (v *LiteralVisitor)

func (*LiteralVisitor) Visit

func (lv *LiteralVisitor) Visit(node ast.Node) ast.Visitor

literalNewName 记录复杂数据

Directories

Path Synopsis
This file may have been modified by Bytedance Ltd.
This file may have been modified by Bytedance Ltd.
* Copyright 2022 ByteDance Inc.
* Copyright 2022 ByteDance Inc.

Jump to

Keyboard shortcuts

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