checker

package
v0.0.0-...-c1d2af8 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAllOnce

func CheckAllOnce(logger zap.SugaredLogger, conf CheckerConfig) error

** * Do entire test process flow only once for all challenges. * Process flow means enumerating challs, executing tests, and write results on DB. **

func Connect

func Connect(dbuser string, dbpass string, dbhost string, dbname string) (*sqlx.DB, error)

** * Connect to mysql server and returns instance. **

func RecordResult

func RecordResult(db *sqlx.DB, chall Challenge) error

** * Write and commit test result. **

Types

type Challenge

type Challenge struct {
	Name             string  `json:"name"`
	Id               int     `json:"id"`
	Default_success  bool    `json:"default"`
	Timeout          float64 `json:"timeout"`
	Exploit_dir_name string
	Result           TestResult
}

** * Information of challenge. * Used to hold information to execute test. * @Name: challenge name * @Id: challenge ID * @Default_success: if test is not executed due to insufficient info, result becomes `Success` if this is true. * @Result: test result **

type CheckerConfig

type CheckerConfig struct {
	Single      bool    `json:"single"`
	Parallel    bool    `json:"parallel"`
	ParallelNum uint    `json:"pnum"`
	Timeout     float64 `json:"timeout"`
	Infofile    string  `json:"infofile"`
	Nodb        bool    `json:"nodb"`
	ChallsDir   string  `json:"challs"`
	Interval    uint    `json:"interval"`
	Retries     uint    `json:"retries"`
}

func ReadConf

func ReadConf(filename string) (CheckerConfig, error)

func (*CheckerConfig) ResolveConflict

func (ch *CheckerConfig) ResolveConflict()

func (*CheckerConfig) Validate

func (ch *CheckerConfig) Validate()

type DbResult

type DbResult struct {
	ChallId   int        `db:"challid"`
	Name      string     `db:"name"`
	Result    TestResult `db:"result"`
	Timestamp time.Time  `db:"timestamp"`
}

** * Data schema of test result table. * Note that this is different from `Challenge` structure, which also contains test result. **

func FetchResult

func FetchResult(db *sqlx.DB, challid int, limit int) ([]DbResult, error)

** * Query test result from DB by challenge ID. **

type Executer

type Executer struct {
	// contains filtered or unexported fields
}

** * Executer of test. * @path: path to challenge directory * @retry_max: maximum # of execution retry * @try_current: # of executed try **

func (*Executer) Check

func (e *Executer) Check(res_chan chan<- Challenge, infofile string)

** * execute tests w/o timeout. * it retries execution for specified times if a test fails. **

func (*Executer) CheckWithTimeout

func (e *Executer) CheckWithTimeout(res_chan chan<- Challenge, infofile string, timeout float64)

** * execute tests with timeout. * it retries execution for specified times if a test fails. **

type TestResult

type TestResult int

** * Test result. **

const (
	// Test is successful
	TestSuccess TestResult = iota
	// Test is not executed due to insufficient info, but defaults to Success
	TestSuccessWithoutExecution
	// Test didn't end before timeout
	TestTimeout
	// Test is not executed due to insufficient info, and falls into Failure
	TestNotExecuted
	// Test is failure
	TestFailure
)

func (TestResult) String

func (tr TestResult) String() string

func (TestResult) ToColor

func (tr TestResult) ToColor() string

func (TestResult) ToMessage

func (tr TestResult) ToMessage() string

Jump to

Keyboard shortcuts

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