oxidized 0.30.1 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +2 -2
  3. data/.github/workflows/stale.yml +4 -2
  4. data/.rubocop.yml +18 -2
  5. data/.rubocop_todo.yml +5 -12
  6. data/CHANGELOG.md +61 -1
  7. data/CONTRIBUTING.md +5 -0
  8. data/Dockerfile +82 -21
  9. data/README.md +5 -21
  10. data/Rakefile +3 -2
  11. data/docs/Configuration.md +36 -12
  12. data/docs/Creating-Models.md +45 -4
  13. data/docs/Hooks.md +34 -0
  14. data/docs/Issues.md +91 -0
  15. data/docs/Model-Notes/Cumulus.md +5 -0
  16. data/docs/Model-Notes/FSOS.md +5 -0
  17. data/docs/Model-Notes/FortiOS.md +21 -5
  18. data/docs/Model-Notes/HPEAruba.md +31 -0
  19. data/docs/Model-Notes/OS6.md +10 -0
  20. data/docs/Model-Notes/RouterOS.md +15 -0
  21. data/docs/Model-Notes/SikluMHTG.md +7 -0
  22. data/docs/Outputs.md +2 -0
  23. data/docs/Release.md +18 -15
  24. data/docs/Sources.md +21 -0
  25. data/docs/Supported-OS-Types.md +11 -5
  26. data/docs/Troubleshooting.md +35 -0
  27. data/examples/device-simulation/README.md +173 -0
  28. data/examples/device-simulation/cmdsets/aoscx +9 -0
  29. data/examples/device-simulation/cmdsets/arubainstant +5 -0
  30. data/examples/device-simulation/cmdsets/asa +7 -0
  31. data/examples/device-simulation/cmdsets/ios +7 -0
  32. data/examples/device-simulation/cmdsets/nxos +5 -0
  33. data/examples/device-simulation/cmdsets/routeros +5 -0
  34. data/examples/device-simulation/cmdsets/srosmd +11 -0
  35. data/examples/device-simulation/device2yaml.rb +225 -0
  36. data/examples/device-simulation/yaml/aoscx_R0X25A-6410_FL.10.10.1100.yaml +2281 -0
  37. data/examples/device-simulation/yaml/aoscx_R8N85A-C6000-48G-CL4_PL.10.08.1010.yaml +451 -0
  38. data/examples/device-simulation/yaml/arubainstant_IAP515_8.10.0.6_VWLC.yaml +213 -0
  39. data/examples/device-simulation/yaml/asa_5512_9.12-4-67_single-context.yaml +531 -0
  40. data/examples/device-simulation/yaml/asr920_16.8.1b.yaml +1122 -0
  41. data/examples/device-simulation/yaml/garderos_R7709_003_006_068.yaml +101 -0
  42. data/examples/device-simulation/yaml/iosxe_C9200L-24P-4G_17.09.04a.yaml +514 -0
  43. data/examples/device-simulation/yaml/iosxe_C9800-L-F-K9_17.06.05.yaml +417 -0
  44. data/examples/device-simulation/yaml/riverbed_915.yaml +123 -0
  45. data/examples/device-simulation/yaml/routeros_CHR_7.10.1.yaml +145 -0
  46. data/examples/device-simulation/yaml/routeros_CHR_7.16.yaml +79 -0
  47. data/examples/device-simulation/yaml/routeros_L009UiGS_7.15.2.yaml +353 -0
  48. data/examples/podman-compose/Makefile +60 -17
  49. data/examples/podman-compose/README.md +63 -27
  50. data/examples/podman-compose/docker-compose.yml +11 -2
  51. data/examples/podman-compose/gitserver/.gitignore +1 -0
  52. data/examples/podman-compose/gitserver/Dockerfile +14 -0
  53. data/examples/podman-compose/model-simulation/Dockerfile-model +1 -1
  54. data/examples/podman-compose/model-simulation/asternos.sh +2 -0
  55. data/examples/podman-compose/oxidized-config/.gitignore +2 -0
  56. data/examples/podman-compose/oxidized-config/config +1 -1
  57. data/examples/podman-compose/oxidized-config/config_csv-file +46 -0
  58. data/examples/podman-compose/oxidized-config/config_csv-gitserver +56 -0
  59. data/examples/podman-compose/oxidized-ssh/.gitignore +1 -0
  60. data/lib/oxidized/config.rb +7 -1
  61. data/lib/oxidized/hook/githubrepo.rb +37 -7
  62. data/lib/oxidized/hook/slackdiff.rb +29 -7
  63. data/lib/oxidized/input/http.rb +1 -0
  64. data/lib/oxidized/input/telnet.rb +1 -1
  65. data/lib/oxidized/manager.rb +17 -16
  66. data/lib/oxidized/model/aoscx.rb +16 -2
  67. data/lib/oxidized/model/aosw.rb +7 -1
  68. data/lib/oxidized/model/arubainstant.rb +90 -0
  69. data/lib/oxidized/model/audiocodes.rb +2 -2
  70. data/lib/oxidized/model/cnos.rb +13 -10
  71. data/lib/oxidized/model/cumulus.rb +3 -0
  72. data/lib/oxidized/model/dlink.rb +1 -0
  73. data/lib/oxidized/model/dlinknextgen.rb +3 -0
  74. data/lib/oxidized/model/edgecos.rb +2 -1
  75. data/lib/oxidized/model/eos.rb +2 -0
  76. data/lib/oxidized/model/f5os.rb +17 -0
  77. data/lib/oxidized/model/firewareos.rb +10 -1
  78. data/lib/oxidized/model/fortios.rb +24 -1
  79. data/lib/oxidized/model/garderos.rb +43 -0
  80. data/lib/oxidized/model/h3c.rb +1 -1
  81. data/lib/oxidized/model/ibos.rb +1 -0
  82. data/lib/oxidized/model/ios.rb +20 -12
  83. data/lib/oxidized/model/iosxr.rb +1 -1
  84. data/lib/oxidized/model/lenovonos.rb +2 -0
  85. data/lib/oxidized/model/linuxgeneric.rb +1 -1
  86. data/lib/oxidized/model/netgear.rb +1 -1
  87. data/lib/oxidized/model/nodegrid.rb +1 -1
  88. data/lib/oxidized/model/nsxdfw.rb +30 -0
  89. data/lib/oxidized/model/nxos.rb +2 -1
  90. data/lib/oxidized/model/os6.rb +48 -0
  91. data/lib/oxidized/model/rgos.rb +1 -1
  92. data/lib/oxidized/model/riverbed.rb +104 -0
  93. data/lib/oxidized/model/routeros.rb +2 -2
  94. data/lib/oxidized/model/saos.rb +18 -1
  95. data/lib/oxidized/model/siklumhtg.rb +22 -0
  96. data/lib/oxidized/model/uplinkolt.rb +46 -0
  97. data/lib/oxidized/model/vyatta.rb +2 -2
  98. data/lib/oxidized/model/xos.rb +7 -0
  99. data/lib/oxidized/node.rb +30 -18
  100. data/lib/oxidized/nodes.rb +13 -5
  101. data/lib/oxidized/output/file.rb +45 -42
  102. data/lib/oxidized/output/git.rb +185 -160
  103. data/lib/oxidized/output/gitcrypt.rb +188 -186
  104. data/lib/oxidized/output/http.rb +53 -51
  105. data/lib/oxidized/output/output.rb +6 -4
  106. data/lib/oxidized/source/csv.rb +44 -49
  107. data/lib/oxidized/source/http.rb +63 -81
  108. data/lib/oxidized/source/jsonfile.rb +63 -0
  109. data/lib/oxidized/source/source.rb +43 -18
  110. data/lib/oxidized/source/sql.rb +66 -59
  111. data/lib/oxidized/version.rb +2 -2
  112. data/oxidized.gemspec +22 -16
  113. metadata +111 -15
