Skip to content

Commit

Permalink
Pass delegation directly to loadDelegatedTargets
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-lowman-dd committed Mar 1, 2022
1 parent d2ae1bc commit bcf8b66
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions client/delegations.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (c *Client) getTargetFileMeta(target string) (data.TargetFileMeta, error) {
}

// covers 5.6.{1,2,3,4,5,6}
targets, err := c.loadDelegatedTargets(snapshot, d.Delegatee.Name, d.DB)
targets, err := c.loadDelegatedTargets(snapshot, d)
if err != nil {
return data.TargetFileMeta{}, err
}
Expand Down Expand Up @@ -79,7 +79,9 @@ func (c *Client) loadLocalSnapshot() (*data.Snapshot, error) {
}

// loadDelegatedTargets downloads, decodes, verifies and stores targets
func (c *Client) loadDelegatedTargets(snapshot *data.Snapshot, role string, db *verify.DB) (*data.Targets, error) {
func (c *Client) loadDelegatedTargets(snapshot *data.Snapshot, delegation targets.Delegation) (*data.Targets, error) {
role := delegation.Delegatee.Name

var err error
fileName := role + ".json"
fileMeta, ok := snapshot.Meta[fileName]
Expand All @@ -102,7 +104,7 @@ func (c *Client) loadDelegatedTargets(snapshot *data.Snapshot, role string, db *
// 5.6.3 verify signature with parent public keys
// 5.6.5 verify that the targets is not expired
// role "targets" is a top role verified by root keys loaded in the client db
err = db.Unmarshal(raw, targets, role, fileMeta.Version)
err = delegation.DB.Unmarshal(raw, targets, role, fileMeta.Version)
if err != nil {
return nil, ErrDecodeFailed{fileName, err}
}
Expand Down

0 comments on commit bcf8b66

Please sign in to comment.