Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegations: Unable to modify properties of a delegated role #330

Closed
asraa opened this issue Jun 29, 2022 · 2 comments
Closed

Delegations: Unable to modify properties of a delegated role #330

asraa opened this issue Jun 29, 2022 · 2 comments
Milestone

Comments

@asraa
Copy link
Contributor

asraa commented Jun 29, 2022

If a user adds a delegation with a repeated name, but with different properties (e.g. Updates it), then it will catch on this error:

go-tuf/repo.go

Lines 559 to 563 in 355e39c

for _, r := range t.Delegations.Roles {
if r.Name == delegatedRole.Name {
return fmt.Errorf("role: %s is already delegated to by %s", delegatedRole.Name, r.Name)
}
}

@ethan-lowman-dd WDYT?

@ethan-lowman-dd
Copy link
Contributor

A workaround is to call ResetTargetsDelegations and add back all delegations in the desired new state. You can see an example here https://github.com/theupdateframework/go-tuf/blob/9a41055/repo_test.go#L2158.

It would indeed be nice to have a new API for modifying though.

The spec says

The rolename MUST be unique in the delegations object: multiple roles with the same rolename are not allowed within a DELEGATIONS.
(ref)

and I think enforcing this in AddDelegatedRoleWithExpires with an error is clearer than implicitly updating. I think we should have separate UpdateDelegatedRole... functions for modification.

@rdimitrov
Copy link
Contributor

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

Thanks for raising this 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants