oxidized 0.29.1 → 0.37.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 (236) hide show
  1. checksums.yaml +4 -4
  2. data/.coderabbit.yaml +21 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +45 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
  5. data/.github/ISSUE_TEMPLATE/support-request.md +39 -0
  6. data/.github/workflows/codeql.yml +4 -4
  7. data/.github/workflows/publishdocker.yml +108 -13
  8. data/.github/workflows/ruby.yml +3 -12
  9. data/.github/workflows/stale.yml +6 -1
  10. data/.gitignore +2 -0
  11. data/.rubocop.yml +69 -13
  12. data/.rubocop_todo.yml +13 -143
  13. data/CHANGELOG.md +431 -4
  14. data/CONTRIBUTING.md +189 -0
  15. data/Dockerfile +89 -34
  16. data/README.md +59 -188
  17. data/Rakefile +58 -12
  18. data/bin/oxidized +2 -5
  19. data/docs/Configuration.md +382 -149
  20. data/docs/Creating-Models.md +262 -10
  21. data/docs/DeviceSimulation.md +196 -0
  22. data/docs/Docker.md +246 -0
  23. data/docs/Hooks.md +146 -51
  24. data/docs/Inputs.md +237 -0
  25. data/docs/Issues.md +123 -0
  26. data/docs/Model-Notes/APC.md +72 -0
  27. data/docs/Model-Notes/Cumulus.md +5 -0
  28. data/docs/Model-Notes/EatonNetwork.md +18 -0
  29. data/docs/Model-Notes/ExaLink.md +43 -0
  30. data/docs/Model-Notes/FSOS.md +17 -0
  31. data/docs/Model-Notes/Fortinet.md +75 -0
  32. data/docs/Model-Notes/GrandstreamHT8xx.md +8 -0
  33. data/docs/Model-Notes/HPEAruba.md +32 -0
  34. data/docs/Model-Notes/IvantiConnectSecure.md +59 -0
  35. data/docs/Model-Notes/OS6.md +10 -0
  36. data/docs/Model-Notes/README.md +1 -20
  37. data/docs/Model-Notes/RouterOS.md +28 -0
  38. data/docs/Model-Notes/SikluMHTG.md +7 -0
  39. data/docs/Model-Notes/TrueNAS.md +23 -0
  40. data/docs/Model-Notes/XGS4600-Zyxel.md +5 -0
  41. data/docs/ModelUnitTests.md +219 -0
  42. data/docs/Outputs.md +102 -5
  43. data/docs/Release.md +102 -0
  44. data/docs/Ruby-API.md +135 -2
  45. data/docs/Sources.md +34 -0
  46. data/docs/Supported-OS-Types.md +207 -270
  47. data/docs/Troubleshooting.md +43 -1
  48. data/extra/device2yaml.rb +259 -0
  49. data/extra/gitdiff-msteams.sh +32 -5
  50. data/extra/hooks/modelrules.rb +55 -0
  51. data/extra/hooks/modelrulesadvanced.rb +167 -0
  52. data/extra/hooks/srcipmap.rb +54 -0
  53. data/extra/nagios_check_failing_nodes.rb +1 -1
  54. data/extra/oxidized.runit +1 -1
  55. data/extra/rest_client.rb +5 -4
  56. data/extra/syslog.rb +11 -6
  57. data/lib/oxidized/cli/support.rb +152 -0
  58. data/lib/oxidized/cli.rb +21 -6
  59. data/lib/oxidized/config/vars.rb +33 -14
  60. data/lib/oxidized/config.rb +28 -17
  61. data/lib/oxidized/core.rb +50 -8
  62. data/lib/oxidized/hook/ciscosparkdiff.rb +11 -9
  63. data/lib/oxidized/hook/exec.rb +5 -4
  64. data/lib/oxidized/hook/githubrepo.rb +55 -18
  65. data/lib/oxidized/hook/noophook.rb +2 -2
  66. data/lib/oxidized/hook/slackdiff.rb +50 -14
  67. data/lib/oxidized/hook/xmppdiff.rb +9 -9
  68. data/lib/oxidized/hook.rb +68 -16
  69. data/lib/oxidized/input/cli.rb +8 -3
  70. data/lib/oxidized/input/debugtext.rb +40 -0
  71. data/lib/oxidized/input/debugyaml.rb +82 -0
  72. data/lib/oxidized/input/exec.rb +2 -11
  73. data/lib/oxidized/input/ftp.rb +2 -19
  74. data/lib/oxidized/input/http.rb +67 -17
  75. data/lib/oxidized/input/input.rb +35 -14
  76. data/lib/oxidized/input/scp.rb +27 -0
  77. data/lib/oxidized/input/ssh.rb +59 -83
  78. data/lib/oxidized/input/sshbase.rb +102 -0
  79. data/lib/oxidized/input/telnet.rb +20 -19
  80. data/lib/oxidized/input/tftp.rb +8 -8
  81. data/lib/oxidized/job.rb +18 -7
  82. data/lib/oxidized/jobs.rb +11 -1
  83. data/lib/oxidized/logger.rb +51 -0
  84. data/lib/oxidized/manager.rb +18 -17
  85. data/lib/oxidized/model/acos.rb +2 -1
  86. data/lib/oxidized/model/addpack.rb +26 -0
  87. data/lib/oxidized/model/adtran.rb +5 -1
  88. data/lib/oxidized/model/adva.rb +3 -3
  89. data/lib/oxidized/model/airfiber.rb +1 -1
  90. data/lib/oxidized/model/aos7.rb +11 -0
  91. data/lib/oxidized/model/aoscx.rb +37 -29
  92. data/lib/oxidized/model/aosw.rb +39 -29
  93. data/lib/oxidized/model/apc_aos.rb +7 -2
  94. data/lib/oxidized/model/apcaos.rb +39 -0
  95. data/lib/oxidized/model/aricentiss.rb +9 -2
  96. data/lib/oxidized/model/arubainstant.rb +93 -0
  97. data/lib/oxidized/model/asa.rb +11 -10
  98. data/lib/oxidized/model/asternos.rb +22 -0
  99. data/lib/oxidized/model/asyncos.rb +3 -3
  100. data/lib/oxidized/model/audiocodes.rb +2 -2
  101. data/lib/oxidized/model/awplus.rb +15 -12
  102. data/lib/oxidized/model/axos.rb +1 -1
  103. data/lib/oxidized/model/bdcom.rb +1 -0
  104. data/lib/oxidized/model/c4cmts.rb +1 -2
  105. data/lib/oxidized/model/ciscosma.rb +1 -1
  106. data/lib/oxidized/model/ciscosmb.rb +6 -1
  107. data/lib/oxidized/model/cnos.rb +13 -10
  108. data/lib/oxidized/model/comtrol.rb +1 -1
  109. data/lib/oxidized/model/comware.rb +5 -3
  110. data/lib/oxidized/model/cumulus.rb +14 -2
  111. data/lib/oxidized/model/defacto.rb +26 -0
  112. data/lib/oxidized/model/dellx.rb +1 -1
  113. data/lib/oxidized/model/dlink.rb +5 -2
  114. data/lib/oxidized/model/dlinknextgen.rb +55 -0
  115. data/lib/oxidized/model/dnos.rb +3 -0
  116. data/lib/oxidized/model/dslcommands.rb +93 -0
  117. data/lib/oxidized/model/dslsetup.rb +102 -0
  118. data/lib/oxidized/model/eatonnetwork.rb +70 -0
  119. data/lib/oxidized/model/edgecos.rb +3 -1
  120. data/lib/oxidized/model/edgeos.rb +7 -6
  121. data/lib/oxidized/model/edgeswitch.rb +3 -1
  122. data/lib/oxidized/model/efos.rb +41 -0
  123. data/lib/oxidized/model/eltex.rb +4 -2
  124. data/lib/oxidized/model/enterasys800.rb +2 -2
  125. data/lib/oxidized/model/enterprise_sonic.rb +46 -0
  126. data/lib/oxidized/model/eos.rb +3 -1
  127. data/lib/oxidized/model/exalink.rb +36 -0
  128. data/lib/oxidized/model/f5os.rb +17 -0
  129. data/lib/oxidized/model/fabricos.rb +2 -2
  130. data/lib/oxidized/model/fastiron.rb +5 -3
  131. data/lib/oxidized/model/firebrick.rb +2 -2
  132. data/lib/oxidized/model/firelinuxos.rb +13 -6
  133. data/lib/oxidized/model/firewareos.rb +10 -1
  134. data/lib/oxidized/model/fortigate.rb +160 -0
  135. data/lib/oxidized/model/fortios.rb +38 -48
  136. data/lib/oxidized/model/fsos.rb +46 -0
  137. data/lib/oxidized/model/gaiaos.rb +4 -4
  138. data/lib/oxidized/model/garderos.rb +38 -0
  139. data/lib/oxidized/model/grandstreamht8xx.rb +19 -0
  140. data/lib/oxidized/model/h3c.rb +1 -1
  141. data/lib/oxidized/model/ibos.rb +1 -0
  142. data/lib/oxidized/model/ingate.rb +47 -0
  143. data/lib/oxidized/model/ios.rb +57 -30
  144. data/lib/oxidized/model/iosxr.rb +2 -2
  145. data/lib/oxidized/model/ironware.rb +7 -5
  146. data/lib/oxidized/model/ivanti.rb +54 -0
  147. data/lib/oxidized/model/junos.rb +12 -5
  148. data/lib/oxidized/model/kornfeldos.rb +33 -0
  149. data/lib/oxidized/model/lenovonos.rb +2 -0
  150. data/lib/oxidized/model/linksyssrw.rb +3 -3
  151. data/lib/oxidized/model/linuxgeneric.rb +4 -2
  152. data/lib/oxidized/model/macros.rb +60 -0
  153. data/lib/oxidized/model/mimosab11.rb +34 -0
  154. data/lib/oxidized/model/ml66.rb +33 -0
  155. data/lib/oxidized/model/mlnxos.rb +18 -14
  156. data/lib/oxidized/model/model.rb +98 -103
  157. data/lib/oxidized/model/mtrlrfs.rb +1 -0
  158. data/lib/oxidized/model/ndms.rb +6 -0
  159. data/lib/oxidized/model/netgear.rb +14 -3
  160. data/lib/oxidized/model/netonix.rb +1 -1
  161. data/lib/oxidized/model/netscaler.rb +1 -1
  162. data/lib/oxidized/model/nodegrid.rb +1 -1
  163. data/lib/oxidized/model/nsxdfw.rb +31 -0
  164. data/lib/oxidized/model/nsxfirewall.rb +2 -1
  165. data/lib/oxidized/model/nxos.rb +20 -15
  166. data/lib/oxidized/model/ocnos.rb +42 -0
  167. data/lib/oxidized/model/onefinity.rb +18 -0
  168. data/lib/oxidized/model/openbsd.rb +1 -1
  169. data/lib/oxidized/model/opengear.rb +36 -1
  170. data/lib/oxidized/model/openwrt.rb +6 -6
  171. data/lib/oxidized/model/opnsense.rb +9 -1
  172. data/lib/oxidized/model/os6.rb +48 -0
  173. data/lib/oxidized/model/outputs.rb +5 -0
  174. data/lib/oxidized/model/panos.rb +2 -0
  175. data/lib/oxidized/model/perle.rb +41 -0
  176. data/lib/oxidized/model/pfsense.rb +9 -0
  177. data/lib/oxidized/model/powerconnect.rb +32 -11
  178. data/lib/oxidized/model/procurve.rb +6 -2
  179. data/lib/oxidized/model/qtech.rb +3 -1
  180. data/lib/oxidized/model/quantaos.rb +8 -6
  181. data/lib/oxidized/model/rgos.rb +33 -0
  182. data/lib/oxidized/model/riverbed.rb +104 -0
  183. data/lib/oxidized/model/routeros.rb +18 -11
  184. data/lib/oxidized/model/saos.rb +18 -1
  185. data/lib/oxidized/model/saos10.rb +38 -0
  186. data/lib/oxidized/model/siklu.rb +1 -1
  187. data/lib/oxidized/model/siklumhtg.rb +22 -0
  188. data/lib/oxidized/model/sixwind.rb +28 -0
  189. data/lib/oxidized/model/slxos.rb +3 -3
  190. data/lib/oxidized/model/smartbyte.rb +48 -0
  191. data/lib/oxidized/model/sonicos.rb +27 -20
  192. data/lib/oxidized/model/speedtouch.rb +1 -1
  193. data/lib/oxidized/model/sros.rb +3 -3
  194. data/lib/oxidized/model/srosmd.rb +1 -1
  195. data/lib/oxidized/model/supermicro.rb +1 -1
  196. data/lib/oxidized/model/telco.rb +1 -1
  197. data/lib/oxidized/model/tmos.rb +1 -0
  198. data/lib/oxidized/model/tnsr.rb +57 -0
  199. data/lib/oxidized/model/tplink.rb +5 -5
  200. data/lib/oxidized/model/trango.rb +4 -2
  201. data/lib/oxidized/model/truenas.rb +64 -3
  202. data/lib/oxidized/model/ucs.rb +1 -1
  203. data/lib/oxidized/model/unifiap.rb +144 -0
  204. data/lib/oxidized/model/uplinkolt.rb +46 -0
  205. data/lib/oxidized/model/voltaire.rb +1 -1
  206. data/lib/oxidized/model/voss.rb +3 -0
  207. data/lib/oxidized/model/vrp.rb +5 -1
  208. data/lib/oxidized/model/vyatta.rb +9 -3
  209. data/lib/oxidized/model/vyos.rb +37 -0
  210. data/lib/oxidized/model/xos.rb +10 -1
  211. data/lib/oxidized/model/zhoneolt.rb +4 -2
  212. data/lib/oxidized/model/zynos.rb +67 -3
  213. data/lib/oxidized/model/zynosadsl.rb +14 -0
  214. data/lib/oxidized/model/zynoscli.rb +1 -1
  215. data/lib/oxidized/model/zynosgs.rb +2 -0
  216. data/lib/oxidized/model/zynosmgs.rb +32 -0
  217. data/lib/oxidized/node.rb +99 -64
  218. data/lib/oxidized/nodes.rb +40 -19
  219. data/lib/oxidized/output/file.rb +80 -43
  220. data/lib/oxidized/output/git.rb +295 -151
  221. data/lib/oxidized/output/gitcrypt.rb +193 -185
  222. data/lib/oxidized/output/http.rb +63 -51
  223. data/lib/oxidized/output/output.rb +20 -4
  224. data/lib/oxidized/signals.rb +44 -0
  225. data/lib/oxidized/source/csv.rb +49 -49
  226. data/lib/oxidized/source/http.rb +76 -63
  227. data/lib/oxidized/source/jsonfile.rb +68 -0
  228. data/lib/oxidized/source/source.rb +73 -18
  229. data/lib/oxidized/source/sql.rb +71 -59
  230. data/lib/oxidized/version.rb +6 -4
  231. data/lib/oxidized/worker.rb +57 -29
  232. data/lib/oxidized.rb +4 -24
  233. data/lib/refinements.rb +21 -1
  234. data/oxidized.gemspec +45 -21
  235. metadata +248 -41
  236. data/lib/oxidized/model/timos.rb +0 -10
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,189 @@
1
+ # Oxidized - Contributing Guide
2
+ You can contribute to [Oxidized](https://github.com/ytti/oxidized/) in many ways, and first of all we'd like to thank you for taking your time to improve this great project!
3
+
4
+ > ## Legal Notice
5
+ > When submitting content to this project, you must agree that you have authored 100%
6
+ > of the content, that you have the necessary rights to the content and that the
7
+ > content you contribute may be provided under the project license.
8
+ >
9
+ > If you are employed, you probably need the permission from your employer to
10
+ > contribute to open source projects.
11
+
12
+
13
+ ## Contribute as a user
14
+ A great place for users to get involved is the [GitHub issues](https://github.com/ytti/oxidized/issues).
15
+ Through the issues, you can interact with maintainers and other users. You can open an issue
16
+ if you need help, but you can also help other users by reviewing their issues and commenting on them.
17
+
18
+ Before writing an issue, please read our documentation on
19
+ [how to write good issues](/docs/Issues.md).
20
+
21
+
22
+ ## Contribute some content
23
+ Content contributions are always welcome. You do not need to be a maintainer for this.
24
+ You even do not need to be a ruby programmer, as an example, the documentation always needs some
25
+ enhancements :-)
26
+
27
+ Contributions can be submitted through pull requests in github. For a full explanation how to
28
+ contribute some content, see [How to contribute content](#how-to-contribute-content).
29
+
30
+
31
+ ## Help Needed
32
+
33
+ As things stand right now, `oxidized` is maintained by a few people. A great
34
+ many [contributors](https://github.com/ytti/oxidized/graphs/contributors) have
35
+ helped further the software, however contributions are not the same as ongoing
36
+ owner- and maintainer-ship. It appears that many companies use the software to
37
+ manage their network infrastructure, this is great news! But without additional
38
+ help to maintain the software and put out releases, the future of oxidized
39
+ might be less bright. The current pace of development and the much needed
40
+ refactoring simply are not sustainable if they are to be driven by a few
41
+ persons.
42
+
43
+ ## Model maintainers
44
+ Oxidized supports more than [150 different devices](docs/Supported-OS-Types.md), and there is no way a person
45
+ maintaining the infrastructure code ([Oxidized maintainers](#oxidized-maintainers))
46
+ has any ability to have complete understanding of each model and validity of changes upon them.
47
+
48
+ On the other hand, we have a lot of great users with a detailed understanding of *their*
49
+ favorite hardware and a technical background which is plenty sufficient to support
50
+ *their*" model in oxidized. The model maintainer role is designed to have a very low
51
+ entry barrier, low maintenance burden and needs no long-term commitment.
52
+
53
+ ### Model maintainer tasks
54
+ A model maintainer has the following tasks:
55
+
56
+ * Monitor and comment any model changes in a reasonable time (up to 3 weeks)
57
+ * Monitor, comment and fix issues related to the model in a reasonable time (up to 3 weeks)
58
+ * Note that Oxidized has a very liberal approach to changes: if someone needed it,
59
+ I need good reason to reject it.
60
+ * When a model maintainer comments a Pull Request as ready to merge into main,
61
+ an [Oxidized maintainer](#oxidized-maintainers) will merge it without any
62
+ further checks. If nothing happens, the model maintainer should trigger an Oxidized maintainer directly ;-).
63
+ * If there are multiple model maintainers for a model, they should agree among themselves
64
+ how they want to collaborate
65
+ * Please remove yourself as maintainer, if you no longer wish to respond on changes related to the model. We may remove unresponsive model maintainers, but it is nicer if you let us know.
66
+ * If a model maintainer is unresponsive, the person pushing the change may be a good candidate as a new model maintainer ;-)
67
+
68
+ ### How to add / remove yourself as a model maintainer?
69
+
70
+ The model maintainers are listed in [docs/Supported.OS-Types.md]. Add or remove yourself in the table and push the change to github (pull request). Don't know how? Have a look at [How to contribute content](#how-to-contribute-content).
71
+
72
+ ## Oxidized maintainers
73
+ ### Become a maintainer for Oxidized
74
+ If you would like to be a maintainer for Oxidized then please read through the below and see if it's something you would like to help with. It's not a requirement that you can tick all the boxes below but it helps :)
75
+
76
+ * Triage on issues, review pull requests and help answer any questions from users.
77
+ * Above average knowledge of the Ruby programming language.
78
+ * Professional experience with both oxidized and some other config backup tool (like rancid).
79
+ * Ability to keep a cool head, and enjoy interaction with end users! :)
80
+ * A desire and passion to help drive `oxidized` towards its `1.x.x` stage of life
81
+ * Help refactor the code
82
+ * Rework the core infrastructure
83
+ * Permission from your employer to contribute to open source projects
84
+
85
+ ### YES, I WANT TO HELP
86
+ Awesome! Simply send an e-mail to Saku Ytti at <saku@ytti.fi>.
87
+
88
+ ### Further reading
89
+ Brian Anderson (from Rust fame) wrote an [excellent
90
+ post](http://brson.github.io/2017/04/05/minimally-nice-maintainer) on what it
91
+ means to be a maintainer.
92
+
93
+ ### Current maintainers
94
+ Current active maintainer of Oxidized are:
95
+ * Saku Ytti (@ytti) - he is the original author of Oxidized
96
+ * Alexander Schaber (@aschaber1)
97
+ * Robert Chéramy (@robertcheramy)
98
+
99
+
100
+ ## How to contribute content
101
+ Content can be code, but also documentation and other things.
102
+
103
+ ### Fork the repository
104
+ Fork this repository to your GitHub account by clicking the "Fork" button at the top right. This creates a personal copy of the project you can work on.
105
+
106
+ ### Clone your fork
107
+ Clone your forked repository to your local machine using the `git clone` command:
108
+ ```bash
109
+ git clone git@github.com:##yourname##/oxidized.git
110
+ ```
111
+
112
+ ### Create a new branch
113
+ Create a new branch for your contribution. Choose a concise name for your branch. If your contribution refers to an issue, you may prepend the number of the issue to the branch name.
114
+ ```bash
115
+ git checkout -b 1234-your-branch-name
116
+ ```
117
+
118
+ ### Create a ruby bundle
119
+ You need [Bundler](https://bundler.io/) to install ruby dependencies locally. If it is not already
120
+ installed on your system, it should be prepackaged in your favorite Linux or
121
+ Ruby distribution. On Debian Bookworm, you can install Bundler with `sudo apt install ruby-bundler`
122
+
123
+ ```bash
124
+ bundle config set --local path 'vendor/bundle'
125
+ bundle install
126
+ ```
127
+
128
+ 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`
129
+
130
+ ### Run your code
131
+ ```bash
132
+ bundle exec bin/oxidized
133
+ ```
134
+
135
+ ### Use a custom oxidized configuration
136
+ If you don't want to use the configuration under `~/.config/oxidized/`, you can set the path to your specific configuration with the environement variable `OXIDIZED_HOME': `export OXIDIZED_HOME=~/oxidized-config/`.
137
+
138
+ ### Code like a ruby professional
139
+ rubocop will help you to respect our coding conventions (which are ruby coding conventions).
140
+ ```bash
141
+ bundle exec rubocop
142
+ ```
143
+
144
+ ### Run tests
145
+ Oxidized has integrated tests, that should be run before submitting your work.
146
+ ```bash
147
+ bundle exec rake test
148
+ ```
149
+
150
+ ### Commit your work
151
+ You can save your changes anytime to the branch. These changes are saved locally and not pushed upstream:
152
+ ```bash
153
+ git status
154
+ git diff
155
+ git add <changed files here>
156
+ git commit
157
+ ```
158
+ You can also use a git GUI like [Git Cola](https://git-cola.github.io/) for a better overview of your changes.
159
+
160
+ The commits will be seen in the pull request, so be concise and remember that someone will try to
161
+ understand what you have done.
162
+
163
+ ### Push your work to your github repository
164
+ With this step, your commits will be seen on github. You are pushing the branch you created before (in this example 1234-your-branch-name`) into your fork of Oxidized.
165
+
166
+ ```bash
167
+ git push -u origin 1234-your-branch-name
168
+ ```
169
+
170
+ You can push as often as you wish. If you already opened a pull request, your pushed commits will automatically get updated there.
171
+
172
+ ### Open a pull request
173
+ Go to your github repository, and github will propose to create a pull request
174
+ and will guide you.
175
+
176
+ We are happy that you are contributing to Oxidized. If something is not as it
177
+ should be, a maintainer will probably ask you to change it when reviewing the
178
+ pull request. And if your pull request breaks something, this can be fixed, so
179
+ don't be shy, submit your code ;-)
180
+
181
+ Note: if the github CI fail on your pull request, fix the problems.
182
+ A pull request with failed CI won't be merged into master, so maintainers may
183
+ only review pull requests that have passed the CIs.
184
+
185
+ ### Delete the branch from your repository
186
+ When the pull request has been merged into main, github will ask if you want to delete your branch. Clean up and delete it, so that you can keep your fork clean and ready for new contributions.
187
+
188
+ ## One last word
189
+ Have fun, and don't forget to congratulate yourself for your great contribution to [Oxidized](https://github.com/ytti/oxidized/)!
data/Dockerfile CHANGED
@@ -1,47 +1,102 @@
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
+ FROM docker.io/debian:trixie-slim
3
2
 
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 \
7
- && apt-get clean \
8
- && rm -rf /var/lib/apt/lists/*
3
+ ##### Place "static" commands at the beginning to optimize image size and build speed
9
4
 
10
- # dependencies for hooks
11
- RUN gem install --no-document aws-sdk slack-ruby-client xmpp4r cisco_spark
5
+ # add non-privileged user
6
+ RUN groupadd -g "30000" -r oxidized && \
7
+ useradd -u "30000" -r -m -d /home/oxidized -g oxidized oxidized && \
8
+ chsh -s /bin/bash oxidized
12
9
 
13
- # dependencies for sources
14
- RUN gem install --no-document gpgme sequel sqlite3 mysql2 pg
10
+ # See PR #3637 - ruby runs /bin/sh and bash is whished for exec hooks
11
+ RUN ln -sf /bin/bash /bin/sh
15
12
 
16
- # dependencies for inputs
17
- RUN gem install --no-document net-tftp net-http-persistent mechanize
13
+ ##### MSMTP - Sending emails
14
+ # link config for msmtp for easier use.
15
+ # /home/oxidized/.msmtprc is a symbolic link to /home/oxidized/.config/oxidized/.msmtprc
16
+ # Create the files as the user oxidized
17
+ RUN mkdir -p /home/oxidized/.config/oxidized/ && \
18
+ touch /home/oxidized/.config/oxidized/.msmtprc && \
19
+ ln -s /home/oxidized/.config/oxidized/.msmtprc /home/oxidized/ && \
20
+ chmod -R ug=rwX,o= /home/oxidized/.config/ && \
21
+ chown -R oxidized:oxidized /home/oxidized/
18
22
 
19
- # build and install oxidized
23
+ # add runit services
24
+ COPY extra/oxidized.runit /etc/service/oxidized/run
25
+ COPY extra/auto-reload-config.runit /etc/service/auto-reload-config/run
26
+ COPY extra/update-ca-certificates.runit /etc/service/update-ca-certificates/run
27
+
28
+ # Prepare the build of oxidized, copy our working directory in the container
20
29
  COPY . /tmp/oxidized/
21
30
  WORKDIR /tmp/oxidized
22
31
 
23
- # docker automated build gets shallow copy, but non-shallow copy cannot be unshallowed
24
- RUN git fetch --unshallow || true
25
-
26
- # Ensure rugged is built with ssh support
27
- RUN CMAKE_FLAGS='-DUSE_SSH=ON' rake install
28
-
29
- # web interface
30
- RUN gem install oxidized-web --no-document
32
+ # set up dependencies for the build process
33
+ RUN set -eux; \
34
+ export DEBIAN_FRONTEND=noninteractive; \
35
+ apt-get update; \
36
+ # no apt-get upgrade needed, as debian images are rebuilt on security issues
37
+ apt-get install -y --no-install-recommends \
38
+ # runit: lightweight service supervisor
39
+ # dumb-init: proper PID 1 signal handling
40
+ # gosu: run oxidized as the user oxidized
41
+ runit dumb-init gosu \
42
+ # Build tools
43
+ build-essential ruby-dev \
44
+ # Useful tools
45
+ openssh-client vim-tiny inetutils-telnet \
46
+ # Dependencies for /extra scripts
47
+ curl jq \
48
+ # Build process of oxidized from git and git-tools in the container
49
+ git \
50
+ # Allow git send-email from docker image
51
+ git-email libmailtools-perl \
52
+ # Allow sending emails in the docker container
53
+ msmtp \
54
+ # Use debian packaged gems where possible
55
+ # ruby and core gems needed by oxidized
56
+ ruby ruby-rugged ruby-slop \
57
+ # Gem dependencies for inputs
58
+ ruby-net-telnet ruby-net-ssh ruby-net-ftp ruby-ed25519 ruby-net-scp \
59
+ ruby-net-http-persistent ruby-mechanize \
60
+ # Gem dependencies for sources
61
+ ruby-sqlite3 ruby-mysql2 ruby-pg ruby-sequel ruby-gpgme\
62
+ # Gem dependencies for hooks
63
+ ruby-aws-sdk ruby-xmpp4r \
64
+ # Gems needed by oxidized-web
65
+ ruby-charlock-holmes ruby-haml ruby-htmlentities ruby-json \
66
+ puma ruby-sinatra ruby-sinatra-contrib \
67
+ # Gems needed by slack-ruby-client
68
+ ruby-faraday ruby-faraday-net-http ruby-faraday-multipart ruby-hashie \
69
+ # Gems needed by semantic logger
70
+ ruby-concurrent \
71
+ ; \
72
+ # build & install oxidized from the working repository
73
+ # docker automated build gets shallow copy, but non-shallow copy cannot be unshallowed
74
+ git fetch --unshallow || true; \
75
+ rake install; \
76
+ # install oxidized-web and gems not available in debian trixie
77
+ gem install --no-document --no-wrappers --conservative --minimal-deps \
78
+ oxidized-web \
79
+ # dependencies for hooks
80
+ slack-ruby-client cisco_spark \
81
+ # dependencies for specific inputs
82
+ net-tftp \
83
+ ##### X25519 (a.k.a. Curve25519) Elliptic Curve Diffie-Hellman
84
+ x25519 \
85
+ ; \
86
+ # remove the packages we do not need.
87
+ apt-get remove -y build-essential ruby-dev; \
88
+ apt-get autoremove -y ; \
89
+ apt-get clean; \
90
+ rm -rf /var/lib/apt/lists/*; \
91
+ find /var/lib/gems/*/cache -mindepth 1 -delete; \
92
+ rm -rf /tmp/oxidized;
31
93
 
32
- # clean up
33
94
  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
36
95
 
37
- # add non-privileged user
38
- ARG UID=30000
39
- ARG GID=$UID
40
- RUN groupadd -g "${GID}" -r oxidized && useradd -u "${UID}" -r -m -d /home/oxidized -g oxidized oxidized
96
+ EXPOSE 8888/tcp
41
97
 
42
- # add runit services
43
- COPY extra/oxidized.runit /etc/service/oxidized/run
44
- COPY extra/auto-reload-config.runit /etc/service/auto-reload-config/run
45
- COPY extra/update-ca-certificates.runit /etc/service/update-ca-certificates/run
98
+ # dumb-init handles PID 1 for proper signal forwarding (Ctrl-C, SIGTERM)
99
+ ENTRYPOINT ["/usr/bin/dumb-init", "--"]
46
100
 
47
- EXPOSE 8888/tcp
101
+ # runit supervises all services in /etc/service/
102
+ CMD ["runsvdir", "-P", "/etc/service"]