strategy

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: 8 Imported by: 0

Documentation

Overview

TODO: Docs

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FuzzingStrategy

type FuzzingStrategy int

A FuzzingStrategy dictates how queries are generated and how bugs are detected.

const (
	// None represents no strategy, it just generates clauses randomly and sees if they trigger exception or crash bugs.
	None FuzzingStrategy = iota
	// EquivalenceTransformation is a strategy which first generates clauses,
	// and then transforms them to an equivalent clause and checks if they cause a different result.
	//
	// For example:
	//	null = null + x or
	//	MATCH (x)-[*5]-(y) = (x)-[*3]-()-[*2]-(y)
	EquivalenceTransformation
	// PredicatePartitioning uses methods introduced by Manuel Rigger:
	//
	//	MATCH (..) RETURN ..
	//
	// must return the same rows as
	//
	//	MATCH (..) WHERE x RETURN ..
	//	 UNION ALL
	//	MATCH (..) WHERE NOT x RETURN ..
	//	 UNION ALL
	//	MATCH (..) WHERE x IS NULL RETURN ..
	PredicatePartitioning
)

func (FuzzingStrategy) ToStrategy

func (s FuzzingStrategy) ToStrategy() Strategy

ToStrategy returns the concrete Strategy associated with a FuzzingStrategy.

func (FuzzingStrategy) ToString

func (s FuzzingStrategy) ToString() string

ToString converts a fuzzing strategy to its equivalent, human-readable string representation

type PrepareQueryForBugreportHandler

type PrepareQueryForBugreportHandler func([]string) []string

type ResetHandler

type ResetHandler func()

type Strategy

type Strategy interface {
	// Reset the strategy to prepare for another fuzzing run
	Reset()
	GetRootClause(translator.Implementation, *schema.Schema, *seed.Seed) translator.Clause
	GetQueryResultType(dbms.DB, dbms.DBOptions, dbms.QueryResult, *dbms.ErrorMessageRegex) dbms.QueryResultType
	DiscardQuery(dbms.QueryResultType, dbms.DB, dbms.DBOptions, dbms.QueryResult, *seed.Seed) bool
	// Reduces the queries from a bug report.
	//
	// Gets passed a context which will be preserved between calls to the reduce function.
	// The second argument is the slice of the currently most reduced root clauses composing the queries.
	//
	// Returns the new context, the newly most reduced queries and true if the reduction is done or false if it can be further reduced.
	//
	// After every reduce call, the passed clause capturer will be regenerated and run against the target.
	// If the query's result now differs, the next ReduceStep call will have the previous root clauses as the second argument.
	// If the query's result still matches, the next ReduceStep call will have the new root clauses as the second argument.
	ReduceStep(context.Context, []*helperclauses.ClauseCapturer) (context.Context, []*helperclauses.ClauseCapturer, bool)
	// Gets passed the results of the original and reduced queries.
	// Returns true if the results still point to the same bug being present, else false.
	ValidateReductionResult(dbms.DB, []dbms.QueryResult, []dbms.QueryResult) bool
	// Gets called when a bug is found with the query generated.
	//
	// Useful for when some statements are not relevant for the bug report.
	//
	// For example during equivalence transformation, if the bug was found before
	// fully transforming all statements, the last few, untransformed, statements can just be omitted.
	PrepareQueryForBugreport([]string) []string
	// Gets passed all query results from a rerun and returns the result type these indicate.
	//
	// This method only gets invoked during a rerun of a bug report and only if no previous queries
	// have returned a non-valid query result.
	ValidateRerunResults([]dbms.QueryResult, dbms.DB) dbms.QueryResultType
}

The Strategy interface represents a fuzzing strategy.

A strategy dictates how queries are generated, which results indicate bugs and how queries are reduced. Available strategies can be viewed at FuzzingStrategy.

func WrapStrategy

func WrapStrategy(toWrap Strategy, wrapper StrategyMiddleware) Strategy

WrapStrategy returns the passed Strategy wrapped in the middleware defined in StrategyMiddleware

type StrategyMiddleware

type StrategyMiddleware struct {
	DiscardQueryMiddleware             func(DiscardQueryHandler) DiscardQueryHandler
	GetQueryResultTypeMiddleware       func(GetQueryResultTypeHandler) GetQueryResultTypeHandler
	GetRootClauseMiddleware            func(GetRootClauseHandler) GetRootClauseHandler
	PrepareQueryForBugreportMiddleware func(PrepareQueryForBugreportHandler) PrepareQueryForBugreportHandler
	ReduceStepMiddleware               func(ReduceStepHandler) ReduceStepHandler
	ResetMiddleware                    func(ResetHandler) ResetHandler
	ValidateReductionResultMiddleware  func(ValidateReductionResultHandler) ValidateReductionResultHandler
	ValidateRerunResultsMiddleware     func(ValidateRerunResultsHandler) ValidateRerunResultsHandler
	// contains filtered or unexported fields
}

StrategyMiddleware implements Strategy

func (*StrategyMiddleware) DiscardQuery

func (s *StrategyMiddleware) DiscardQuery(a0 dbms.QueryResultType, a1 dbms.DB, a2 dbms.DBOptions, a3 dbms.QueryResult, a4 *seed.Seed) bool

func (*StrategyMiddleware) GetQueryResultType

func (*StrategyMiddleware) GetRootClause

func (*StrategyMiddleware) PrepareQueryForBugreport

func (s *StrategyMiddleware) PrepareQueryForBugreport(a0 []string) []string

func (*StrategyMiddleware) ReduceStep

func (*StrategyMiddleware) Reset

func (s *StrategyMiddleware) Reset()

func (*StrategyMiddleware) ValidateReductionResult

func (s *StrategyMiddleware) ValidateReductionResult(a0 dbms.DB, a1 []dbms.QueryResult, a2 []dbms.QueryResult) bool

func (*StrategyMiddleware) ValidateRerunResults

func (s *StrategyMiddleware) ValidateRerunResults(a0 []dbms.QueryResult, a1 dbms.DB) dbms.QueryResultType

type ValidateReductionResultHandler

type ValidateReductionResultHandler func(dbms.DB, []dbms.QueryResult, []dbms.QueryResult) bool

type ValidateRerunResultsHandler

type ValidateRerunResultsHandler func([]dbms.QueryResult, dbms.DB) dbms.QueryResultType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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