api

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 15 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNonceAndSession

func GetNonceAndSession(url string, opts ...Option) (nonce string, session string, err error)

GetNonceAndSession is provided for simplicity. It uses the default HTTP client under the hood.

Types

type Attempt

type Attempt struct {
	Status  string `json:"status"`
	Message string `json:"message"`
}

type Award

type Award struct {
	ID           int           `json:"id"`
	TeamID       int           `json:"team_id"`
	Category     *string       `json:"category"`
	UserID       int           `json:"user_id"`
	Team         int           `json:"team"` // XXX may be duplicated with ID ?
	Date         string        `json:"date"`
	Description  *string       `json:"description"`
	User         int           `json:"user"` // XXX may be duplicated with UserID ?
	Type         string        `json:"type"`
	Value        int           `json:"value"`
	Requirements *Requirements `json:"requirements"`
	Name         string        `json:"name"`
	Icon         string        `json:"icon"`
}

type Bracket added in v0.6.3

type Bracket struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Type        string `json:"type"`
}

type CUV

type CUV struct {
	Create string  `json:"create"`
	Update string  `json:"update"`
	View   *string `json:"view,omitempty"`
}

type Challenge

type Challenge struct {
	ID             int           `json:"id"`
	Name           string        `json:"name"`
	Description    string        `json:"description"`
	ConnectionInfo *string       `json:"connection_info,omitempty"`
	MaxAttempts    *int          `json:"max_attempts,omitempty"`
	Function       string        `json:"function"`
	Value          int           `json:"value"`
	Initial        *int          `json:"initial,omitempty"`
	Decay          *int          `json:"decay,omitempty"`
	Minimum        *int          `json:"minimum,omitempty"`
	Category       string        `json:"category"`
	Type           string        `json:"type"`
	TypeDate       *Type         `json:"type_data,omitempty"`
	State          string        `json:"state"`
	NextID         *int          `json:"next_id"`
	Requirements   *Requirements `json:"requirements"` // List of challenge IDs to complete before
	Solves         int           `json:"solves"`
	SolvedByMe     bool          `json:"solved_by_me"`
}

type Client

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

Client is in charge of interacting with a CTFd instance.

func NewClient

func NewClient(url, nonce, session, apiKey string) *Client

NewClient creates a fresh *Client. It automatically handles the session and its updates (login, logout...).

func (*Client) DeleteAward

func (client *Client) DeleteAward(id string, opts ...Option) error

func (*Client) DeleteChallenge

func (client *Client) DeleteChallenge(id int, opts ...Option) error

func (*Client) DeleteComment

func (client *Client) DeleteComment(id int, opts ...Option) error

func (*Client) DeleteConfigsByKey

func (client *Client) DeleteConfigsByKey(key string, opts ...Option) error

TODO confirm delete does not take parameters and returns anything

func (*Client) DeleteConfigsField

func (client *Client) DeleteConfigsField(id string, opts ...Option) error

func (*Client) DeleteFile

func (client *Client) DeleteFile(id string, opts ...Option) error

func (*Client) DeleteFlag

func (client *Client) DeleteFlag(id string, opts ...Option) error

func (*Client) DeleteHint

func (client *Client) DeleteHint(id string, opts ...Option) error

func (*Client) DeleteNotification

func (client *Client) DeleteNotification(id string, opts ...Option) error

func (*Client) DeletePage

func (client *Client) DeletePage(id string, opts ...Option) error

func (*Client) DeleteSubmission

func (client *Client) DeleteSubmission(id string, opts ...Option) error

func (*Client) DeleteTag

func (client *Client) DeleteTag(id string, opts ...Option) error

func (*Client) DeleteTeam

func (client *Client) DeleteTeam(id int, opts ...Option) error

func (*Client) DeleteTeamMembers

func (client *Client) DeleteTeamMembers(id int, params *DeleteTeamMembersParams, opts ...Option) ([]int, error)

XXX mixture of DELETE and body for control should be cleaned

func (*Client) DeleteTeamsMe

func (client *Client) DeleteTeamsMe(opts ...Option) error

func (*Client) DeleteToken

func (client *Client) DeleteToken(id string, opts ...Option) error

func (*Client) DeleteTopic

func (client *Client) DeleteTopic(params *DeleteTopicArgs, opts ...Option) error

TODO fix this endpoint API instability, should reconsider using a DELETE method with a JSON body rather that URL-encoded parameters as for all other endpoints

func (*Client) DeleteUser

func (client *Client) DeleteUser(id int, opts ...Option) error

func (*Client) Do

func (client *Client) Do(req *http.Request) (*http.Response, error)

func (*Client) GetAward

func (client *Client) GetAward(id string, opts ...Option) (*Award, error)

func (*Client) GetAwards

func (client *Client) GetAwards(params *GetAwardsParams, opts ...Option) ([]*Award, error)

func (*Client) GetBrackets added in v0.6.3

func (client *Client) GetBrackets(params *GetBracketsParams, opts ...Option) ([]*Bracket, error)

func (*Client) GetChallenge

func (client *Client) GetChallenge(id int, opts ...Option) (*Challenge, error)

func (*Client) GetChallengeFiles

func (client *Client) GetChallengeFiles(id int, opts ...Option) ([]*File, error)

func (*Client) GetChallengeFlags

func (client *Client) GetChallengeFlags(id int, opts ...Option) ([]*Flag, error)

func (*Client) GetChallengeHints

func (client *Client) GetChallengeHints(id int, opts ...Option) ([]*Hint, error)

func (*Client) GetChallengeRequirements

func (client *Client) GetChallengeRequirements(id int, opts ...Option) (*Requirements, error)

func (*Client) GetChallengeSolves

func (client *Client) GetChallengeSolves(id int, opts ...Option) (*Challenge, error)

TODO find content to determine model

func (*Client) GetChallengeTags

func (client *Client) GetChallengeTags(id int, opts ...Option) ([]*Tag, error)

func (*Client) GetChallengeTopics

func (client *Client) GetChallengeTopics(id int, opts ...Option) ([]*Topic, error)

func (*Client) GetChallenges

func (client *Client) GetChallenges(params *GetChallengesParams, opts ...Option) ([]*Challenge, error)

func (*Client) GetChallengesTypes

