From e4680d181c368d901e27023c1f7ab524007d5b64 Mon Sep 17 00:00:00 2001 From: mbakerbp Date: Tue, 24 Jan 2017 06:47:57 +0800 Subject: Untested GPG work --- lib/oxidized/manager.rb | 1 + lib/oxidized/source/csv.rb | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/manager.rb b/lib/oxidized/manager.rb index bf28ae7..60394fd 100644 --- a/lib/oxidized/manager.rb +++ b/lib/oxidized/manager.rb @@ -3,6 +3,7 @@ module Oxidized require 'oxidized/input/input' require 'oxidized/output/output' require 'oxidized/source/source' + require 'gpgme' class Manager class << self def load dir, file diff --git a/lib/oxidized/source/csv.rb b/lib/oxidized/source/csv.rb index d498e0b..c41162d 100644 --- a/lib/oxidized/source/csv.rb +++ b/lib/oxidized/source/csv.rb @@ -11,6 +11,7 @@ class CSV < Source Oxidized.asetus.user.source.csv.delimiter = /:/ Oxidized.asetus.user.source.csv.map.name = 0 Oxidized.asetus.user.source.csv.map.model = 1 + Oxidized.asetus.user.source.csv.gpg = false Oxidized.asetus.save :user raise NoConfig, 'no source csv config, edit ~/.config/oxidized/config' end @@ -18,7 +19,8 @@ class CSV < Source def load nodes = [] - open(File.expand_path @cfg.file).each_line do |line| + file = @cfg.gpg == 'false' ? open(File.expand_path @cfg.file) : crypto.decrypt File.open(@cfg.file) + open(file).each_line do |line| next if line.match(/^\s*#/) data = line.chomp.split(@cfg.delimiter, -1) next if data.empty? -- cgit v1.2.1 From da69f568422ad918e734ecbc0feef15b1b7cac03 Mon Sep 17 00:00:00 2001 From: mbakerbp Date: Tue, 24 Jan 2017 06:50:24 +0800 Subject: Syntax error --- lib/oxidized/source/csv.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/source/csv.rb b/lib/oxidized/source/csv.rb index c41162d..757acf4 100644 --- a/lib/oxidized/source/csv.rb +++ b/lib/oxidized/source/csv.rb @@ -19,7 +19,7 @@ class CSV < Source def load nodes = [] - file = @cfg.gpg == 'false' ? open(File.expand_path @cfg.file) : crypto.decrypt File.open(@cfg.file) + file = (@cfg.gpg == 'false') ? open(File.expand_path @cfg.file) : crypto.decrypt(File.open(@cfg.file)) open(file).each_line do |line| next if line.match(/^\s*#/) data = line.chomp.split(@cfg.delimiter, -1) -- cgit v1.2.1 From 737ffa54eb42537f9fbd6bb6a2a708507fd802e3 Mon Sep 17 00:00:00 2001 From: mbakerbp Date: Tue, 24 Jan 2017 07:40:36 +0800 Subject: Update --- lib/oxidized/source/csv.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/oxidized') diff --git a/lib/oxidized/source/csv.rb b/lib/oxidized/source/csv.rb index 757acf4..dc246ab 100644 --- a/lib/oxidized/source/csv.rb +++ b/lib/oxidized/source/csv.rb @@ -19,6 +19,7 @@ class CSV < Source def load nodes = [] + crypto = GPGME::Crypto.new file = (@cfg.gpg == 'false') ? open(File.expand_path @cfg.file) : crypto.decrypt(File.open(@cfg.file)) open(file).each_line do |line| next if line.match(/^\s*#/) -- cgit v1.2.1 From 62a990bc08c23684840d34eccd46c54197cb7d02 Mon Sep 17 00:00:00 2001 From: mbakerbp Date: Tue, 24 Jan 2017 07:44:23 +0800 Subject: GPG support --- lib/oxidized/source/csv.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/source/csv.rb b/lib/oxidized/source/csv.rb index dc246ab..85fee77 100644 --- a/lib/oxidized/source/csv.rb +++ b/lib/oxidized/source/csv.rb @@ -19,9 +19,13 @@ class CSV < Source def load nodes = [] - crypto = GPGME::Crypto.new - file = (@cfg.gpg == 'false') ? open(File.expand_path @cfg.file) : crypto.decrypt(File.open(@cfg.file)) - open(file).each_line do |line| + if @cfg.gpg != 'false' + crypto = GPGME::Crypto.new :password => @cfg.gpg_password + file = crypto.decrypt(File.open(@cfg.file)) + else + file = open(File.expand_path @cfg.file) + end + file.each_line do |line| next if line.match(/^\s*#/) data = line.chomp.split(@cfg.delimiter, -1) next if data.empty? -- cgit v1.2.1 From 0e7bbeaad452e8e719e1d66c314bcc4523e46579 Mon Sep 17 00:00:00 2001 From: mbakerbp Date: Tue, 24 Jan 2017 07:50:44 +0800 Subject: GPG support working --- lib/oxidized/source/csv.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/source/csv.rb b/lib/oxidized/source/csv.rb index 85fee77..449b297 100644 --- a/lib/oxidized/source/csv.rb +++ b/lib/oxidized/source/csv.rb @@ -21,7 +21,7 @@ class CSV < Source nodes = [] if @cfg.gpg != 'false' crypto = GPGME::Crypto.new :password => @cfg.gpg_password - file = crypto.decrypt(File.open(@cfg.file)) + file = crypto.decrypt(File.open(@cfg.file)).to_s else file = open(File.expand_path @cfg.file) end -- cgit v1.2.1 From ce283fa4399bf0bfaf7d677e52ce7a65b424e776 Mon Sep 17 00:00:00 2001 From: mbakerbp Date: Tue, 24 Jan 2017 10:45:34 +0800 Subject: Requested changes --- lib/oxidized/manager.rb | 1 - lib/oxidized/source/csv.rb | 13 +++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/manager.rb b/lib/oxidized/manager.rb index 60394fd..bf28ae7 100644 --- a/lib/oxidized/manager.rb +++ b/lib/oxidized/manager.rb @@ -3,7 +3,6 @@ module Oxidized require 'oxidized/input/input' require 'oxidized/output/output' require 'oxidized/source/source' - require 'gpgme' class Manager class << self def load dir, file diff --git a/lib/oxidized/source/csv.rb b/lib/oxidized/source/csv.rb index 449b297..c508358 100644 --- a/lib/oxidized/source/csv.rb +++ b/lib/oxidized/source/csv.rb @@ -10,21 +10,22 @@ class CSV < Source Oxidized.asetus.user.source.csv.file = File.join(Config::Root, 'router.db') Oxidized.asetus.user.source.csv.delimiter = /:/ Oxidized.asetus.user.source.csv.map.name = 0 - Oxidized.asetus.user.source.csv.map.model = 1 Oxidized.asetus.user.source.csv.gpg = false Oxidized.asetus.save :user raise NoConfig, 'no source csv config, edit ~/.config/oxidized/config' end + require 'gpgme' if @cfg.gpg? end def load nodes = [] - if @cfg.gpg != 'false' - crypto = GPGME::Crypto.new :password => @cfg.gpg_password - file = crypto.decrypt(File.open(@cfg.file)).to_s + file = File.expand_path(@cfg.file) + file = if @cfg.gpg? + crypto = GPGME::Crypto.new password: @cfg.gpg_password + crypto.decrypt(file).to_s else - file = open(File.expand_path @cfg.file) - end + open(file) + end file.each_line do |line| next if line.match(/^\s*#/) data = line.chomp.split(@cfg.delimiter, -1) -- cgit v1.2.1 From 07b4d0c52ce7b5c2377a4547686b95b7ddb62986 Mon Sep 17 00:00:00 2001 From: mbakerbp Date: Wed, 25 Jan 2017 05:46:50 +0800 Subject: Update --- lib/oxidized/source/csv.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/oxidized') diff --git a/lib/oxidized/source/csv.rb b/lib/oxidized/source/csv.rb index c508358..c1e310a 100644 --- a/lib/oxidized/source/csv.rb +++ b/lib/oxidized/source/csv.rb @@ -10,6 +10,7 @@ class CSV < Source Oxidized.asetus.user.source.csv.file = File.join(Config::Root, 'router.db') Oxidized.asetus.user.source.csv.delimiter = /:/ Oxidized.asetus.user.source.csv.map.name = 0 + Oxidized.asetus.user.source.csv.map.model = 1 Oxidized.asetus.user.source.csv.gpg = false Oxidized.asetus.save :user raise NoConfig, 'no source csv config, edit ~/.config/oxidized/config' -- cgit v1.2.1