diff options
author | Louis Rossouw <lrossouw@gmail.com> | 2017-07-02 11:53:29 +0200 |
---|---|---|
committer | Louis Rossouw <lrossouw@gmail.com> | 2017-07-02 11:53:29 +0200 |
commit | 0dcc9a0215f7ee3e10f864c04dcc09c4b0050aeb (patch) | |
tree | 2dd06cb7e7f001e1441ba6bcb405fb730ed80926 /lib/oxidized/model/routeros.rb | |
parent | 51e05d2d1be662c6a805e92f03327d4ab365ab2e (diff) |
Use `/export hide-sensitive` when `remove_secret` is set in Oxidized config.
Diffstat (limited to 'lib/oxidized/model/routeros.rb')
-rw-r--r-- | lib/oxidized/model/routeros.rb | 13 |
1 files changed, 8 insertions, 5 deletions
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 |