challenge

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Overview

Package challenge is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	ChallengeStore_CreateChallenge_FullMethodName   = "/api.v1.challenge.ChallengeStore/CreateChallenge"
	ChallengeStore_RetrieveChallenge_FullMethodName = "/api.v1.challenge.ChallengeStore/RetrieveChallenge"
	ChallengeStore_QueryChallenge_FullMethodName    = "/api.v1.challenge.ChallengeStore/QueryChallenge"
	ChallengeStore_UpdateChallenge_FullMethodName   = "/api.v1.challenge.ChallengeStore/UpdateChallenge"
	ChallengeStore_DeleteChallenge_FullMethodName   = "/api.v1.challenge.ChallengeStore/DeleteChallenge"
)

Variables

View Source
var (
	UpdateStrategy_name = map[int32]string{
		0: "update_in_place",
		1: "blue_green",
		2: "recreate",
	}
	UpdateStrategy_value = map[string]int32{
		"update_in_place": 0,
		"blue_green":      1,
		"recreate":        2,
	}
)

Enum value maps for UpdateStrategy.

View Source
var ChallengeStore_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "api.v1.challenge.ChallengeStore",
	HandlerType: (*ChallengeStoreServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "CreateChallenge",
			Handler:    _ChallengeStore_CreateChallenge_Handler,
		},
		{
			MethodName: "RetrieveChallenge",
			Handler:    _ChallengeStore_RetrieveChallenge_Handler,
		},
		{
			MethodName: "UpdateChallenge",
			Handler:    _ChallengeStore_UpdateChallenge_Handler,
		},
		{
			MethodName: "DeleteChallenge",
			Handler:    _ChallengeStore_DeleteChallenge_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "QueryChallenge",
			Handler:       _ChallengeStore_QueryChallenge_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "api/v1/challenge/challenge.proto",
}

ChallengeStore_ServiceDesc is the grpc.ServiceDesc for ChallengeStore service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var File_api_v1_challenge_challenge_proto protoreflect.FileDescriptor

Functions

func RegisterChallengeStoreHandler

func RegisterChallengeStoreHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterChallengeStoreHandler registers the http handlers for service ChallengeStore to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterChallengeStoreHandlerClient

func RegisterChallengeStoreHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ChallengeStoreClient) error

RegisterChallengeStoreHandlerClient registers the http handlers for service ChallengeStore to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ChallengeStoreClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ChallengeStoreClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "ChallengeStoreClient" to call the correct interceptors.

func RegisterChallengeStoreHandlerFromEndpoint

func RegisterChallengeStoreHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterChallengeStoreHandlerFromEndpoint is same as RegisterChallengeStoreHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterChallengeStoreHandlerServer

func RegisterChallengeStoreHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ChallengeStoreServer) error

RegisterChallengeStoreHandlerServer registers the http handlers for service ChallengeStore to "mux". UnaryRPC :call ChallengeStoreServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterChallengeStoreHandlerFromEndpoint instead.

func RegisterChallengeStoreServer

func RegisterChallengeStoreServer(s grpc.ServiceRegistrar, srv ChallengeStoreServer)

Types

type Challenge

type Challenge struct {

	// The challenge identifier.
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// The scenario hash, could be usefull to determine when an update is
	// necessary.
	Hash string `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"`
	// The timeout after which the janitor will have permission to delete
	// the instances.
	Timeout *durationpb.Duration `protobuf:"bytes,3,opt,name=timeout,proto3" json:"timeout,omitempty"`
	// The date after which the janitor will have permission to delete
	// the instances.
	Until *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=until,proto3" json:"until,omitempty"`
	// The challenge running instances.
	Instances []*instance.Instance `protobuf:"bytes,5,rep,name=instances,proto3" json:"instances,omitempty"`
	// contains filtered or unexported fields
}

The challenge object that the chall-manager exposes. Notice it differs from the internal representation, as it also handles filesystem-related information.

func (*Challenge) Descriptor deprecated

func (*Challenge) Descriptor() ([]byte, []int)

Deprecated: Use Challenge.ProtoReflect.Descriptor instead.

func (*Challenge) GetHash

func (x *Challenge) GetHash() string

func (*Challenge) GetId

func (x *Challenge) GetId() string

func (*Challenge) GetInstances

func (x *Challenge) GetInstances() []*instance.Instance

func (*Challenge) GetTimeout

