Documentation ¶
Index ¶
- func AddTarget(role string, r *tuf.Repo) (name string, meta data.FileMeta, content []byte, err error)
- func CopyRepoMetadata(from map[string][]byte) map[string][]byte
- func EmptyRepo(gun string, delegationRoles ...string) (*tuf.Repo, signed.CryptoService, error)
- func FlushDB(db *sql.DB)
- func GetSqliteDB() *sql.DB
- func NewRepoMetadata(gun string, delegationRoles ...string) (map[string][]byte, signed.CryptoService, error)
- func RandomByteSlice(maxSize int) []byte
- func SampleMeta() data.FileMeta
- func Serialize(sRoot, sTargets, sSnapshot, sTimestamp *data.Signed) (root, targets, snapshot, timestamp []byte, err error)
- func Sign(repo *tuf.Repo) (root, targets, snapshot, timestamp *data.Signed, err error)
- type CorruptingMemoryStore
- type ErrNoKeyForRole
- type LongMemoryStore
- type MetadataSwizzler
- func (m *MetadataSwizzler) AddExtraSpace(role string) error
- func (m *MetadataSwizzler) ChangeRootKey() error
- func (m *MetadataSwizzler) ExpireMetadata(role string) error
- func (m *MetadataSwizzler) InvalidateMetadataSignatures(role string) error
- func (m *MetadataSwizzler) MutateRoot(mutate func(*data.Root)) error
- func (m *MetadataSwizzler) MutateSnapshot(mutate func(*data.Snapshot)) error
- func (m *MetadataSwizzler) MutateTargets(mutate func(*data.Targets)) error
- func (m *MetadataSwizzler) MutateTimestamp(mutate func(*data.Timestamp)) error
- func (m *MetadataSwizzler) OffsetMetadataVersion(role string, offset int) error
- func (m *MetadataSwizzler) RemoveMetadata(role string) error
- func (m *MetadataSwizzler) SetInvalidJSON(role string) error
- func (m *MetadataSwizzler) SetInvalidMetadataType(role string) error
- func (m *MetadataSwizzler) SetInvalidSigned(role string) error
- func (m *MetadataSwizzler) SetInvalidSignedMeta(role string) error
- func (m *MetadataSwizzler) SetThreshold(role string, newThreshold int) error
- func (m *MetadataSwizzler) SignMetadataWithInvalidKey(role string) error
- func (m *MetadataSwizzler) UpdateSnapshotHashes(roles ...string) error
- func (m *MetadataSwizzler) UpdateTimestampHash() error
- type ShortMemoryStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddTarget ¶
func AddTarget(role string, r *tuf.Repo) (name string, meta data.FileMeta, content []byte, err error)
AddTarget generates a fake target and adds it to a repo.
func CopyRepoMetadata ¶
CopyRepoMetadata makes a copy of a metadata->bytes mapping
func EmptyRepo ¶
EmptyRepo creates an in memory crypto service and initializes a repo with no targets. Delegations are only created if delegation roles are passed in.
func NewRepoMetadata ¶
func NewRepoMetadata(gun string, delegationRoles ...string) (map[string][]byte, signed.CryptoService, error)
NewRepoMetadata creates a TUF repo and returns the metadata
func RandomByteSlice ¶
RandomByteSlice generates some random data to be used for testing only
func SampleMeta ¶
SampleMeta returns a static, fake (and invalid) FileMeta object
Types ¶
type CorruptingMemoryStore ¶
type CorruptingMemoryStore struct {
store.MemoryStore
}
CorruptingMemoryStore corrupts all data returned by GetMeta
func NewCorruptingMemoryStore ¶
func NewCorruptingMemoryStore(meta map[string][]byte) *CorruptingMemoryStore
NewCorruptingMemoryStore returns a new instance of memory store that corrupts all data requested from it.
type ErrNoKeyForRole ¶
type ErrNoKeyForRole struct {
Role string
}
ErrNoKeyForRole returns an error when the cryptoservice provided to MetadataSwizzler has no key for a particular role
func (ErrNoKeyForRole) Error ¶
func (e ErrNoKeyForRole) Error() string
type LongMemoryStore ¶
type LongMemoryStore struct {
store.MemoryStore
}
LongMemoryStore corrupts all data returned by GetMeta
func NewLongMemoryStore ¶
func NewLongMemoryStore(meta map[string][]byte) *LongMemoryStore
NewLongMemoryStore returns a new instance of memory store that returns one byte too much data on any request to GetMeta
type MetadataSwizzler ¶
type MetadataSwizzler struct { Gun string MetadataCache store.MetadataStore CryptoService signed.CryptoService Roles []string // list of Roles in the metadataStore }
MetadataSwizzler fuzzes the metadata in a MetadataStore
func NewMetadataSwizzler ¶
func NewMetadataSwizzler(gun string, initialMetadata map[string][]byte, cryptoService signed.CryptoService) *MetadataSwizzler
NewMetadataSwizzler returns a new swizzler when given a gun, mapping of roles to initial metadata bytes, and a cryptoservice
func (*MetadataSwizzler) AddExtraSpace ¶
func (m *MetadataSwizzler) AddExtraSpace(role string) error
AddExtraSpace adds an extra space to the beginning and end of the serialized JSON bytes, which should not affect serialization, but will change the checksum of the file.
func (*MetadataSwizzler) ChangeRootKey ¶
func (m *MetadataSwizzler) ChangeRootKey() error
ChangeRootKey swaps out the root key with a new key, and re-signs the metadata with the new key
func (*MetadataSwizzler) ExpireMetadata ¶
func (m *MetadataSwizzler) ExpireMetadata(role string) error
ExpireMetadata expires the metadata, which would make it invalid - don't do anything if we don't have the timestamp key
func (*MetadataSwizzler) InvalidateMetadataSignatures ¶
func (m *MetadataSwizzler) InvalidateMetadataSignatures(role string) error
InvalidateMetadataSignatures signs with the right key(s) but wrong hash
func (*MetadataSwizzler) MutateRoot ¶
func (m *MetadataSwizzler) MutateRoot(mutate func(*data.Root)) error
MutateRoot takes a function that mutates the root metadata - once done, it serializes the root again
func (*MetadataSwizzler) MutateSnapshot ¶
func (m *MetadataSwizzler) MutateSnapshot(mutate func(*data.Snapshot)) error
MutateSnapshot takes a function that mutates the snapshot metadata - once done, it serializes the snapshot again
func (*MetadataSwizzler) MutateTargets ¶
func (m *MetadataSwizzler) MutateTargets(mutate func(*data.Targets)) error
MutateTargets takes a function that mutates the targets metadata - once done, it serializes the targets again
func (*MetadataSwizzler) MutateTimestamp ¶
func (m *MetadataSwizzler) MutateTimestamp(mutate func(*data.Timestamp)) error
MutateTimestamp takes a function that mutates the timestamp metadata - once done, it serializes the timestamp again
func (*MetadataSwizzler) OffsetMetadataVersion ¶
func (m *MetadataSwizzler) OffsetMetadataVersion(role string, offset int) error
OffsetMetadataVersion updates the metadata version
func (*MetadataSwizzler) RemoveMetadata ¶
func (m *MetadataSwizzler) RemoveMetadata(role string) error
RemoveMetadata deletes the metadata entirely
func (*MetadataSwizzler) SetInvalidJSON ¶
func (m *MetadataSwizzler) SetInvalidJSON(role string) error
SetInvalidJSON corrupts metadata into something that is no longer valid JSON
func (*MetadataSwizzler) SetInvalidMetadataType ¶
func (m *MetadataSwizzler) SetInvalidMetadataType(role string) error
SetInvalidMetadataType unmarshallable, but has the wrong metadata type (not actually a metadata type)
func (*MetadataSwizzler) SetInvalidSigned ¶
func (m *MetadataSwizzler) SetInvalidSigned(role string) error
SetInvalidSigned corrupts the metadata into something that is valid JSON, but not unmarshallable into signed JSON
func (*MetadataSwizzler) SetInvalidSignedMeta ¶
func (m *MetadataSwizzler) SetInvalidSignedMeta(role string) error
SetInvalidSignedMeta corrupts the metadata into something that is unmarshallable as a Signed object, but not unmarshallable into a SignedMeta object
func (*MetadataSwizzler) SetThreshold ¶
func (m *MetadataSwizzler) SetThreshold(role string, newThreshold int) error
SetThreshold sets a threshold for a metadata role - can invalidate metadata for which the threshold is increased, if there aren't enough signatures or can be invalid because the threshold is 0
func (*MetadataSwizzler) SignMetadataWithInvalidKey ¶
func (m *MetadataSwizzler) SignMetadataWithInvalidKey(role string) error
SignMetadataWithInvalidKey signs the metadata with the wrong key
func (*MetadataSwizzler) UpdateSnapshotHashes ¶
func (m *MetadataSwizzler) UpdateSnapshotHashes(roles ...string) error
UpdateSnapshotHashes updates the snapshot to reflect the latest hash changes, to ensure that failure isn't because the snapshot has the wrong hash.
func (*MetadataSwizzler) UpdateTimestampHash ¶
func (m *MetadataSwizzler) UpdateTimestampHash() error
UpdateTimestampHash updates the timestamp to reflect the latest snapshot changes, to ensure that failure isn't because the timestamp has the wrong hash.
type ShortMemoryStore ¶
type ShortMemoryStore struct {
store.MemoryStore
}
ShortMemoryStore corrupts all data returned by GetMeta
func NewShortMemoryStore ¶
func NewShortMemoryStore(meta map[string][]byte) *ShortMemoryStore
NewShortMemoryStore returns a new instance of memory store that returns one byte too little data on any request to GetMeta