mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-21 10:20:05 +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:
parent
31aba3b13c
commit
351499aef6
4 changed files with 9 additions and 9 deletions
|
@ -46,5 +46,5 @@ OptionParser.new do |opts|
|
||||||
end
|
end
|
||||||
end.parse!
|
end.parse!
|
||||||
|
|
||||||
puts MPW::MPW::password(options)
|
puts MPW::MPW.password(options)
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -379,7 +379,7 @@ class Cli
|
||||||
|
|
||||||
system("#{editor} #{tmp_file}")
|
system("#{editor} #{tmp_file}")
|
||||||
|
|
||||||
opts = YAML::load_file(tmp_file)
|
opts = YAML.load_file(tmp_file)
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.delete_if { |k,v| v.to_s.empty? }
|
opts.delete_if { |k,v| v.to_s.empty? }
|
||||||
|
@ -396,7 +396,7 @@ class Cli
|
||||||
def add(password=false)
|
def add(password=false)
|
||||||
options = text_editor('add_form', nil, password)
|
options = text_editor('add_form', nil, password)
|
||||||
item = Item.new(options)
|
item = Item.new(options)
|
||||||
options[:password] = MPW::password(@config.password) if password
|
options[:password] = MPW.password(@config.password) if password
|
||||||
|
|
||||||
@mpw.add(item)
|
@mpw.add(item)
|
||||||
@mpw.set_password(item.id, options[:password]) if options.key?(:password)
|
@mpw.set_password(item.id, options[:password]) if options.key?(:password)
|
||||||
|
@ -421,7 +421,7 @@ class Cli
|
||||||
|
|
||||||
item = get_item(items)
|
item = get_item(items)
|
||||||
options = text_editor('update_form', item, password)
|
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)
|
item.update(options)
|
||||||
@mpw.set_password(item.id, options[:password]) if options.key?(:password)
|
@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_empty') if file.to_s.empty?
|
||||||
raise I18n.t('form.import.file_not_exist') unless File.exist?(file)
|
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'],
|
item = Item.new(group: row['group'],
|
||||||
host: row['host'],
|
host: row['host'],
|
||||||
protocol: row['protocol'],
|
protocol: row['protocol'],
|
||||||
|
|
|
@ -130,7 +130,7 @@ class Config
|
||||||
|
|
||||||
# Load the config file
|
# Load the config file
|
||||||
def load_config
|
def load_config
|
||||||
config = YAML::load_file(@config_file)
|
config = YAML.load_file(@config_file)
|
||||||
@gpg_key = config['gpg_key']
|
@gpg_key = config['gpg_key']
|
||||||
@lang = config['lang']
|
@lang = config['lang']
|
||||||
@wallet_dir = config['wallet_dir']
|
@wallet_dir = config['wallet_dir']
|
||||||
|
|
|
@ -54,7 +54,7 @@ class MPW
|
||||||
tar.each do |f|
|
tar.each do |f|
|
||||||
case f.full_name
|
case f.full_name
|
||||||
when 'wallet/config.gpg'
|
when 'wallet/config.gpg'
|
||||||
@config = YAML.load(decrypt(f.read))
|
@config = YAML.safe_load(decrypt(f.read))
|
||||||
|
|
||||||
when 'wallet/meta.gpg'
|
when 'wallet/meta.gpg'
|
||||||
data = decrypt(f.read)
|
data = decrypt(f.read)
|
||||||
|
@ -81,7 +81,7 @@ class MPW
|
||||||
end
|
end
|
||||||
|
|
||||||
unless data.to_s.empty?
|
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'],
|
@data.push(Item.new(id: d['id'],
|
||||||
group: d['group'],
|
group: d['group'],
|
||||||
host: d['host'],
|
host: d['host'],
|
||||||
|
@ -178,7 +178,7 @@ class MPW
|
||||||
# args: id -> the item id
|
# args: id -> the item id
|
||||||
# password -> the new password
|
# password -> the new password
|
||||||
def set_password(id, 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}"
|
password = "$#{salt}::#{password}"
|
||||||
|
|
||||||
@passwords[id] = encrypt(password)
|
@passwords[id] = encrypt(password)
|
||||||
|
|
Loading…
Add table
Reference in a new issue