···1919require "openssl"
20202121class Bitwarden
2222- class InvalidCipherString < RuntimeError; end
2222+ class InvalidCipherString < StandardError; end
23232424 # convenience methods for hashing/encryption/decryption that the apps do,
2525 # just so we can test against
···144144145145 def self.parse(str)
146146 if !(m = str.to_s.match(/\A(\d)\.([^|]+)\|(.+)\z/))
147147- raise InvalidCipherString "invalid CipherString: #{str.inspect}"
147147+ raise Bitwarden::InvalidCipherString, "invalid CipherString: " <<
148148+ str.inspect
148149 end
149150150151 type = m[1].to_i
+3-2
lib/cipher.rb
···52525353 # migrate from older style everything-in-data to separate fields
5454 def migrate_data!
5555- return if !self.data
5555+ return false if !self.data
56565757 js = JSON.parse(self.data)
5858- return if !js
5858+ return false if !js
59596060 self.name = js.delete("Name")
6161 self.notes = js.delete("Notes")
···7878 self.send("#{fmap[self.type]}=", js)
79798080 self.save || raise("failed migrating #{self.inspect}")
8181+ true
8182 end
82838384 def to_hash