notary: github.com/theupdateframework/notary/storage Index | Files | Directories

package storage

import "github.com/theupdateframework/notary/storage"

Index

Package Files

errors.go filestore.go httpstore.go interfaces.go memorystore.go offlinestore.go

Constants

const (
    // MaxErrorResponseSize is the maximum size for an error message - 1KiB
    MaxErrorResponseSize int64 = 1 << 10
    // MaxKeySize is the maximum size for a stored TUF key - 256KiB
    MaxKeySize = 256 << 10
)
const NoSizeLimit int64 = -1

NoSizeLimit is represented as -1 for arguments to GetMeta

Variables

var (
    // ErrPathOutsideStore indicates that the returned path would be
    // outside the store
    ErrPathOutsideStore = errors.New("path outside file store")
)

func NewMultiPartMetaRequest Uses

func NewMultiPartMetaRequest(url string, metas map[string][]byte) (*http.Request, error)

NewMultiPartMetaRequest builds a request with the provided metadata updates in multipart form

type Bootstrapper Uses

type Bootstrapper interface {
    // Bootstrap instructs a configured Bootstrapper to perform
    // its setup operations.
    Bootstrap() error
}

Bootstrapper is a thing that can set itself up

type ErrInvalidOperation Uses

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

ErrInvalidOperation indicates that the server returned a 400 response and propagate any body we received.

func (ErrInvalidOperation) Error Uses

func (err ErrInvalidOperation) Error() string

type ErrMaliciousServer Uses

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 Uses

func (err ErrMaliciousServer) Error() string

type ErrMetaNotFound Uses

type ErrMetaNotFound struct {
    Resource string
}

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

func (ErrMetaNotFound) Error Uses

func (err ErrMetaNotFound) Error() string

type ErrOffline Uses

type ErrOffline struct{}

ErrOffline is used to indicate we are operating offline

func (ErrOffline) Error Uses

func (e ErrOffline) Error() string

type ErrServerUnavailable Uses

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 Uses

func (err ErrServerUnavailable) Error() string

type FilesystemStore Uses

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

FilesystemStore is a store in a locally accessible directory

func NewFileStore Uses

func NewFileStore(baseDir, fileExt string) (*FilesystemStore, error)

NewFileStore creates a fully configurable file store

func NewPrivateKeyFileStorage Uses

func NewPrivateKeyFileStorage(baseDir, fileExt string) (*FilesystemStore, error)

NewPrivateKeyFileStorage initializes a new filestore for private keys, appending the notary.PrivDir to the baseDir.

func NewPrivateSimpleFileStore Uses

func NewPrivateSimpleFileStore(baseDir, fileExt string) (*FilesystemStore, error)

NewPrivateSimpleFileStore is a wrapper to create an owner readable/writeable _only_ filestore

func (*FilesystemStore) Get Uses

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

Get returns the meta for the given name.

func (*FilesystemStore) GetSized Uses

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

GetSized returns the meta for the given name (a role) up to size bytes If size is "NoSizeLimit", this corresponds to "infinite," but we cut off at a predefined threshold "notary.MaxDownloadSize". If the file is larger than size we return ErrMaliciousServer for consistency with the HTTPStore

func (FilesystemStore) ListFiles Uses

func (f FilesystemStore) ListFiles() []string

ListFiles returns a list of all the filenames that can be used with Get* to retrieve content from this filestore

func (FilesystemStore) Location Uses

func (f FilesystemStore) Location() string

Location returns a human readable name for the storage location

func (*FilesystemStore) Remove Uses

func (f *FilesystemStore) Remove(name string) error

Remove removes the metadata for a single role - if the metadata doesn't exist, no error is returned

func (*FilesystemStore) RemoveAll Uses

func (f *FilesystemStore) RemoveAll() error

RemoveAll clears the existing filestore by removing its base directory

func (*FilesystemStore) Set Uses

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

Set sets the meta for a single role

func (*FilesystemStore) SetMulti Uses

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

SetMulti sets the metadata for multiple roles in one operation

type HTTPStore Uses

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 Uses

func (s HTTPStore) GetKey(role data.RoleName) ([]byte, error)

GetKey retrieves a public key from the remote server

func (HTTPStore) GetSized Uses

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

GetSized 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. If size is "NoSizeLimit", this corresponds to "infinite," but we cut off at a predefined threshold "notary.MaxDownloadSize".

func (HTTPStore) Location Uses

func (s HTTPStore) Location() string

Location returns a human readable name for the storage location

func (HTTPStore) Remove Uses

func (s HTTPStore) Remove(name string) error

Remove always fails, because we should never be able to delete metadata remotely

func (HTTPStore) RemoveAll Uses

func (s HTTPStore) RemoveAll() error

