Skip to content

Use []byte instead of string for BootstrapToken protobuf#782

Merged
jessepeterson merged 1 commit intomicromdm:mainfrom
korylprince:fix-bootstrap-bytes
Oct 6, 2021
Merged

Use []byte instead of string for BootstrapToken protobuf#782
jessepeterson merged 1 commit intomicromdm:mainfrom
korylprince:fix-bootstrap-bytes

Conversation

@korylprince
Copy link
Contributor

This fixes issues that occur when rebasing #773 onto current main. Storing non-UTF-8 characters in a protobuf string doesn't cause issues for the version of protoc-gen-go currently used for device.proto in main, but it does cause this issue with the updated version used for #773.

This PR just changes the BootstrapToken to be stored as a []byte, and removes any string/[]byte conversions like @jessepeterson and I had discussed on #781.

I've tested this and verified functionality is the same as #781 (profiles install, validate).

I've also tested that rebasing #773 on top of this PR doesn't have this issue. (That's the only testing I've done on #773 so far.)

Also, as an aside, Device.Token and Device.UnlockToken are also stored as strings in the protobuf, but they're encoded to hex first. Maybe this issue is why...

@jessepeterson
Copy link
Member

It looks like the underlying type is still a string? I vote that we do one of two things: we convert the protobuf type to a bytes type (over a string) or we encode (hex/b64/whatever) the value like we do with Device.Token and Device.UnlockToken (as you noted). Thoughts?

@korylprince
Copy link
Contributor Author

korylprince commented Oct 6, 2021

This PR does change device.proto to usebytes for the bootstrap token and changes the bootstrap token code everywhere else to remove all of the []byte/string conversions.

I'm 90% sure I fixed all of the conversions, but if you're seeing something in particular, can you put a comment on the line?

@jessepeterson
Copy link
Member

lol. I'm apparently blind, yes, yes indeed your change makes it a binary field, heh. If this were already a release or something I might suggest we change the id number to 31, but it's unlikely anybody is pulling in main branch changes to production this soon after the PR landed yesterday.

@korylprince
Copy link
Contributor Author

I can make that change if you want, just let me know. In practice, protos generated when it was a string still read correctly with the new code. Just let me know and I can add a commit to the PR.

Copy link
Member

@jessepeterson jessepeterson left a comment

Choose a reason for hiding this comment

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

lgtm!

@jessepeterson jessepeterson merged commit 804b439 into micromdm:main Oct 6, 2021
@korylprince korylprince deleted the fix-bootstrap-bytes branch October 6, 2021 20:02
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.

2 participants