@@ -31,7 +31,8 @@ class EdgeCOS < Oxidized::Model
31
31
 
32
32
  cmd 'show system' do |cfg|
33
33
  cfg.gsub! /^.*\sUp Time\s*:.*\n/i, ''
34
- cfg.gsub! /^(.*\sTemperature \d*\s*:\s*).*/i, '\\1<removed>'
34
+ cfg.gsub! /(\sTemperature \d*:)\s*\d+ degrees/, '\\1 <temperature values hidden>'
35
+ cfg.gsub! /^!?\s*Fan \d+ speed:\s+\d+ rpm\s+Fan \d+ speed:\s+\d+ rpm\s+Fan \d+ speed:\s+\d+ rpm$/, '<fan speeds hidden>'
35
36
  comment cfg
36
37
  end
37
38
 
@@ -18,7 +18,9 @@ class EOS < Oxidized::Model
18
18
  cfg.gsub! /^(enable (?:secret|password)).*/, '\\1 <configuration removed>'
19
19
  cfg.gsub! /^(service unsupported-transceiver).*/, '\\1 <license key removed>'
20
20
  cfg.gsub! /^(tacacs-server key \d+).*/, '\\1 <configuration removed>'
21
+ cfg.gsub! /^(radius-server .+ key \d) \S+/, '\\1 <radius secret hidden>'
21
22
  cfg.gsub! /( {6}key) (\h+ 7) (\h+).*/, '\\1 <secret hidden>'
23
+ cfg.gsub! /(localized|auth (md5|sha\d{0,3})|priv (des|aes\d{0,3})) \S+/, '\\1 <secret hidden>'
22
24
  cfg
23
25
  end