func (client *Client) GetChallengesTypes(opts ...Option) (map[string]*Type, error)

func (*Client) GetComments

func (client *Client) GetComments(params *GetCommentsParams, opts ...Option) ([]*Comment, error)

func (*Client) GetConfigs

func (client *Client) GetConfigs(params *GetConfigsParams, opts ...Option) ([]*Config, error)

func (*Client) GetConfigsByKey

func (client *Client) GetConfigsByKey(key string, opts ...Option) (any, error)

TODO find model

func (*Client) GetConfigsField

func (client *Client) GetConfigsField(id string, opts ...Option) (*ConfigField, error)

func (*Client) GetConfigsFields

func (client *Client) GetConfigsFields(params *GetConfigsParams, opts ...Option) ([]*ConfigField, error)

func (*Client) GetFile

func (client *Client) GetFile(id string, opts ...Option) (*File, error)

func (*Client) GetFileContent added in v0.3.3

func (client *Client) GetFileContent(file *File, opts ...Option) ([]byte, error)

GetFileContent is a helper leveraging the CTFd API that downloads a file's content given its location.

func (*Client) GetFiles

func (client *Client) GetFiles(params *GetFilesParams, opts ...Option) ([]*File, error)

func (*Client) GetFlag

func (client *Client) GetFlag(id string, opts ...Option) (*Flag, error)

func (*Client) GetFlags

func (client *Client) GetFlags(params *GetFlagsParams, opts ...Option) ([]*Flag, error)

func (*Client) GetFlagsType

func (client *Client) GetFlagsType(typename string, opts ...Option) (*Type, error)

func (*Client) GetFlagsTypes

func (client *Client) GetFlagsTypes(opts ...Option) (map[string]*Type, error)

func (*Client) GetHint

func (client *Client) GetHint(id string, opts ...Option) (*Hint, error)

func (*Client) GetHints

func (client *Client) GetHints(params *GetHintsParams, opts ...Option) ([]*Hint, error)

func (*Client) GetNotification

func (client *Client) GetNotification(id string, opts ...Option) (*Notification, error)

func (*Client) GetNotifications

func (client *Client) GetNotifications(params *GetNotificationsParams, opts ...Option) ([]*Notification, error)

func (*Client) GetPage

func (client *Client) GetPage(id string, opts ...Option) (*Page, error)

func (*Client) GetPages

func (client *Client) GetPages(params *GetPagesParams, opts ...Option) ([]*Page, error)

func (*Client) GetScoreboard

func (client *Client) GetScoreboard(opts ...Option) ([]*Scoreboard, error)

func (*Client) GetScoreboardTop

func (client *Client) GetScoreboardTop(count int, opts ...Option) ([]*Scoreboard, error)

func (*Client) GetStatisticsChallengesColumn

func (client *Client) GetStatisticsChallengesColumn(column string, opts ...Option) (map[string]int, error)

func (*Client) GetStatisticsChallengesSolves

func (client *Client) GetStatisticsChallengesSolves(opts ...Option) ([]*StatChallSubmission, error)

func (*Client) GetStatisticsScoresDistribution

func (client *Client) GetStatisticsScoresDistribution(opts ...Option) (*Distribution, error)

func (*Client) GetStatisticsSubmissionsColumn

func (client *Client) GetStatisticsSubmissionsColumn(column string, opts ...Option) (map[string]int, error)

func (*Client) GetStatisticsTeams

func (client *Client) GetStatisticsTeams(opts ...Option) (*StatTeams, error)

func (*Client) GetStatisticsUsers

func (client *Client) GetStatisticsUsers(opts ...Option) (*StatUsers, error)

func (*Client) GetStatisticsUsersColumn

func (client *Client) GetStatisticsUsersColumn(column string, opts ...Option) (*StatUsers, error)

func (*Client) GetSubmission

func (client *Client) GetSubmission(id string, opts ...Option) (*Submission, error)

func (*Client) GetSubmissions

func (client *Client) GetSubmissions(params *GetSubmissionsParams, opts ...Option) ([]*Submission, error)

TODO support pagination ? CTFd does not seem to support parameters for this

func (*Client) GetTag

func (client *Client) GetTag(id string, opts ...Option) (*Tag, error)

func (*Client) GetTags

func (client *Client) GetTags(params *GetTagsParams, opts ...Option) ([]*Tag, error)

func (*Client) GetTeam

func (client *Client) GetTeam(id int, opts ...Option) (*Team, error)

func (*Client) GetTeamAwards

func (client *Client) GetTeamAwards(id int, opts ...Option) ([]*Award, error)

func (*Client) GetTeamFails

func (client *Client) GetTeamFails(id int, opts ...Option) ([]*Submission, error)

func (*Client) GetTeamMembers

func (client *Client) GetTeamMembers(id int, opts ...Option) ([]int, error)

func (*Client) GetTeamSolves

func (client *Client) GetTeamSolves(id int, opts ...Option) ([]*Submission, error)

func (*Client) GetTeams

func (client *Client) GetTeams(params *GetTeamsParams, opts ...Option) ([]*Team, error)

func (*Client) GetTeamsMe

func (client *Client) GetTeamsMe(opts ...Option) (*Team, error)

func (*Client) GetTeamsMeAwards

func (client *Client) GetTeamsMeAwards(opts ...Option) ([]*Award, error)

func (*Client) GetTeamsMeFails

func (client *Client) GetTeamsMeFails(opts ...Option) ([]*Submission, error)

func (*Client) GetTeamsMeSolves

func (client *Client) GetTeamsMeSolves(opts ...Option) ([]*Submission, error)

func (*Client) GetToken

func (client *Client) GetToken(id string, opts ...Option) (*Token, error)

XXX Using this endpoint, you could get back the token value which is not a desired behaviour ! Issue #2309

func (*Client) GetTokens

func (client *Client) GetTokens(opts ...Option) ([]*Token, error)

func (*Client) GetTopic

func (client *Client) GetTopic(id string, opts ...Option) (*Topic, error)

func (*Client) GetTopics

func (client *Client) GetTopics(params *GetTopicsParams, opts ...Option) ([]*Topic, error)

func (*Client) GetUnlocks

func (client *Client) GetUnlocks(params *GetUnlocksParams, opts ...Option) ([]*Unlock, error)

