oxidized 0.30.1 → 0.32.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +3 -4
  3. data/.github/workflows/stale.yml +4 -2
  4. data/.rubocop.yml +18 -3
  5. data/.rubocop_todo.yml +4 -11
  6. data/CHANGELOG.md +93 -1
  7. data/CONTRIBUTING.md +5 -0
  8. data/Dockerfile +84 -20
  9. data/README.md +5 -21
  10. data/Rakefile +31 -2
  11. data/docs/Configuration.md +50 -14
  12. data/docs/Creating-Models.md +75 -4
  13. data/docs/DeviceSimulation.md +184 -0
  14. data/docs/Hooks.md +39 -5
  15. data/docs/Issues.md +97 -0
  16. data/docs/Model-Notes/APC_AOS.md +29 -16
  17. data/docs/Model-Notes/Cumulus.md +5 -0
  18. data/docs/Model-Notes/FSOS.md +6 -0
  19. data/docs/Model-Notes/FortiOS.md +21 -5
  20. data/docs/Model-Notes/HPEAruba.md +31 -0
  21. data/docs/Model-Notes/OS6.md +10 -0
  22. data/docs/Model-Notes/RouterOS.md +15 -0
  23. data/docs/Model-Notes/SikluMHTG.md +7 -0
  24. data/docs/ModelUnitTests.md +186 -0
  25. data/docs/Outputs.md +2 -0
  26. data/docs/Release.md +18 -15
  27. data/docs/Sources.md +21 -0
  28. data/docs/Supported-OS-Types.md +14 -7
  29. data/docs/Troubleshooting.md +35 -0
  30. data/examples/podman-compose/Makefile +59 -17
  31. data/examples/podman-compose/README.md +63 -27
  32. data/examples/podman-compose/docker-compose.yml +11 -2
  33. data/examples/podman-compose/gitserver/.gitignore +1 -0
  34. data/examples/podman-compose/gitserver/Dockerfile +14 -0
  35. data/examples/podman-compose/model-simulation/Dockerfile-model +1 -1
  36. data/examples/podman-compose/model-simulation/asternos.sh +2 -0
  37. data/examples/podman-compose/oxidized-config/.gitignore +2 -0
  38. data/examples/podman-compose/oxidized-config/config +1 -1
  39. data/examples/podman-compose/oxidized-config/config_csv-file +46 -0
  40. data/examples/podman-compose/oxidized-config/config_csv-gitserver +56 -0
  41. data/examples/podman-compose/oxidized-ssh/.gitignore +1 -0
  42. data/extra/device2yaml.rb +245 -0
  43. data/extra/gitdiff-msteams.sh +32 -5
  44. data/extra/nagios_check_failing_nodes.rb +1 -1
  45. data/extra/rest_client.rb +1 -1
  46. data/lib/oxidized/config.rb +8 -2
  47. data/lib/oxidized/hook/githubrepo.rb +37 -7
  48. data/lib/oxidized/hook/slackdiff.rb +29 -7
  49. data/lib/oxidized/input/http.rb +1 -0
  50. data/lib/oxidized/input/ssh.rb +13 -5
  51. data/lib/oxidized/input/telnet.rb +1 -1
  52. data/lib/oxidized/manager.rb +17 -16
  53. data/lib/oxidized/model/aos7.rb +2 -0
  54. data/lib/oxidized/model/aoscx.rb +16 -2
  55. data/lib/oxidized/model/aosw.rb +8 -2
  56. data/lib/oxidized/model/apc_aos.rb +1 -1
  57. data/lib/oxidized/model/arubainstant.rb +90 -0
  58. data/lib/oxidized/model/asa.rb +2 -1
  59. data/lib/oxidized/model/asyncos.rb +1 -1
  60. data/lib/oxidized/model/audiocodes.rb +2 -2
  61. data/lib/oxidized/model/cnos.rb +13 -10
  62. data/lib/oxidized/model/cumulus.rb +19 -2
  63. data/lib/oxidized/model/dlink.rb +1 -0
  64. data/lib/oxidized/model/dlinknextgen.rb +3 -0
  65. data/lib/oxidized/model/edgecos.rb +2 -1
  66. data/lib/oxidized/model/enterprise_sonic.rb +46 -0
  67. data/lib/oxidized/model/eos.rb +2 -0
  68. data/lib/oxidized/model/f5os.rb +17 -0
  69. data/lib/oxidized/model/firewareos.rb +10 -1
  70. data/lib/oxidized/model/fortios.rb +24 -1
  71. data/lib/oxidized/model/fsos.rb +5 -1
  72. data/lib/oxidized/model/garderos.rb +43 -0
  73. data/lib/oxidized/model/h3c.rb +1 -1
  74. data/lib/oxidized/model/ibos.rb +1 -0
  75. data/lib/oxidized/model/ios.rb +20 -12
  76. data/lib/oxidized/model/iosxr.rb +1 -1
  77. data/lib/oxidized/model/junos.rb +1 -1
  78. data/lib/oxidized/model/kornfeldos.rb +33 -0
  79. data/lib/oxidized/model/lenovonos.rb +2 -0
  80. data/lib/oxidized/model/linuxgeneric.rb +1 -1
  81. data/lib/oxidized/model/model.rb +2 -2
  82. data/lib/oxidized/model/netgear.rb +1 -1
  83. data/lib/oxidized/model/nodegrid.rb +1 -1
  84. data/lib/oxidized/model/nsxdfw.rb +30 -0
  85. data/lib/oxidized/model/nxos.rb +2 -1
  86. data/lib/oxidized/model/os6.rb +48 -0
  87. data/lib/oxidized/model/rgos.rb +1 -1
  88. data/lib/oxidized/model/riverbed.rb +104 -0
  89. data/lib/oxidized/model/routeros.rb +2 -2
  90. data/lib/oxidized/model/saos.rb +18 -1
  91. data/lib/oxidized/model/siklumhtg.rb +22 -0
  92. data/lib/oxidized/model/sonicos.rb +8 -2
  93. data/lib/oxidized/model/tplink.rb +1 -0
  94. data/lib/oxidized/model/uplinkolt.rb +46 -0
  95. data/lib/oxidized/model/vyatta.rb +2 -2
  96. data/lib/oxidized/model/xos.rb +7 -0
  97. data/lib/oxidized/node.rb +30 -18
  98. data/lib/oxidized/nodes.rb +13 -5
  99. data/lib/oxidized/output/file.rb +45 -42
  100. data/lib/oxidized/output/git.rb +185 -160
  101. data/lib/oxidized/output/gitcrypt.rb +188 -186
  102. data/lib/oxidized/output/http.rb +53 -51
  103. data/lib/oxidized/output/output.rb +6 -4
  104. data/lib/oxidized/source/csv.rb +44 -49
  105. data/lib/oxidized/source/http.rb +63 -81
  106. data/lib/oxidized/source/jsonfile.rb +63 -0
  107. data/lib/oxidized/source/source.rb +73 -18
  108. data/lib/oxidized/source/sql.rb +66 -59
  109. data/lib/oxidized/version.rb +2 -2
  110. data/oxidized.gemspec +25 -18
  111. metadata +115 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 408f73ee50ed7040fab6c0034d197c5755f4d1042e8f9923ab8159fd90d36497
