Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update cnos.rb #3256

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading