Skip to content
Open
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
6 changes: 1 addition & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]
### Added
- eatonnetwork: model unit test (@thanegill)
- source/sql: support defining port in configuration. Closes #3853 (@ytti)
- vsololt: new model for VSOL GPON OLT (@Vantomas)
- tplink: add simulation data and unit tests for the TP-Link DeltaStream DS-P7001-08 GPON OLT (@Vantomas)
- device2yaml: add `-n`/`--newline` option to set the command line terminator (e.g. `-n "\r\n"`) for devices that submit a command only on a carriage return; the terminator is recorded as a `command_newline` key in the generated YAML (@Vantomas)
- westermoweos.rb: support for Westermo WeOS network devices (@joschi99)

### Changed
- docker: set LANG=C.UTF-8. Fixes #3690 (@ytti)
Expand Down
73 changes: 73 additions & 0 deletions lib/oxidized/model/westermoweos.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
class WestermoWeos < Oxidized::Model
using Refinements

comment '# '

#Prompt based on real device
prompt %r{[\w\-.]+:/.*[#>]\s?$}

#Handle paging / viewer (WeOS specific)
expect /--More--|Space for next page/ do |data, re|
send ' '
data.sub re, ''
end

#Global cleanup
cmd :all do |cfg|
# remove CR
cfg = cfg.gsub(/\r/, '')

# remove ANSI escape sequences
cfg = cfg.gsub(/\e\[[0-9;]*[A-Za-z]/, '')

# remove viewer header
cfg = cfg.gsub(/Press Ctrl-C.*?\n/, '')

# remove paging remnants
cfg = cfg.gsub(/--More--.*?\n/, '')

# remove viewer progress markers like "(1% of 28118 bytes)"
cfg = cfg.gsub(/\(\d+% of \d+ bytes\)\s*/, '')

# remove timestamp line (diff noise)
cfg = cfg.gsub(/running-config\.cfg.*$/, '')

# remove command echo like "hostname:/#>show running-config"
cfg = cfg.gsub(/^[\w\-.]+:\/.*[#>].*show .*$/, '')

# remove standalone prompt lines like "hostname:/#>"
cfg = cfg.gsub(/^[\w\-.]+:\/.*[#>]\s*$/, '')

# normalize
cfg.strip
end

#1. System info FIRST (as comments)
cmd 'show system-information' do |cfg|
comment cfg
end

#2. Then full config
cmd 'show running-config'

#Sensitive data masking
cmd :secret do |cfg|
# password fields
cfg.gsub!(/("password"\s*:\s*)".*?"/i, '\\1"<hidden>"')

# generic secrets
cfg.gsub!(/("secret"\s*:\s*)".*?"/i, '\\1"<hidden>"')

# keys / tokens
cfg.gsub!(/("key[^"]*"\s*:\s*)".*?"/i, '\\1"<hidden>"')

# long IDs / base64 values
cfg.gsub!(/(".*id"\s*:\s*)".{20,}"/i, '\\1"<hidden>"')

cfg
end

cfg :ssh do
pre_logout 'exit'
end
end
Loading