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

Jose unable to parse setting containing an array #68

Closed
dnoliver opened this issue Jun 5, 2019 · 2 comments
Closed

Jose unable to parse setting containing an array #68

dnoliver opened this issue Jun 5, 2019 · 2 comments

Comments

@dnoliver
Copy link

dnoliver commented Jun 5, 2019

Discovered in latchset/clevis#102

Clevis is failing to create a TPM PCR Policy to enforce platform integrity state through Jose when the number of selected pcrs_ids is more than one, and an array is passed to the configuration.

From @martinezjavier comment:

$ jose fmt -j- -Og pcr_ids -u- <<< '{"pcr_bank":"sha1","pcr_ids":"16"}'
16
$ echo $?
0

$ jose fmt -j- -Og pcr_ids -u- <<< '{"pcr_bank":"sha1","pcr_ids":["16"]}'
$ echo $?
4

Apparently, Jose is not happy with the array notation in pcrs_ids.
Due to this, on Clevis, when using more than one PCR to declare the policy, it silently fails to parse the config, and create the LUKS key slot without any PCR policy silently

Jose Version: jose-10-3.fc29.x86_64

@dnoliver dnoliver changed the title Jose unable to parse {"pcr_bank":"sha1","pcr_ids":["16"]} setting Jose unable to parse setting containing an array Jun 5, 2019
@sergio-correia
Copy link
Collaborator

I am not sure this is an actual bug in jose. jose-fmt man page for -u option is as follows: Write TOP (str.) to STDOUT without quotes.

However we are now trying to use this option against an array. jose does parse it correctly, as we can see if you just change the -u- option to -o-:

$ jose fmt -j- -Og pcr_ids -o- <<< '{"pcr_bank":"sha1","pcr_ids":["16"]}'
["16"]
$ echo $?
0

We can also use -A to check whether jose thinks it is an actual array:

$ jose fmt -j- -Og pcr_ids -A <<< '{"pcr_bank":"sha1","pcr_ids":["16"]}'
$ echo $?
0

@dnoliver
Copy link
Author

dnoliver commented Dec 4, 2019

Agreed, I now think that clevis-encrypt-tpm should be validating that the configuration passed to "pcr_ids" is a string configuration instead of blindly accepting what jose returns in stdout.

As you said, -u expect a string, and it will not magically convert an array of things into a comma separated string.

Thanks! closing

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

2 participants