Documentation ¶
Index ¶
- Variables
- func CreateKey() (*ed25519.PublicKey, *ed25519.PrivateKey, *signature.Signer)
- func GetRootBytes(localMetadataDir string) ([]byte, error)
- func InitLocalEnv() error
- func IsWindowsPath(path string) bool
- func RepositoryCleanup(tmpDir string)
- type FTMetadata
- type FTTargets
- type FetchTracker
- type RepositorySimulator
- func (rs *RepositorySimulator) AddDelegation(delegatorName string, role metadata.DelegatedRole, ...)
- func (rs *RepositorySimulator) AddSigner(role string, keyID string, signer signature.Signer)
- func (rs *RepositorySimulator) AddSuccinctRoles(delegatorName string, bitLength int, namePrefix string)
- func (rs *RepositorySimulator) AddTarget(role string, data []byte, path string)
- func (rs *RepositorySimulator) AllTargets() <-chan metadata.TargetsType
- func (rs *RepositorySimulator) DownloadFile(urlPath string, maxLength int64, timeout time.Duration) ([]byte, error)
- func (rs *RepositorySimulator) FetchMetadata(role string, version *int) ([]byte, error)
- func (rs *RepositorySimulator) FetchTarget(targetPath string, targetHash string) ([]byte, error)
- func (rs *RepositorySimulator) PublishRoot()
- func (rs *RepositorySimulator) Root() metadata.RootType
- func (rs *RepositorySimulator) RotateKeys(role string)
- func (rs *RepositorySimulator) Snapshot() metadata.SnapshotType
- func (rs *RepositorySimulator) Targets() metadata.TargetsType
- func (rs *RepositorySimulator) Timestamp() metadata.TimestampType
- func (rs *RepositorySimulator) UpdateSnapshot()
- func (rs *RepositorySimulator) UpdateTimestamp()
- func (rs *RepositorySimulator) Write()
- type RepositoryTarget
Constants ¶
This section is empty.
Variables ¶
var ( MetadataURL = "https://jku.github.io/tuf-demo/metadata" TargetsURL = "https://jku.github.io/tuf-demo/targets" MetadataDir string RootBytes []byte PastDateTime time.Time Sim *RepositorySimulator LocalDir string DumpDir string )
var SPEC_VER = "." + metadata.SPECIFICATION_VERSION
Functions ¶
func GetRootBytes ¶
func InitLocalEnv ¶
func InitLocalEnv() error
func IsWindowsPath ¶
func RepositoryCleanup ¶
func RepositoryCleanup(tmpDir string)
Types ¶
type FTMetadata ¶
type FetchTracker ¶
type FetchTracker struct { Metadata []FTMetadata Targets []FTTargets }
FetchTracker contains actual target data and the related target metadata
type RepositorySimulator ¶
type RepositorySimulator struct { fetcher.Fetcher MDDelegates map[string]metadata.Metadata[metadata.TargetsType] SignedRoots [][]byte Signers map[string]map[string]*signature.Signer TargetFiles map[string]RepositoryTarget ComputeMetafileHashesAndLength bool PrefixTargetsWithHash bool DumpDir string DumpVersion int64 FetchTracker FetchTracker SafeExpiry time.Time MDTargets *metadata.Metadata[metadata.TargetsType] MDSnapshot *metadata.Metadata[metadata.SnapshotType] MDTimestamp *metadata.Metadata[metadata.TimestampType] MDRoot *metadata.Metadata[metadata.RootType] LocalDir string }
RepositorySimulator simulates a repository that can be used for testing
func InitMetadataDir ¶
func InitMetadataDir() (*RepositorySimulator, string, string, error)
func NewRepository ¶
func NewRepository() *RepositorySimulator
New initializes a RepositorySimulator
func (*RepositorySimulator) AddDelegation ¶
func (rs *RepositorySimulator) AddDelegation(delegatorName string, role metadata.DelegatedRole, targets metadata.TargetsType)
AddDelegation adds delegated target role to the repository
func (*RepositorySimulator) AddSigner ¶
func (rs *RepositorySimulator) AddSigner(role string, keyID string, signer signature.Signer)
func (*RepositorySimulator) AddSuccinctRoles ¶
func (rs *RepositorySimulator) AddSuccinctRoles(delegatorName string, bitLength int, namePrefix string)
AddSuccinctRoles adds succinct roles info to a delegator with name "delegatorName".
Note that for each delegated role represented by succinct roles an empty Targets instance is created
func (*RepositorySimulator) AddTarget ¶
func (rs *RepositorySimulator) AddTarget(role string, data []byte, path string)
AddTarget creates a target from data and adds it to the TargetFiles.
func (*RepositorySimulator) AllTargets ¶
func (rs *RepositorySimulator) AllTargets() <-chan metadata.TargetsType
AllTargets allows receiving role name and signed portion of targets one by one
func (*RepositorySimulator) DownloadFile ¶
func (*RepositorySimulator) FetchMetadata ¶
func (rs *RepositorySimulator) FetchMetadata(role string, version *int) ([]byte, error)
FetchMetadata returns signed metadata for 'role', using 'version' if it is given. If version is None, non-versioned metadata is being requested
func (*RepositorySimulator) FetchTarget ¶
func (rs *RepositorySimulator) FetchTarget(targetPath string, targetHash string) ([]byte, error)
FetchTarget returns data for 'targetPath', checking 'targetHash' if it is given. If hash is None, then consistentSnapshot is not used
func (*RepositorySimulator) PublishRoot ¶
func (rs *RepositorySimulator) PublishRoot()
PublishRoot signs and stores a new serialized version of root
func (*RepositorySimulator) Root ¶
func (rs *RepositorySimulator) Root() metadata.RootType
func (*RepositorySimulator) RotateKeys ¶
func (rs *RepositorySimulator) RotateKeys(role string)
RotateKeys removes all keys for role, then add threshold of new keys
func (*RepositorySimulator) Snapshot ¶
func (rs *RepositorySimulator) Snapshot() metadata.SnapshotType
func (*RepositorySimulator) Targets ¶
func (rs *RepositorySimulator) Targets() metadata.TargetsType
func (*RepositorySimulator) Timestamp ¶
func (rs *RepositorySimulator) Timestamp() metadata.TimestampType
func (*RepositorySimulator) UpdateSnapshot ¶
func (rs *RepositorySimulator) UpdateSnapshot()
UpdateSnapshot updates snapshot, assigns targets versions and updates timestamp
func (*RepositorySimulator) UpdateTimestamp ¶
func (rs *RepositorySimulator) UpdateTimestamp()
UpdateTimestamp updates timestamp and assign snapshot version to snapshot meta version
func (*RepositorySimulator) Write ¶
func (rs *RepositorySimulator) Write()
This is a debugging tool: dumping repository state before running Updater refresh may be useful while debugging a test.
type RepositoryTarget ¶
type RepositoryTarget struct { Data []byte TargetFile *metadata.TargetFiles }
RepositoryTarget contains actual target data and the related target metadata