Skip to content

Metadata API: Make Role.keyids ordered #1754

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

Merged
merged 1 commit into from
Jan 11, 2022

Conversation

jku
Copy link
Member

@jku jku commented Jan 5, 2022

keyids are ordered in the data we deserialize: Not preserving that order
breaks canonicalization. Set does not preserve order.

Change Role.keyids type from Set to List. This is strictly speaking
an API change but a minor one: keyids are supposed to be changed
via add_key()/remove_key().

Add tests for this for both Role and DelegatedRole. Shorten a related
exception message.

Fix #1752

Signed-off-by: Jussi Kukkonen [email protected]


Please verify and check that the pull request fulfills the following
requirements
:

@jku
Copy link
Member Author

jku commented Jan 5, 2022

This modifies test_update_root_new_root_fail_threshold_verification() which seems broken to me: I left that for #1753

@coveralls
Copy link

coveralls commented Jan 5, 2022

Pull Request Test Coverage Report for Build 1657734798

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.0%) to 98.73%

Totals Coverage Status
Change from base Build 1611151931: 1.0%
Covered Lines: 3934
Relevant Lines: 3955

💛 - Coveralls

Copy link
Collaborator

@MVrachev MVrachev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me with only one minor detail that should be fixed.

keyids are ordered in the data we deserialize: Not preserving that order
breaks canonicalization. Set does not preserve order.

Change Role.keyids type from Set to List. This is strictly speaking
an API change but a minor one: keyids are supposed to be changed
via add_key()/remove_key().

Add tests for this for both Role and DelegatedRole. Shorten a related
exception message.

Fix theupdateframework#1752

Signed-off-by: Jussi Kukkonen <[email protected]>
@jku jku force-pushed the role-keyids-order-fix branch from 85ca3c2 to 80d3fcf Compare January 5, 2022 12:28
@jku
Copy link
Member Author

jku commented Jan 5, 2022

focre-pushed: Only change is a string marked as f-string

Copy link
Member

@joshuagl joshuagl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant, thanks!

f" instead got {keyids}"
)
if len(set(keyids)) != len(keyids):
raise ValueError(f"Nonunique keyids: {keyids}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit, feel free to ignore

Suggested change
raise ValueError(f"Nonunique keyids: {keyids}")
raise ValueError(f"Non-unique keyids: {keyids}")

@ivanayov
Copy link
Collaborator

ivanayov commented Jan 6, 2022

Looks good to me.

Copy link
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM! @jku, will you s/nonunique/non-unique? Let's merge otherwise!

@jku
Copy link
Member Author

jku commented Jan 11, 2022

I will live with nonunique since there's no other changes...

@jku jku merged commit 5809ec5 into theupdateframework:develop Jan 11, 2022
@jku jku deleted the role-keyids-order-fix branch December 30, 2024 09:11
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

Successfully merging this pull request may close these issues.

role keyids still not ordered
6 participants