func (*Client) GetUser

func (client *Client) GetUser(id int, opts ...Option) (*User, error)

func (*Client) GetUserAwards

func (client *Client) GetUserAwards(id int, opts ...Option) ([]*Award, error)

func (*Client) GetUserFails

func (client *Client) GetUserFails(id int, opts ...Option) ([]*Submission, error)

func (*Client) GetUserSolves

func (client *Client) GetUserSolves(id int, opts ...Option) ([]*Submission, error)

func (*Client) GetUsers

func (client *Client) GetUsers(params *GetUsersParams, opts ...Option) ([]*User, error)

TODO handle pagination, but don't seem supported by CTFd API

func (*Client) GetUsersMe

func (client *Client) GetUsersMe(opts ...Option) (*User, error)

func (*Client) GetUsersMeAwards

func (client *Client) GetUsersMeAwards(opts ...Option) ([]*Award, error)

func (*Client) GetUsersMeFails

func (client *Client) GetUsersMeFails(opts ...Option) ([]*Submission, error)

func (*Client) GetUsersMeSolves

func (client *Client) GetUsersMeSolves(opts ...Option) ([]*Submission, error)

func (*Client) HeadNotifications

func (client *Client) HeadNotifications(params *HeadNotificationsParams, opts ...Option) (int, error)

XXX does not need to be authenticated. Issue #2310

func (*Client) Login

func (client *Client) Login(params *LoginParams, opts ...Option) error

Returns the session value or an error.

WARNING 1: this endpoint is not officially supported. WARNING 2: provided client must have a no-follow-redirect behaviour, or a cookie jar. Else, it won't detect the login worked properly thus won't extract and save the new session id.

func (*Client) Logout

func (client *Client) Logout(opts ...Option) error

func (*Client) PatchChallenge

func (client *Client) PatchChallenge(id int, params *PatchChallengeParams, opts ...Option) (*Challenge, error)

func (*Client) PatchConfigs

func (client *Client) PatchConfigs(params *PatchConfigsParams, opts ...Option) error

func (*Client) PatchConfigsByKey

func (client *Client) PatchConfigsByKey(key string, params any, opts ...Option) (any, error)

TODO find input model

func (client *Client) PatchConfigsCTFLogo(params *PatchConfigsCTFLogo, opts ...Option) (*ThemeImage, error)

func (*Client) PatchConfigsCTFSmallIcon added in v0.6.3

func (client *Client) PatchConfigsCTFSmallIcon(params *PatchConfigsCTFLogo, opts ...Option) (*ThemeImage, error)

func (*Client) PatchConfigsField

func (client *Client) PatchConfigsField(id string, params *PatchConfigsFieldParams, opts ...Option) (*ConfigField, error)

func (*Client) PatchFlag

func (client *Client) PatchFlag(id string, params *PatchFlagParams, opts ...Option) (*Flag, error)

func (*Client) PatchHint

func (client *Client) PatchHint(id string, params *PatchHintsParams, opts ...Option) (*Hint, error)

func (*Client) PatchPage

func (client *Client) PatchPage(id string, params *PatchPageParams, opts ...Option) (*Page, error)

func (*Client) PatchTags

func (client *Client) PatchTags(id string, params *PatchTagsParams, opts ...Option) (*Tag, error)

func (*Client) PatchTeam

func (client *Client) PatchTeam(id int, params *PatchTeamsParams, opts ...Option) (*Team, error)

func (*Client) PatchTeamsMe

func (client *Client) PatchTeamsMe(params *PatchTeamsParams, opts ...Option) (*Team, error)

func (*Client) PatchUser

func (client *Client) PatchUser(id int, params *PatchUsersParams, opts ...Option) (*User, error)

func (*Client) PatchUsersMe

func (client *Client) PatchUsersMe(params *PatchUsersParams, opts ...Option) (*User, error)

func (*Client) PostAwards

func (client *Client) PostAwards(params *PostAwardsParams, opts ...Option) (*Award, error)

func (*Client) PostBrackets added in v0.6.3

func (client *Client) PostBrackets(params *PostBracketsParams, opts ...Option) (*Bracket, error)

func (*Client) PostChallenges

func (client *Client) PostChallenges(params *PostChallengesParams, opts ...Option) (*Challenge, error)

func (*Client) PostChallengesAttempt

func (client *Client) PostChallengesAttempt(params *PostChallengesAttemptParams, opts ...Option) (*Attempt, error)

func (*Client) PostComments

func (client *Client) PostComments(params *PostCommentsParams, opts ...Option) (*Comment, error)

func (*Client) PostConfigFields

func (client *Client) PostConfigFields(params *PostConfigFieldsParams, opts ...Option) (*ConfigField, error)

func (*Client) PostConfigs

func (client *Client) PostConfigs(params *PostConfigsParams, opts ...Option) (*Config, error)

func (*Client) PostFiles

func (client *Client) PostFiles(params *PostFilesParams, opts ...Option) ([]*File, error)

func (*Client) PostFlags

func (client *Client) PostFlags(params *PostFlagsParams, opts ...Option) (*Flag, error)

func (*Client) PostHints

func (client *Client) PostHints(params *PostHintsParams, opts ...Option) (*Hint, error)

func (*Client) PostNotifications

func (client *Client) PostNotifications(params *PostNotificationsParams, opts ...Option) (*Notification, error)

func (*Client) PostPages

func (client *Client) PostPages(params *PostPagesParams, opts ...Option) (*Page, error)

XXX find if could use constraint error on .route to get a shell using the PIN form on sqlalchemy.exc.IntegrityError

func (*Client) PostTags

func (client *Client) PostTags(params *PostTagsParams, opts ...Option) (*Tag, error)

func (*Client) PostTeamMembers

func (client *Client) PostTeamMembers(id int, params *PostTeamsMembersParams, opts ...Option) (int, error)

func (*Client) PostTeams

func (client *Client) PostTeams(params *PostTeamsParams, opts ...Option) (*Team, error)

func (*Client) PostTeamsMeMembers

func (client *Client) PostTeamsMeMembers(params *PostTeamsMembersParams, opts ...Option) (*Team, error)

func (*Client) PostTokens

func (client *Client) PostTokens(params *PostTokensParams, opts ...Option) (*Token, error)

