lib/symmetric_encryption/keystore/aws.rb in symmetric-encryption-4.3.1 vs lib/symmetric_encryption/keystore/aws.rb in symmetric-encryption-4.3.2

- old
+ new

@@ -1,6 +1,6 @@ -require 'aws-sdk-kms' +require "aws-sdk-kms" module SymmetricEncryption module Keystore # Support AWS Key Management Service (KMS) # # Terms: @@ -80,16 +80,16 @@ **_args) # TODO: Also support generating environment variables instead of files. version >= 255 ? (version = 1) : (version += 1) - regions = Array(regions).dup + regions = Array(regions).dup master_key_alias = master_key_alias(app_name, environment) # File per region for holding the encrypted data key - key_files = regions.collect do |region| + key_files = regions.collect do |region| file_name = "#{app_name}_#{environment}_#{region}_v#{version}.encrypted_key" {region: region, file_name: ::File.join(key_path, file_name)} end keystore = new(key_files: key_files, master_key_alias: master_key_alias) @@ -117,13 +117,13 @@ # Stores the Encryption key in a file. # Secures the Encryption key by encrypting it with a key encryption key. def initialize(region: nil, key_files:, master_key_alias:, key_encrypting_key: nil) @key_files = key_files @master_key_alias = master_key_alias - @region = region || ENV['AWS_REGION'] || ENV['AWS_DEFAULT_REGION'] || ::Aws.config[:region] + @region = region || ENV["AWS_REGION"] || ENV["AWS_DEFAULT_REGION"] || ::Aws.config[:region] if key_encrypting_key - raise(SymmetricEncryption::ConfigError, 'AWS KMS keystore encrypts the key itself, so does not support supplying a key_encrypting_key') + raise(SymmetricEncryption::ConfigError, "AWS KMS keystore encrypts the key itself, so does not support supplying a key_encrypting_key") end end # Reads the data key environment variable, if present, otherwise a file. # Decrypts the key using the master key for this region. @@ -141,10 +141,10 @@ def write(data_key) key_files.each do |key_file| region = key_file[:region] file_name = key_file[:file_name] - raise(ArgumentError, 'region and file_name are mandatory for each key_file entry') unless region && file_name + raise(ArgumentError, "region and file_name are mandatory for each key_file entry") unless region && file_name encrypted_data_key = aws(region).encrypt(data_key) write_encoded_to_file(file_name, encrypted_data_key) end end