From 351499aef6c76b99f75f6789c2440b5c387bc39c Mon Sep 17 00:00:00 2001 From: Adrien Waksberg Date: Tue, 28 Mar 2017 22:56:23 +0200 Subject: [PATCH] replace MPW::password to MPW.password replace YAML::load_file to YAML.load_file replace YAML::load to YAML.safe_load --- bin/mpw-genpwd | 2 +- lib/mpw/cli.rb | 8 ++++---- lib/mpw/config.rb | 2 +- lib/mpw/mpw.rb | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/mpw-genpwd b/bin/mpw-genpwd index 0370732..1c09489 100644 --- a/bin/mpw-genpwd +++ b/bin/mpw-genpwd @@ -46,5 +46,5 @@ OptionParser.new do |opts| end end.parse! -puts MPW::MPW::password(options) +puts MPW::MPW.password(options) exit 0 diff --git a/lib/mpw/cli.rb b/lib/mpw/cli.rb index 90f7665..7f406b7 100644 --- a/lib/mpw/cli.rb +++ b/lib/mpw/cli.rb @@ -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'], diff --git a/lib/mpw/config.rb b/lib/mpw/config.rb index b7cf5e8..6f3632c 100644 --- a/lib/mpw/config.rb +++ b/lib/mpw/config.rb @@ -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'] diff --git a/lib/mpw/mpw.rb b/lib/mpw/mpw.rb index a957ef0..70f3847 100644 --- a/lib/mpw/mpw.rb +++ b/lib/mpw/mpw.rb @@ -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)