func (*Client) PostTopics

func (client *Client) PostTopics(params *PostTopicsParams, opts ...Option) (*Topic, error)

func (*Client) PostUnlocks

func (client *Client) PostUnlocks(params *PostUnlocksParams, opts ...Option) (*Unlock, error)

func (*Client) PostUserMail

func (client *Client) PostUserMail(params *PostUserMailParams, id int, opts ...Option) (any, error)

TODO find model when email turned on

func (*Client) PostUsers

func (client *Client) PostUsers(params *PostUsersParams, opts ...Option) (*User, error)

func (*Client) Register

func (client *Client) Register(params *RegisterParams, opts ...Option) error

func (*Client) Reset

func (client *Client) Reset(params *ResetParams, opts ...Option) error

func (*Client) SetAPIKey

func (client *Client) SetAPIKey(apiKey string)

SetAPIKey enables you to set a mandatory API key, or reset it by setting an empty one.

func (*Client) Setup

func (client *Client) Setup(params *SetupParams, opts ...Option) error

WARNING: this endpoint is not officially supported.

type Comment

type Comment struct {
	ID       int     `json:"id"`
	AuthorID int     `json:"author_id"`
	Content  *string `json:"content"`
	Date     string  `json:"date"`
	HTML     *string `json:"html,omitempty"`
	Author   struct {
		Name string `json:"name"`
	} `json:"author"`
	Type string `json:"type"`
}

type Config

type Config struct {
	ID    int    `json:"id"`
	Key   string `json:"key"`
	Value string `json:"value"`
}

type ConfigField

type ConfigField struct {
	FieldType   any     `json:"field_type"`
	Editable    bool    `json:"editable"`
	Type        string  `json:"type"`
	Required    bool    `json:"required"`
	Public      bool    `json:"public"`
	Name        *string `json:"name"`
	Description *string `json:"description"`
	ID          int     `json:"id"`
}

type DeleteTeamMembersParams

type DeleteTeamMembersParams struct {
	UserID int `json:"user_id"`
}

type DeleteTopicArgs added in v0.3.6

type DeleteTopicArgs struct {
	ID   string `schema:"target_id"`
	Type string `schema:"type"`
}

type Distribution

type Distribution struct {
	Brackets map[string]int `json:"brackets"`
}

type Field

type Field struct {
	FieldID int    `json:"field_id"`
	Value   string `json:"value"` // seems could be int/bool/string, let CTFd interfer type
}

type File

type File struct {
	ID       int    `json:"id"`
	Type     string `json:"type"`
	Location string `json:"location"`
	SHA1sum  string `json:"sha1sum"`
}

type Flag

type Flag struct {
	ID          int    `json:"id"`
	ChallengeID int    `json:"challenge_id"`
	Content     string `json:"content"`
	Data        string `json:"data"`
	Type        string `json:"type"`
	Challenge   int    `json:"challenge"` // XXX may be duplicated with ChallengeID ?
}

type GetAwardsParams

type GetAwardsParams struct {
	UserID   *int    `schema:"user_id,omitempty"`
	TeamID   *int    `schema:"team_id,omitempty"`
	Type     *string `schema:"type,omitempty"`
	Value    *int    `schema:"value,omitempty"`
	Category *int    `schema:"category,omitempty"`
	Icon     *int    `schema:"icon,omitempty"`
	Q        *string `schema:"q,omitempty"`
	Field    *string `schema:"field,omitempty"`
}

type GetBracketsParams added in v0.6.3

type GetBracketsParams struct{}

type GetChallengesParams

type GetChallengesParams struct {
	Name        *string `schema:"name,omitempty"`
	MaxAttempts *int    `schema:"max_attempts,omitempty"`
	Value       *int    `schema:"value,omitempty"`
	Category    *int    `schema:"category,omitempty"`
	Type        *string `schema:"type,omitempty"`
	State       *string `schema:"state,omitempty"`
	Q           *string `schema:"q,omitempty"`
}

type GetCommentsParams

type GetCommentsParams struct {
	ChallengeID *int    `schema:"challenge_id,omitempty"`
	UserID      *int    `schema:"user_id,omitempty"`
	TeamID      *int    `schema:"team_id,omitempty"`
	PageID      *int    `schema:"page_id,omitempty"`
	Q           *string `schema:"q,omitempty"`
	Field       *string `schema:"field,omitempty"`
}

type GetConfigsFieldsParams

type GetConfigsFieldsParams struct {
	Type  *string `schema:"type,omitempty"`
	Q     *string `schema:"q,omitempty"`
	Field *string `schema:"field,omitempty"`
}

type GetConfigsParams

type GetConfigsParams struct {
	Key   *string `schema:"key,omitempty"`
	Value *string `schema:"value,omitempty"`
	Q     *string `schema:"q,omitempty"`
	Field *string `schema:"field,omitempty"`
}

type GetFilesParams

type GetFilesParams struct {
	Type     *string `schema:"type,omitempty"`
	Location *string `schema:"location,omitempty"`
	Q        *string `schema:"q,omitempty"`
	Field    *string `schema:"field,omitempty"`
}

type GetFlagsParams

type GetFlagsParams struct {
	ChallengeID *int    `schema:"challenge_id,omitempty"`
	Type        *string `schema:"type,omitempty"`
	Content     *string `schema:"content,omitempty"`
	Data        *string `schema:"data,omitempty"`
	Q           *string `schema:"q,omitempty"`
	Field       *string `schema:"field,omitempty"`
}

type GetHintsParams

type GetHintsParams struct {
	Type        *string `schema:"type,omitempty"`
	ChallengeID *int    `schema:"challenge_id,omitempty"`
	Content     *string `schema:"content,omitempty"`
	Cost        *int    `schema:"cost,omitempty"`
	Q           *string `schema:"q,omitempty"`
	Field       *string `schema:"field,omitempty"`
}

type GetNotificationsParams

type GetNotificationsParams struct {
	Title   *string `schema:"title,omitempty"`
	Content *string `schema:"content,omitempty"`
	UserID  *int    `schema:"user_id,omitempty"`
	TeamID  *int    `schema:"team_id,omitempty"`
	Q       *string `schema:"q,omitempty"`
	Field   *string `schema:"field,omitempty"`
	SinceID *int    `schema:"since_id,omitempty"`
}

