diff options
author | Michel Salim <michel@fb.com> | 2019-06-20 17:15:17 -0700 |
---|---|---|
committer | Michel Salim <michel@fb.com> | 2019-06-20 17:20:07 -0700 |
commit | 8bf253419558ffbed353a22171150f0dfff949c4 (patch) | |
tree | a20352300f77fd1d6edd79827e0e49ccb3ae2d39 | |
parent | 570fb2f076a420cab1e793e6849f80d2ba32722b (diff) | |
download | ohai-8bf253419558ffbed353a22171150f0dfff949c4.tar.gz |
[shard_seed] fix default_digest_algorithm on darwin
`fips` is nil on Macs, and `default_digest_algorithm` did not check for this, causing the shard plugin to throw an exception.
Make it safer by assuming `fips` is not enabled by default.
Signed-off-by: Michel Salim <michel@fb.com>
-rw-r--r-- | lib/ohai/plugins/shard.rb | 2 | ||||
-rw-r--r-- | spec/unit/plugins/shard_spec.rb | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/lib/ohai/plugins/shard.rb b/lib/ohai/plugins/shard.rb index b3c6e932..176bacbd 100644 --- a/lib/ohai/plugins/shard.rb +++ b/lib/ohai/plugins/shard.rb @@ -38,7 +38,7 @@ Ohai.plugin(:ShardSeed) do end def default_digest_algorithm - if fips["kernel"]["enabled"] + if fips && fips["kernel"]["enabled"] # Even though it is being used safely, FIPS-mode will still blow up on # any use of MD5 so default to SHA2 instead. "sha256" diff --git a/spec/unit/plugins/shard_spec.rb b/spec/unit/plugins/shard_spec.rb index d8d48fa5..cc12f380 100644 --- a/spec/unit/plugins/shard_spec.rb +++ b/spec/unit/plugins/shard_spec.rb @@ -68,6 +68,7 @@ describe Ohai::System, "shard plugin" do context "with Darwin OS" do let(:os) { :darwin } before do + plugin.data.delete("fips") # FIPS is undefined on Macs, make sure this still work plugin["hardware"] = { "serial_number" => serial, "platform_UUID" => uuid } end |