1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-02-20 01:50:04 +00:00

replace MPW::password to MPW.password

replace YAML::load_file to YAML.load_file
replace YAML::load to YAML.safe_load
This commit is contained in:
Adrien Waksberg 2017-03-28 22:56:23 +02:00
parent 31aba3b13c
commit 351499aef6
4 changed files with 9 additions and 9 deletions

View file

@ -46,5 +46,5 @@ OptionParser.new do |opts|
end
end.parse!
puts MPW::MPW::password(options)
puts MPW::MPW.password(options)
exit 0

View file

@ -379,7 +379,7 @@ class Cli
system("#{editor} #{tmp_file}")
opts = YAML::load_file(tmp_file)
opts = YAML.load_file(tmp_file)
end
opts.delete_if { |k,v| v.to_s.empty? }
@ -396,7 +396,7 @@ class Cli
def add(password=false)
options = text_editor('add_form', nil, password)
item = Item.new(options)
options[:password] = MPW::password(@config.password) if password
options[:password] = MPW.password(@config.password) if password
@mpw.add(item)
@mpw.set_password(item.id, options[:password]) if options.key?(:password)
@ -421,7 +421,7 @@ class Cli
item = get_item(items)
options = text_editor('update_form', item, password)
options[:password] = MPW::password(@config.password) if password
options[:password] = MPW.password(@config.password) if password
item.update(options)
@mpw.set_password(item.id, options[:password]) if options.key?(:password)
@ -512,7 +512,7 @@ class Cli
raise I18n.t('form.import.file_empty') if file.to_s.empty?
raise I18n.t('form.import.file_not_exist') unless File.exist?(file)
YAML::load_file(file).each_value do |row|
YAML.load_file(file).each_value do |row|
item = Item.new(group: row['group'],
host: row['host'],
protocol: row['protocol'],

View file

@ -130,7 +130,7 @@ class Config
# Load the config file
def load_config
config = YAML::load_file(@config_file)
config = YAML.load_file(@config_file)
@gpg_key = config['gpg_key']
@lang = config['lang']
@wallet_dir = config['wallet_dir']

View file

@ -54,7 +54,7 @@ class MPW
tar.each do |f|
case f.full_name
when 'wallet/config.gpg'
@config = YAML.load(decrypt(f.read))
@config = YAML.safe_load(decrypt(f.read))
when 'wallet/meta.gpg'
data = decrypt(f.read)
@ -81,7 +81,7 @@ class MPW
end
unless data.to_s.empty?
YAML.load(data).each_value do |d|
YAML.safe_load(data).each_value do |d|
@data.push(Item.new(id: d['id'],
group: d['group'],
host: d['host'],
@ -178,7 +178,7 @@ class MPW
# args: id -> the item id
# password -> the new password
def set_password(id, password)
salt = MPW::password(length: Random.rand(4..9))
salt = MPW.password(length: Random.rand(4..9))
password = "$#{salt}::#{password}"
@passwords[id] = encrypt(password)