type GetPagesParams

type GetPagesParams struct {
	ID           *int    `schema:"id,omitempty"`
	Title        *string `schema:"title,omitempty"`
	Route        *string `schema:"route,omitempty"`
	Draft        *bool   `schema:"draft,omitempty"`
	Hidden       *bool   `schema:"hidden,omitempty"`
	AuthRequired *bool   `schema:"auth_required,omitempty"`
	Q            *string `schema:"q,omitempty"`
	Field        *string `schema:"field,omitempty"`
}

type GetSubmissionsParams

type GetSubmissionsParams struct {
	ChallengeID *int    `schema:"challenge_id,omitempty"`
	UserID      *int    `schema:"user_id,omitempty"`
	TeamID      *int    `schema:"team_id,omitempty"`
	IP          *string `schema:"ip,omitempty"`
	Provided    *string `schema:"provided,omitempty"`
	Type        *string `schema:"type,omitempty"`
	Q           *string `schema:"q,omitempty"`
	Field       *string `schema:"field,omitempty"`
}

type GetTagsParams

type GetTagsParams struct {
	ChallengeID *int    `schema:"challenge_id,omitempty"`
	Value       *string `schema:"value,omitempty"`
	Q           *string `schema:"q,omitempty"`
	Field       *string `schema:"field,omitempty"`
}

type GetTeamsParams

type GetTeamsParams struct {
	Affiliation *string `schema:"affiliation"`
	Country     *string `schema:"country"`
	Bracket     *string `schema:"bracket"`
	Q           *string `schema:"q"`
	Field       *string `schema:"field"`
}

type GetTopicsParams

type GetTopicsParams struct {
	Value *string `schema:"value,omitempty"`
	Q     *string `schema:"q,omitempty"`
	Field *string `schema:"field,omitempty"`
}

type GetUnlocksParams

type GetUnlocksParams struct {
	UserID *int    `schema:"user_id,omitempty"`
	TeamID *int    `schema:"team_id,omitempty"`
	Target *int    `schema:"target,omitempty"`
	Type   *string `schema:"type,omitempty"`
	Q      *string `schema:"q,omitempty"`
	Field  *string `schema:"field,omitempty"`
}

type GetUsersParams

type GetUsersParams struct {
	Affiliation *string `schema:"affiliation"`
	Country     *string `schema:"country"`
	Bracket     *string `schema:"bracket"`
	Q           *string `schema:"q"`
	Field       *string `schema:"field"`
}

type HeadNotificationsParams

type HeadNotificationsParams struct {
	Title   *string `schema:"title,omitempty"`
	Content *string `schema:"content,omitempty"`
	UserID  *int    `schema:"user_id,omitempty"`
	TeamID  *int    `schema:"team_id,omitempty"`
	Q       *string `schema:"q,omitempty"`
	Field   *string `schema:"field,omitempty"`
	SinceID *int    `schema:"since_id,omitempty"`
}

type Hint

type Hint struct {
	ID           int           `json:"id"`
	HTML         *string       `json:"html,omitempty"`
	Content      *string       `json:"content,omitempty"`
	Cost         int           `json:"cost"`
	Type         string        `json:"type"`
	ChallengeID  int           `json:"challenge_id"`
	Challenge    int           `json:"challenge"` // XXX may be duplicated with ChallengeID ?
	Requirements *Requirements `json:"requirements,omitempty"`
}

type InputFile

type InputFile struct {
	Name    string
	Content []byte
}

type LoginParams

type LoginParams struct {
	Name     string
	Password string
}

type Notification

type Notification struct {
	ID      int     `json:"id"`
	TeamID  *int    `json:"team_id"` // XXX may be duplicated with Team ?
	HTML    string  `json:"html"`
	UserID  *int    `json:"user_id"` // XXX may be duplicated with User ?
	Team    *int    `json:"team"`
	Content string  `json:"content"`
	Date    string  `json:"date"`
	Title   string  `json:"title"`
	User    *int    `json:"user"`
	Type    *string `json:"type,omitempty"`
	Sound   *bool   `json:"sound,omitempty"`
}

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithContext

func WithContext(ctx context.Context) Option

type Page

type Page struct {
	Files        []any   `json:"files"` // XXX find model
	ID           int     `json:"id"`
	Draft        bool    `json:"draft"`
	Route        string  `json:"route"`
	Title        string  `json:"title"`
	Hidden       bool    `json:"hidden"`
	Format       string  `json:"format"`
	AuthRequired bool    `json:"auth_required"`
	Content      *string `json:"content,omitempty"`
}

type PatchChallengeParams

type PatchChallengeParams struct {
	Name           string  `json:"name"`
	Category       string  `json:"category"`
	Description    string  `json:"description"`
	Function       string  `json:"function"`
	ConnectionInfo *string `json:"connection_info,omitempty"`
	Value          *int    `json:"value,omitempty"`
	Initial        *int    `json:"initial,omitempty"`
	Decay          *int    `json:"decay,omitempty"`
	Minimum        *int    `json:"minimum,omitempty"`
	MaxAttempts    *int    `json:"max_attempts,omitempty"`
	NextID         *int    `json:"next_id,omitempty"`
	// Requirements can update the challenge's behavior and prerequisites i.e.
	// the other challenges the team/user must have solved before.
	// WARNING: it won't return those in the response body, so updating this
	// field requires you to do it manually through *Client.GetChallengeRequirements
	Requirements *Requirements `json:"requirements,omitempty"`
	State        string        `json:"state"`
}
type PatchConfigsCTFLogo struct {
	Value *string `json:"value"`
}

type PatchConfigsFieldParams

type PatchConfigsFieldParams struct {
	ID          int    `json:"id"` // XXX duplicated with the ID in URL
	Name        string `json:"name"`
	Description string `json:"description"`
	FieldType   string `json:"field_type"`
	Type        string `json:"type"`
	Editable    bool   `json:"editable"`
	Public      bool   `json:"public"`
	Required    bool   `json:"required"`
}

type PatchConfigsParams

