Documentation ¶
Overview ¶
Package fs wraps filesystem operations to provide a simple and resilient API.
This enable low development and maintainenance effort, while avoiding breaking changes introduced on the high level of the chall-manager gRPC API (keep it as simple and readable as possible).
The storage is based on a filesystem, future works could move this to an object store such a S3-compliant solution.
Index ¶
- func ChallengeDirectory(id string) string
- func CheckChallenge(id string) error
- func CheckInstance(challId, sourceId string) error
- func Hash(id string) string
- func InstanceDirectory(challId, sourceId string) string
- func ListChallenges() (ids []string, merr error)
- func ListInstances(challId string) (iids []string, merr error)
- type Challenge
- type Instance
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChallengeDirectory ¶
func CheckChallenge ¶
CheckChallenge returns an error if there is no challenge with the given id.
func CheckInstance ¶
CheckInstance returns an error if there is no instance with the given ids.
func Hash ¶
Hash computes the Hash of the given ID. It is used to get a standard identifier (both in size and format) while avoiding filesystem manipulation (e.g. path traversal).
func InstanceDirectory ¶
func ListChallenges ¶
func ListInstances ¶
Types ¶
type Challenge ¶
type Challenge struct { ID string `json:"id"` Directory string `json:"directory"` Hash string `json:"hash"` // must be kept up coherent with directory content as its sha256 sum of base64(zip(content)) Until *time.Time `json:"until,omitempty"` Timeout *time.Duration `json:"timeout,omitempty"` }
Challenge is the internal model of an API Challenge as it is stored on the filesystem (at `<global.Conf.Directory>/chall/<id>/info.json`).
func LoadChallenge ¶
type Instance ¶
type Instance struct { Identity string `json:"identity"` ChallengeID string `json:"challenge_id"` SourceID string `json:"source_id"` State any `json:"state"` Since time.Time `json:"since"` LastRenew time.Time `json:"last_renew"` Until *time.Time `json:"until,omitempty"` ConnectionInfo string `json:"connection_info"` Flag *string `json:"flag,omitempty"` }
Instance is the internal model of an API Instance as it is stored on the filesystem (at `<global.Conf.Directory>/chall/<id>/instance/<id>/info.json`)