4
- data.tar.gz: 747b1a2c42d53a8eb1903b61119f7184b8fe78c2ea240d879523c6d8758cc42a
3
+ metadata.gz: b47cc2ddbb41778414a86ed387714b91340ff440f125d948b8168c6ab1641f71
4
+ data.tar.gz: 492d75d181d94cef898e5a687715d81e94dd9139ff6310e4c6b304edb92be39e
5
5
  SHA512:
6
- metadata.gz: 216511de21f3497c2cf36f22b379b3eba411e39e969544e7a6fb0d5ec60e725d2086621f8c803cfef3fb88655fd27d78a1973a2df947712a3ee124f7189c5293
7
- data.tar.gz: 567883bf03d9e46c0df4f4fead4e361f7a2b30e648cad01e994da14a705d99cd7e06763de9f8f8aedc87578757df02e2fad9bda343fd08dca22770d3478a4ebb
6
+ metadata.gz: c5028d2ae6b9ecb04783381d0804d68014f308e4109627b27d7a4c8225529ea06d3c300a46547fcfd47f1c961acab294cb7abae8200b0aa857a86af27c6f1269
7
+ data.tar.gz: cbeebeca48db2727432e42d069f3b94d326e150163944f27a21594dcaf73bc0eab7b91518f5d265c5a576e083b749ca733123fa438d247d15d9d2cf365b4a1dc
@@ -19,7 +19,8 @@ jobs:
19
19
  runs-on: ubuntu-latest