func (x *Challenge) GetTimeout() *durationpb.Duration

func (*Challenge) GetUntil

func (x *Challenge) GetUntil() *timestamppb.Timestamp

func (*Challenge) ProtoMessage

func (*Challenge) ProtoMessage()

func (*Challenge) ProtoReflect

func (x *Challenge) ProtoReflect() protoreflect.Message

func (*Challenge) Reset

func (x *Challenge) Reset()

func (*Challenge) String

func (x *Challenge) String() string

type ChallengeStoreClient

type ChallengeStoreClient interface {
	// Before spinning up instances of a challenge, you need to register it.
	// That is the goal of CreateChallenge.
	// If will perform validation on your inputs and especially on the scenario.
	CreateChallenge(ctx context.Context, in *CreateChallengeRequest, opts ...grpc.CallOption) (*Challenge, error)
	// Once saved, you can retrieve the challenge information.
	// If it has not been created yet, returns an error.
	// If the challenge has instances running, returns their information too.
	RetrieveChallenge(ctx context.Context, in *RetrieveChallengeRequest, opts ...grpc.CallOption) (*Challenge, error)
	// Query all challenges information and their instances running.
	QueryChallenge(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (ChallengeStore_QueryChallengeClient, error)
	// A challenge can evolve through time, and on live.
	// The goal of UpdateChallenge is to handle those evolves.
	// If the until changes, sets it up to running instances.
	// If the timeout changes, set running instances until to the last renewal increased by
	// the new timeout.
	// If the scenario changes, update the running instances, but even if this is
	// technically possible we do not recommend it has we do not look for infrastructure
	// drift.
	UpdateChallenge(ctx context.Context, in *UpdateChallengeRequest, opts ...grpc.CallOption) (*Challenge, error)
	// At the end of its life, a challenge can be deleted.
	// If it has running instances, it will spin them down.
	DeleteChallenge(ctx context.Context, in *DeleteChallengeRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
}

ChallengeStoreClient is the client API for ChallengeStore service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type ChallengeStoreServer

type ChallengeStoreServer interface {
	// Before spinning up instances of a challenge, you need to register it.
	// That is the goal of CreateChallenge.
	// If will perform validation on your inputs and especially on the scenario.
	CreateChallenge(context.Context, *CreateChallengeRequest) (*Challenge, error)
	// Once saved, you can retrieve the challenge information.
	// If it has not been created yet, returns an error.
	// If the challenge has instances running, returns their information too.
	RetrieveChallenge(context.Context, *RetrieveChallengeRequest) (*Challenge, error)
	// Query all challenges information and their instances running.
	QueryChallenge(*emptypb.Empty, ChallengeStore_QueryChallengeServer) error
	// A challenge can evolve through time, and on live.
	// The goal of UpdateChallenge is to handle those evolves.
	// If the until changes, sets it up to running instances.
	// If the timeout changes, set running instances until to the last renewal increased by
	// the new timeout.
	// If the scenario changes, update the running instances, but even if this is
	// technically possible we do not recommend it has we do not look for infrastructure
	// drift.
	UpdateChallenge(context.Context, *UpdateChallengeRequest) (*Challenge, error)
	// At the end of its life, a challenge can be deleted.
	// If it has running instances, it will spin them down.
	DeleteChallenge(context.Context, *DeleteChallengeRequest) (*emptypb.Empty, error)
	// contains filtered or unexported methods
}

ChallengeStoreServer is the server API for ChallengeStore service. All implementations must embed UnimplementedChallengeStoreServer for forward compatibility

type ChallengeStore_QueryChallengeClient

type ChallengeStore_QueryChallengeClient interface {
	Recv() (*Challenge, error)
	grpc.ClientStream
}

type ChallengeStore_QueryChallengeServer

type ChallengeStore_QueryChallengeServer interface {
	Send(*Challenge) error
	grpc.ServerStream
}

type CreateChallengeRequest

type CreateChallengeRequest struct {

	// The challenge identifier.
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// The scenario of the challenge, i.e. the Pulumi infrastructure factory.
	// Please look at the sdk documentation to understand how to write it.
	// Technically, it is the base64(zip(<directory>)).
	Scenario string `protobuf:"bytes,2,opt,name=scenario,proto3" json:"scenario,omitempty"`
	// The timeout after which the janitor will have permission to delete the instance.
	Timeout *durationpb.Duration `protobuf:"bytes,4,opt,name=timeout,proto3" json:"timeout,omitempty"`
	// The date after which the janitor will have permission to delete the instance.
	Until *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=until,proto3" json:"until,omitempty"`
	// contains filtered or unexported fields
}

The request to create a challenge.

func (*CreateChallengeRequest) Descriptor deprecated

func (*CreateChallengeRequest) Descriptor() ([]byte, []int)

Deprecated: Use CreateChallengeRequest.ProtoReflect.Descriptor instead.

func (*CreateChallengeRequest) GetId

func (x *CreateChallengeRequest) GetId() string

func (*CreateChallengeRequest) GetScenario

func (x *CreateChallengeRequest) GetScenario() string

func (*CreateChallengeRequest) GetTimeout

func (x *CreateChallengeRequest) GetTimeout() *durationpb.Duration

func (*CreateChallengeRequest) GetUntil

func (*CreateChallengeRequest) ProtoMessage

func (*CreateChallengeRequest) ProtoMessage()

func (*CreateChallengeRequest) ProtoReflect

func (x *CreateChallengeRequest) ProtoReflect() protoreflect.Message

func (*CreateChallengeRequest) Reset

func (x *CreateChallengeRequest) Reset()

func (*CreateChallengeRequest) String

func (x *CreateChallengeRequest) String() string

type DeleteChallengeRequest

type DeleteChallengeRequest struct {

	// The challenge identifier.
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteChallengeRequest) Descriptor deprecated

func (*DeleteChallengeRequest) Descriptor() ([]byte, []int)

Deprecated: Use DeleteChallengeRequest.ProtoReflect.Descriptor instead.

func (*DeleteChallengeRequest) GetId

func (x *DeleteChallengeRequest) GetId() string

func (*DeleteChallengeRequest) ProtoMessage

func (*DeleteChallengeRequest) ProtoMessage()

func (*DeleteChallengeRequest) ProtoReflect

func (x *DeleteChallengeRequest) ProtoReflect() protoreflect.Message

func (*DeleteChallengeRequest) Reset

func (x *DeleteChallengeRequest) Reset()

func (*DeleteChallengeRequest) String

func (x *DeleteChallengeRequest) String() string

type RetrieveChallengeRequest

type RetrieveChallengeRequest struct {

	// The challenge identifier.
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*RetrieveChallengeRequest) Descriptor deprecated

func (*RetrieveChallengeRequest) Descriptor() ([]byte, []int)

Deprecated: Use RetrieveChallengeRequest.ProtoReflect.Descriptor instead.

func (*RetrieveChallengeRequest) GetId

func (x *RetrieveChallengeRequest) GetId() string

func (*RetrieveChallengeRequest) ProtoMessage

func (*RetrieveChallengeRequest) ProtoMessage()

func (*RetrieveChallengeRequest) ProtoReflect

func (x *RetrieveChallengeRequest) ProtoReflect() protoreflect.Message

func (*RetrieveChallengeRequest) Reset

func (x *RetrieveChallengeRequest) Reset()

func (*RetrieveChallengeRequest) String

func (x *RetrieveChallengeRequest) String() string

type Store

type Store struct {
	UnimplementedChallengeStoreServer
}

Store holds a distributed filesystem along its integrity to handle challenge scenario storage. In case of updates, it locks the instances and update them to avoid infrastructure drift through time.

The etcd key is "store". The filesystem to write into is "<storage>/challenge/<id>".

func NewStore

func NewStore() *Store

func (*Store) CreateChallenge

func (store *Store) CreateChallenge(ctx context.Context, req *CreateChallengeRequest) (*Challenge, error)

func (*Store) DeleteChallenge

func (store *Store) DeleteChallenge(ctx context.Context, req *DeleteChallengeRequest) (*emptypb.Empty, error)

func (*Store) QueryChallenge

func (store *Store) QueryChallenge(_ *emptypb.Empty, server ChallengeStore_QueryChallengeServer) error

func (*Store) RetrieveChallenge

func (store *Store) RetrieveChallenge(ctx context.Context, req *RetrieveChallengeRequest) (*Challenge, error)

func (*Store) UpdateChallenge

func (store *Store) UpdateChallenge(ctx context.Context, req *UpdateChallengeRequest) (*Challenge, error)

type UnimplementedChallengeStoreServer

type UnimplementedChallengeStoreServer struct {
}

UnimplementedChallengeStoreServer must be embedded to have forward compatible implementations.

func (UnimplementedChallengeStoreServer) CreateChallenge

func (UnimplementedChallengeStoreServer) DeleteChallenge

func (UnimplementedChallengeStoreServer) QueryChallenge

func (UnimplementedChallengeStoreServer) RetrieveChallenge

func (UnimplementedChallengeStoreServer) UpdateChallenge

type UnsafeChallengeStoreServer

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

UnsafeChallengeStoreServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ChallengeStoreServer will result in compilation errors.

type UpdateChallengeRequest

type UpdateChallengeRequest struct {

	// The challenge identifier.
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// The scenario of the challenge. If specified, will updates running instances iif the
	// old and new hashes differs.
	Scenario *string `protobuf:"bytes,2,opt,name=scenario,proto3,oneof" json:"scenario,omitempty"`
	// If specified, sets the update strategy to adopt in case the challenge has running
	// instances.
	// Default to an update in place.
	UpdateStrategy *UpdateStrategy `` /* 147-byte string literal not displayed */
	// The timeout after which the janitor will have permission to delete the instances.
	Timeout *durationpb.Duration `protobuf:"bytes,4,opt,name=timeout,proto3" json:"timeout,omitempty"`
	// The date after which the janitor will have permission to delete the instances.
	Until      *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=until,proto3" json:"until,omitempty"`
	UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,6,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"`
	// contains filtered or unexported fields
}

The request to update a challenge.

func (*UpdateChallengeRequest) Descriptor deprecated

func (*UpdateChallengeRequest) Descriptor() ([]byte, []int)

Deprecated: Use UpdateChallengeRequest.ProtoReflect.Descriptor instead.

func (*UpdateChallengeRequest) GetId

func (x *UpdateChallengeRequest) GetId() string

func (*UpdateChallengeRequest) GetScenario

func (x *UpdateChallengeRequest) GetScenario() string

func (*UpdateChallengeRequest) GetTimeout

func (x *UpdateChallengeRequest) GetTimeout() *durationpb.Duration

func (*UpdateChallengeRequest) GetUntil

func (*UpdateChallengeRequest) GetUpdateMask

func (x *UpdateChallengeRequest) GetUpdateMask() *fieldmaskpb.FieldMask

func (*UpdateChallengeRequest) GetUpdateStrategy

func (x *UpdateChallengeRequest) GetUpdateStrategy() UpdateStrategy

func (*UpdateChallengeRequest) ProtoMessage

func (*UpdateChallengeRequest) ProtoMessage()

func (*UpdateChallengeRequest) ProtoReflect

func (x *UpdateChallengeRequest) ProtoReflect() protoreflect.Message

func (*UpdateChallengeRequest) Reset

func (x *UpdateChallengeRequest) Reset()

func (*UpdateChallengeRequest) String

func (x *UpdateChallengeRequest) String() string

type UpdateStrategy

type UpdateStrategy int32

The UpdateStrategy to use in case of a Challenge scenario update with running instances. Default strategy is the update-in-place.

const (
	// update_in_place updates the existing state based on the new stack in the scenario.
	// This update strategy provide high availability with low update costs.
	UpdateStrategy_update_in_place UpdateStrategy = 0
	// blue_green spins up a second instance of the scenario in parallel and once up,
	// delete the previous one for players to shift.
	// This update strategy provide high availability with high update costs due to infra
	// deduplication.
	UpdateStrategy_blue_green UpdateStrategy = 1
	// recreate delete the previous instance then spins up a fresh instance of the scenario.
	// This update strategy provide no availability guarantee with medium update costs due
	// to intensive create/delete operations. It should be used at a last relief, for
	// instance if the update is inconsistent and the outcomes are not predictable.
	UpdateStrategy_recreate UpdateStrategy = 2
)

func (UpdateStrategy) Descriptor

func (UpdateStrategy) Enum

func (x UpdateStrategy) Enum() *UpdateStrategy

func (UpdateStrategy) EnumDescriptor deprecated

func (UpdateStrategy) EnumDescriptor() ([]byte, []int)

Deprecated: Use UpdateStrategy.Descriptor instead.

func (UpdateStrategy) Number

func (UpdateStrategy) String

func (x UpdateStrategy) String() string

func (UpdateStrategy) Type

Jump to

Keyboard shortcuts

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