tuf

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTargetsNotEmpty = errors.New("`targets` field in gittuf Targets metadata must be empty")
)

Functions

This section is empty.

Types

type Delegation

type Delegation struct {
	Name        string           `json:"name"`
	Paths       []string         `json:"paths"`
	Terminating bool             `json:"terminating"`
	Custom      *json.RawMessage `json:"custom,omitempty"`
	Role
}

Delegation defines the schema for a single delegation entry. It differs from the standard TUF schema by allowing a `custom` field to record details pertaining to the delegation.

func (*Delegation) Matches

func (d *Delegation) Matches(target string) bool

Matches checks if any of the delegation's patterns match the target.

type Delegations

type Delegations struct {
	Keys  map[string]*Key `json:"keys"`
	Roles []Delegation    `json:"roles"`
}

Delegations defines the schema for specifying delegations in TUF's Targets metadata.

func (*Delegations) AddDelegation

func (d *Delegations) AddDelegation(delegation Delegation)

AddDelegation adds a new delegation.

func (*Delegations) AddKey

func (d *Delegations) AddKey(key *Key)

AddKey adds a delegations key.

type Key

Key defines the structure for how public keys are stored in TUF metadata.

func LoadKeyFromBytes

func LoadKeyFromBytes(contents []byte) (*Key, error)

LoadKeyFromBytes returns a pointer to a Key instance created from the contents of the bytes. The key contents are expected to be in the custom securesystemslib format.

type Role

type Role struct {
	KeyIDs    []string `json:"keyids"`
	Threshold int      `json:"threshold"`
}

Role records common characteristics recorded in a role entry in Root metadata and in a delegation entry.

type RootMetadata

type RootMetadata struct {
	Type               string          `json:"type"`
	SpecVersion        string          `json:"spec_version"`
	ConsistentSnapshot bool            `json:"consistent_snapshot"` // TODO: how do we handle this?
	Version            int             `json:"version"`
	Expires            string          `json:"expires"`
	Keys               map[string]*Key `json:"keys"`
	Roles              map[string]Role `json:"roles"`
}

RootMetadata defines the schema of TUF's Root role.

func NewRootMetadata

func NewRootMetadata() *RootMetadata

NewRootMetadata returns a new instance of RootMetadata.

func (*RootMetadata) AddKey

func (r *RootMetadata) AddKey(key *Key)

AddKey adds a key to the RootMetadata instance.

func (*RootMetadata) AddRole

func (r *RootMetadata) AddRole(roleName string, role Role)

AddRole adds a role object and associates it with roleName in the RootMetadata instance.

func (*RootMetadata) SetExpires

func (r *RootMetadata) SetExpires(expires string)

SetExpires sets the expiry date of the RootMetadata to the value passed in.

func (*RootMetadata) SetVersion

func (r *RootMetadata) SetVersion(version int)

SetVersion sets the version of the RootMetadata to the value passed in.

type TargetsMetadata

type TargetsMetadata struct {
	Type        string         `json:"type"`
	SpecVersion string         `json:"spec_version"`
	Version     int            `json:"version"`
	Expires     string         `json:"expires"`
	Targets     map[string]any `json:"targets"`
	Delegations *Delegations   `json:"delegations"`
}

TargetsMetadata defines the schema of TUF's Targets role.

func NewTargetsMetadata

func NewTargetsMetadata() *TargetsMetadata

NewTargetsMetadata returns a new instance of TargetsMetadata.

func (*TargetsMetadata) SetExpires

func (t *TargetsMetadata) SetExpires(expires string)

SetExpires sets the expiry date of the TargetsMetadata to the value passed in.

func (*TargetsMetadata) SetVersion

func (t *TargetsMetadata) SetVersion(version int)

SetVersion sets the version of the TargetsMetadata to the value passed in.

func (*TargetsMetadata) Validate

func (t *TargetsMetadata) Validate() error

Validate ensures the instance of TargetsMetadata matches gittuf expectations.

Jump to

Keyboard shortcuts

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