type PatchConfigsParams struct {
	CTFDescription *string `json:"ctf_description,omitempty"`
	CTFName        *string `json:"ctf_name,omitempty"`

	CTFTheme      *string `json:"ctf_theme,omitempty"`
	ThemeFooter   *string `json:"theme_footer,omitempty"`
	ThemeHeader   *string `json:"theme_header,omitempty"`
	ThemeSettings *string `json:"theme_settings,omitempty"`

	DomainWhitelist            *string `json:"domain_whitelist,omitempty"`
	IncorrectSubmissionsPerMin *int    `json:"incorrect_submissions_per_min,omitempty"`
	NameChanges                *bool   `json:"name_changes,omitempty"`
	NumTeams                   *int    `json:"num_teams,omitempty"`
	NumUsers                   *int    `json:"num_users,omitempty"`
	TeamCreation               *bool   `json:"team_creation,omitempty"`
	TeamDisbanding             *string `json:"team_disbanding,omitempty"`
	TeamSize                   *int    `json:"team_size,omitempty"`
	VerifyEmails               *bool   `json:"verify_emails,omitempty"`

	RobotsTxt *string `json:"robots_txt,omitempty"`

	OauthClientID     *string `json:"oauth_client_id,omitempty"`
	OauthClientSecret *string `json:"oauth_client_secret,omitempty"`

	AccountVisibility      *string `json:"account_visibility,omitempty"`
	ChallengeVisibility    *string `json:"challenge_visibility,omitempty"`
	Paused                 *bool   `json:"paused,omitempty"`
	RegistrationVisibility *string `json:"registration_visibility,omitempty"`
	ScoreVisibility        *string `json:"score_visibility,omitempty"`

	HTMLSanitization *bool   `json:"html_sanitization,omitempty"`
	RegistrationCode *string `json:"registration_code,omitempty"`

	MailPassword                       *string `json:"mail_password,omitempty"`
	MailPort                           *string `json:"mail_port,omitempty"`
	MailServer                         *string `json:"mail_server,omitempty"`
	MailSSL                            *bool   `json:"mail_ssl,omitempty"`
	MailTLS                            *bool   `json:"mail_tls,omitempty"`
	MailUseAuth                        *bool   `json:"mail_useauth,omitempty"`
	MailUsername                       *string `json:"mail_username,omitempty"`
	PasswordChangeAlertBody            *string `json:"password_change_alert_body,omitempty"`
	PasswordChangeAlertSubject         *string `json:"password_change_alert_subject,omitempty"`
	PasswordResetBody                  *string `json:"password_reset_body,omitempty"`
	PasswordResetSubject               *string `json:"password_reset_subject,omitempty"`
	SuccessfulRegistrationEmailBody    *string `json:"successful_registration_email_body,omitempty"`
	SuccessfulRegistrationEmailSubject *string `json:"successful_registration_email_subject,omitempty"`
	UserCreationEmailBody              *string `json:"user_creation_email_body,omitempty"`
	UserCreationEmailSubject           *string `json:"user_creation_email_subject,omitempty"`
	VerificationEmailBody              *string `json:"verification_email_body,omitempty"`
	VerificationEmailSubject           *string `json:"verification_email_subject,omitempty"`

	// DEPRECATED
	MailFromAddr *string `json:"mailfrom_addr,omitempty"`
	// DEPRECATED
	MailGunAPIKey *string `json:"mailgun_api_key,omitempty"`
	// DEPRECATED
	MailGunBaseURL *string `json:"mailgun_base_url,omitempty"`

	End          *string `json:"end,omitempty"`
	Freeze       *string `json:"freeze,omitempty"`
	Start        *string `json:"start,omitempty"`
	ViewAfterCTF *bool   `json:"view_after_ctf,omitempty"`

	SocialShares *bool `json:"social_shares,omitempty"`

	PrivacyText *string `json:"privacy_text,omitempty"`
	PrivacyURL  *string `json:"privacy_url,omitempty"`
	TOSText     *string `json:"tos_text,omitempty"`
	TOSURL      *string `json:"tos_url,omitempty"`

	UserMode *string `json:"user_mode,omitempty"`
}

type PatchFlagParams

type PatchFlagParams struct {
	Content string `json:"content"`
	Data    string `json:"data"`
	ID      string `json:"id"` // XXX should be int + duplicated with id in URL
	Type    string `json:"type"`
}

type PatchHintsParams

type PatchHintsParams struct {
	ChallengeID  int          `json:"challenge_id"`
	Content      string       `json:"content"`
	Cost         int          `json:"cost"`
	Requirements Requirements `json:"requirements"`
}

type PatchPageParams

type PatchPageParams struct {
	Title        string `json:"title"`
	Content      string `json:"content"`
	Format       string `json:"format"`
	Route        string `json:"route"`
	Nonce        string `json:"nonce"` // XXX API should not use the nonce as you need to parse HTML content to get it, going against the API workflow
	AuthRequired bool   `json:"auth_required"`
	Draft        bool   `json:"draft"`
	Hidden       bool   `json:"hidden"`
}

type PatchTagsParams

type PatchTagsParams struct {
	Value string `json:"value"`
}

type PatchTeamsParams

type PatchTeamsParams struct {
	CaptainID   *int    `json:"captain_id,omitempty"`
	Name        *string `json:"name,omitempty"`
	Email       *string `json:"email,omitempty"`
	Password    *string `json:"password,omitempty"`
	Website     *string `json:"website,omitempty"`
	Affiliation *string `json:"affiliation,omitempty"`
	Country     *string `json:"country,omitempty"`
	Banned      *bool   `json:"banned,omitempty"`
	Hidden      *bool   `json:"hidden,omitempty"`
	Fields      []Field `json:"fields"`
}

type PatchUsersParams

type PatchUsersParams struct {
	Name        string  `json:"name"`
	Email       string  `json:"email"`
	Language    *string `json:"language,omitempty"`
	Password    *string `json:"password,omitempty"`
	Website     *string `json:"website,omitempty"`
	Affiliation *string `json:"affiliation,omitempty"`
	Country     *string `json:"country,omitempty"`
	Type        *string `json:"type,omitempty"`
	Verified    *bool   `json:"verified,omitempty"`
	Hidden      *bool   `json:"hidden,omitempty"`
	Banned      *bool   `json:"banned,omitempty"`
	Fields      []Field `json:"fields"`
}

type PostAwardsParams

