diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-03-14 11:05:44 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-03-14 11:05:44 -0700 |
commit | d4579addae1dafa6b9e39b286995b97dac450aa2 (patch) | |
tree | 31aa3b95b252acc947df1e3307ab1b987a696ebe | |
parent | 6705acbd7f301d1b04388043a3dfa0308655f120 (diff) | |
download | chef-d4579addae1dafa6b9e39b286995b97dac450aa2.tar.gz |
This commit is why AndOr needs to be banned
I can barely understand what these intend. I'm pretty certain that
the logic in the encrypted data bag item code was wrong (fixed now
to match the comment) and I'm believe I converted the yum code to
preserve the logic. But holy fuck its hard to read the yum code
that I'm replacing.
-rw-r--r-- | lib/chef/encrypted_data_bag_item/decryptor.rb | 8 | ||||
-rw-r--r-- | lib/chef/provider/package/yum.rb | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/chef/encrypted_data_bag_item/decryptor.rb b/lib/chef/encrypted_data_bag_item/decryptor.rb index a002a98a79..773ff4e154 100644 --- a/lib/chef/encrypted_data_bag_item/decryptor.rb +++ b/lib/chef/encrypted_data_bag_item/decryptor.rb @@ -92,8 +92,8 @@ class Chef::EncryptedDataBagItem plaintext = openssl_decryptor.update(encrypted_bytes) plaintext << openssl_decryptor.final rescue OpenSSL::Cipher::CipherError => e - # if the key length is less than 150 characters, and it contains slashes, we think it may be a path. - raise DecryptionFailure, "Error decrypting data bag value: '#{e.message}'. Most likely the provided key is incorrect. #{ @key.length < 255 and @key.include?('/') ? 'You may need to use --secret-file rather than --secret.' : '' }" + # if the key length is less than 255 characters, and it contains slashes, we think it may be a path. + raise DecryptionFailure, "Error decrypting data bag value: '#{e.message}'. Most likely the provided key is incorrect. #{ (@key.length < 255 && @key.include?('/')) ? 'You may need to use --secret-file rather than --secret.' : '' }" end end @@ -143,8 +143,8 @@ class Chef::EncryptedDataBagItem plaintext = openssl_decryptor.update(encrypted_bytes) plaintext << openssl_decryptor.final rescue OpenSSL::Cipher::CipherError => e - # if the key length is less than 150 characters, and it contains slashes, we think it may be a path. - raise DecryptionFailure, "Error decrypting data bag value: '#{e.message}'. Most likely the provided key is incorrect. #{ @key.length < 255 and @key.include?('/') ? 'You may need to use --secret-file rather than --secret.' : '' }" + # if the key length is less than 255 characters, and it contains slashes, we think it may be a path. + raise DecryptionFailure, "Error decrypting data bag value: '#{e.message}'. Most likely the provided key is incorrect. #{ ( @key.length < 255 && @key.include?('/')) ? 'You may need to use --secret-file rather than --secret.' : '' }" end end diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb index 73507ec5ab..dfd32fde55 100644 --- a/lib/chef/provider/package/yum.rb +++ b/lib/chef/provider/package/yum.rb @@ -478,9 +478,9 @@ class Chef sense = x.version.partial_compare(y.version) # Thanks to rpmdsCompare() rpmds.c - if sense < 0 and (x.flag == :> || x.flag == :>=) || (y.flag == :<= || y.flag == :<) + if (sense < 0) && ((x.flag == :> || x.flag == :>=) || (y.flag == :<= || y.flag == :<)) return true - elsif sense > 0 and (x.flag == :< || x.flag == :<=) || (y.flag == :>= || y.flag == :>) + elsif (sense > 0) && ((x.flag == :< || x.flag == :<=) || (y.flag == :>= || y.flag == :>)) return true elsif sense == 0 && ( ((x.flag == :== || x.flag == :<= || x.flag == :>=) && (y.flag == :== || y.flag == :<= || y.flag == :>=)) || |