20
20
  strategy:
21
21
  matrix:
22
- ruby-version: ['3.0', '3.1', '3.2']
22
+ ruby-version: ['3.1', '3.2', '3.3', '3.4', 'ruby-head']
23
+ continue-on-error: ${{ matrix.ruby-version == 'ruby-head' }}
23
24
 
24
25
  steps:
25
26
  - uses: actions/checkout@v4
@@ -34,9 +35,7 @@ jobs:
34
35
  uses: reviewdog/action-rubocop@v2
35
36
  with:
36
37
  rubocop_version: gemfile
37
- rubocop_extensions: rubocop-minitest:gemfile rubocop-rake:gemfile
38
+ rubocop_extensions: rubocop-minitest:gemfile rubocop-rake:gemfile rubocop-sequel:gemfile
38
39
  reporter: github-pr-review
39
40
  - name: Run tests
40
41
  run: bundle exec rake
41
- - uses: codecov/codecov-action@v3
42
- if: ${{ always() }}
@@ -14,6 +14,8 @@ jobs:
14
14
  steps:
15
15
  - uses: actions/stale@v9
16
16
  with:
17
+ stale-issue-message: 'This issue is stale because it has been open 90 days with no activity.'
18
+ stale-pr-message: 'This PR is stale because it has been open 90 days with no activity.'
17
19
  operations-per-run: 500
18
- days-before-issue-stale: 90
19
- days-before-close: 30
20
+ days-before-stale: 90
21
+ days-before-close: -1
data/.rubocop.yml CHANGED
@@ -1,9 +1,8 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
- # Do not attempt to police vendored code
4
3
  AllCops:
5
4
  NewCops: enable
6
- TargetRubyVersion: 3.0
5
+ # Do not attempt to police vendored code
7
6
  Exclude:
8
7
  - 'vendor/**/*'
9
8
 
@@ -19,8 +18,12 @@ Style/FrozenStringLiteralComment:
19
18
  Layout/LineLength:
20
19
  Enabled: false
21
20
 
21
+ # We do not enforce the cop in the models as it would not work with the
22
+ # DSL style of the models
22
23
  Lint/AmbiguousRegexpLiteral:
23
- Enabled: false
24
+ Enabled: true
25
+ Exclude:
26
+ - lib/oxidized/model/*.rb
24
27
 
25
28
  Lint/RaiseException:
26
29
  Enabled: true
@@ -52,12 +55,19 @@ Style/FormatStringToken:
52
55
  Style/HashEachMethods:
53
56
  Enabled: true
54
57
 
58
+ Style/HashSyntax:
59
+ EnforcedShorthandSyntax: either
60
+
55
61
  Style/HashTransformKeys:
56
62
  Enabled: true
57
63
 
58
64
  Style/HashTransformValues:
59
65
  Enabled: true
60
66
 
67
+ Style/RegexpLiteral:
68
+ EnforcedStyle: slashes
69
+ AllowInnerSlashes: true
70
+
61
71
  Style/RescueModifier:
62
72
  Enabled: false
63
73
 
@@ -82,8 +92,12 @@ Metrics/ClassLength:
82
92
  ## Metrics/CyclomaticComplexity:
83
93
  ## Max: 7
84
94
 
95
+ # The BlockLength metric does not apply to unit tests. They are in nature
96
+ # long and not very pretty
85
97
  Metrics/BlockLength:
86
98
  Max: 150
99
+ Exclude:
100
+ - spec/**/*_spec.rb
87
101
 
88
102
  Metrics/ParameterLists:
89
103
  Max: 6
@@ -94,3 +108,4 @@ Lint/EmptyBlock:
94
108
  require:
95
109
  - rubocop-rake
96
110
  - rubocop-minitest
111
+ - rubocop-sequel
data/.rubocop_todo.yml CHANGED
@@ -1,12 +1,12 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2024-02-27 14:27:59 UTC using RuboCop version 1.60.2.
3
+ # on 2025-02-17 10:13:53 UTC using RuboCop version 1.72.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 27
9
+ # Offense count: 30
10
10
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
11
11
  Metrics/AbcSize:
12
12
  Enabled: false
@@ -72,19 +72,12 @@ Style/OpenStructUse:
72
72
  - 'lib/oxidized/node.rb'
73
73
  - 'spec/hook/githubrepo_spec.rb'
74
74
 