type PostAwardsParams struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Category    string `json:"category"`
	Icon        string `json:"icon"`
	UserID      int    `json:"user_id"`
	Value       int    `json:"value"`
}

type PostBracketsParams added in v0.6.3

type PostBracketsParams struct {
	ID          float64 `json:"id"` // XXX Why is that a float64 ?? Why is it even sent by the client as CTFd will return a new one ?
	Name        string  `json:"name"`
	Description string  `json:"description"`
	Type        string  `json:"type"`
}

type PostChallengesAttemptParams

type PostChallengesAttemptParams struct {
	// TODO support parameter (e.g. "preview=true")
	ChallengeID int    `json:"challenge_id"`
	Submission  string `json:"submission"`
}

type PostChallengesParams

type PostChallengesParams struct {
	Name           string        `json:"name"`
	Category       string        `json:"category"`
	Description    string        `json:"description"`
	Function       string        `json:"function"`
	ConnectionInfo *string       `json:"connection_info,omitempty"`
	Value          int           `json:"value"`
	Initial        *int          `json:"initial,omitempty"`
	Decay          *int          `json:"decay,omitempty"`
	Minimum        *int          `json:"minimum,omitempty"`
	MaxAttempts    *int          `json:"max_attempts,omitempty"`
	NextID         *int          `json:"next_id,omitempty"`
	Requirements   *Requirements `json:"requirements,omitempty"`
	State          string        `json:"state"`
	Type           string        `json:"type"`
}

type PostCommentsParams

type PostCommentsParams struct {
	PageID  int    `json:"page_id"`
	Content string `json:"content"`
	Type    string `json:"type"`
}

type PostConfigFieldsParams

type PostConfigFieldsParams struct {
	ID          float64 `json:"id"`
	Name        string  `json:"name"`
	Description string  `json:"description"`
	FieldType   string  `json:"field_type"`
	Editable    bool    `json:"editable"`
	Public      bool    `json:"public"`
	Required    bool    `json:"required"`
	Type        string  `json:"type"`
}

type PostConfigsParams

type PostConfigsParams struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type PostFilesParams

type PostFilesParams struct {
	Files     []*InputFile // XXX backend code shows it could be a list, but not the doc
	Challenge int          // TODO May be additional i.e. pages don't need it
	Location  *string
}

type PostFlagsParams

type PostFlagsParams struct {
	Challenge int    `json:"challenge"`
	Content   string `json:"content"`
	Data      string `json:"data"`
	Type      string `json:"type"`
}

type PostHintsParams

type PostHintsParams struct {
	ChallengeID  int          `json:"challenge_id"`
	Content      string       `json:"content"`
	Cost         int          `json:"cost"`
	Requirements Requirements `json:"requirements"`
}

type PostNotificationsParams

type PostNotificationsParams struct {
	Content string `json:"content"`
	Sound   bool   `json:"sound"`
	Title   string `json:"title"`
	Type    string `json:"type"`
}

type PostPagesParams

type PostPagesParams struct {
	AuthRequired bool   `json:"auth_required"`
	Content      string `json:"content"`
	Draft        bool   `json:"draft"`
	Format       string `json:"format"`
	Hidden       bool   `json:"hidden"`
	Nonce        string `json:"nonce"` // XXX API should not use the nonce as you need to parse HTML content to get it, going against the API workflow
	Route        string `json:"route"`
	Title        string `json:"title"`
}

type PostTagsParams

type PostTagsParams struct {
	Challenge int    `json:"challenge"`
	Value     string `json:"value"`
}

type PostTeamsMembersParams added in v0.4.0

type PostTeamsMembersParams struct {
	UserID int `json:"user_id"`
}

type PostTeamsParams

type PostTeamsParams struct {
	Name        string  `json:"name"`
	Email       string  `json:"email"`
	Password    string  `json:"password"`
	Website     *string `json:"website,omitempty"`
	Affiliation *string `json:"affiliation,omitempty"`
	Country     *string `json:"country,omitempty"`
	Banned      bool    `json:"banned"`
	Hidden      bool    `json:"hidden"`
	Fields      []Field `json:"fields"`
}

type PostTokensParams

type PostTokensParams struct {
	Description string `json:"description"`
	Expiration  string `json:"expiration"`
}

type PostTopicsParams

type PostTopicsParams struct {
	Challenge int    `json:"challenge"`
	Type      string `json:"type"`
	Value     string `json:"value"`
}

type PostUnlocksParams

type PostUnlocksParams struct {
	Target int    `json:"target"`
	Type   string `json:"type"`
}

type PostUserMailParams

type PostUserMailParams struct {
	Text string `json:"text"`
}

type PostUsersParams

type PostUsersParams struct {
	Name        string  `json:"name"`
	Email       string  `json:"email"`
	Language    *string `json:"language,omitempty"`
	Password    string  `json:"password"`
	Website     *string `json:"website,omitempty"`
	Affiliation *string `json:"affiliation,omitempty"`
	Country     *string `json:"country,omitempty"`
	Type        string  `json:"type"` // "user" or "admin"
	Verified    bool    `json:"verified"`
	Hidden      bool    `json:"hidden"`
	Banned      bool    `json:"banned"`
	Fields      []Field `json:"fields"`
}

type RegisterParams

type RegisterParams struct {
	Name     string
	Email    string
	Password string
}

type Requirements

type Requirements struct {
	// Anonymize control the behavior of the resource if the prerequisites are
	// not validated:
	//  - if `nil`, defaults to `*false`
	//  - if `*false`, set the behavior as "hidden" (invisible until validated)
	//  - if `*true`, set the behavior to "anonymized" (visible but not much info)
	Anonymize *bool `json:"anonymize,omitempty"`

	// Prerequisites is the list of resources' ID that need to be validated in
	// order for the resource to meet its requirements.
	Prerequisites []int `json:"prerequisites"`
}

type ResetParams

type ResetParams struct {
	Accounts      *string `schema:"accounts,omitempty"`
	Submissions   *string `schema:"submissions,omitempty"`
	Challenges    *string `schema:"challenges,omitempty"`
	Pages         *string `schema:"pages,omitempty"`
	Notifications *string `schema:"notifications,omitempty"`
	// Nonce is autofilled by the API wrapper.
	// XXX the "nonce" should not be part of the API call but rather be extracted from HTTP headers.
	Nonce string `schema:"nonce"`
}

