go-tuf icon indicating copy to clipboard operation
go-tuf copied to clipboard

Improve API for setting metadata version of delegated roles

Open joshuagl opened this issue 3 years ago • 4 comments

The repo API includes functions for setting the version () of top-level metadata through:

func (r *Repo) SetTimestampVersion(v int64) error {}
func (r *Repo) SetRootVersion(v int64) error {}
func (r *Repo) SetTargetsVersion(v int64) error {}
func (r *Repo) SetSnapshotVersion(v int64) error {}
func (r *Repo) SetTimestampVersion(v int64) error {}

However, we do not yet provide any API for modifying the version of delegated targets roles. This absence of API results in go-tuf users having to implement functions which modify the version number in a file IFF that file isn't a top-level role, for example: https://github.com/sigstore/root-signing/pull/417

We should provide a function to set the version number in a delegated targets role metadata, something like:

func (r *Repo) SetDelegatedTargetsVersion(metaName string, v int64) error {}

joshuagl avatar Sep 30 '22 09:09 joshuagl

Related: https://github.com/theupdateframework/go-tuf/issues/330

znewman01 avatar Sep 30 '22 11:09 znewman01

How related do you think this is to a sign command that updates the expiration and therefore the version?

That's the main use-case for this command: a metadata refresh near expiration.

asraa avatar Sep 30 '22 15:09 asraa

I'm mostly referring to:

I think we should have separate UpdateDelegatedRole... functions for modification.

Originally posted by @ethan-lowman-dd in https://github.com/theupdateframework/go-tuf/issues/330#issuecomment-1170077905

I think it's worth considering any proposed changes to the interface for interacting with delegations together.

znewman01 avatar Sep 30 '22 15:09 znewman01

I think we should have separate UpdateDelegatedRole... functions for modification.

I think versions & expiration are separate from properties of delegated roles: I think I wouldn't use UpdateDelegatedRole to a new version, but I might change the role prpoerties itself. Versions and expirations are properties of refreshing or updating all types of metadata, which is why I see them as different

:/ Ahhhhh how I wish there were repository API models!

asraa avatar Sep 30 '22 16:09 asraa

Closing since the code base changed and this is no longer valid.

Thanks for raising this 👍

rdimitrov avatar Jan 31 '24 21:01 rdimitrov