Documentation ¶
Index ¶
- Constants
- Variables
- func CopyMap(m map[string][]string) map[string][]string
- func GetDirNameForEvent(path string, tag Tag, date *time.Time) (string, error)
- func GetTokenForTeam(key []byte, t *Team) (string, error)
- func NewExerciseClientConn(config ServiceConfig) (eproto.ExerciseStoreClient, error)
- func NewGRPClientDBConnection(dbConn ServiceConfig) (pbc.StoreClient, error)
- func NewTeamStore(conf EventConfig, dbc pbc.StoreClient) *teamstore
- func TranslateRPCErr(err error) error
- type Category
- type Challenge
- type ChildrenChalConfig
- type ContainerOptions
- type Creds
- type EmptyVarErr
- type EnvVarConfig
- type Event
- type EventConfig
- type ExerTagExistsErr
- type Exercise
- type ExerciseInstanceConfig
- type Flag
- type FrontendStore
- type InstanceConfig
- type InvalidTagSyntaxErr
- type Lab
- type PChallenge
- type Profile
- type RecordConfig
- type ServiceConfig
- type SignupKey
- type SignupKeyStore
- type Tag
- type Team
- func (t *Team) AddChallenge(c Challenge) (string, error)
- func (t *Team) AddDisabledChal(parentTag string)
- func (t *Team) CorrectedAssignedLab()
- func (t *Team) Email() string
- func (t *Team) GetChildChallenges(parentTag string) []string
- func (t *Team) GetDisabledChalMap() map[string][]string
- func (t *Team) GetDisabledChals() []string
- func (t *Team) GetHashedPassword() string
- func (t *Team) GetHostsInfo() []string
- func (t *Team) GetLabInfo() string
- func (t *Team) GetVPNConn() []string
- func (t *Team) GetVPNKeys() map[int]string
- func (t *Team) ID() string
- func (t *Team) IsLabAssigned() bool
- func (t *Team) IsPasswordEqual(pass string) bool
- func (t *Team) IsTeamSolvedChallenge(tag string) *time.Time
- func (t *Team) LastAccessTime() time.Time
- func (t *Team) ManageDisabledChals(parentTag string) bool
- func (t *Team) Name() string
- func (t *Team) SetHostsInfo(hostInfo []string)
- func (t *Team) SetLabInfo(labSubnet string)
- func (t *Team) SetVPNConn(clientConfig []string)
- func (t *Team) SetVPNKeys(id int, key string)
- func (t *Team) UpdateAllChallenges(challenges map[string][]string)
- func (t *Team) UpdatePass(pass, passRepeat, evTag string) error
- func (t *Team) UpdateTeamAccessed(tm time.Time) error
- func (t *Team) UpdateTeamSolvedChallenges(chal TeamChallenge) error
- func (t *Team) VerifyFlag(tag Challenge, f string) error
- type TeamChallenge
- type TeamStore
- type UnknownExerTagErr
- type User
- type UserStore
- type UsersFile
- type VboxConfig
- type VpnConn
Constants ¶
const ( ID_KEY = "I" TEAMNAME_KEY = "TN" )
const ( NoTokenErrMsg = "token contains an invalid number of segments" AUTH_KEY = "au" )
Variables ¶
var ( UnknownTeamErr = errors.New("Unknown team") UnknownTokenErr = errors.New("Unknown token") )
var ( EmptyExTags = errors.New("Exercise cannot have zero tags") ImageNotDefinedErr = errors.New("image cannot be empty") MemoryNotDefinedErr = errors.New("memory cannot be empty") )
var ( UnreachableDBErr = errors.New("Database seems to be unreachable") )
var ( ErrUnknownTeam = errors.New("Unknown team") ErrEmailAlreadyExists = errors.New("Email is already registered") //ErrEmptyTag = errors.New("Tag cannot be empty") ErrUnknownFlag = errors.New("Unknown flag") ErrFlagAlreadyComplete = errors.New("Flag is already completed") ErrChallengeDuplicate = errors.New("Challenge duplication") ErrTeamAlreadyExist = errors.New("Team is already exists") )
var ( UserStoreNoFileErr = errors.New("Unable to find user store file") UserExistsErr = errors.New("User already exists") UserNotFoundErr = errors.New("User not found") PasswdTooShortErr = errors.New("Password too short, requires at least six characters") SignupKeyExistsErr = errors.New("Signup key already exists") SignupKeyNotFoundErr = errors.New("Signup key not found") )
var (
ErrInvalidFlagFormat = errors.New("Invalid flag format")
)
var (
TagEmptyErr = errors.New("Tag cannot be empty")
)
Functions ¶
func GetDirNameForEvent ¶
func NewExerciseClientConn ¶
func NewExerciseClientConn(config ServiceConfig) (eproto.ExerciseStoreClient, error)
NewExerciseClientConn does not require CA file to communicate due to the fact that a script is running on Gitlab CI to push exercises to the service
func NewGRPClientDBConnection ¶
func NewGRPClientDBConnection(dbConn ServiceConfig) (pbc.StoreClient, error)
func NewTeamStore ¶
func NewTeamStore(conf EventConfig, dbc pbc.StoreClient) *teamstore
func TranslateRPCErr ¶
Types ¶
type ChildrenChalConfig ¶
type ChildrenChalConfig struct { Tag Tag `json:"tag,omitempty"` Name string `json:"name,omitempty"` EnvVar string `json:"envFlag,omitempty"` StaticFlag string `json:"static,omitempty"` Points uint `json:"points,omitempty"` Category string `json:"category,omitempty"` TeamDescription string `json:"teamDescription,omitempty"` PreRequisites []string `json:"prerequisite,omitempty"` Outcomes []string `json:"outcome,omitempty"` StaticChallenge bool `json:"staticChallenge,omitempty"` }
func (ChildrenChalConfig) Validate ¶
func (fc ChildrenChalConfig) Validate() error
type ContainerOptions ¶
type ContainerOptions struct { DockerConf docker.ContainerConfig Records []RecordConfig Challenges []Challenge }
type EmptyVarErr ¶
func (*EmptyVarErr) Error ¶
func (eve *EmptyVarErr) Error() string
type EnvVarConfig ¶
type EnvVarConfig struct { EnvVar string `json:"name,omitempty"` Value string `json:"value,omitempty"` }
func (EnvVarConfig) Validate ¶
func (evc EnvVarConfig) Validate() error
type Event ¶
type Event struct { Dir string TeamStore EventConfig wg.WireGuardConfig // contains filtered or unexported fields }
func NewEventStore ¶
func NewEventStore(conf EventConfig, eDir string, dbc pbc.StoreClient) (Event, error)
Create the EventSore for the event. It contains: The connection with the DB A new TeamStore that contains all the teams retrieved from the DB (if no teams are retrieved the TeamStore will be empty) The EventConfiguration
func (Event) SetCapacity ¶
Change the Capacity of the event and update the DB
type EventConfig ¶
type EventConfig struct { Name string Host string Tag Tag Available int Capacity int Lab Lab StartedAt *time.Time FinishExpected *time.Time FinishedAt *time.Time Status int32 CreatedBy string OnlyVPN int32 VPNAddress string EndPointPort int DisabledChallenges map[string][]string // list of disabled children challenge tags to be used for amigo frontend ... AllChallenges map[string][]string SecretKey string // secret key is a key which is defined by event creator to setup events which are accessible only with signup key }
func (EventConfig) Validate ¶
func (e EventConfig) Validate() error
type ExerTagExistsErr ¶
type ExerTagExistsErr struct {
// contains filtered or unexported fields
}
func (*ExerTagExistsErr) Error ¶
func (eee *ExerTagExistsErr) Error() string
type Exercise ¶
type Exercise struct { Tag Tag `json:"tag,omitempty"` Name string `json:"name,omitempty"` Category string `json:"category,omitempty"` Secret bool `json:"secret,omitempty"` // specifies whether challenge will be on docker/vm or none // true: none , false: docker/vm Static bool `json:"static,omitempty"` Instance []ExerciseInstanceConfig `json:"instance,omitempty"` Status int `json:"status,omitempty"` OrgDescription string `json:"organizerDescription,omitempty"` }
todo manage the status somehow
func (Exercise) ContainerOpts ¶
func (e Exercise) ContainerOpts() []ContainerOptions
func (Exercise) Flags ¶
func (e Exercise) Flags() []ChildrenChalConfig
type ExerciseInstanceConfig ¶
type ExerciseInstanceConfig struct { Image string `json:"image,omitempty"` MemoryMB uint `json:"memory,omitempty"` CPU float64 `json:"cpu,omitempty"` Envs []EnvVarConfig `json:"envs,omitempty"` Flags []ChildrenChalConfig `json:"children,omitempty"` Records []RecordConfig `json:"records,omitempty"` }
type FrontendStore ¶
type FrontendStore interface { GetFrontends(...string) []InstanceConfig SetMemoryMB(string, uint) error SetCpu(string, float64) error // contains filtered or unexported methods }
func NewFrontendsFile ¶
func NewFrontendsFile(path string) (FrontendStore, error)
type InstanceConfig ¶
type InstanceConfig struct { Image string `yaml:"image"` MemoryMB uint `yaml:"memoryMB"` CPU float64 `yaml:"cpu"` }
func (InstanceConfig) Validate ¶
func (ic InstanceConfig) Validate() error
type InvalidTagSyntaxErr ¶
type InvalidTagSyntaxErr struct {
// contains filtered or unexported fields
}
func (*InvalidTagSyntaxErr) Error ¶
func (ite *InvalidTagSyntaxErr) Error() string
type Lab ¶
type Lab struct { Frontends []InstanceConfig Exercises []Tag DisabledExercises []Tag }
type PChallenge ¶
type Profile ¶
type Profile struct { Name string `json:"name,omitempty"` Secret bool `json:"secret,omitempty"` Challenges []PChallenge `json:"challenges,omitempty"` }
type RecordConfig ¶
type RecordConfig struct { Type string `json:"type,omitempty"` Name string `json:"name,omitempty"` RData string `json:"data,omitempty"` }
func (RecordConfig) Format ¶
func (rc RecordConfig) Format(ip string) string
func (RecordConfig) Validate ¶
func (rc RecordConfig) Validate() error
type ServiceConfig ¶
type SignupKey ¶
type SignupKey struct { WillBeNPUser bool `yaml:"np-user,omitempty"` WillBeSuperUser bool `yaml:"super-user,omitempty"` Value string `yaml:"value,omitempty"` }
admin has all permissions -- superuser user has all permissions except invitation -- user np-user has limited permissions -- np-user [non-priviledged user]
func NewSignupKey ¶
func NewSignupKey() SignupKey
type SignupKeyStore ¶
type SignupKeyStore interface { CreateSignupKey(SignupKey) error GetSignupKey(string) (SignupKey, error) DeleteSignupKey(SignupKey) error ListSignupKeys() []SignupKey }
func NewSignupKeyStore ¶
func NewSignupKeyStore(keys []SignupKey, hooks ...func([]SignupKey) error) SignupKeyStore
type Team ¶
type Team struct {
// contains filtered or unexported fields
}
func (*Team) AddDisabledChal ¶
func (*Team) CorrectedAssignedLab ¶
func (t *Team) CorrectedAssignedLab()
func (*Team) GetChildChallenges ¶
func (*Team) GetDisabledChalMap ¶
func (*Team) GetDisabledChals ¶
func (*Team) GetHashedPassword ¶
func (*Team) GetHostsInfo ¶
func (*Team) GetLabInfo ¶
func (*Team) GetVPNConn ¶
func (*Team) GetVPNKeys ¶
func (*Team) IsLabAssigned ¶
func (*Team) IsPasswordEqual ¶
func (*Team) LastAccessTime ¶
func (*Team) ManageDisabledChals ¶
func (*Team) SetHostsInfo ¶
func (*Team) SetLabInfo ¶
func (*Team) SetVPNConn ¶
will be taken from amigo side
func (*Team) SetVPNKeys ¶
func (*Team) UpdateAllChallenges ¶
func (*Team) UpdatePass ¶
func (*Team) UpdateTeamAccessed ¶
Update the Team access time on the DB
func (*Team) UpdateTeamSolvedChallenges ¶
func (t *Team) UpdateTeamSolvedChallenges(chal TeamChallenge) error
Update the Team Solved Challenges on the DB
type TeamChallenge ¶
func ParseSolvedChallenges ¶
func ParseSolvedChallenges(solvedChalsDB string) ([]TeamChallenge, error)
type UnknownExerTagErr ¶
type UnknownExerTagErr struct {
// contains filtered or unexported fields
}
func (*UnknownExerTagErr) Error ¶
func (uee *UnknownExerTagErr) Error() string
type User ¶
type User struct { Username string `yaml:"username"` Name string `yaml:"name"` Surname string `yaml:"surname"` Email string `yaml:"email"` HashedPassword string `yaml:"hashed-password"` SuperUser bool `yaml:"super-user"` NPUser bool `yaml:"np-user"` CreatedAt time.Time `yaml:"created-at"` }
func (User) IsCorrectPassword ¶
type UserStore ¶
type VboxConfig ¶
type VboxConfig struct {
ExerciseInstanceConfig `yaml:",inline"`
}
func (VboxConfig) Validate ¶
func (vc VboxConfig) Validate() error