type Response

type Response struct {
	Success bool    `json:"success"`
	Data    any     `json:"data,omitempty"`
	Errors  any     `json:"errors,omitempty"` // can't type it to []string due to API model instabilities
	Message *string `json:"message,omitempty"`
}

type Scoreboard

type Scoreboard struct {
	Pos         int    `json:"pos"`
	AccountId   int    `json:"account_id"`
	AccountURL  string `json:"account_url"`
	AccountType string `json:"account_type"`
	OauthID     any    `json:"oauth_id"`
	Name        string `json:"name"`
	Score       int    `json:"score"`
	Members     []struct {
		ID      int    `json:"id"`
		OauthID any    `json:"oauth_id"`
		Name    string `json:"name"`
		Score   int    `json:"score"`
	} `json:"members"`
	BracketID   *string `json:"bracket_id"`
	BracketName *string `json:"bracket_name"`
}

type SetupParams

type SetupParams struct {
	CTFName                string
	CTFDescription         string
	UserMode               string
	ChallengeVisibility    string
	AccountVisibility      string
	ScoreVisibility        string
	RegistrationVisibility string
	VerifyEmails           bool
	TeamSize               *int
	Name                   string
	Email                  string
	Password               string
	CTFBanner              *InputFile
	CTFSmallIcon           *InputFile
	CTFTheme               string
	ThemeColor             string
	Start                  string
	End                    string
}

type StatChallSubmission

type StatChallSubmission struct {
	ID         int      `json:"id"`
	Name       string   `json:"name"`
	Solves     *int     `json:"solves,omitempty"`
	Percentage *float64 `json:"percentage,omitempty"`
}

type StatTeams

type StatTeams struct {
	Registered int `json:"registered"`
}

type StatUsers

type StatUsers struct {
	Registered int `json:"registered"`
	Confirmed  int `json:"confirmed"`
}

type Submission

type Submission struct {
	ID          int    `json:"id"`
	TeamID      int    `json:"team_id"` // XXX may be duplicated with team.id ?
	IP          string `json:"ip"`
	ChallengeID int    `json:"challenge_id"`
	UserID      int    `json:"user_id"` // XXX may be duplicated with user.id ?
	Team        struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"team"`
	Date string `json:"date"`
	User struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"user"`
	Type      string `json:"type"`
	Challenge struct {
		Value    int    `json:"value"`
		ID       int    `json:"id"`
		Name     string `json:"name"`
		Category string `json:"category"`
	} `json:"challenge"`
	Provided string `json:"provided"`
}

type Tag

type Tag struct {
	ID          int    `json:"id"`
	Challenge   *int   `json:"challenge,omitempty"` // XXX This may be duplicated with ChallengeID ?
	ChallengeID int    `json:"challenge_id"`
	Value       string `json:"value"`
}

type Team

type Team struct {
	Bracket     *string  `json:"bracket,omitempty"`
	Members     []int    `json:"members,omitempty"`
	ID          int      `json:"id"`
	Created     string   `json:"created"`
	Country     *string  `json:"country,omitempty"`
	Email       *string  `json:"email,omitempty"`
	Affiliation *string  `json:"affiliation,omitempty"`
	CaptainID   *int     `json:"captain_id,omitempty"`
	Fields      []string `json:"fields"`
	Banned      bool     `json:"banned"`
	Website     *string  `json:"website,omitempty"`
	Hidden      bool     `json:"hidden"`
	Secret      *bool    `json:"secret,omitempty"`
	Name        string   `json:"name"`
	OauthID     *string  `json:"oauth_id,omitempty"`
	Place       *string  `json:"place,omitempty"`
	Score       *int     `json:"score,omitempty"`
}

type ThemeImage added in v0.6.3

type ThemeImage struct {
	ID    int     `json:"id"`
	Key   string  `json:"key"`
	Value *string `json:"value"`
}

type Token

type Token struct {
	Expiration  string  `json:"expiration"`
	ID          int     `json:"id"`
	Type        string  `json:"type"`
	Value       *string `json:"value,omitempty"`
	Description *string `json:"description,omitempty"`
	Created     *string `json:"created,omitempty"`
	UserID      *int    `json:"user_id,omitempty"`
}

type Topic

type Topic struct {
	ID          int    `json:"id"`
	ChallengeID *int   `json:"challenge_id,omitempty"`
	Challenge   *int   `json:"challenge,omitempty"` // XXX may be duplicated with ChallengeID ?
	TopicID     *int   `json:"topic_id,omitempty"`  // XXX may be duplicated with ID ?
	Topic       *int   `json:"topic,omitempty"`     // XXX may be duplicated with ID ?
	Value       string `json:"value"`
}

type Type

type Type struct {
	ID        *string `json:"id,omitempty"`
	Name      string  `json:"name"`
	Templates CUV     `json:"templates"`
	Scripts   *CUV    `json:"scripts,omitempty"`
	Create    *string `json:"create,omitempty"`
}

type Unlock

type Unlock struct {
	Type   string `json:"type"`
	TeamID int    `json:"team_id"`
	Target int    `json:"target"`
	Date   string `json:"date"`
	UserID int    `json:"user_id"`
	ID     int    `json:"id"`
}

type User

type User struct {
	Bracket     *string `json:"bracket"`
	ID          int     `json:"id"`
	TeamID      *int    `json:"team_id,omitempty"`
	Country     *string `json:"country,omitempty"`
	Language    *string `json:"language,omitempty"`
	Affiliation *string `json:"affiliation,omitempty"`
	Fields      []Field `json:"fields"`
	Website     *string `json:"website,omitempty"`
	Name        string  `json:"name"`
	Email       *string `json:"email,omitempty"`
	OauthID     *string `json:"oauth_id,omitempty"`
	Verified    *bool   `json:"verified,omitempty"`
	Banned      *bool   `json:"banned,omitempty"`
	Hidden      *bool   `json:"hidden,omitempty"`
	Type        *string `json:"type,omitempty"`
	Created     *string `json:"created,omitempty"`
	Secret      *string `json:"secret,omitempty"`
}

Jump to

Keyboard shortcuts

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