75
- # Offense count: 47
76
- # This cop supports safe autocorrection (--autocorrect).
77
- # Configuration parameters: EnforcedStyle, AllowInnerSlashes.
78
- # SupportedStyles: slashes, percent_r, mixed
79
- Style/RegexpLiteral:
80
- Enabled: false
81
-
82
- # Offense count: 31
75
+ # Offense count: 33
83
76
  # This cop supports unsafe autocorrection (--autocorrect-all).
84
77
  Style/SlicingWithRange:
85
78
  Enabled: false
86
79
 
87
- # Offense count: 83
80
+ # Offense count: 94
88
81
  # This cop supports unsafe autocorrection (--autocorrect-all).
89
82
  # Configuration parameters: Mode.
90
83
  Style/StringConcatenation:
data/CHANGELOG.md CHANGED
@@ -4,6 +4,99 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
6
 
7
+ ## [0.32.0 – 2025-02-17]
8
+ This release fixes a security issue in oxidized-web, which is included in the
9
+ Docker container of oxidized. If you are not using the Docker container but
10
+ use oxidized-web, be sure to update your oxidized-web gem to 0.15.0.
11
+
12
+ ### Added
13
+ - junos: add unit test (@systeembeheerder)
14
+ - apc_aos: support for scp (@robertcheramy)
15
+ - config: allow model_map and group_map keys to be regexp. Fixes #3360 (@ytti)
16
+ - enterprise_sonic: add new model enterprise_sonic (@ohai89)
17
+ - model for Kornfeld Operating System (@yurenkov)
18
+
19
+ ### Changed
20
+ - sonicos: accept policy message. Fixes #3339 (@Steve-M-C, @robertcheramy)
21
+ - input/ssh: change input.debug to dump all characters and include sent commands. (@robertcheramy)
22
+ - cumulus: remove ANSI Escape codes and fix prompt issues. The prompt is more specific now (@alchemyx, @robertcheramy)
23
+ - model unit tests: the tests are automated and simpler to use (@ytti, @robertcheramy)
24
+ - device2yaml.rb: moved to extra/, commands can be specified from the command line or from a file (no cmdsets provided anymore) (@robertcheramy)
25
+ - extra/gitdiff-msteams.sh: honor the 28KB size limit and add an optional link to GitHub (@mopi3456)
26
+
27
+ ### Fixed
28
+ - tplink: send 'enable' before the enable password. Fixes #3271 (@robertcheramy)
29
+ - asyncos: fix prompt for hostnames containing "-" . Fixes #3327 (@robertcheramy)
30
+ - sonicos: fix prompt for hostnames containing "-" . Fixes #3333 (@robertcheramy)
31
+ - xos: Hide radius accounting secret
32
+ - fsos: Hide AAA and SNMP secrets (@RayaneB35)
33
+ - aos7: fix prompt for version 8.8x. Fixes #3351 (@robertcheramy)
34
+ - aosw: Hide power measurements (@rouven0)
35
+ - arubainstant: show version prepends a space to prompt when a core file is present. Fixes #3398 (@robertcheramy)
36
+
37
+
38
+ ## [0.31.0 – 2024-11-29]
39
+
40
+ ### Added
41
+ - model for Riverbed Steelhead (@Swaeltjie)
42
+ - model for uplink EP4440-DP OLT (@AAm-kun)
43
+ - model for Siklu Multihaul TG radios (@bdg-robert)
44
+ - model for VMWare NSX DFW (@elmobp)
45
+ - model for F5OS (@teunvink)
46
+ - cumulus: Add possibility to use NVUE (@lagertonne)
47
+ - model for garderos (@robertcheramy)
48
+ - unit tests framework for models with ssh input (@robertcheramy)
49
+ - os6: Added support to Dell EMC Networking OS6 (@anubisg1)
50
+ - model for HPE Aruba Networking Instant Mode (Aruba Instant). Fixes #3057 (@robertcheramy)
51
+ - Add JSONFILE source (@sargon)
52
+
53
+ ### Changed
54
+ - h3c: change prompt to expect either angle (user-view) or square (system-view) brackets (@nl987)
55
+ - xos: Hide radius and user secrets for XOS (@iriseden)
56
+ - eos: Hide radius and snmp secrets for Arista EOS (@iriseden)
57
+ - fortios: Hide date in acme certifcate comments (@systeembeheerder)
58
+ - dlink: added support for 'enable admin' before getting configuration, if enable=true (@as8net)
59
+ - dlinknextgen: strip uptime and ntp update time from config
60
+ - Updated slackdiff.rb to use slack_ruby_client instead of slack-api (@Punicaa)
61
+ - oxidized: options (such as credentials, etc.) now use the same resolution logic as variables and can also be defined per model in a group (@EinGlasVollKakao)
62
+ - saos: add inventory and software status collection (@grbeneke)
63
+ - container-image: update to phusion/baseimage:noble-1.0.0 and include security upgrades at build time (@robertcheramy)
64
+ - container-image: use ubuntu-packages instead of gems in order to reduce container image size (@robertcheramy)
65
+ - edgecos.rb: hide temperature and fan speed (@dhooper6430)
66
+ - cnos: show information before config, remove secrets only when told to do so (@robje)
67
+ - Updated slackdiff.rb to use new files.getUploadURLExternal slack file upload API instead of deprecated files.upload (@varesa)
68
+ - Updated source/output files to reference a Source/Output module to avoid namespace duplication (@laf, @robertcheramy)
69
+ - ios: Hide WLAN PSK, AP profile dot1x password, AP profile mgmtuser password/secret and radius COA server-key (@devon-mar)
70
+ - ios: remove values from custom SNMP OID's, set by an EEM script (@syn-bit)
71
+ - Update net-ssh to 7.3 to enable support for aes(128|256)gcm. Fixes #3168 (@jacobw)
72
+ - removed time command from uplink EP4440-DP OLT model
73
+ - fortios: variable `fullconfig` to get the configuration with default values. Fixes: #3159 (@robertcheramy)
74
+ - container-image: install x25519 gem package to support more ssh kex. Fixes #3070 (@benasse)
75
+ - lenovonos: Salt administrator-password line when remove_unstable_lines is set to True (@kani999)
76
+ - lenovonos: Removes lines that started with Fan because RPM always changes. (@kani999)
77
+
78
+ ### Fixed
79
+ - fixed error for ibos when remove_secret is set (@dminuoso)
80
+ - fixed prompt for Watchguard FirewareOS not matching the regex when the node is managed and master (@benasse)
81
+ - fixed prompt for vyos/vyatta to allow logins with non-priviliged accounts. Fixes #3111 (@h-lopez)
82
+ - fixed power consumption included in ArubaOS-CX diffs starting with FL.10.13.xxx. Fixes #3142 (@terratalpi)
83
+ - fixed oxidized-web getting "version not found" when fetching a version from git and no group is defined. Fixes #2222 (@robertcheramy)
84
+ - fixed telnet to disconnect gracefully even if it throws IOError while disconnect. Fixes #3212 (@ytti)
85
+ - docs: run git garbage collection to address performance issues. Fixes #3121 (@robertcheramy)
86
+ - saos: fixed handling of 'unsaved configuration' indicator in prompt (@grbeneke)
87
+ - rgos: also strip "System uptime" for installed modules (@spike77453)
88
+ - fixed digest authentication when using http input (@spike77453)
89
+ - fixed aosw prompt; now working with ArubaOS 8 (@mabezi, @robertcheramy)
90
+ - routeros: fix system info for CHR. Fixes #3180 (@systeembeheerder)
91
+ - removed hardcoded '~/.config/oxidized/config'. Fixes #3229 (@robertcheramy)
92
+ - linuxgeneric: updated prompt to support '$' at the end (@robertcheramy)
93
+ - hook githubrepo: add a specific warning when rugged not installed with ssh support. Fixes #3211 (@robertcheramy)
94
+ - hook githubrepo: works with custom branch names (@robertcheramy)
95
+ - ios: removes secrets when config has multiple snmp-server host lines. Fixes #3239 (@robertcheramy)
96
+ - ios: fixed device specs on ASR900 Series. Fixes #3297 (@robertcheramy, @roshnaraman)
97
+ - netgear: prompt for gs752tpp. Fixes #3287 (@robertcheramy)
98
+ - aoscx: fixed regex for 6400 switches to hide temperature and power (@steveneppler)
99
+
7
100
 
