dbms

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Code generated by "middlewarer -type=DB"; DO NOT EDIT.

Package dbms provides types and constants for database interaction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	// Initialises the DB connection
	Init(DBOptions) error
	// Reset the DB to its original state
	Reset(DBOptions) error
	// Fetch the DB's schema
	GetSchema(DBOptions) (*schema.Schema, error)
	// Runs a given query against the database
	RunQuery(DBOptions, string) QueryResult
	// Verifies that the database can still be reached.
	//
	// Returns true if connection is successful and an optional error describing the connection error.
	//
	// If, after a query was run, the database is no longer reachable,
	// a bug report is created with the assumption that the database crashed
	VerifyConnectivity(DBOptions) (bool, error)

	// Returns the type of the query's result.
	GetQueryResultType(QueryResult, *ErrorMessageRegex) QueryResultType
	// Returns true if the query should not be generated further.
	// Gets passed the result of executing the previous statement and the seed being used for generation
	DiscardQuery(QueryResult, *seed.Seed) bool
	// Returns true if the two passed query results are equal, else false.
	// Used by strategies fuzzing for logic bugs.
	IsEqualResult(QueryResult, QueryResult) bool
}

A DB is a database driver implementation.

Any struct implementing this interface can be used as a fuzzing target.

func WrapDB

func WrapDB(toWrap DB, wrapper DBMiddleware) DB

WrapDB returns the passed DB wrapped in the middleware defined in DBMiddleware

type DBMiddleware

type DBMiddleware struct {
	DiscardQueryMiddleware       func(DiscardQueryHandler) DiscardQueryHandler
	GetQueryResultTypeMiddleware func(GetQueryResultTypeHandler) GetQueryResultTypeHandler
	GetSchemaMiddleware          func(GetSchemaHandler) GetSchemaHandler
	InitMiddleware               func(InitHandler) InitHandler
	IsEqualResultMiddleware      func(IsEqualResultHandler) IsEqualResultHandler
	ResetMiddleware              func(ResetHandler) ResetHandler
	RunQueryMiddleware           func(RunQueryHandler) RunQueryHandler
	VerifyConnectivityMiddleware func(VerifyConnectivityHandler) VerifyConnectivityHandler
	// contains filtered or unexported fields
}

DBMiddleware implements DB

func (*DBMiddleware) DiscardQuery

func (d *DBMiddleware) DiscardQuery(a0 QueryResult, a1 *seed.Seed) bool

func (*DBMiddleware) GetQueryResultType

func (d *DBMiddleware) GetQueryResultType(a0 QueryResult, a1 *ErrorMessageRegex) QueryResultType

func (*DBMiddleware) GetSchema

func (d *DBMiddleware) GetSchema(a0 DBOptions) (*schema.Schema, error)

func (*DBMiddleware) Init

func (d *DBMiddleware) Init(a0 DBOptions) error

func (*DBMiddleware) IsEqualResult

func (d *DBMiddleware) IsEqualResult(a0 QueryResult, a1 QueryResult) bool

func (*DBMiddleware) Reset

func (d *DBMiddleware) Reset(a0 DBOptions) error

func (*DBMiddleware) RunQuery

func (d *DBMiddleware) RunQuery(a0 DBOptions, a1 string) QueryResult

func (*DBMiddleware) VerifyConnectivity

func (d *DBMiddleware) VerifyConnectivity(a0 DBOptions) (bool, error)

type DBOptions

type DBOptions struct {
	// The host where the DB is accessible at.
	Host string
	// The port where the DB is accessible at.
	//
	// If the port is nil, the driver should use the default port for the DBMS.
	Port *int
	// The timeout for database requests.
	// This timeout should be used for every request that is sent to the DB.
	Timeout time.Duration
	// Whether the driver should run in backwards compatible mode.
	// This is used during bisection, where older versions may be tested and some features either disabled or adjusted
	BackwardsCompatibleMode bool
}

DBOptions specify driver behavior and connection information.

type DiscardQueryHandler

type DiscardQueryHandler func(QueryResult, *seed.Seed) bool

type ErrorMessageRegex

type ErrorMessageRegex struct {
	// Ignored matches error messages that should be ignored
	Ignored *regexp.Regexp
	// Reported matches error messages that indicate an already reported bug
	Reported *regexp.Regexp
}

ErrorMessageRegex holds regular expressions, matching different types of error messages

type GetQueryResultTypeHandler

type GetQueryResultTypeHandler func(QueryResult, *ErrorMessageRegex) QueryResultType

type GetSchemaHandler

type GetSchemaHandler func(DBOptions) (*schema.Schema, error)

type InitHandler

type InitHandler func(DBOptions) error

type IsEqualResultHandler

type IsEqualResultHandler func(QueryResult, QueryResult) bool

type QueryResult

type QueryResult struct {
	// Returned rows
	Rows []any
	// The error as returned by the driver
	ProducedError error
	// The fingerprint of the graph, used for comparing if results changed
	Fingerprint string
	// The DB schema
	Schema any
}

QueryResult embodies the result returned from a DBMS after running a query

type QueryResultType

type QueryResultType int

A QueryResultType specifies what a query's result indicates to dictate how to classify the query

const (
	// Valid indicates query of no importance was run
	Valid QueryResultType = iota
	// Invalid indicates a semantically or syntactically invalid query was run
	Invalid
	// Bug indicates that the query triggered a bug in the DBMS
	Bug
	// Crash indicates that the query caused the DBMS to crash
	Crash
	// ReportedBug indicates that the query triggered a bug in the DBMS which has already been reported
	ReportedBug
	// Timeout indicates that the query timed out
	Timeout
)

func (QueryResultType) ToString

func (q QueryResultType) ToString() string

ToString converts a query result type to its equivalent, human-readable string representation

type ResetHandler

type ResetHandler func(DBOptions) error

type RunQueryHandler

type RunQueryHandler func(DBOptions, string) QueryResult

type VerifyConnectivityHandler

type VerifyConnectivityHandler func(DBOptions) (bool, error)

Jump to

Keyboard shortcuts

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