Skip to content

Commit

Permalink
Merge pull request #271 from criteo-forks/explicit_sparse_mode
Browse files Browse the repository at this point in the history
Make sure sparse mode is used on secrets where it is explicit
  • Loading branch information
thommay committed May 15, 2017
2 parents 5044d9a + 8ee25fc commit de4a1f9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/chef-vault/item_keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def [](key)
ckey = @cache[key]
return ckey unless ckey.nil?
# check if the key is saved in sparse mode
skey = sparse_key(sparse_id(key))
skey = sparse_key(sparse_id(key)) if sparse?
if skey
skey[key]
else
Expand Down Expand Up @@ -213,6 +213,10 @@ def self.load(vault, name)

# @private

def sparse?
@raw_data["mode"] == "sparse"
end

def sparse_id(key, item_id = @raw_data["id"])
"#{item_id.chomp("_keys")}_key_#{key}"
end
Expand Down

0 comments on commit de4a1f9

Please sign in to comment.