From 0dcc9a0215f7ee3e10f864c04dcc09c4b0050aeb Mon Sep 17 00:00:00 2001 From: Louis Rossouw Date: Sun, 2 Jul 2017 11:53:29 +0200 Subject: Use `/export hide-sensitive` when `remove_secret` is set in Oxidized config. --- lib/oxidized/model/routeros.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/model/routeros.rb b/lib/oxidized/model/routeros.rb index 31650c7..f391fb9 100644 --- a/lib/oxidized/model/routeros.rb +++ b/lib/oxidized/model/routeros.rb @@ -14,11 +14,14 @@ class RouterOS < Oxidized::Model comment cfg end - cmd '/export' do |cfg| - cfg.gsub! /\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]/, '' # strip ANSI colours - cfg.gsub! /\\\r\n\s+/, '' # strip new line - cfg = cfg.split("\n").select { |line| not line[/^\#\s\w{3}\/\d{2}\/\d{4}.*$/] } - cfg.join("\n") + "\n" + post do + run_cmd = vars(:remove_secret) ? '/export hide-sensitive' : '/export' + cmd run_cmd do |cfg| + cfg.gsub! /\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]/, '' # strip ANSI colours + cfg.gsub! /\\\r\n\s+/, '' # strip new line + cfg = cfg.split("\n").select { |line| not line[/^\#\s\w{3}\/\d{2}\/\d{4}.*$/] } + cfg.join("\n") + "\n" + end end cfg :telnet do -- cgit v1.2.1