Data Bags - Secrets should not be read with IO.read() for Encrytped Data Bags
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 143
- Forks
- 438
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 16
Description
Follow up to thread at https://discourse.chef.io/t/reading-secret-for-encrypted-data-bag/11414/3
According to the data bags documentation, it should be possible to do this:
data_bag_item('bag', 'item', IO.read('secret_file'))
If the secret in the file secret_file contains trailing whitespace (ie. space or even just a simple new line '\n'!), then Chef (at least version 12.21.4 on Ubuntu 16.04) cannot decode. The encrypted data bag has been created like so:
$ knife data bag create my-data-bag secret_item --local-mode --config-option data_bag_path=./data_bags --secret-file ./.data_bags/secret_file
If the secret has been read with Chef::EncryptedDataBagItem.load_secret('secret_file') or IO.read('secret_file').strip, then it's possible for Chef to decode.
Thus: please change the data bags documentation to show only Chef::EncryptedDataBagItem.load_secret('secret_file').
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the data bags documentation section titled “load with recipe DSL,” linked in the issue, and review the example that reads the secret with IO.read(). Update the example to use Chef::EncryptedDataBagItem.load_secret('secret_file'), then verify the documentation no longer recommends IO.read() for encrypted data bag secrets.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100