steward

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAdvisory

func AddAdvisory(db *sql.DB, teamID int, text string) (id int, err error)

AddAdvisory add advisory for team to database

func AddFlag

func AddFlag(db *sql.DB, flg Flag) error

AddFlag add flag to database

func AddRoundResult

func AddRoundResult(db *sql.DB, res RoundResult) (id int, err error)

AddRoundResult add round result to database

func AddService

func AddService(db *sql.DB, svc Service) error

AddService add service to database

func AddTeam

func AddTeam(db *sql.DB, team Team) (id int, err error)

AddTeam add team to database

func AlreadyCaptured

func AlreadyCaptured(db *sql.DB, flagID int) (captured bool, err error)

AlreadyCaptured returns false if flag already captured

func CaptureFlag

func CaptureFlag(db *sql.DB, flagID, teamID int) (err error)

CaptureFlag add correct flag to db

func CleanDatabase

func CleanDatabase(db *sql.DB) (err error)

CleanDatabase remove all data from database and restart sequences

func FlagExist

func FlagExist(db *sql.DB, flag string) (exist bool, err error)

FlagExist check for flag exist in database

func GetAdvisoryScore

func GetAdvisoryScore(db *sql.DB, teamID int) (score int, err error)

GetAdvisoryScore get advisory score for team

func GetCred

func GetCred(db *sql.DB, round, team, service int) (flag, cred string, err error)

GetCred returns credentials for check flag in service

func HideAdvisory

func HideAdvisory(db *sql.DB, advisoryID int, hide bool) error

HideAdvisory used for hide advisory from cli

func NewRound

func NewRound(db *sql.DB, len time.Duration) (round int, err error)

NewRound add new round to database

func OpenDatabase

func OpenDatabase(path string) (db *sql.DB, err error)

OpenDatabase do not forget defer db.Close() after open

func PutStatus

func PutStatus(db *sql.DB, status Status) (err error)

PutStatus add status to database

func ReviewAdvisory

func ReviewAdvisory(db *sql.DB, advisoryID int, score int) error

ReviewAdvisory used for set score for advisory

Types

type Advisory

type Advisory struct {
	ID        int
	Text      string
	Reviewed  bool
	Score     int
	Timestamp time.Time
}

Advisory contains info about advisory

func GetAdvisories

func GetAdvisories(db *sql.DB) (advisories []Advisory, err error)

GetAdvisories get all advisories

type Flag

type Flag struct {
	ID        int
	Flag      string
	Round     int
	TeamID    int
	ServiceID int
	Cred      string
}

Flag contains info about flag

func GetCapturedFlags

func GetCapturedFlags(db *sql.DB, round, teamID int) (flgs []Flag, err error)

GetCapturedFlags get all captured flags for team and round

func GetFlagInfo

func GetFlagInfo(db *sql.DB, flag string) (flg Flag, err error)

GetFlagInfo returns info about flag

type Round

type Round struct {
	ID        int
	Len       time.Duration
	StartTime time.Time
}

Round contains info about round

func CurrentRound

func CurrentRound(db *sql.DB) (round Round, err error)

CurrentRound returns current round

type RoundResult

type RoundResult struct {
	ID           int
	TeamID       int
	Round        int
	AttackScore  float64
	DefenceScore float64
}

RoundResult contains info about result of round

func GetLastResult

func GetLastResult(db *sql.DB, teamID int) (res RoundResult, err error)

GetLastResult get last round result for team

func GetRoundResult

func GetRoundResult(db *sql.DB, teamID, round int) (res RoundResult, err error)

GetRoundResult get result for team and round

type Service

type Service struct {
	ID          int
	Name        string
	Port        int
	CheckerPath string
	UDP         bool
}

Service contains info about service

func GetServices

func GetServices(db *sql.DB) (services []Service, err error)

GetServices get all services from database

type ServiceState

type ServiceState int

ServiceState provide type for service status

const (
	// StatusUP Service is online, serves the requests, stores and
	// returns flags and behaves as expected
	StatusUP ServiceState = iota
	// StatusMumble Service is online, but behaves not as expected,
	// e.g. if HTTP server listens the port, but doesn't respond on request
	StatusMumble
	// StatusCorrupt Service is online, but past flags cannot be retrieved
	StatusCorrupt
	// StatusDown Service is offline
	StatusDown
	// StatusError Checker error
	StatusError
	// StatusUnknown Unknown
	StatusUnknown
)

func GetState

func GetState(db *sql.DB, halfStatus Status) (state ServiceState, err error)

GetState get state for service status

func GetStates

func GetStates(db *sql.DB, halfStatus Status) (states []ServiceState,
	err error)

GetStates get states for services status

func (ServiceState) String

func (state ServiceState) String() string

type Status

type Status struct {
	Round     int
	TeamID    int
	ServiceID int
	State     ServiceState
}

Status contains info about services status

type Team

type Team struct {
	ID        int
	Name      string
	Subnet    string
	Vulnbox   string
	UseNetbox bool
	Netbox    string
}

Team contains info about team

func GetTeam

func GetTeam(db *sql.DB, teamID int) (team Team, err error)

GetTeam get team by id from database

func GetTeams

func GetTeams(db *sql.DB) (teams []Team, err error)

GetTeams get all teams from database

Jump to

Keyboard shortcuts

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