8
101
  ## [0.30.1 – 2024-04-12]
9
102
 
@@ -13,7 +106,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
13
106
  ### Fixed
14
107
  - The version string was not set correctly (@robertcheramy)
15
108
 
16
-
17
109
  ## [0.30.0 – 2024-04-11]
18
110
 
19
111
  ### Added
data/CONTRIBUTING.md CHANGED
@@ -6,6 +6,9 @@ A great place for users to get involved is the [GitHub issues](https://github.co
6
6
  Through the issues, you can interact with maintainers and other users. You can open an issue
7
7
  if you need help, but you can also help other users by reviewing their issues and commenting on them.
8
8
 
9
+ Before writing an issue, please read our documentation on
10
+ [how to write good issues](/docs/Issues.md).
11
+
9
12
  > ## Legal Notice
10
13
  > When submitting content to this project, you must agree that you have authored 100%
11
14
  > of the content, that you have the necessary rights to the content and that the
@@ -119,6 +122,8 @@ bundle config set --local path 'vendor/bundle'
119
122
  bundle install
120
123
  ```
121
124
 
125
+ Note: if you need to install rugged with ssh support, you can tell bundler so with `bundle config build.rugged --with-ssh`. Reinstall rugged with `bundle pristine rugged`
126
+
122
127
  ### Run your code
123
128
  ```bash
124
129
  bundle exec bin/oxidized
data/Dockerfile CHANGED
@@ -1,39 +1,46 @@
1
- # Single-stage build of an oxidized container from phusion/baseimage-docker jammy-1.0.1, derived from Ubuntu 22.04 (Jammy Jellyfish)
2
- FROM docker.io/phusion/baseimage:jammy-1.0.1
1
+ ###################
2
+ # Stage 1: Prebuild to save space in the final image.
3
3
 
4
- # set up dependencies for the build process
5
- RUN apt-get -yq update \
6
- && apt-get -yq --no-install-recommends install ruby3.0 ruby3.0-dev libssl3 bzip2 libssl-dev pkg-config make cmake libssh2-1 libssh2-1-dev git git-email libmailtools-perl g++ libffi-dev ruby-bundler libicu70 libicu-dev libsqlite3-0 libsqlite3-dev libmysqlclient21 libmysqlclient-dev libpq5 libpq-dev zlib1g-dev msmtp \
7
- && apt-get clean \
4
+ FROM docker.io/phusion/baseimage:noble-1.0.0 AS prebuilder
5
+
6
+ # install necessary packages for building gems
7
+ RUN apt-get update && apt-get install -y \
8
+ build-essential \
9
+ git \
10
+ ruby-dev \
8
11
  && rm -rf /var/lib/apt/lists/*
9
12
 
10
- # dependencies for hooks
11
- RUN gem install --no-document aws-sdk slack-ruby-client xmpp4r cisco_spark
13
+ # create bundle directory
14
+ RUN mkdir -p /usr/local/bundle
15
+ ENV GEM_HOME=/usr/local/bundle
12
16
 
13
- # dependencies for sources
14
- RUN gem install --no-document gpgme sequel sqlite3 mysql2 pg
17
+ ###################
18
+ # Install the x25519 gem
19
+ RUN gem install x25519 --no-document
15
20
 
16
- # dependencies for inputs
17
- RUN gem install --no-document net-tftp net-http-persistent mechanize
18
21
 
19
- # build and install oxidized
22
+ ###################
23
+ # build oxidized
20
24
  COPY . /tmp/oxidized/
21
25
  WORKDIR /tmp/oxidized
22
26
 
23
27
  # docker automated build gets shallow copy, but non-shallow copy cannot be unshallowed
24
28
  RUN git fetch --unshallow || true
25
29
 
30
+ # Remove any older gems of oxidized if they exist
31
+ RUN rm pkg/* || true
32
+
26
33
  # Ensure rugged is built with ssh support
27
- RUN CMAKE_FLAGS='-DUSE_SSH=ON' rake install
34
+ RUN rake build
28
35
 
29
- # web interface
30
- RUN gem install oxidized-web --no-document
31
36
 
32
- # clean up
33
- WORKDIR /
34
- RUN rm -rf /tmp/oxidized
35
- RUN apt-get -yq --purge autoremove ruby-dev pkg-config make cmake ruby-bundler libssl-dev libssh2-1-dev libicu-dev libsqlite3-dev libmysqlclient-dev libpq-dev zlib1g-dev
37
+ ###################
38
+ # Stage2: build an oxidized container from phusion/baseimage-docker and install x25519 from stage1
39
+ FROM docker.io/phusion/baseimage:noble-1.0.0
40
+
41
+ ENV DEBIAN_FRONTEND=noninteractive
36
42
 
43
+ ##### Place "static" commands at the beginning to optimize image size and build speed
37
44
  # add non-privileged user
38
45
  ARG UID=30000
39
46
  ARG GID=$UID
@@ -55,4 +62,61 @@ COPY extra/oxidized.runit /etc/service/oxidized/run
55
62
  COPY extra/auto-reload-config.runit /etc/service/auto-reload-config/run
56
63
  COPY extra/update-ca-certificates.runit /etc/service/update-ca-certificates/run
57
64
 
65
+ # set up dependencies for the build process
66
+ RUN apt-get -yq update \
67
+ && apt-get -yq upgrade \
68
+ && apt-get -yq --no-install-recommends install ruby \
69
+ # Build process of oxidized from git (beloww)
70
+ git \
71
+ # Allow git send-email from docker image
72
+ git-email libmailtools-perl \
73
+ # Allow sending emails in the docker container
74
+ msmtp \
75
+ # Debuging tools inside the container
76
+ inetutils-telnet \
77
+ # Use ubuntu gems where possible
78
+ # Gems needed by oxidized
79
+ ruby-rugged ruby-slop ruby-psych \
80
+ ruby-net-telnet ruby-net-ssh ruby-net-ftp ruby-ed25519 \
81
+ # Gem dependencies for inputs
82
+ ruby-net-http-persistent ruby-mechanize \
83
+ # Gem dependencies for sources
84
+ ruby-sqlite3 ruby-mysql2 ruby-pg ruby-sequel ruby-gpgme\
85
+ # Gem dependencies for hooks
86
+ ruby-aws-sdk ruby-xmpp4r \
87
+ # Gems needed by oxidized-web
88
+ ruby-charlock-holmes ruby-haml ruby-htmlentities ruby-json \
89
+ puma ruby-sinatra ruby-sinatra-contrib \
90
+ && apt-get clean \
91
+ && rm -rf /var/lib/apt/lists/*
92
+
93
+ # copy the compiled gem from the builder stage
94
+ COPY --from=prebuilder /usr/local/bundle /usr/local/bundle
95
+
96
+ # Set environment variables for bundler
97
+ ENV GEM_HOME="/usr/local/bundle"
98
+ ENV PATH="$GEM_HOME/bin:$PATH"
99
+
100
+ # gems not available in ubuntu noble
101
+ RUN gem install --no-document \
102
+ # dependencies for hooks
103
+ slack-ruby-client cisco_spark \
104
+ # dependencies for specific inputs
105
+ net-tftp \
106
+ # Net scp is needed in Version >= 4.1.0, which is not available in ubuntu
107
+ net-scp
108
+
109
+ # install oxidized from prebuilder
110
+ # The Dockerfile ist version-independent, so use oxidized-*.gem to cach the gem
111
+ RUN mkdir -p /tmp/oxidized
112
+ COPY --from=prebuilder /tmp/oxidized/pkg/oxidized-*.gem /tmp/oxidized/
113
+ RUN gem install /tmp/oxidized/oxidized-*.gem
114
+
115
+ # install oxidized-web
116
+ RUN gem install oxidized-web --no-document
117
+
118
+ # clean up
119
+ WORKDIR /
120
+ RUN rm -rf /tmp/oxidized
121
+
58
122
  EXPOSE 8888/tcp
data/README.md CHANGED
@@ -101,23 +101,7 @@ gem install oxidized-script oxidized-web # If you don't install oxidized-web, en
101
101
 
102
102
  ### CentOS, Oracle Linux, Red Hat Linux
103
103
 
104
- On CentOS 6 and 7 / RHEL 6 and 7, begin by installing Ruby 2.3 or greater. This can be accomplished in one of several ways:
105
-
106
- Install Ruby 2.3 from [SCL](https://www.softwarecollections.org/en/scls/rhscl/rh-ruby23/):
107
-
108
- ```shell
109
- yum install centos-release-scl
110
- yum install rh-ruby30 rh-ruby30-ruby-devel
111
- scl enable rh-ruby30 bash
112
- ```
113
-
114
- The following additional packages will be required to build the dependencies:
115
-
116
- ```shell
117
- yum install make cmake which sqlite-devel openssl-devel libssh2-devel ruby gcc ruby-devel libicu-devel gcc-c++
118
- ```
119
-
120
- Alternatively, install Ruby 2.6 via RVM by following the instructions:
104
+ On CentOS 6 and 7 / RHEL 6 and 7, begin by installing Ruby 3.1 via RVM by following the instructions:
121
105
 
122
106
  Make sure you dont have any leftover ruby:
123
107
  ```yum erase ruby```
@@ -129,8 +113,8 @@ sudo gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A17031138
129
113
  curl -sSL https://get.rvm.io | bash -s stable
130
114
  source /etc/profile.d/rvm.sh
131
115
  rvm requirements run
132
- rvm install 3.0
133
- rvm use 3.0
116
+ rvm install 3.1
117
+ rvm use 3.1
134
118
  ```
135
119
 
136
120
  Install oxidized requirements:
@@ -200,7 +184,7 @@ Run the container for the first time to initialize the config:
200
184
  _Note: this step in only required for creating the Oxidized configuration file and can be skipped if you already have one._
201
185
 
202
186
  ```shell
203
- docker run --rm -v /etc/oxidized:/home/oxidized/.config/oxidized -p 8888:8888/tcp -t oxidized/oxidized:latest oxidized
187
+ docker run --rm -v /etc/oxidized:/home/oxidized/.config/oxidized -p 8888:8888/tcp --user oxidized -t oxidized/oxidized:latest oxidized
204
188
  ```
205
189
 
206
190
  If the RESTful API and Web Interface are enabled, on the docker host running the container
@@ -295,7 +279,7 @@ It is recommended practice to run Oxidized using its own username. This usernam
295
279
  useradd -s /bin/bash -m oxidized
296
280
  ```
297
281
 
298
- > It is recommended __not__ to run Oxidized as root.
282
+ > It is recommended __not__ to run Oxidized as root. After creating a dedicated user, switch to the oxidized user using su oxidized to ensure that Oxidized is run under the correct user context.
299
283
 
300
284
  To initialize a default configuration in your home directory `~/.config/oxidized/config`, simply run `oxidized` once. If you don't further configure anything from the output and source sections, it'll extend the examples on a subsequent `oxidized` execution. This is useful to see what options for a specific source or output backend are available.
301
285
 
data/Rakefile CHANGED
@@ -27,7 +27,8 @@ task :test do
27
27
  Rake::TestTask.new do |t|
28
28
  t.libs << 'spec'
29
29
  t.test_files = FileList['spec/**/*_spec.rb']
30
- t.warning = true
30
+ # Don't display ambiguity warning between regexp and division in models
31
+ t.warning = false
31
32
  t.verbose = true
32
33
  end
33
34
  end
@@ -73,13 +74,41 @@ task :chmod do
73
74
  extra/oxidized.runit
74
75
  extra/syslog.rb
75
76
  extra/update-ca-certificates.runit
77
+ extra/device2yaml.rb
76
78
  ]
