Documentation ¶
Index ¶
- Constants
- Variables
- func NewMultiPartMetaRequest(url string, metas map[string][]byte) (*http.Request, error)
- type Bootstrapper
- type ErrInvalidOperation
- type ErrMaliciousServer
- type ErrMetaNotFound
- type ErrOffline
- type ErrServerUnavailable
- type FilesystemStore
- func (f *FilesystemStore) Get(name string) ([]byte, error)
- func (f *FilesystemStore) GetSized(name string, size int64) ([]byte, error)
- func (f FilesystemStore) ListFiles() []string
- func (f FilesystemStore) Location() string
- func (f *FilesystemStore) Remove(name string) error
- func (f *FilesystemStore) RemoveAll() error
- func (f *FilesystemStore) Set(name string, meta []byte) error
- func (f *FilesystemStore) SetMulti(metas map[string][]byte) error
- type HTTPStore
- func (s HTTPStore) GetKey(role data.RoleName) ([]byte, error)
- func (s HTTPStore) GetSized(name string, size int64) ([]byte, error)
- func (s HTTPStore) Location() string
- func (s HTTPStore) Remove(name string) error
- func (s HTTPStore) RemoveAll() error
- func (s HTTPStore) RotateKey(role data.RoleName) ([]byte, error)
- func (s HTTPStore) Set(name string, blob []byte) error
- func (s HTTPStore) SetMulti(metas map[string][]byte) error
- type MemoryStore
- func (m MemoryStore) Get(name string) ([]byte, error)
- func (m MemoryStore) GetSized(name string, size int64) ([]byte, error)
- func (m *MemoryStore) ListFiles() []string
- func (m MemoryStore) Location() string
- func (m *MemoryStore) Remove(name string) error
- func (m *MemoryStore) RemoveAll() error
- func (m *MemoryStore) Set(name string, meta []byte) error
- func (m *MemoryStore) SetMulti(metas map[string][]byte) error
- type MetadataStore
- type NetworkError
- type OfflineStore
- func (es OfflineStore) GetKey(role data.RoleName) ([]byte, error)
- func (es OfflineStore) GetSized(name string, size int64) ([]byte, error)
- func (es OfflineStore) Location() string
- func (es OfflineStore) Remove(name string) error
- func (es OfflineStore) RemoveAll() error
- func (es OfflineStore) RotateKey(role data.RoleName) ([]byte, error)
- func (es OfflineStore) Set(name string, blob []byte) error
- func (es OfflineStore) SetMulti(map[string][]byte) error
- type PublicKeyStore
- type RemoteStore
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") )
Functions ¶
Types ¶
type Bootstrapper ¶
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 ¶
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 ¶
func (err ErrInvalidOperation) Error() string
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 {
Resource string
}
ErrMetaNotFound indicates we did not find a particular piece of metadata in the store
func (ErrMetaNotFound) Error ¶
func (err ErrMetaNotFound) Error() string
type ErrOffline ¶
type ErrOffline struct{}
ErrOffline is used to indicate we are operating offline
func (ErrOffline) Error ¶
func (e ErrOffline) 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 NewFileStore ¶
func NewFileStore(baseDir, fileExt string) (*FilesystemStore, error)
NewFileStore creates a fully configurable file store
func NewPrivateKeyFileStorage ¶
func NewPrivateKeyFileStorage(baseDir, fileExt string) (*FilesystemStore, error)
NewPrivateKeyFileStorage initializes a new filestore for private keys, appending the notary.PrivDir to the baseDir.
func NewPrivateSimpleFileStore ¶
func NewPrivateSimpleFileStore(baseDir, fileExt string) (*FilesystemStore, error)
NewPrivateSimpleFileStore is a wrapper to create an owner readable/writeable _only_ filestore
func (*FilesystemStore) Get ¶
func (f *FilesystemStore) Get(name string) ([]byte, error)
Get returns the meta for the given name.
func (*FilesystemStore) GetSized ¶
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 ¶
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 ¶
func (f FilesystemStore) Location() string
Location returns a human readable name for the storage location
func (*FilesystemStore) Remove ¶
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 ¶
func (f *FilesystemStore) RemoveAll() error
RemoveAll clears the existing filestore by removing its base directory
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) GetSized ¶
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) Remove ¶
Remove always fails, because we should never be able to delete metadata remotely
func (HTTPStore) RotateKey ¶
RotateKey rotates a private key and returns the public component from the remote server
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore implements a mock RemoteStore entirely in memory. For testing purposes only.
func NewMemoryStore ¶
func NewMemoryStore(seed map[data.RoleName][]byte) *MemoryStore
NewMemoryStore returns a MetadataStore that operates entirely in memory. Very useful for testing
func (MemoryStore) Get ¶
func (m MemoryStore) Get(name string) ([]byte, error)
Get returns the data associated with name
func (MemoryStore) GetSized ¶
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 ¶
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 ¶
func (m MemoryStore) Location() string
Location provides a human readable name for the storage location
func (*MemoryStore) Remove ¶
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 ¶
func (m *MemoryStore) RemoveAll() error
RemoveAll clears the existing memory store by setting this store as new empty one
type MetadataStore ¶
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 ¶
type NetworkError struct {
Wrapped error
}
NetworkError represents any kind of network error when attempting to make a request
func (NetworkError) Error ¶
func (n NetworkError) Error() string
type OfflineStore ¶
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 ¶
func (es OfflineStore) GetKey(role data.RoleName) ([]byte, error)
GetKey returns ErrOffline
func (OfflineStore) GetSized ¶
func (es OfflineStore) GetSized(name string, size int64) ([]byte, error)
GetSized returns ErrOffline
func (OfflineStore) Location ¶
func (es OfflineStore) Location() string
Location returns a human readable name for the storage location
func (OfflineStore) Remove ¶
func (es OfflineStore) Remove(name string) error
Remove returns ErrOffline
func (OfflineStore) RemoveAll ¶
func (es OfflineStore) RemoveAll() error
RemoveAll return ErrOffline
func (OfflineStore) RotateKey ¶
func (es OfflineStore) RotateKey(role data.RoleName) ([]byte, error)
RotateKey returns ErrOffline
type PublicKeyStore ¶
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 ¶
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 ¶
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 ¶
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