Documentation ¶
Index ¶
- Constants
- func LogServiceEnd(ctx context.Context, resource, action string, start time.Time)
- func LogServiceStart(ctx context.Context, resource, action string) time.Time
- func TakeBytes(ctx context.Context) int
- func TakeTransactionID(ctx context.Context) uuid.UUID
- func WithBytes(ctx context.Context, bytes int) context.Context
- func WithTransactionID(ctx context.Context, transactionID uuid.UUID) context.Context
- func WithUser(ctx context.Context, u User) context.Context
- type APIRoot
- type APIRootService
- type Collection
- type CollectionAccess
- type CollectionService
- type Collections
- type CollectionsInAPIRoot
- type Config
- type DataStore
- type Discovery
- type DiscoveryService
- type Envelope
- type Error
- type Filter
- type ID
- type Key
- type Manifest
- type ManifestEntry
- type ManifestService
- type MigrationService
- type ObjectService
- type Page
- type Status
- type StatusService
- type User
- type UserCollectionList
- type UserService
- type Versions
- type VersionsService
Constants ¶
const ( // DefaultDevelopmentConfig is the path to the local dev config DefaultDevelopmentConfig = "config/cabby.json" // DefaultProductionConfig is the path to the packaged config file DefaultProductionConfig = "/etc/cabby/cabby.json" // StixContentType20 represents a stix 2.0 content type StixContentType20 = "application/vnd.oasis.stix+json;version=2.0" // StixContentType represents a stix 2 content type StixContentType = "application/vnd.oasis.stix+json" // TaxiiContentType21 represents a taxii 2.1 content type TaxiiContentType21 = "application/vnd.oasis.taxii+json;version=2.1" // TaxiiContentType represents a taxii 2 content type TaxiiContentType = "application/vnd.oasis.taxii+json" // TaxiiVersion notes the supported version of the server TaxiiVersion = "taxii-2.1" // UnsetUnixNano is the value returned from an unset time.Time{}.UnixNano() call UnsetUnixNano = -6795364578871345152 )
Variables ¶
This section is empty.
Functions ¶
func LogServiceEnd ¶
LogServiceEnd takes a resource and action being performed and a start time, and logs it and how long it took
func LogServiceStart ¶
LogServiceStart takes a resource and action being performed and logs it
func TakeTransactionID ¶
TakeTransactionID returns the transaction id stored in a context
func WithTransactionID ¶
WithTransactionID decorates a context with a transaction id
Types ¶
type APIRoot ¶
type APIRoot struct { Path string `json:"path,omitempty"` Title string `json:"title"` Description string `json:"description,omitempty"` Versions []string `json:"versions"` MaxContentLength int64 `json:"max_content_length"` }
APIRoot resource
func (*APIRoot) IncludesMinVersion ¶
IncludesMinVersion checks if minimum taxii version is included in list
type APIRootService ¶
type APIRootService interface { APIRoot(ctx context.Context, path string) (APIRoot, error) APIRoots(ctx context.Context) ([]APIRoot, error) CreateAPIRoot(ctx context.Context, a APIRoot) error DeleteAPIRoot(ctx context.Context, path string) error UpdateAPIRoot(ctx context.Context, a APIRoot) error }
APIRootService for interacting with APIRoots
type Collection ¶
type Collection struct { APIRootPath string `json:"api_root_path,omitempty"` ID ID `json:"id"` CanRead bool `json:"can_read"` CanWrite bool `json:"can_write"` Title string `json:"title"` Description string `json:"description,omitempty"` MediaTypes []string `json:"media_types,omitempty"` }
Collection resource
func NewCollection ¶
func NewCollection(id ...string) (Collection, error)
NewCollection returns a collection resource; it takes an optional id string
type CollectionAccess ¶
type CollectionAccess struct { ID ID `json:"id"` CanRead bool `json:"can_read"` CanWrite bool `json:"can_write"` }
CollectionAccess defines read/write access on a collection
type CollectionService ¶
type CollectionService interface { Collection(ctx context.Context, apiRoot, collectionID string) (Collection, error) Collections(ctx context.Context, apiRoot string, cr *Page) (Collections, error) CollectionsInAPIRoot(ctx context.Context, apiRoot string) (CollectionsInAPIRoot, error) CreateCollection(ctx context.Context, c Collection) error DeleteCollection(ctx context.Context, collectionID string) error UpdateCollection(ctx context.Context, c Collection) error }
CollectionService interface for interacting with data store
type Collections ¶
type Collections struct {
Collections []Collection `json:"collections"`
}
Collections resource
type CollectionsInAPIRoot ¶
CollectionsInAPIRoot associated a list of collection IDs that belong to a API Root Path
type Config ¶
type Config struct { Host string Port int SSLCert string `json:"ssl_cert"` SSLKey string `json:"ssl_key"` DataStore map[string]string `json:"data_store"` }
Config for a server
type DataStore ¶
type DataStore interface { APIRootService() APIRootService Close() CollectionService() CollectionService DiscoveryService() DiscoveryService ManifestService() ManifestService MigrationService() MigrationService ObjectService() ObjectService Open() error StatusService() StatusService UserService() UserService VersionsService() VersionsService }
DataStore interface for backend implementations
type Discovery ¶
type Discovery struct { Title string `json:"title"` Description string `json:"description,omitempty"` Contact string `json:"contact,omitempty"` Default string `json:"default,omitempty"` APIRoots []string `json:"api_roots,omitempty"` }
Discovery resource
type DiscoveryService ¶
type DiscoveryService interface { CreateDiscovery(ctx context.Context, d Discovery) error DeleteDiscovery(ctx context.Context) error Discovery(ctx context.Context) (Discovery, error) UpdateDiscovery(ctx context.Context, d Discovery) error }
DiscoveryService interface for interacting with Discovery resources
type Envelope ¶
type Envelope struct { More bool `json:"more"` Objects []json.RawMessage `json:"objects"` }
Envelope resource for transmitting stix objects
type Error ¶
type Error struct { Title string `json:"title"` Description string `json:"description,omitempty"` ErrorID string `json:"error_id,omitempty"` ErrorCode string `json:"error_code,omitempty"` HTTPStatus int `json:"http_status,string,omitempty"` ExternalDetails string `json:"external_details,omitempty"` Details map[string]string `json:"details,omitempty"` }
Error struct for TAXII 2 errors
type ID ¶
ID for taxii resources
func IDFromString ¶
IDFromString takes a uuid string and coerces to ID
func IDUsingString ¶
IDUsingString creates a V5 UUID from the given string
type Key ¶
type Key int
Key type for context ids; per context docuentation, use a Key type for context Keys
type Manifest ¶
type Manifest struct {
Objects []ManifestEntry `json:"objects,omitempty"`
}
Manifest resource lists a summary of objects in a collection
type ManifestEntry ¶
type ManifestEntry struct { ID string `json:"id"` DateAdded stones.Timestamp `json:"date_added"` Version stones.Timestamp `json:"version"` MediaTypes []string `json:"media_types"` }
ManifestEntry is a summary of an object in a manifest
type ManifestService ¶
type ManifestService interface {
Manifest(ctx context.Context, collectionID string, cr *Page, f Filter) (Manifest, error)
}
ManifestService provides manifest data
type MigrationService ¶
MigrationService for performing database migrations
type ObjectService ¶
type ObjectService interface { CreateEnvelope(ctx context.Context, e Envelope, collectionID string, s Status, ss StatusService) CreateObject(ctx context.Context, collectionID string, o stones.Object) error DeleteObject(ctx context.Context, collectionID, objecteID string) error Object(ctx context.Context, collectionID, objectID string, f Filter) ([]stones.Object, error) Objects(ctx context.Context, collectionID string, cr *Page, f Filter) ([]stones.Object, error) }
ObjectService provides Object data
type Page ¶
type Page struct { Limit uint64 // Used for setting X-TAXII-Date-Added-First MinimumAddedAfter stones.Timestamp // Used for setting X-TAXII-Date-Added-Last MaximumAddedAfter stones.Timestamp Total uint64 }
Page is used for paginated requests to represent the requested data range
func NewPage ¶
NewPage returns a Page given a string from the 'Page' HTTP header string the Page HTTP Header is specified by the request with the syntax 'items X-Y'
func (*Page) AddedAfterFirst ¶
AddedAfterFirst returns the first added after as a string
func (*Page) AddedAfterLast ¶
AddedAfterLast returns the last added after as a string
func (*Page) SetAddedAfters ¶
SetAddedAfters only takes one date string and uses it to update the minimum and maximum added after fields
type Status ¶
type Status struct { ID ID `json:"id"` Status string `json:"status"` RequestTimestamp stones.Timestamp `json:"request_timestamp"` TotalCount int64 `json:"total_count"` SuccessCount int64 `json:"success_count"` Successes []string `json:"successes"` FailureCount int64 `json:"failure_count"` Failures []string `json:"failures"` PendingCount int64 `json:"pending_count"` Pendings []string `json:"pendings"` }
Status represents a TAXII status object
type StatusService ¶
type StatusService interface { CreateStatus(ctx context.Context, s Status) error Status(ctx context.Context, statusID string) (Status, error) UpdateStatus(ctx context.Context, s Status) error }
StatusService for status structs
type User ¶
type User struct { Email string `json:"email"` CanAdmin bool `json:"can_admin"` CollectionAccessList map[ID]CollectionAccess }
User represents a cabby user should User and UserCollectionList be combined?
type UserCollectionList ¶
type UserCollectionList struct { Email string `json:"email"` CollectionAccessList map[ID]CollectionAccess `json:"collection_access_list"` }
UserCollectionList holds a list of collections a user can access
type UserService ¶
type UserService interface { CreateUser(ctx context.Context, u User, password string) error DeleteUser(ctx context.Context, u string) error UpdateUser(ctx context.Context, u User) error CreateUserCollection(ctx context.Context, u string, ca CollectionAccess) error DeleteUserCollection(ctx context.Context, u, id string) error UpdateUserCollection(ctx context.Context, u string, ca CollectionAccess) error User(ctx context.Context, user, password string) (User, error) UserCollections(ctx context.Context, user string) (UserCollectionList, error) }
UserService provides Users behavior