Documentation
¶
Overview ¶
Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
Package sqlbuilders provides SQL builder library-specific checkers for SELECT * detection.
Index ¶
- func IsTypeFromPackage(info *types.Info, expr ast.Expr, pkgPathPrefix string) bool
- type BunChecker
- type EntChecker
- type GORMChecker
- type GoquChecker
- type JetChecker
- type PGXChecker
- type ReformChecker
- func (c *ReformChecker) Check(pass *analysis.Pass, file *ast.File)
- func (c *ReformChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation
- func (c *ReformChecker) CheckFile(file *ast.File, fset *token.FileSet) []ReformViolation
- func (c *ReformChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation
- func (c *ReformChecker) IsApplicable(info *types.Info, call *ast.CallExpr) bool
- func (c *ReformChecker) Name() string
- type ReformViolation
- type Registry
- type RelChecker
- func (c *RelChecker) Check(pass *analysis.Pass, file *ast.File)
- func (c *RelChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation
- func (c *RelChecker) CheckFile(file *ast.File, fset *token.FileSet) []RelViolation
- func (c *RelChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation
- func (c *RelChecker) IsApplicable(info *types.Info, call *ast.CallExpr) bool
- func (c *RelChecker) Name() string
- type RelViolation
- type SQLBoilerChecker
- type SQLBuilderChecker
- type SQLCChecker
- type SQLxChecker
- type SelectStarViolation
- type SquirrelChecker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTypeFromPackage ¶ added in v1.5.2
IsTypeFromPackage checks if the type of an expression belongs to a package with the given path prefix. This is used to verify that a method call is actually from the expected SQL builder library.
Types ¶
type BunChecker ¶
type BunChecker struct{}
BunChecker checks github.com/uptrace/bun for SELECT * patterns.
func (*BunChecker) CheckChainedCalls ¶
func (c *BunChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation
CheckChainedCalls checks method chains for SELECT * patterns.
func (*BunChecker) CheckSelectStar ¶
func (c *BunChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation
CheckSelectStar checks for SELECT * in bun calls.
func (*BunChecker) IsApplicable ¶
IsApplicable checks if the call is from bun using type information.
type EntChecker ¶
type EntChecker struct{}
EntChecker checks entgo.io/ent for SELECT * patterns.
func (*EntChecker) CheckChainedCalls ¶
func (c *EntChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation
CheckChainedCalls checks method chains for SELECT * patterns.
func (*EntChecker) CheckSelectStar ¶
func (c *EntChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation
CheckSelectStar checks for SELECT * in ent calls.
func (*EntChecker) IsApplicable ¶
IsApplicable checks if the call is from ent using type information.
type GORMChecker ¶
type GORMChecker struct{}
GORMChecker checks gorm.io/gorm for SELECT * patterns.
func (*GORMChecker) CheckChainedCalls ¶
func (c *GORMChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation
func (*GORMChecker) CheckSelectStar ¶
func (c *GORMChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation
CheckSelectStar checks for SELECT * in GORM calls.
func (*GORMChecker) IsApplicable ¶
IsApplicable checks if the call is from GORM using type information.
func (*GORMChecker) Name ¶
func (c *GORMChecker) Name() string
Name returns the name of this checker.
type GoquChecker ¶ added in v1.5.0
type GoquChecker struct{}
GoquChecker checks for SELECT * in goqu queries.
func NewGoquChecker ¶ added in v1.5.0
func NewGoquChecker() *GoquChecker
NewGoquChecker creates a new goqu checker.
func (*GoquChecker) CheckChainedCalls ¶ added in v1.5.0
func (c *GoquChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation
CheckChainedCalls checks chained method calls.
func (*GoquChecker) CheckSelectStar ¶ added in v1.5.0
func (c *GoquChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation
CheckSelectStar checks for SELECT * patterns in goqu.
func (*GoquChecker) IsApplicable ¶ added in v1.5.0
IsApplicable checks if the call is from goqu using type information.
func (*GoquChecker) Name ¶ added in v1.5.0
func (c *GoquChecker) Name() string
Name returns the checker name.
type JetChecker ¶
type JetChecker struct{}
JetChecker checks github.com/go-jet/jet for SELECT * patterns.
func (*JetChecker) CheckChainedCalls ¶
func (c *JetChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation
CheckChainedCalls checks method chains for SELECT * patterns.
func (*JetChecker) CheckSelectStar ¶
func (c *JetChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation
CheckSelectStar checks for SELECT * in jet calls.
func (*JetChecker) IsApplicable ¶
IsApplicable checks if the call is from jet using type information.
type PGXChecker ¶
type PGXChecker struct{}
PGXChecker checks github.com/jackc/pgx for SELECT * patterns.
func (*PGXChecker) CheckChainedCalls ¶
func (c *PGXChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation
CheckChainedCalls checks method chains for SELECT * patterns.
func (*PGXChecker) CheckSelectStar ¶
func (c *PGXChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation
CheckSelectStar checks for SELECT * in pgx calls.
func (*PGXChecker) IsApplicable ¶
IsApplicable checks if the call is from pgx using type information.
type ReformChecker ¶ added in v1.5.0
type ReformChecker struct{}
ReformChecker detects SELECT * patterns in gopkg.in/reform.v1 queries. https://github.com/go-reform/reform
func NewReformChecker ¶ added in v1.5.0
func NewReformChecker() *ReformChecker
NewReformChecker creates a new reform checker.
func (*ReformChecker) Check ¶ added in v1.5.0
func (c *ReformChecker) Check(pass *analysis.Pass, file *ast.File)
Check analyzes a file for reform SELECT * patterns.
func (*ReformChecker) CheckChainedCalls ¶ added in v1.5.1
func (c *ReformChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation
CheckChainedCalls analyzes method chains for SELECT * patterns.
func (*ReformChecker) CheckFile ¶ added in v1.5.0
func (c *ReformChecker) CheckFile(file *ast.File, fset *token.FileSet) []ReformViolation
CheckFile checks a file and returns violations.
func (*ReformChecker) CheckSelectStar ¶ added in v1.5.1
func (c *ReformChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation
CheckSelectStar checks a single call expression for SELECT * usage.
func (*ReformChecker) IsApplicable ¶ added in v1.5.1
IsApplicable checks if the call is from reform using type information.
func (*ReformChecker) Name ¶ added in v1.5.1
func (c *ReformChecker) Name() string
Name returns the name of the SQL builder.
type ReformViolation ¶ added in v1.5.0
ReformViolation represents a reform SELECT * violation.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all registered SQL builder checkers and provides a unified interface.
func NewRegistry ¶
func NewRegistry(cfg *config.SQLBuildersConfig) *Registry
NewRegistry creates a new Registry with checkers based on the configuration.
func (*Registry) Check ¶
Check analyzes a call expression against all registered checkers. Returns all violations found across all applicable checkers. The info parameter provides type information for accurate type checking.
func (*Registry) HasCheckers ¶
HasCheckers returns true if at least one checker is registered.
type RelChecker ¶ added in v1.5.0
type RelChecker struct{}
RelChecker detects SELECT * patterns in go-rel/rel queries. https://github.com/go-rel/rel
func NewRelChecker ¶ added in v1.5.0
func NewRelChecker() *RelChecker
NewRelChecker creates a new rel checker.
func (*RelChecker) Check ¶ added in v1.5.0
func (c *RelChecker) Check(pass *analysis.Pass, file *ast.File)
Check analyzes a file for rel SELECT * patterns.
func (*RelChecker) CheckChainedCalls ¶ added in v1.5.1
func (c *RelChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation
CheckChainedCalls analyzes method chains for SELECT * patterns.
func (*RelChecker) CheckFile ¶ added in v1.5.0
func (c *RelChecker) CheckFile(file *ast.File, fset *token.FileSet) []RelViolation
CheckFile checks a file and returns violations.
func (*RelChecker) CheckSelectStar ¶ added in v1.5.1
func (c *RelChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation
CheckSelectStar checks a single call expression for SELECT * usage.
func (*RelChecker) IsApplicable ¶ added in v1.5.1
IsApplicable checks if the call is from rel using type information.
func (*RelChecker) Name ¶ added in v1.5.1
func (c *RelChecker) Name() string
Name returns the name of the SQL builder.
type RelViolation ¶ added in v1.5.0
RelViolation represents a rel SELECT * violation.
type SQLBoilerChecker ¶
type SQLBoilerChecker struct{}
SQLBoilerChecker checks github.com/volatiletech/sqlboiler for SELECT * patterns.
func NewSQLBoilerChecker ¶
func NewSQLBoilerChecker() *SQLBoilerChecker
NewSQLBoilerChecker creates a new SQLBoilerChecker.
func (*SQLBoilerChecker) CheckChainedCalls ¶
func (c *SQLBoilerChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation
CheckChainedCalls checks method chains for SELECT * patterns.
func (*SQLBoilerChecker) CheckSelectStar ¶
func (c *SQLBoilerChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation
CheckSelectStar checks for SELECT * in sqlboiler calls.
func (*SQLBoilerChecker) IsApplicable ¶
IsApplicable checks if the call is from sqlboiler using type information.
func (*SQLBoilerChecker) Name ¶
func (c *SQLBoilerChecker) Name() string
Name returns the name of this checker.
type SQLBuilderChecker ¶
type SQLBuilderChecker interface {
// Name returns the name of the SQL builder library
Name() string
// IsApplicable checks if the call expression is from this SQL builder.
// It uses type information to verify the receiver type belongs to the correct package.
IsApplicable(info *types.Info, call *ast.CallExpr) bool
// CheckSelectStar checks a single call expression for SELECT * usage
CheckSelectStar(call *ast.CallExpr) *SelectStarViolation
// CheckChainedCalls analyzes method chains for SELECT * patterns
CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation
}
SQLBuilderChecker is the interface for SQL builder library-specific checkers. Each SQL builder library (GORM, sqlx, etc.) implements this interface.
type SQLCChecker ¶ added in v1.5.0
type SQLCChecker struct{}
SQLCChecker checks for SELECT * in sqlc generated code.
func NewSQLCChecker ¶ added in v1.5.0
func NewSQLCChecker() *SQLCChecker
NewSQLCChecker creates a new sqlc checker.
func (*SQLCChecker) CheckChainedCalls ¶ added in v1.5.0
func (c *SQLCChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation
CheckChainedCalls checks chained method calls.
func (*SQLCChecker) CheckSelectStar ¶ added in v1.5.0
func (c *SQLCChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation
CheckSelectStar checks for SELECT * in the call.
func (*SQLCChecker) IsApplicable ¶ added in v1.5.0
IsApplicable checks if the call is from sqlc generated code using type information.
func (*SQLCChecker) Name ¶ added in v1.5.0
func (c *SQLCChecker) Name() string
Name returns the checker name.
type SQLxChecker ¶
type SQLxChecker struct{}
SQLxChecker checks github.com/jmoiron/sqlx for SELECT * patterns.
func (*SQLxChecker) CheckChainedCalls ¶
func (c *SQLxChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation
CheckChainedCalls checks method chains for SELECT * patterns.
func (*SQLxChecker) CheckSelectStar ¶
func (c *SQLxChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation
CheckSelectStar checks for SELECT * in sqlx calls.
func (*SQLxChecker) IsApplicable ¶
IsApplicable checks if the call is from sqlx using type information.
func (*SQLxChecker) Name ¶
func (c *SQLxChecker) Name() string
Name returns the name of this checker.
type SelectStarViolation ¶
type SelectStarViolation struct {
// Pos is the position in source code where the violation was detected
Pos token.Pos
// End is the end position of the violation
End token.Pos
// Message is the human-readable description of the violation
Message string
// Builder is the name of the SQL builder library
Builder string
// Context provides additional context about the violation type
Context string
}
SelectStarViolation represents a detected SELECT * usage in SQL builder code.
type SquirrelChecker ¶
type SquirrelChecker struct{}
SquirrelChecker checks github.com/Masterminds/squirrel for SELECT * patterns.
func NewSquirrelChecker ¶
func NewSquirrelChecker() *SquirrelChecker
NewSquirrelChecker creates a new SquirrelChecker.
func (*SquirrelChecker) CheckChainedCalls ¶
func (c *SquirrelChecker) CheckChainedCalls(call *ast.CallExpr) []*SelectStarViolation
func (*SquirrelChecker) CheckSelectStar ¶
func (c *SquirrelChecker) CheckSelectStar(call *ast.CallExpr) *SelectStarViolation
CheckSelectStar checks for SELECT * in Squirrel calls.
func (*SquirrelChecker) IsApplicable ¶
IsApplicable checks if the call is from Squirrel using type information.
func (*SquirrelChecker) Name ¶
func (c *SquirrelChecker) Name() string
Name returns the name of this checker.