77
79
  dirs = []
78
- %x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }.each do |file|
80
+ %x(git ls-files -z).split("\x0").reject { |f| f.match(/^(test|spec|features)\//) }.each do |file|
79
81
  dirs.push(File.dirname(file))
80
82
  xbit.include?(file) ? File.chmod(0o0755, file) : File.chmod(0o0644, file)
81
83
  end
82
84
  dirs.sort.uniq.each { |dir| File.chmod(0o0755, dir) }
83
85
  end
84
86
 
87
+ # Build the container image with docker or podman
88
+ def command_available?(command)
89
+ system("which #{command} > /dev/null 2>&1")
90
+ end
91
+
92
+ def docker_needs_root?
93
+ !system('docker info > /dev/null 2>&1')
94
+ end
95
+
96
+ desc 'Build the container image with docker or podman'
97
+ task :build_container do
98
+ # Prefer podman if available as it runs rootless
99
+ if command_available?('podman')
100
+ sh 'podman build -t oxidized:`git describe --tags` -t oxidized:latest .'
101
+ elsif command_available?('docker')
102
+ if docker_needs_root?
103
+ puts 'docker needs root to build the image. Using sudo...'
104
+ sh 'sudo docker build -t oxidized:`git describe --tags` -t oxidized:latest .'
105
+ else
106
+ sh 'docker build -t oxidized:`git describe --tags` -t oxidized:latest .'
107
+ end
108
+ else
109
+ puts 'You need Podman or Docker to build the container image.'
110
+ exit 1
111
+ end
112
+ end
113
+
85
114
  task default: :test