store

package
v0.0.0-...-3b700e2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2015 License: BSD-3-Clause Imports: 15 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrMaliciousServer

type ErrMaliciousServer struct{}

ErrMaliciousServer indicates the server returned a response that is highly suspected of being malicious. i.e. it attempted to send us more data than the known size of a particular role metadata.

func (ErrMaliciousServer) Error

func (err ErrMaliciousServer) Error() string

type ErrMetaNotFound

type ErrMetaNotFound struct{}

ErrMetaNotFound indicates we did not find a particular piece of metadata in the store

func (ErrMetaNotFound) Error

func (err ErrMetaNotFound) Error() string

type ErrServerUnavailable

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

ErrServerUnavailable indicates an error from the server. code allows us to populate the http error we received

func (ErrServerUnavailable) Error

func (err ErrServerUnavailable) Error() string

type FilesystemStore

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

FilesystemStore is a store in a locally accessible directory

func NewFilesystemStore

func NewFilesystemStore(baseDir, metaSubDir, metaExtension, targetsSubDir string) (*FilesystemStore, error)

NewFilesystemStore creates a new store in a directory tree

func (*FilesystemStore) GetMeta

func (f *FilesystemStore) GetMeta(name string, size int64) ([]byte, error)

GetMeta returns the meta for the given name (a role)

func (*FilesystemStore) SetMeta

func (f *FilesystemStore) SetMeta(name string, meta []byte) error

SetMeta sets the meta for a single role

func (*FilesystemStore) SetMultiMeta

func (f *FilesystemStore) SetMultiMeta(metas map[string][]byte) error

SetMultiMeta sets the metadata for multiple roles in one operation

type HTTPStore

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

HTTPStore manages pulling and pushing metadata from and to a remote service over HTTP. It assumes the URL structure of the remote service maps identically to the structure of the TUF repo: <baseURL>/<metaPrefix>/(root|targets|snapshot|timestamp).json <baseURL>/<targetsPrefix>/foo.sh

If consistent snapshots are disabled, it is advised that caching is not enabled. Simple set a cachePath (and ensure it's writeable) to enable caching.

func (HTTPStore) GetKey

func (s HTTPStore) GetKey(role string) ([]byte, error)

GetKey retrieves a public key from the remote server

func (HTTPStore) GetMeta

func (s HTTPStore) GetMeta(name string, size int64) ([]byte, error)

GetMeta downloads the named meta file with the given size. A short body is acceptable because in the case of timestamp.json, the size is a cap, not an exact length.

func (HTTPStore) GetTarget

func (s HTTPStore) GetTarget(path string) (io.ReadCloser, error)

GetTarget returns a reader for the desired target or an error. N.B. The caller is responsible for closing the reader.

func (HTTPStore) SetMeta

func (s HTTPStore) SetMeta(name string, blob []byte) error

SetMeta uploads a piece of TUF metadata to the server

func (HTTPStore) SetMultiMeta

func (s HTTPStore) SetMultiMeta(metas map[string][]byte) error

SetMultiMeta does a single batch upload of multiple pieces of TUF metadata. This should be preferred for updating a remote server as it enable the server to remain consistent, either accepting or rejecting the complete update.

type LocalStore

type LocalStore interface {
	MetadataStore
	TargetStore
}

LocalStore represents a local TUF sture

type MetadataStore

type MetadataStore interface {
	GetMeta(name string, size int64) ([]byte, error)
	SetMeta(name string, blob []byte) error
	SetMultiMeta(map[string][]byte) error
}

MetadataStore must be implemented by anything that intends to interact with a store of TUF files

type PublicKeyStore

type PublicKeyStore interface {
	GetKey(role string) ([]byte, error)
}

PublicKeyStore must be implemented by a key service

type RemoteStore

type RemoteStore interface {
	MetadataStore
	PublicKeyStore
	GetTarget(path string) (io.ReadCloser, error)
}

RemoteStore is similar to LocalStore with the added expectation that it should provide a way to download targets once located

func NewHTTPStore

func NewHTTPStore(baseURL, metaPrefix, metaExtension, targetsPrefix, keyExtension string, roundTrip http.RoundTripper) (RemoteStore, error)

NewHTTPStore initializes a new store against a URL and a number of configuration options

func NewMemoryStore

func NewMemoryStore(meta map[string][]byte, files map[string][]byte) RemoteStore

NewMemoryStore returns a MetadataStore that operates entirely in memory. Very useful for testing

type TargetStore

type TargetStore interface {
	WalkStagedTargets(paths []string, targetsFn targetsWalkFunc) error
}

TargetStore represents a collection of targets that can be walked similarly to walking a directory, passing a callback that receives the path and meta for each target

Jump to

Keyboard shortcuts

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