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

Switch canonical json #92

Merged
merged 4 commits into from
May 24, 2021

Conversation

carolynvs
Copy link
Contributor

@carolynvs carolynvs commented May 17, 2021

Per CNAB Spec cnabio/cnab-spec#414, we want to support numbers in our canonical json representation.

The library we are currently using, github.com/docker/go/json, does not support this. So I am migrating us to the library mentioned in the spec as being compliant. This is the same library used by cnab-go in cnabio/cnab-go#247.

I was not able to completely remove the import of the old library because TUF uses its RawMessage struct, which is a very simple wrapper around a byte array.

If we are interested we can try to get TUF to use an interface instead of a hard-coded struct type so that we can drop the dependency on the other canonical json library.

@carolynvs carolynvs requested a review from radu-matei May 17, 2021 20:36
@trishankatdatadog
Copy link
Member

Interesting! Let's discuss at the CNAB Security meeting this week please...

@carolynvs
Copy link
Contributor Author

I've added it to Wednesday's agenda.

@radu-matei
Copy link
Member

radu-matei commented May 19, 2021

FYI, the expiration error is now fixed by #91.

Happy to chat about this at the next meeting, but as long as all CNAB tooling has the same serialization rules, it should not affect how we sign and verify bundles, although keep in mind this is a breaking change, i.e. the same bundle could get a different content digest and invalidate the signature.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Per CNAB Spec cnabio/cnab-spec#414, we want to
support numbers in our canonical json representation.

The library we are currently using, github.com/docker/go/json, does not support this.
So I am migrating us to the library mentioned in the spec as being
compliant. This is the same library used by cnab-go.

I was not able to completely remove the import of the old library
because TUF uses its RawMessage struct, which is a very simple wrapper
around a byte array.

If we are intersted we can try to get TUF to use an interface instead
of a hard-coded struct type so that we can drop the
dependency on the other canonical json library.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Rename package to not use an underscore

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
@carolynvs
Copy link
Contributor Author

@trishankatdatadog @radu-matei I've rebased to pick up the fix from main and made the linter happy.

This wasn't necessary like I originally thought since []byte converts
cleanly to RawMessage by the compiler with any extra code.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
@trishankatdatadog trishankatdatadog merged commit 143a4ac into cnabio:main May 24, 2021
@carolynvs carolynvs deleted the switch-canonical-json branch May 24, 2021 21:12
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.

3 participants