RemoveAll will attempt to delete all TUF metadata for a GUN

func (HTTPStore) RotateKey Uses

func (s HTTPStore) RotateKey(role data.RoleName) ([]byte, error)

RotateKey rotates a private key and returns the public component from the remote server

func (HTTPStore) Set Uses

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

Set sends a single piece of metadata to the TUF server

func (HTTPStore) SetMulti Uses

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

SetMulti 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 MemoryStore Uses

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

MemoryStore implements a mock RemoteStore entirely in memory. For testing purposes only.

func NewMemoryStore Uses

func NewMemoryStore(seed map[data.RoleName][]byte) *MemoryStore

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

func (MemoryStore) Get Uses

func (m MemoryStore) Get(name string) ([]byte, error)

Get returns the data associated with name

func (MemoryStore) GetSized Uses

func (m MemoryStore) GetSized(name string, size int64) ([]byte, error)

GetSized returns up to size bytes of data references by name. If size is "NoSizeLimit", this corresponds to "infinite," but we cut off at a predefined threshold "notary.MaxDownloadSize", as we will always know the size for everything but a timestamp and sometimes a root, neither of which should be exceptionally large

func (*MemoryStore) ListFiles Uses

func (m *MemoryStore) ListFiles() []string

ListFiles returns a list of all files. The names returned should be usable with Get directly, with no modification.

func (MemoryStore) Location Uses

func (m MemoryStore) Location() string

Location provides a human readable name for the storage location

func (*MemoryStore) Remove Uses

func (m *MemoryStore) Remove(name string) error

Remove removes the metadata for a single role - if the metadata doesn't exist, no error is returned

func (*MemoryStore) RemoveAll Uses

func (m *MemoryStore) RemoveAll() error

RemoveAll clears the existing memory store by setting this store as new empty one

func (*MemoryStore) Set Uses

func (m *MemoryStore) Set(name string, meta []byte) error

Set sets the metadata value for the given name

func (*MemoryStore) SetMulti Uses

func (m *MemoryStore) SetMulti(metas map[string][]byte) error

SetMulti sets multiple pieces of metadata for multiple names in a single operation.

type MetadataStore Uses

type MetadataStore interface {
    GetSized(name string, size int64) ([]byte, error)
    Set(name string, blob []byte) error
    SetMulti(map[string][]byte) error
    RemoveAll() error
    Remove(name string) error
    Location() string
}

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

type NetworkError Uses

type NetworkError struct {
    Wrapped error
}

NetworkError represents any kind of network error when attempting to make a request

func (NetworkError) Error Uses

func (n NetworkError) Error() string

type OfflineStore Uses

type OfflineStore struct{}

OfflineStore is to be used as a placeholder for a nil store. It simply returns ErrOffline for every operation

func (OfflineStore) GetKey Uses

func (es OfflineStore) GetKey(role data.RoleName) ([]byte, error)

GetKey returns ErrOffline

func (OfflineStore) GetSized Uses

func (es OfflineStore) GetSized(name string, size int64) ([]byte, error)

GetSized returns ErrOffline

func (OfflineStore) Location Uses

func (es OfflineStore) Location() string

Location returns a human readable name for the storage location

func (OfflineStore) Remove Uses

func (es OfflineStore) Remove(name string) error

Remove returns ErrOffline

func (OfflineStore) RemoveAll Uses

func (es OfflineStore) RemoveAll() error

RemoveAll return ErrOffline

func (OfflineStore) RotateKey Uses

func (es OfflineStore) RotateKey(role data.RoleName) ([]byte, error)

RotateKey returns ErrOffline

func (OfflineStore) Set Uses

func (es OfflineStore) Set(name string, blob []byte) error

Set returns ErrOffline

func (OfflineStore) SetMulti Uses

func (es OfflineStore) SetMulti(map[string][]byte) error

SetMulti returns ErrOffline

type PublicKeyStore Uses

type PublicKeyStore interface {
    GetKey(role data.RoleName) ([]byte, error)
    RotateKey(role data.RoleName) ([]byte, error)
}

PublicKeyStore must be implemented by a key service

type RemoteStore Uses

type RemoteStore interface {
    MetadataStore
    PublicKeyStore
}

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

func NewHTTPStore Uses

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

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

In case of a nil `roundTrip`, a default offline store is used instead.

func NewNotaryServerStore Uses

func NewNotaryServerStore(serverURL string, gun data.GUN, roundTrip http.RoundTripper) (RemoteStore, error)

NewNotaryServerStore returns a new HTTPStore against a URL which should represent a notary server

Directories

PathSynopsis
rethinkdb

Package storage imports 20 packages (graph) and is imported by 41 packages. Updated 2019-03-31. Refresh now. Tools for package owners.