Version: v1.1.3 Latest Latest

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

Go to latest
Published: Jun 26, 2021 License: MIT Imports: 23 Imported by: 0




This section is empty.


View Source
var (
	ErrQueryArgUnsupportedType = errors.New("unexpected query arg type")
	ErrQueryArgUnsafe          = errors.New("potentially unsafe query string")
	ErrQueryArgTODO            = errors.New("TODO: support this type")


func AddQueryParam

func AddQueryParam(target *[]QueryParam, param QueryParam)

insert query param based on parameter number and avoid deduplications

func AddQueryParams

func AddQueryParams(target *[]QueryParam, params []QueryParam)

func DebugQuery

func DebugQuery(q string)


type ColumnUsed

type ColumnUsed struct {
	Column   string
	Table    string
	Location int

type MatchedSqlFunc

type MatchedSqlFunc struct {
	SSA         *ssa.Function
	QueryArgPos int

type ParseResult

type ParseResult struct {
	Columns []ColumnUsed
	Params  []QueryParam

type QueryParam

type QueryParam struct {
	Number int

func ValidateSqlQuery

func ValidateSqlQuery(ctx VetContext, queryStr string) ([]QueryParam, error)

type QuerySite

type QuerySite struct {
	Called            string
	Position          token.Position
	Query             string
	ParameterArgCount int
	Err               error

func CheckDir

func CheckDir(ctx VetContext, dir string, extraMatchers []SqlFuncMatcher) ([]*QuerySite, error)

type SqlFuncMatchRule

type SqlFuncMatchRule struct {
	FuncName string `toml:"func_name"`
	// zero indexed
	QueryArgPos  int    `toml:"query_arg_pos"`
	QueryArgName string `toml:"query_arg_name"`

type SqlFuncMatcher

type SqlFuncMatcher struct {
	PkgPath string             `toml:"pkg_path"`
	Rules   []SqlFuncMatchRule `toml:"rules"`
	// contains filtered or unexported fields

func (*SqlFuncMatcher) IterPackageExportedFuncs

func (s *SqlFuncMatcher) IterPackageExportedFuncs(cb func(*types.Func))

func (*SqlFuncMatcher) MatchSqlFuncs

func (s *SqlFuncMatcher) MatchSqlFuncs(prog *ssa.Program) []MatchedSqlFunc

func (*SqlFuncMatcher) PackageImported

func (s *SqlFuncMatcher) PackageImported() bool

func (*SqlFuncMatcher) SetGoPackage

func (s *SqlFuncMatcher) SetGoPackage(p *packages.Package)

type SqlVetAnnotation

type SqlVetAnnotation struct {
	Ignore bool

func ParseComment

func ParseComment(comment string) (SqlVetAnnotation, error)

type TableUsed

type TableUsed struct {
	Name  string
	Alias string

type VetContext

type VetContext struct {
	Schema *schema.Db

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to