24
26
 
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ class F5OS < Oxidized::Model
4
+ # F5OS Model #
5
+
6
+ comment '!'
7
+ prompt(/^([\w.@()-]+ ?[#>]\s+)$/)
8
+
9
+ cmd 'show running-config'
10
+
11
+ cfg :ssh do
12
+ post_login do
13
+ cmd 'paginate false'
14
+ end
15
+ pre_logout 'exit'
16
+ end
17
+ end
@@ -1,7 +1,16 @@
1
1
  class FirewareOS < Oxidized::Model
2
2
  using Refinements
3
3
 
4
- prompt /^\[?\w*\]?\w*?(<[\w-]*>)?(#|>)\s*$/
4
+ # matched prompts:
5
+ # [FAULT]WG<managed-by-wsm><master>>
6
+ # WG<managed-by-wsm><master>>
7
+ # WG<managed-by-wsm>>
8
+ # [FAULT]WG<non-master>>
9
+ # [FAULT]WG>
10
+ # WG>
11
+
12
+ prompt /^\[?\w*\]?\w*?(?:<[\w-]+>)*(#|>)\s*$/
13
+
5
14
  comment '-- '
6
15
 
7
16
  cmd :all do |cfg|
@@ -22,6 +22,8 @@ class FortiOS < Oxidized::Model
22
22
  end
23
23
 
24
24
  cmd :secret do |cfg|
25
+ # Remove private key for encrypted configs
26
+ cfg.gsub! /^(\#private-encryption-key=).+/, '\\1 <configuration removed>'
25
27
  # ENC indicates an encrypted password, and secret indicates a secret string
26
28
  cfg.gsub! /(set .+ ENC) .+/, '\\1 <configuration removed>'
27
29
  cfg.gsub! /(set .*secret) .+/, '\\1 <configuration removed>'
@@ -73,10 +75,31 @@ class FortiOS < Oxidized::Model
73
75
 
74
76
  cfg << cmd('end') if @vdom_enabled
75
77
 
76
- ['show | grep .', 'show full-configuration', 'show'].each do |fullcmd|
78
+ # Different OS have different commands - we use the first that works
79
+ # - For fortigate > 7 and possibly earlier versions, we use:
80
+ # show | grep . # backup as in fortigate GUI
81
+ # show full-configuration | grep . # bakup including default values
82
+ # | grep is used to avoid the --More-- prompt
83
+ # - It is not documented which systems need the commands without | grep:
84
+ # show full-configuration
85
+ # show
86
+ # Document it here and make a PR on github if you know!
87
+ # By default, we use the configuration without default values
88
+ # If fullconfig: true is set in the configuration, we get the full config
89
+ commandlist = if vars(:fullconfig)
90
+ ['show full-configuration | grep .',
91
+ 'show full-configuration', 'show']
92
+ else
93
+ ['show | grep .',
94
+ 'show full-configuration', 'show']
95
+ end
96
+
97
+ commandlist.each do |fullcmd|
77
98
  fullcfg = cmd(fullcmd)
78
99
  next if fullcfg.lines[1..3].join =~ /(Parsing error at|command parse error)/ # Don't show for unsupported devices (e.g. FortiAnalyzer, FortiManager, FortiMail)
79
100
 
101
+ fullcfg.gsub! /(set comments "Error \(No order (found )?for (account )?ID \d+\) on).*/, '\\1 <stripped>"'
102
+
80
103
  cfg << fullcfg
81
104
  break
82
105
  end
@@ -0,0 +1,43 @@
1
+ class Garderos < Oxidized::Model
2
+ using Refinements
3
+ # Garderos GmbH https://www.garderos.com/
4
+ # Routers for harsh environments
5
+ # grs = Garderos Router Software
6
+
7
+ # remove all ANSI escape codes, as GRS uses them :-(
8
+ # the prompt does not need to match escape codes, as they have been removed
9
+ expect /\e\[\d*m\r?/ do |data, re|
10
+ data.gsub re, ''
11
+ end
12
+
13
+ prompt /[\w-]+# /
14
+ comment '# '
15
+
16
+ cmd :all do |cfg|
17
+ # Remove the echo of the entered command and the prompt after it
18
+ cfg.cut_both
19
+ end
20
+
21
+ cmd 'show system version' do |cfg|
22
+ comment "#{cfg}\n"
23
+ end
24
+
25
+ cmd 'show system serial' do |cfg|
26
+ comment "#{cfg}\n"
27
+ end
28
+
29
+ # If we have a radio modem installed, we'd like to list the SIM Card
30
+ cmd 'show hardware wwan wwan0 sim' do |cfg|
31
+ if cfg.start_with? 'Unknown command'
32
+ ''
33
+ else
34
+ comment "#{cfg}\n"
35
+ end
36
+ end
37
+
38
+ cmd 'show configuration running'
39
+
40
+ cfg :ssh do
41
+ pre_logout 'exit'
42
+ end
43
+ end
@@ -3,7 +3,7 @@ class H3C < Oxidized::Model
3
3
 
4
4
  # H3C
5
5
 
6
- prompt /^.*(<[\w.-]+>)$/
6
+ prompt /^.*([<\[][\w.-]+[>\]])$/
7
7
  comment '# '
8
8
 
9
9
  cmd :secret do |cfg|
@@ -22,6 +22,7 @@ class IBOS < Oxidized::Model
22
22
 
23
23
  # radius server 10.1.1.1 secret public
24
24
  cfg.gsub! /^radius server (\S+) secret (\S+)(.*)/, 'radius server \\1 secret <hidden> \\3'
25
+ cfg
25
26
  end
26
27
 
27
28
  cmd 'show version' do |cfg|
@@ -27,23 +27,29 @@ class IOS < Oxidized::Model
27
27
 
28
28
  cmd :secret do |cfg|
29
29
  cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
30
- cfg.gsub! /^(snmp-server host \S+( vrf \S+)?( informs?)?( version (1|2c|3 (noauth|auth|priv)))?)\s+\S+((\s+\S*)*)\s*/, '\\1 <secret hidden> \\7'
30
+ cfg.gsub! /^(snmp-server host \S+( vrf \S+)?( informs?)?( version (1|2c))?) +\S+( .*)?$*/, '\\1 <secret hidden>\\6'
31
31
  cfg.gsub! /^(username .+ (password|secret) \d) .+/, '\\1 <secret hidden>'
32
32
  cfg.gsub! /^(enable (password|secret)( level \d+)? \d) .+/, '\\1 <secret hidden>'
33
- cfg.gsub! /^(\s+(?:password|secret)) (?:\d )?\S+/, '\\1 <secret hidden>'
33
+ cfg.gsub! /^( +(?:password|secret)) (?:\d )?\S+/, '\\1 <secret hidden>'
34
34
  cfg.gsub! /^(.*wpa-psk ascii \d) (\S+)/, '\\1 <secret hidden>'
35
35
  cfg.gsub! /^(.*key 7) (\d.+)/, '\\1 <secret hidden>'
36
36
  cfg.gsub! /^(tacacs-server (.+ )?key) .+/, '\\1 <secret hidden>'
37
37
  cfg.gsub! /^(crypto isakmp key) (\S+) (.*)/, '\\1 <secret hidden> \\3'
38
- cfg.gsub! /^(\s+ip ospf message-digest-key \d+ md5) .+/, '\\1 <secret hidden>'
39
- cfg.gsub! /^(\s+ip ospf authentication-key) .+/, '\\1 <secret hidden>'
40
- cfg.gsub! /^(\s+neighbor \S+ password) .+/, '\\1 <secret hidden>'
41
- cfg.gsub! /^(\s+vrrp \d+ authentication text) .+/, '\\1 <secret hidden>'
42
- cfg.gsub! /^(\s+standby \d+ authentication) .{1,8}$/, '\\1 <secret hidden>'
43
- cfg.gsub! /^(\s+standby \d+ authentication md5 key-string) .+?( timeout \d+)?$/, '\\1 <secret hidden> \\2'
44
- cfg.gsub! /^(\s+key-string) .+/, '\\1 <secret hidden>'
45
- cfg.gsub! /^((tacacs|radius) server [^\n]+\n(\s+[^\n]+\n)*\s+key) [^\n]+$/m, '\1 <secret hidden>'
46
- cfg.gsub! /^(\s+ppp (chap|pap) password \d) .+/, '\\1 <secret hidden>'
38
+ cfg.gsub! /^( +ip ospf message-digest-key \d+ md5) .+/, '\\1 <secret hidden>'
39
+ cfg.gsub! /^( +ip ospf authentication-key) .+/, '\\1 <secret hidden>'
40
+ cfg.gsub! /^( +neighbor \S+ password) .+/, '\\1 <secret hidden>'
41
+ cfg.gsub! /^( +vrrp \d+ authentication text) .+/, '\\1 <secret hidden>'
42
+ cfg.gsub! /^( +standby \d+ authentication) .{1,8}$/, '\\1 <secret hidden>'
43
+ cfg.gsub! /^( +standby \d+ authentication md5 key-string) .+?( timeout \d+)?$/, '\\1 <secret hidden> \\2'
44
+ cfg.gsub! /^( +key-string) .+/, '\\1 <secret hidden>'
45
+ cfg.gsub! /^((tacacs|radius) server [^\n]+\n( +[^\n]+\n)* +key) [^\n]+$/m, '\1 <secret hidden>'
46
+ cfg.gsub! /^( +ppp (chap|pap) password \d) .+/, '\\1 <secret hidden>'
47
+ cfg.gsub! /^( +security wpa psk set-key (?:ascii|hex) \d) (.*)$/, '\\1 <secret hidden>'
48
+ cfg.gsub! /^( +dot1x username \S+ password \d) (.*)$/, '\\1 <secret hidden>'
49
+ cfg.gsub! /^( +mgmtuser username \S+ password \d) (.*) (secret \d) (.*)$/, '\\1 <secret hidden> \\3 <secret hidden>'
50
+ cfg.gsub! /^( +client \S+ server-key \d) (.*)$/, '\\1 <secret hidden>'
51
+ cfg.gsub! /^( +domain-password) \S+ ?(.*)/, '\\1 <secret hidden> \\2'
52
+ cfg.gsub! /^( +pre-shared-key).*/, '\\1 <configuration removed>'
47
53
  cfg
48
54
  end
49
55
 
@@ -74,7 +80,7 @@ class IOS < Oxidized::Model
74
80
 
75
81
  comments << "Memory: pcmcia #{Regexp.last_match(2)} #{Regexp.last_match(3)}#{Regexp.last_match(4)} #{Regexp.last_match(1)}" if line =~ /^(\d+[kK]) bytes of (Flash|ATA)?.*PCMCIA .*(slot|disk) ?(\d)/i
76
82
 
77
- if line =~ /(\S+(?:\sseries)?)\s+(?:\((\S+)\)\s+processor|\(revision[^)]+\)).*\s+with (\S+k) bytes/i
83
+ if line =~ /(\S+(?:\sseries)?)\s+(?:\(([\S ]+)\)\s+processor|\(revision[^)]+\)).*\s+with (\S+k) bytes/i
78
84
  sproc = Regexp.last_match(1)
79
85
  cpu = Regexp.last_match(2)
80
86
  mem = Regexp.last_match(3)
@@ -118,6 +124,8 @@ class IOS < Oxidized::Model
118
124
  cfg.gsub! /^ tunnel mpls traffic-eng bandwidth[^\n]*\n*(
119
125
  (?: [^\n]*\n*)*
120
126
  tunnel mpls traffic-eng auto-bw)/mx, '\1'
127
+ # get rid of values of custom SNMP OID's
128
+ cfg.gsub! /^(\s+expression) \d+$/, '\\1 <value removed>'
121
129
  cfg
122
130
  end
123
131
  end
@@ -16,7 +16,7 @@ class IOSXR < Oxidized::Model
16
16
  cfg
17
17
  end
18
18
 
19
- cmd 'admin show inventory' do |cfg|
19
+ cmd 'show inventory all' do |cfg|
20
20
  comment cfg
21
21
  end
22
22
 
@@ -42,6 +42,7 @@ class LenovoNOS < Oxidized::Model
42
42
  cfg = cfg.reject { |line| line.match /^Last boot:/ }
43
43
  cfg = cfg.reject { |line| line.match /^Temperature / }
44
44
  cfg = cfg.reject { |line| line.match /^Power Consumption/ }
45
+ cfg = cfg.reject { |line| line.match /^Fan/ }
45
46
 
46
47
  cfg = cfg.join
47
48
  comment_ext("=== show version ===", cfg)
@@ -63,6 +64,7 @@ class LenovoNOS < Oxidized::Model
63
64
  cfg.gsub! /^Current configuration:[^\n]*\n/, ''
64
65
  if vars(:remove_unstable_lines) == true
65
66
  cfg.gsub! /(.* password )"[0-9a-f]+"(.*)/, '\\1<unstable line hidden>\\2'
67
+ cfg.gsub! /(.* administrator-password )"[0-9a-f]+"(.*)/, '\\1<unstable line hidden>\\2'
66
68
  cfg.gsub! /(.*ekey )"[0-9a-f]+"(.*)/, '\\1<unstable line hidden>\\2'
67
69
  end
68
70
  cfg
@@ -1,7 +1,7 @@
1
1
  class LinuxGeneric < Oxidized::Model
2
2
  using Refinements
3
3
 
4
- prompt /^(\w.*|\W.*)(:|#) /
4
+ prompt /^(\w.*|\W.*)[:#$] /
5
5
  comment '# '
6
6
 
7
7
  # add a comment in the final conf
@@ -2,7 +2,7 @@ class Netgear < Oxidized::Model
2
2
  using Refinements
3
3
 
4
4
  comment '!'
5
- prompt /^(\([\w\s\-\+.]+\)\s?[#>])$/
5
+ prompt /^\(?[\w \-+.]+\)? ?[#>] ?$/
6
6
 
7
7
  cmd :secret do |cfg|
8
8
  cfg.gsub!(/password (\S+)/, 'password <hidden>')
@@ -4,7 +4,7 @@ class Nodegrid < Oxidized::Model
4
4
  # ZPE Nodegrid (Tested with Nodegrid Gate/Bold/NSR)
5
5
  # https://www.zpesystems.com/products/
6
6
 
7
- prompt(%r{(?<!@)\[(.*?\s/)\]#})
7
+ prompt /(?<!@)\[(.*?\s\/)\]#/
8
8
  comment '# '
9
9
 
10
10
  cmd 'show system/about/' do |cfg|
@@ -0,0 +1,30 @@
1
+ require 'net/http'
2
+ class NSXDfw < Oxidized::Model
3
+ using Refinements
4
+
5
+ cmd "/policy/api/v1/infra/domains/" do |cfg|
6
+ domains = JSON.parse(cfg.encode('UTF-8', { invalid: :replace, undef: :replace, replace: '?' }))["results"]
7
+ domain_config = {}
8
+ domains.each do |domain|
9
+ domain_config[domain['id']] = {}
10
+ policies_data = cmd "/policy/api/v1/infra/domains/#{domain['id']}/security-policies/"
11
+ policies = JSON.parse(policies_data.encode('UTF-8', { invalid: :replace, undef: :replace, replace: '?' }))["results"]
12
+ policies_config = {}
13
+ policies.each do |policy|
14
+ rules_data = cmd "/policy/api/v1/infra/domains/#{domain['id']}/security-policies/#{policy['id']}/rules"
15
+ rules = JSON.parse(rules_data.encode('UTF-8', { invalid: :replace, undef: :replace, replace: '?' }))["results"]
16
+ policies_config[policy['id']] = rules
17
+ end
18
+ domain_config[domain['id']] = policies_config
19
+ end
20
+ JSON.pretty_generate(domain_config)
21
+ end
22
+
23
+ cfg :http do
24
+ @username = @node.auth[:username]
25
+ @password = @node.auth[:password]
26
+ @headers['Content-Type'] = 'application/json'
27
+ @headers['Accept'] = 'application/json'
28
+ @secure = true
29
+ end
30
+ end
@@ -13,8 +13,9 @@ class NXOS < Oxidized::Model
13
13
  cfg.gsub! /^(snmp-server community).*/, '\\1 <secret hidden>'
14
14
  cfg.gsub! /^(snmp-server user (\S+) (\S+) auth (\S+)) (\S+) (priv) (\S+)/, '\\1 <secret hidden> '
15
15
  cfg.gsub! /^(snmp-server host.*? )\S+( udp-port \d+)?$/, '\\1<secret hidden>\\2'
16
+ cfg.gsub! /^(snmp-server mib community-map) \S+ ?(.*)/, '\\1 <secret hidden> \\2'
16
17
  cfg.gsub! /(password \d+) (\S+)/, '\\1 <secret hidden>'
17
- cfg.gsub! /^(radius-server key).*/, '\\1 <secret hidden>'
18
+ cfg.gsub! /^(radius-server .*key(?: \d+)?) \S+/, '\\1 <secret hidden>'
18
19
  cfg.gsub! /^(tacacs-server .*key(?: \d+)?) \S+/, '\\1 <secret hidden>'
19
20
  cfg
20
21
  end
@@ -0,0 +1,48 @@
1
+ class OS6 < Oxidized::Model
2
+ using Refinements
3
+
4
+ # For switches running Dell EMC Networking OS6 #
5
+ #
6
+ # Tested with : Dell PowerSwitch N2048
7
+
8
+ comment '! '
9
+
10
+ cmd :all do |cfg|
11
+ cfg.gsub! /^% Invalid input detected at '\^' marker\.$|^\s+\^$/, ''
12
+ cfg.each_line.to_a[2..-2].join
13
+ end
14
+
15
+ cmd :secret do |cfg|
16
+ cfg.gsub! /(password )(\S+)/, '\1<secret hidden>'
17
+ cfg
18
+ end
19
+
20
+ cmd 'show version' do |cfg|
21
+ comment cfg
22
+ end
23
+
24
+ cmd 'show interfaces transceiver properties' do |cfg|
25
+ comment cfg
26
+ end
27
+
28
+ cmd 'show running-config' do |cfg|
29
+ cfg.each_line.to_a[3..-1].join
30
+ end
31
+
32
+ cfg :telnet do
33
+ username /^Login:/
34
+ password /^Password:/
35
+ end
36
+
37
+ cfg :telnet, :ssh do
38
+ if vars :enable
39
+ post_login do
40
+ send "enable\n"
41
+ cmd vars(:enable)
42
+ end
43
+ end
44
+ post_login 'terminal length 0'
45
+ pre_logout 'exit'
46
+ pre_logout 'exit'
47
+ end
48
+ end
@@ -12,7 +12,7 @@ class RGOS < Oxidized::Model
12
12
 
13
13
  cmd 'show version' do |cfg|
14
14
  cfg = cfg.each_line.reject { |line| line.match /^System start time/ }.join
15
- cfg = cfg.each_line.reject { |line| line.match /^System uptime/ }.join
15
+ cfg = cfg.each_line.reject { |line| line.match /^\s*System uptime/ }.join
16
16
  comment "#{cfg.cut_both}\n"
17
17
  end
18
18
 
@@ -0,0 +1,104 @@
1
+ class Riverbed < Oxidized::Model
2
+ using Refinements
3
+
4
+ # Define the prompt
5
+ prompt /^.* *[\w-]+ *[#>] *$/
6
+
7
+ # Define comment character
8
+ comment '! '
9
+
10
+ # Remove sensitive information
11
+ cmd :secret do |cfg|
12
+ cfg.gsub! /^( *tacacs-server (.+ )?key) .+/, '\\1 <secret hidden>'
13
+ cfg.gsub! /^( *username .+ (password|secret) \d) .+/, '\\1 <secret hidden>'
14
+ cfg.gsub! /^( *ntp server .+ key) .+/, '\\1 <secret hidden>'
15
+ cfg.gsub! /^( *ntp peer .+ key) .+/, '\\1 <secret hidden>'
16
+ cfg.gsub! /^( *snmp-server community).*/, '\\1 <configuration removed>'
17
+ cfg.gsub! /^( *ip security shared secret).*/, '\\1 <secret hidden>'
18
+ cfg.gsub! /^( *service shared-secret secret client).*/, '\\1 <secret hidden>'
19
+ cfg.gsub! /^( *service shared-secret secret server).*/, '\\1 <secret hidden>'
20
+ cfg
21
+ end
22
+
23
+ # Get version information and output it as comments
24
+ cmd 'show version' do |cfg|
25
+ cfg = cfg.cut_both
26
+
27
+ output = ''
28
+ cfg.each_line do |line|
29
+ line.strip!
30
+ output << comment("Product name: #{Regexp.last_match(1)}\n") if line =~ /^Product name:\s+(.*)$/
31
+ output << comment("Product release: #{Regexp.last_match(1)}\n") if line =~ /^Product release:\s+(.*)$/
32
+ output << comment("Build ID: #{Regexp.last_match(1)}\n") if line =~ /^Build ID:\s+(.*)$/
33
+ output << comment("Build date: #{Regexp.last_match(1)}\n") if line =~ /^Build date:\s+(.*)$/
34
+ output << comment("Build arch: #{Regexp.last_match(1)}\n") if line =~ /^Build arch:\s+(.*)$/
35
+ output << comment("Built by: #{Regexp.last_match(1)}\n") if line =~ /^Built by:\s+(.*)$/
36
+ output << comment("Product model: #{Regexp.last_match(1)}\n") if line =~ /^Product model:\s+(.*)$/
37
+ output << comment("Number of CPUs: #{Regexp.last_match(1)}\n") if line =~ /^Number of CPUs:\s+(.*)$/
38
+ end
39
+ output + "\n"
40
+ end
41
+
42
+ # Get hardware information and output it as comments
43
+ cmd 'show hardware all' do |cfg|
44
+ cfg = cfg.cut_both
45
+
46
+ output = ''
47
+ cfg.each_line do |line|
48
+ line.strip!
49
+ output << comment("Hardware revision: #{Regexp.last_match(1)}\n") if line =~ /^Hardware revision:\s+(.*)$/
50
+ output << comment("Mainboard: #{Regexp.last_match(1)}\n") if line =~ /^Mainboard:\s+(.*)$/
51
+ if line =~ /^Slot (\d+):\s+\.*\s+(.*)$/
52
+ slot_number = Regexp.last_match(1)
53
+ slot_info = Regexp.last_match(2)
54
+ output << comment("Slot #{slot_number}: #{slot_info}\n")
55
+ end
56
+ output << comment("System led: #{Regexp.last_match(1)}\n") if line =~ /^System led:\s+(.*)$/
57
+ end
58
+ output + "\n"
59
+ end
60
+
61
+ # Get serial information and output it as comment
62
+ cmd 'show info' do |cfg|
63
+ cfg = cfg.cut_both
64
+
65
+ output = ''
66
+ cfg.each_line do |line|
67
+ line.strip!
68
+ output << comment("Serial: #{Regexp.last_match(1)}\n") if line =~ /^Serial:\s+(.*)$/
69
+ end
70
+ output + "\n"
71
+ end
72
+
73
+ # Get the running configuration
74
+ cmd 'show running-config' do |cfg|
75
+ cfg = cfg.cut_both
76
+
77
+ cfg = cfg.each_line.map do |line|
78
+ if line =~ /^(.*##.*?##)(.*)$/
79
+ comment_part = Regexp.last_match(1).strip
80
+ command_part = Regexp.last_match(2).strip
81
+ comment_line = comment(comment_part)
82
+ if command_part.empty?
83
+ comment_line + "\n"
84
+ else
85
+ comment_line + "\n" + command_part + "\n"
86
+ end
87
+ else
88
+ line
89
+ end
90
+ end.join
91
+
92
+ cfg
93
+ end
94
+
95
+ # SSH configuration
96
+ cfg :ssh do
97
+ post_login do
98
+ cmd 'enable'
99
+ cmd 'terminal length 0'
100
+ cmd 'terminal width 1024'
101
+ end
102
+ pre_logout 'exit'
103
+ end
104
+ end
@@ -14,8 +14,8 @@ class RouterOS < Oxidized::Model
14
14
  cfg
15
15
  end
16
16
 
17
- cmd '/system routerboard print' do |cfg|
18
- cfg = cfg.each_line.grep(/(model|firmware-type|current-firmware|serial-number):/).join
17
+ cmd '/system resource print' do |cfg|
18
+ cfg = cfg.each_line.grep(/(version|factory-software|total-memory|cpu|cpu-count|total-hdd-space|architecture-name|board-name|platform):/).join
19
19
  comment cfg
20
20
  end
21
21
 
@@ -4,12 +4,29 @@ class SAOS < Oxidized::Model
4
4
  # Ciena SAOS switch
5
5
  # used for 6.x devices
6
6
 
7
- comment '! '
7
+ comment '! '
8
+ prompt /^[\w-]+\*?>\s?/
8
9
 
9
10
  cmd :all do |cfg|
11
+ cfg.gsub! /(Waiting for )(accounting|authorization).*\n/, '' # Remove TACACS errors
10
12
  cfg.cut_both
11
13
  end
12
14
 
15
+ cmd 'chassis show device-id power' do |cfg|
16
+ comment cfg
17
+ end
18
+
19
+ cmd 'software show' do |cfg|
20
+ cfg.gsub! /^\| Bank status.*/, '| Bank status : <removed> |'
21
+ comment cfg
22
+ end
23
+
24
+ cmd 'port xcvr show' do |cfg|
25
+ cfg.gsub! /^SHELL PARSER FAILURE.*/, '' # Ignore command failure
26
+ cfg.gsub! /(\s\|.{10}\|)(Ena\s\s|\s\sDis|UCTF\s)(.*)/, '\1 \3' # Remove transient operational state
27
+ comment cfg
28
+ end
29
+
13
30
  cmd 'configuration show' do |cfg|
14
31
  cfg.gsub! /^! Created: [^\n]*\n/, ''
15
32
  cfg.gsub! /^! On terminal: [^\n]*\n/, ''
@@ -0,0 +1,22 @@
1
+ class SikluMHTG < Oxidized::Model
2
+ using Refinements
3
+
4
+ # Siklu MultiHaul TG#
5
+ # Requires source to define the model as SikluMHTG #
6
+
7
+ prompt /^\r?MH-[TN]\d{3}[\@][\w]{2,8}>$/
8
+
9
+ expect /--More--/ do |data, re|
10
+ send ' '
11
+ data.sub re, ''
12
+ end
13
+
14
+ cmd 'show startup' do |cfg|
15
+ cfg.gsub! /[\b]|\e\[A|\e\[2K/, ''
16
+ cfg.cut_both
17
+ end
18
+
19
+ cfg :ssh do
20
+ pre_logout 'quit'
21
+ end
22
+ end
@@ -0,0 +1,46 @@
1
+ class UPLINKOLT < Oxidized::Model
2
+ prompt /^([\w.@()-]+[#>]\s?)$/
3
+ comment '! '
4
+
5
+ cmd :all do |cfg|
6
+ cfg.gsub! /^% Invalid input detected at '\^' marker\.$|^\s+\^$/, ''
7
+ cfg.gsub!(/^show running-config$/, '')
8
+ cfg.gsub!(/^.*\s*#\s*$/, '')
9
+ # Remove leading and trailing whitespace
10
+ cfg.strip!
11
+ # Remove empty lines
12
+ cfg.gsub!(/^\s*$/, '')
13
+ cfg
14
+ end
15
+
16
+ cmd 'configure terminal' do
17
+ # Enter configure terminal mode
18
+ cmd 'show version' do |cfg|
19
+ cfg.gsub! /^show version/, ''
20
+ comment cfg
21
+ end
22
+ end
23
+
24
+ cmd 'show running-config' do |cfg|
25
+ cfg.gsub! /^Current configuration:/, ''
26
+ cfg
27
+ end
28
+
29
+ cfg :telnet, :ssh do
30
+ username /^Login:/i
31
+ password /^Password:/i
32
+ # preferred way to handle additional passwords
33
+ post_login do
34
+ if vars(:enable) == true
35
+ cmd "enable"
36
+ elsif vars(:enable)
37
+ cmd "enable", /^[pP]assword:/
38
+ cmd vars(:enable)
39
+ end
40
+ end
41
+ post_login 'terminal length 0'
42
+ pre_logout 'exit'
43
+ pre_logout 'disable'
44
+ pre_logout 'exit'
45
+ end
46
+ end
@@ -3,7 +3,7 @@ class Vyatta < Oxidized::Model
3
3
 
4
4
  # Brocade Vyatta / VyOS model #
5
5
 
6
- prompt /@.*?:~\$\s/
6
+ prompt /@.*(:~\$|>)\s/
7
7
 
8
8
  cmd :all do |cfg|
9
9
  cfg.lines.to_a[1..-2].join
@@ -14,7 +14,7 @@ class Vyatta < Oxidized::Model
14
14
  cfg.gsub! /plaintext-password (\S+).*/, 'plaintext-password <secret removed>'
15
15
  cfg.gsub! /password (\S+).*/, 'password <secret removed>'
16
16
  cfg.gsub! /pre-shared-secret (\S+).*/, 'pre-shared-secret <secret removed>'
17
- cfg.gsub! /community (\S+) {/, 'community <hidden> {'
17
+ cfg.gsub! /community (\S+)/, 'community <hidden>'
18
18
  cfg.gsub! /private-key (\S+).*/, 'private-key <secret removed>'
19
19
  cfg.gsub! /preshared-key (\S+).*/, 'preshared-key <secret removed>'
20
20
  cfg
@@ -12,6 +12,13 @@ class XOS < Oxidized::Model
12
12
  cfg.each_line.to_a[1..-2].map { |line| line.delete("\r").rstrip }.join("\n") + "\n"
13
13
  end
14
14
 
15
+ cmd :secret do |cfg|
16
+ cfg.gsub! /^(configure radius (netlogin|mgmt-access) (primary|secondary) shared-secret encrypted).+/, '\\1 <secret hidden>'
17
+ cfg.gsub! /^(configure account admin encrypted).+/, '\\1 <secret hidden>'
18
+ cfg.gsub! /^(create account (admin|user) (.+) encrypted).+/, '\\1 <secret hidden>'
19
+ cfg
20
+ end
21
+
15
22
  cmd 'show version' do |cfg|
16
23
  comment cfg
17
24
  end