-
Notifications
You must be signed in to change notification settings - Fork 275
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
Metadata API: Accept X.Y spec_version #1796
Metadata API: Accept X.Y spec_version #1796
Conversation
4cd9e15
to
b857a37
Compare
Pull Request Test Coverage Report for Build 1751048969
💛 - Coveralls |
if len(spec_list) not in [2, 3] or not all( | ||
el.isdigit() for el in spec_list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a weird construct but black wants to lay it out this way -- I'll take suggestions to make it clearer though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a better suggestion as well, but it's not so bad.
black splits all
brackets so that we can see clearly what are the arguments which are the complicated part.
coverage claims none of the valueerrors are tested. I'll have to investigate that -- EDIT: done, bug fix commit added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The specification does suggest semver, but also leaves it up to clients to decide what is considered a match.
This seems fine to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I agree with the changes even though it would have been better if the clients and implementations all stick to using all of the numbers in semver
.
if spec_list[0] != SPECIFICATION_VERSION[0]: | ||
raise ValueError(f"Unsupported spec_version {spec_version}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, finally, we don't want to log if there are differences in minor versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could do a debug log I suppose... but realistically a large portion of metadata that is deserialized is likely to not match exactly (think updated clients loading older targets metadata that was created with lower spec_version).
"no spec_version": '{"_type": "snapshot", "version": 1, "expires": "2030-01-01T00:00:00Z", "meta": {}}', | ||
"no version": '{"_type": "snapshot", "spec_version": "1.0.0", "expires": "2030-01-01T00:00:00Z", "meta": {}}', | ||
"no expires": '{"_type": "snapshot", "spec_version": "1.0.0", "version": 1, "meta": {}}', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. The data can even be valid, but because of the _type
, it will fail...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah -- one of those cases where parsing exception messages might have helped... but I'm still not willing to do that amount of work
All TUF implementations used to use "1.0" as the spec version and most of them have never modified that value since. Accept two-part spec_version for legacy compatibility: it is strictly speaking against the current spec (which requires semver) but there should be no harm in doing this and it allows us to deserialize metadata generated by e.g. go-tuf. Fixes theupdateframework#1751 Signed-off-by: Jussi Kukkonen <[email protected]>
Most of the test_invalid_signed_serialization subtests are currently failing because "_type": "signed" and then the test tries to deserialize them as Snapshot (which fails a type check). Correct the type to "snapshot" so that we can fail in the correct places during serialization instead. Signed-off-by: Jussi Kukkonen <[email protected]>
996f477
to
1695622
Compare
force pushed with one change:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patch looks good to me. Also kudos for catching the test bug!
All TUF implementations used to use "1.0" as the spec version and most
of them have never modified that value since.
Accept two-digit spec_version for legacy compatibility: it is strictly
speaking against the current spec (which requires semver) but there
should be no harm in doing this and it allows us to deserialize
metadata generated by e.g. go-tuf.
Fixes #1751
Signed-off-by: Jussi Kukkonen [email protected]
Please verify and check that the pull request fulfills the following
requirements: