Skip to content

Commit

Permalink
Merge pull request #3256 from robje/update-cnos
Browse files Browse the repository at this point in the history
update cnos.rb
  • Loading branch information
robertcheramy authored Oct 2, 2024
2 parents d3fa27b + e279da4 commit fea6647
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- container-image: update to phusion/baseimage:noble-1.0.0 and include security upgrades at build time (@robertcheramy)
- container-image: use ubuntu-packages instead of gems in order to reduce container image size (@robertcheramy)
- edgecos.rb: hide temperature and fan speed (@dhooper6430)
- cnos: show information before config, remove secrets only when told to do so (@robje)

### Fixed
- fixed prompt for vyos/vyatta to allow logins with non-priviliged accounts. Fixes #3111 (@h-lopez)
Expand Down
23 changes: 13 additions & 10 deletions lib/oxidized/model/cnos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,31 @@ class CNOS < Oxidized::Model

comment '! '

cmd :all do |cfg|
cfg.each_line.to_a[0..-2].join
cmd :secret do |cfg|
cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
cfg.gsub! /^(username .+ (password|secret) \d) .+/, '\\1 <secret hidden>'
cfg.gsub! /^(enable (password|secret)( level \d+)?( \d)?) .+/, '\\1 <secret hidden>'
cfg
end

cmd 'show running-config' do |cfg|
cfg.gsub!(/(snmp-server community )(\S+)/, '\1<hidden>')
cfg.gsub!(/key type private.+key string end/m, '<private key hidden>')
cfg
cmd :all do |cfg|
cfg = cfg.delete("\r")
cfg.cut_both
end

cmd 'show version' do |cfg|
cfg.gsub! /^(.* uptime is ).*\n/, '\1'
cfg = cfg.each_line.reject { |line| line.match /\ uptime\ is\ / }.join
comment cfg
end

cmd 'show transceiver' do |cfg|
comment cfg
end

cfg :telnet do
username /^Username:/
password /^Password:/
cmd 'show running-config' do |cfg|
# remove empty lines
cfg = cfg.each_line.reject { |line| line.match /^[\r\n\s\u0000#]+$/ }.join
cfg
end

cfg :telnet, :ssh do
Expand Down

0 comments on commit fea6647

Please sign in to comment.