GitHub PullRequestReviewCommentEvent at 2014-03-05 17:05:17
Repository: attr_encrypted
Actor: billymonk
Payload: {"comment":{"url":"https://api.github.com/repos/attr-encrypted/attr_encrypted/pulls/comments/10307783","id":10307783,"diff_hunk":"@@ -193,7 +193,17 @@ def decrypt(attribute, encrypted_value, options = {})\n     options = encrypted_attributes[attribute.to_sym].merge(options)\n     if options[:if] && !options[:unless] && !encrypted_value.nil? && !(encrypted_value.is_a?(String) && encrypted_value.empty?)\n       encrypted_value = encrypted_value.unpack(options[:encode]).first if options[:encode]\n-      value = options[:encryptor].send(options[:decrypt_method], options.merge!(:value => encrypted_value))\n+      begin\n+        value = options[:encryptor].send(options[:decrypt_method], options.merge!(:value => encrypted_value))\n+      rescue OpenSSL::Cipher::CipherError => ex\n+        if ex.message == 'bad decrypt'\n+          raise Errors::BadDecryptError, \"Could not decrypt attribute #{ attribute }: key, iv, or salt may have changed or been corrupted.\"\n+        elsif ex.message == 'wrong final block length'\n+          raise Errors::BlockLengthError, \"Could not decrypt attribute #{ attribute } the cyphertext has an invalid final block. It may have been truncated when stored to the database.\"\n+        else\n+          raise CipherError, \"Could not decrypt attribute #{ attribute }\"","path":"lib/attr_encrypted.rb","position":null,"original_position":13,"commit_id":"69971f770d7f48b501300d70d6f5281b1fb220ba","original_commit_id":"bf87feb20f21a5323a70539b74435dc112fa0cbc","user":{"login":"billymonk","id":191687,"avatar_url":"https://gravatar.com/avatar/40e0778364c79c40ffb3edc4314a3d99?d=https%3A%2F%2Fidenticons.github.com%2F804754e98ed50241ac0908e341158723.png&r=x","gravatar_id":"40e0778364c79c40ffb3edc4314a3d99","url":"https://api.github.com/users/billymonk","html_url":"https://github.com/billymonk","followers_url":"https://api.github.com/users/billymonk/followers","following_url":"https://api.github.com/users/billymonk/following{/other_user}","gists_url":"https://api.github.com/users/billymonk/gists{/gist_id}","starred_url":"https://api.github.com/users/billymonk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/billymonk/subscriptions","organizations_url":"https://api.github.com/users/billymonk/orgs","repos_url":"https://api.github.com/users/billymonk/repos","events_url":"https://api.github.com/users/billymonk/events{/privacy}","received_events_url":"https://api.github.com/users/billymonk/received_events","type":"User","site_admin":false},"body":"Agreed with handling these specific errors within ```encryptor``` gem and\r\nthen handling ```encryptor``` errors within this gem.\r\n\r\nHandling ```OpenSSL``` exceptions in the ```encryptor``` gem allows others\r\nwho may want to use the gem outside of ```attr_encrypted``` to benefit.","created_at":"2014-03-05T17:05:17Z","updated_at":"2014-03-05T17:05:17Z","html_url":"https://github.com/attr-encrypted/attr_encrypted/pull/98#discussion_r10307783","pull_request_url":"https://api.github.com/repos/attr-encrypted/attr_encrypted/pulls/98","_links":{"self":{"href":"https://api.github.com/repos/attr-encrypted/attr_encrypted/pulls/comments/10307783"},"html":{"href":"https://github.com/attr-encrypted/attr_encrypted/pull/98#discussion_r10307783"},"pull_request":{"href":"https://api.github.com/repos/attr-encrypted/attr_encrypted/pulls/98"}}}}