oxidized 0.38.0 → 0.38.1

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.
data/AGENTS.md DELETED
@@ -1,174 +0,0 @@
1
- # AGENTS.md
2
-
3
- Guidance for AI coding agents working in the Oxidized repository. Human
4
- contributors should read [CONTRIBUTING.md](CONTRIBUTING.md) and the
5
- [docs/](docs/) folder.
6
-
7
- ## Project overview
8
-
9
- Oxidized is a network device configuration backup tool (a RANCID replacement)
10
- written in Ruby. It logs into network devices, runs commands, and stores the
11
- resulting configuration in an output backend (git, file, ...). It supports
12
- 150+ device types through "models".
13
-
14
- Core concepts:
15
-
16
- - **Model** ([lib/oxidized/model/](lib/oxidized/model/)) – describes how to talk
17
- to one OS type: prompt, commands, comment style, secret removal, etc. Uses a
18
- Ruby DSL built on `Oxidized::Model`.
19
- - **Input** ([lib/oxidized/input/](lib/oxidized/input/)) – transport such as
20
- `ssh`, `telnet`, `ftp`, `scp`.
21
- - **Output** ([lib/oxidized/output/](lib/oxidized/output/)) – where configs are
22
- stored (`git`, `file`, ...).
23
- - **Source** ([lib/oxidized/source/](lib/oxidized/source/)) – where the node
24
- list comes from (`csv`, `sql`, `http`, ...).
25
- - **Node / Nodes / Job / Worker** ([lib/oxidized/](lib/oxidized/)) – the
26
- scheduling and execution core.
27
-
28
- ## Environment & common commands
29
-
30
- Dependencies are managed with Bundler into `vendor/bundle`. Prefix commands with
31
- `bundle exec`.
32
-
33
- ```bash
34
- bundle config set --local path 'vendor/bundle'
35
- bundle install
36
-
37
- bundle exec rake # default task (rubocop + minitest)
38
- bundle exec rake test # run the whole test suite (minitest)
39
- bundle exec rubocop # lint / style
40
- bundle exec bin/oxidized # run Oxidized locally
41
- ```
42
-
43
- Run a single model test while iterating:
44
-
45
- ```bash
46
- bundle exec rake test TESTOPTS="--verbose --name=/ios#C9800.*output/"
47
- ```
48
-
49
- Use `OXIDIZED_HOME` to point at a custom config directory instead of
50
- `~/.config/oxidized/`.
51
-
52
- ## Communication
53
-
54
- - Respond to the user in the language they write in.
55
- - **All code, identifiers, comments, commit messages and documentation must be
56
- in English.**
57
-
58
- ## Coding conventions
59
-
60
- - Target Ruby `>= 3.0` (see [oxidized.gemspec](oxidized.gemspec)). Do not use
61
- syntax or stdlib features newer than 3.0.
62
- - Follow RuboCop; the config lives in [.rubocop.yml](.rubocop.yml). Run
63
- `bundle exec rubocop` before finishing and fix offenses instead of disabling
64
- cops, unless a disable is clearly justified.
65
- - Strings: prefer `"double quotes"`; use `'single quotes'` to signal that string
66
- interpolation is intentionally not wanted (not enforced by RuboCop).
67
- - Max line length is 120 (models under `lib/oxidized/model/*.rb` are exempt from
68
- the RuboCop check, but keep new model lines reasonable — aim for 80 characters
69
- where possible, without forcing it).
70
- - **Comments should be sparse and concise.** Only comment when the code is not
71
- self-evident (a non-obvious device quirk, a workaround, a referenced issue).
72
- Do not add comments, docstrings, or type annotations to code you did not
73
- change.
74
- - Keep changes focused and minimal. Do not refactor or "clean up" unrelated code
75
- as part of an unrelated fix.
76
-
77
- ## Working on models
78
-
79
- Read these before touching a model:
80
-
81
- - [docs/Creating-Models.md](docs/Creating-Models.md) – model structure, DSL,
82
- common tasks (`enable`, `clean :escape_codes`, `reject_lines`, ...).
83
- - [docs/Ruby-API.md](docs/Ruby-API.md) – available DSL methods.
84
- - [docs/DeviceSimulation.md](docs/DeviceSimulation.md) – simulation files.
85
- - [docs/ModelUnitTests.md](docs/ModelUnitTests.md) – how models are tested.
86
-
87
- Notes:
88
-
89
- - A model file is named after the OS type and defines a class of the same name
90
- inheriting from `Oxidized::Model` (or from another model such as `Defacto`).
91
- - Prefer extending existing behaviour with the DSL (`cmd`, `pre`/`post`,
92
- `prompt`, `comment`, `cfg`, `macro`) over ad-hoc Ruby.
93
- - When adding a new model, add it to
94
- [docs/Supported-OS-Types.md](docs/Supported-OS-Types.md).
95
-
96
- ## Testing conventions
97
-
98
- Model unit tests are data-driven from [spec/model/data/](spec/model/data/) and
99
- run automatically by `rake test`. Relevant file suffixes for a given
100
- `<model>#<description>`:
101
-
102
- - `#simulation.yaml` – recorded device session (input for the test).
103
- - `#output.txt` – expected rendered configuration.
104
- - `#prompt.yaml`, `#secret.yaml`, `#significant_changes.yaml` – optional focused
105
- tests.
106
-
107
- Generate a missing `#output.txt` from the current model:
108
-
109
- ```bash
110
- bundle exec ruby spec/model/atoms_generate.rb
111
- ```
112
-
113
- Custom Ruby tests live in `spec/**/*_spec.rb` (minitest + mocha). Use the
114
- `#custom_simulation.yaml` suffix for custom simulation data so it does not
115
- collide with the automatic tests.
116
-
117
- ## IMPORTANT: never generate YAML simulation files
118
-
119
- An agent must **never** create or hand-write a device simulation YAML file
120
- (`spec/model/data/*#simulation.yaml`). These files must be captured from a real
121
- device so that ANSI escape codes, `\r`, trailing spaces (`\x20`), prompts and
122
- timing are faithful — hand-crafted data produces misleading tests.
123
-
124
- Instead, **guide the user** to record one themselves, using one of:
125
-
126
- 1. **`extra/device2yaml.rb`** – connects over SSH and records the session. See
127
- [docs/DeviceSimulation.md](docs/DeviceSimulation.md#creating-a-yaml-simulation-file-with-device2yamlrb).
128
- Example:
129
-
130
- ```bash
131
- extra/device2yaml.rb oxidized@device \
132
- -c "terminal length 0
133
- show version
134
- show running-config
135
- exit" \
136
- -o spec/model/data/ios#C8200L_16.12.1#simulation.yaml
137
- ```
138
-
139
- 2. **`input.debug: yaml`** (Oxidized `>= 0.37.0`) – lets a running Oxidized
140
- instance write the simulation file from a real backup session into
141
- `~/.config/oxidized/logs/`. See
142
- [docs/DeviceSimulation.md](docs/DeviceSimulation.md#creating-a-yaml-simulation-file-with-the-debug-option).
143
-
144
- ```yaml
145
- input:
146
- default: ssh
147
- debug: yaml
148
- ```
149
-
150
- Remind the user to redact secrets (passwords, IP addresses, serial numbers)
151
- before committing, and to follow the
152
- `<model>#<hardware>_<software>#simulation.yaml` naming convention. Once the user
153
- provides a real simulation file, the agent may generate/adjust the matching
154
- `#output.txt` and edit the model.
155
-
156
- The agent may help redact secrets in a captured simulation file, but must leave
157
- the first and last line of each command output unchanged: they contain the
158
- command echo and the following prompt, which Oxidized relies on for prompt
159
- detection.
160
-
161
- To test how a model processes command output (e.g. secret removal), the agent
162
- may add a few configuration lines to an existing, captured simulation file,
163
- inside the output of the command concerned. The same rule applies: keep the
164
- first and last line of the command output unchanged, use fabricated values,
165
- and add the lines to the matching `#output.txt` (and `#secret.yaml` if
166
- relevant). Prefer this over a separate Ruby spec.
167
-
168
- ## Contribution workflow
169
-
170
- - Branch names may be prefixed with the issue number (e.g.
171
- `1234-short-description`).
172
- - Keep commits small and messages descriptive; they appear in the pull request.
173
- - Before opening a PR: `bundle exec rubocop` and `bundle exec rake test` must
174
- pass (CI blocks merges otherwise).
data/Dockerfile DELETED
@@ -1,106 +0,0 @@
1
- FROM docker.io/debian:trixie-slim
2
-
3
- ENV LANG=C.UTF-8
4
-
5
- ##### Place "static" commands at the beginning to optimize image size and build speed
6
-
7
- # add non-privileged user
8
- RUN groupadd -g "30000" -r oxidized && \
9
- useradd -u "30000" -r -m -d /home/oxidized -g oxidized oxidized && \
10
- chsh -s /bin/bash oxidized
11
-
12
- # See PR #3637 - ruby runs /bin/sh and bash is whished for exec hooks
13
- RUN ln -sf /bin/bash /bin/sh
14
-
15
- ##### MSMTP - Sending emails
16
- # link config for msmtp for easier use.
17
- # /home/oxidized/.msmtprc is a symbolic link to /home/oxidized/.config/oxidized/.msmtprc
18
- # Create the files as the user oxidized
19
- RUN mkdir -p /home/oxidized/.config/oxidized/ && \
20
- touch /home/oxidized/.config/oxidized/.msmtprc && \
21
- ln -s /home/oxidized/.config/oxidized/.msmtprc /home/oxidized/ && \
22
- chmod -R ug=rwX,o= /home/oxidized/.config/ && \
23
- chown -R oxidized:oxidized /home/oxidized/
24
-
25
- # add runit services
26
- COPY extra/oxidized.runit /etc/service/oxidized/run
27
- COPY extra/auto-reload-config.runit /etc/service/auto-reload-config/run
28
- COPY extra/update-ca-certificates.runit /etc/service/update-ca-certificates/run
29
-
30
- # Prepare the build of oxidized, copy our working directory in the container
31
- COPY . /tmp/oxidized/
32
- WORKDIR /tmp/oxidized
33
-
34
- # set up dependencies for the build process
35
- RUN set -eux; \
36
- export DEBIAN_FRONTEND=noninteractive; \
37
- apt-get update; \
38
- # no apt-get upgrade needed, as debian images are rebuilt on security issues
39
- apt-get install -y --no-install-recommends \
40
- # runit: lightweight service supervisor
41
- # dumb-init: proper PID 1 signal handling
42
- # gosu: run oxidized as the user oxidized
43
- runit dumb-init gosu \
44
- # Build tools
45
- build-essential ruby-dev \
46
- # Useful tools
47
- openssh-client vim-tiny inetutils-telnet \
48
- # Dependencies for /extra scripts
49
- curl jq \
50
- # Build process of oxidized from git and git-tools in the container
51
- git \
52
- # Allow git send-email from docker image
53
- git-email libmailtools-perl \
54
- # Allow sending emails in the docker container
55
- msmtp \
56
- # Use debian packaged gems where possible
57
- # ruby and core gems needed by oxidized
58
- ruby ruby-rugged ruby-slop \
59
- # Gem dependencies for inputs
60
- ruby-net-telnet ruby-net-ftp \
61
- ruby-net-http-persistent ruby-mechanize \
62
- # Gem dependencies for sources
63
- ruby-sqlite3 ruby-mysql2 ruby-pg ruby-sequel ruby-gpgme\
64
- # Gem dependencies for hooks
65
- ruby-aws-sdk ruby-xmpp4r \
66
- # Gem dependencies for models
67
- ruby-zip \
68
- # Gems needed by oxidized-web
69
- ruby-charlock-holmes ruby-haml ruby-htmlentities ruby-json \
70
- puma ruby-sinatra ruby-sinatra-contrib \
71
- # Gems needed by slack-ruby-client
72
- ruby-faraday ruby-faraday-net-http ruby-faraday-multipart ruby-hashie \
73
- # Gems needed by semantic logger
74
- ruby-concurrent \
75
- ; \
76
- # build & install oxidized from the working repository
77
- # docker automated build gets shallow copy, but non-shallow copy cannot be unshallowed
78
- git fetch --unshallow || true; \
79
- rake install; \
80
- # install oxidized-web and gems not available in debian trixie
81
- gem install --no-document --no-wrappers --conservative --minimal-deps \
82
- oxidized-web \
83
- # dependencies for hooks
84
- slack-ruby-client cisco_spark \
85
- # dependencies for specific inputs
86
- # net-ssh >= 8 (installed by rake install) is not packaged in trixie,
87
- # and the packaged ruby-net-scp requires net-ssh < 8
88
- net-tftp net-scp \
89
- ; \
90
- # remove the packages we do not need.
91
- apt-get remove -y build-essential ruby-dev; \
92
- apt-get autoremove -y ; \
93
- apt-get clean; \
94
- rm -rf /var/lib/apt/lists/*; \
95
- find /var/lib/gems/*/cache -mindepth 1 -delete; \
96
- rm -rf /tmp/oxidized;
97
-
98
- WORKDIR /
99
-
100
- EXPOSE 8888/tcp
101
-
102
- # dumb-init handles PID 1 for proper signal forwarding (Ctrl-C, SIGTERM)
103
- ENTRYPOINT ["/usr/bin/dumb-init", "--"]
104
-
105
- # runit supervises all services in /etc/service/
106
- CMD ["runsvdir", "-P", "/etc/service"]
data/Gemfile DELETED
@@ -1,2 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
data/Rakefile DELETED
@@ -1,131 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
- require 'time'
4
- require_relative 'lib/oxidized/version'
5
-
6
- gemspec = Gem::Specification.load(Dir['*.gemspec'].first)
7
- gemfile = [gemspec.name, gemspec.version].join('-') + '.gem'
8
-
9
- # Integrate Rubocop if available
10
- begin
11
- require 'rubocop/rake_task'
12
-
13
- RuboCop::RakeTask.new
14
- rescue LoadError
15
- task :rubocop do
16
- puts 'Install rubocop to run its rake tasks'
17
- end
18
- end
19
-
20
- desc 'Validate gemspec'
21
- task :gemspec do
22
- gemspec.validate
23
- end
24
-
25
- desc 'Run minitest'
26
- task :test do
27
- Rake::TestTask.new do |t|
28
- t.libs << 'spec'
29
- t.test_files = FileList['spec/**/*_spec.rb']
30
- t.ruby_opts = ['-W:deprecated']
31
- # Don't display ambiguity warning between regexp and division in models
32
- t.warning = false
33
- t.verbose = false
34
- end
35
- end
36
-
37
- task build: %i[chmod version_set]
38
-
39
- desc 'Set Gem Version'
40
- task :version_set do
41
- Oxidized.version_set
42
- Bundler::GemHelper.instance.gemspec.version = Oxidized::VERSION
43
- end
44
-
45
- desc 'Remove gems'
46
- task :clean do
47
- FileUtils.rm_rf 'pkg'
48
- end
49
-
50
- desc 'Tag the release'
51
- task :tag do
52
- system "git tag #{gemspec.version} -m 'Release #{gemspec.version}'"
53
- end
54
-
55
- desc 'Push to rubygems'
56
- task push: :tag do
57
- system "gem push pkg/#{gemfile}"
58
- end
59
-
60
- desc 'Normalise file permissions'
61
- task :chmod do
62
- xbit = %w[
63
- bin/oxidized
64
- bin/console
65
- extra/auto-reload-config.runit
66
- extra/nagios_check_failing_nodes.rb
67
- extra/oxidized-report-git-commits
68
- extra/oxidized.init
69
- extra/oxidized.init.d
70
- extra/oxidized.runit
71
- extra/syslog.rb
72
- extra/update-ca-certificates.runit
73
- extra/device2yaml.rb
74
- ]
75
- dirs = []
76
- %x(git ls-files -z).split("\x0").reject { |f| f.match(/^(test|spec|features)\//) }.each do |file|
77
- dirs.push(File.dirname(file))
78
- xbit.include?(file) ? File.chmod(0o0755, file) : File.chmod(0o0644, file)
79
- end
80
- dirs.sort.uniq.each { |dir| File.chmod(0o0755, dir) }
81
- end
82
-
83
- # Build the container image with docker or podman
84
- def command_available?(command)
85
- system("which #{command} > /dev/null 2>&1")
86
- end
87
-
88
- def docker_needs_root?
89
- !system('docker info > /dev/null 2>&1')
90
- end
91
-
92
- desc 'Build the container image with docker or podman'
93
- task :build_container do
94
- branch_name = %x(git rev-parse --abbrev-ref HEAD).chop.gsub '/', '_'
95
- sha_hash = %x(git rev-parse --short HEAD).chop
96
- sha_hash_long = %x(git rev-parse HEAD).chop
97
- image_tag = "#{branch_name}-#{sha_hash}"
98
- created_time = Time.now.iso8601
99
-
100
- # Build-Args for consistent labels
101
- build_args = [
102
- "--label org.opencontainers.image.title=oxidized",
103
- "--label org.opencontainers.image.description='Local build of Oxidized'",
104
- "--label org.opencontainers.image.url=https://github.com/ytti/oxidized",
105
- "--label org.opencontainers.image.source=https://github.com/ytti/oxidized",
106
- "--label org.opencontainers.image.created=#{created_time}",
107
- "--label org.opencontainers.image.ref.name=#{image_tag}",
108
- "--label org.opencontainers.image.licenses=Apache-2.0",
109
- "--label org.opencontainers.image.version=#{image_tag}",
110
- "--label org.opencontainers.image.revision=#{sha_hash_long}",
111
- "-t oxidized:#{image_tag}",
112
- "-t oxidized:latest"
113
- ].join(' ')
114
-
115
- # Prefer podman if available as it runs rootless
116
- if command_available?('podman')
117
- sh "podman build #{build_args} ."
118
- elsif command_available?('docker')
119
- if docker_needs_root?
120
- puts 'docker needs root to build the image. Using sudo...'
121
- sh "sudo docker build #{build_args} ."
122
- else
123
- sh "docker build #{build_args} ."
124
- end
125
- else
126
- puts 'You need Podman or Docker to build the container image.'
127
- exit 1
128
- end
129
- end
130
-
131
- task default: %i[rubocop test]
data/TODO.md DELETED
@@ -1,29 +0,0 @@
1
- # To Do
2
-
3
- ## refactor core
4
-
5
- * move state from memory to disk, sqlite probably
6
- * allows us to retain stats etc over restart
7
- * simplifies code
8
- * keep only running nodes in memory
9
- * negligible I/O cost, as majority is I/O wait getting config
10
-
11
- ## separate login to own package
12
-
13
- * oxidized-script is not only use-case
14
- * it would be good to have minimal package used to login to routers
15
- * oxidized just one consumer of that functionality
16
- * what to do with models, we need model to know how to login. Should models be separated to another package? oxidized-core, oxidized-models and oxidized-login?
17
- * how can we allow interactive login in oxidized-login? With functional VTY etc? REPL loop in input/ssh and input/telnet?
18
-
19
- ## thread number
20
-
21
- * think about algo
22
- * if job ended later than now-iteration have rand(node.size) == 0 to add thread
23
- * if now is less than job_ended+iteration same chance to remove thread?
24
- * should we try to avoid max threads from being hit? (like maybe non-success thread is pulling average?)
25
-
26
- ## docs, testing
27
-
28
- * yard docs
29
- * minitest tests
data/bin/console DELETED
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- lib = File.expand_path('../lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
-
6
- require 'oxidized'
7
- require 'pry'
8
-
9
- Pry.start
data/oxidized.gemspec DELETED
@@ -1,77 +0,0 @@
1
- lib = File.expand_path('lib', __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'oxidized/version'
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'oxidized'
7
- s.version = Oxidized::VERSION
8
- s.licenses = %w[Apache-2.0]
9
- s.platform = Gem::Platform::RUBY
10
- s.authors = ['Saku Ytti', 'Samer Abdel-Hafez', 'Anton Aksola']
11
- s.email = %w[saku@ytti.fi sam@arahant.net aakso@iki.fi]
12
- s.homepage = 'http://github.com/ytti/oxidized'
13
- s.summary = 'feeble attempt at rancid'
14
- s.description = 'software to fetch configuration from network devices and store them'
15
- s.files = %x(git ls-files -z).split("\x0").reject { |f| f.match(/^(test|spec|features)\//) }
16
- s.executables = %w[oxidized]
17
- s.require_path = 'lib'
18
-
19
- s.metadata['rubygems_mfa_required'] = 'true'
20
-
21
- # Ruby version strategy
22
- #
23
- # We try to keep the minimum version of Ruby to match supported LTS versions
24
- # of common Linux distributions, as long as the maintenance effort remains
25
- # reasonable.
26
- s.required_ruby_version = '>= 3.0'
27
-
28
- # Gemspec strategy
29
- #
30
- # For dependency and optional dependencies, we try to set the minimal
31
- # dependency lower or equal to the Debian 13 "Trixie" package version,
32
- # so that native packages can be used.
33
- # We limit the maximal minor version so that dependabot can warn about new
34
- # major versions and we can test them before activating them in Oxidized.
35
-
36
- s.add_dependency 'asetus', '~> 0.4'
37
- s.add_dependency 'bcrypt_pbkdf', '~> 1.0'
38
- s.add_dependency 'net-ftp', '~> 0.2'
39
- s.add_dependency 'net-http-digest_auth', '~> 1.4'
40
- # Net-SSH require a newer version than Debian 13 provides.
41
- s.add_dependency 'net-ssh', '~> 8.1'
42
- s.add_dependency 'net-telnet', '~> 0.2'
43
- s.add_dependency 'psych', '~> 5.0'
44
- s.add_dependency 'rugged', '~> 1.9'
45
- s.add_dependency 'semantic_logger', '>= 4.17', '< 6'
46
- s.add_dependency 'slop', '~> 4.6'
47
- s.add_dependency 'syslog', '~> 0.3'
48
- s.add_dependency 'syslog_protocol', '~> 0.9'
49
-
50
- s.add_development_dependency 'minitest', '>= 5.18', '<7'
51
- s.add_development_dependency 'mocha', '>= 2.1', '<4'
52
- s.add_development_dependency 'pry', '~> 0.15'
53
- s.add_development_dependency 'rake', '~> 13.0'
54
- # Rubocop introduces new rules in minor versions, so we limit automatic updates to patches
55
- s.add_development_dependency 'rubocop', '~> 1.92.0'
56
- s.add_development_dependency 'rubocop-minitest', '~> 0.41.0'
57
- s.add_development_dependency 'rubocop-rake', '~> 0.7.0'
58
- s.add_development_dependency 'rubocop-sequel', '~> 0.4.0'
59
- s.add_development_dependency 'simplecov', '~> 0.22'
60
-
61
- # Optional runtime libraries, needed here for the unit tests
62
- # Used by output/gitcrypt
63
- # git 6.0 removes APIs used by output/gitcrypt.rb (config, status, Log#first)
64
- s.add_development_dependency 'git', '>= 2.0', '< 6'
65
- # Used by input/scp (e.g. model apc_aos).
66
- # Requires a newer version than Debian 13 provides.
67
- s.add_development_dependency 'net-scp', '~> 4.2'
68
- # Used by input/tftp (e.g. model alvarion)
69
- s.add_development_dependency 'net-tftp', '~> 0.1.0'
70
- # Used by model panos_api
71
- s.add_development_dependency 'nokogiri', '>= 1.16', '< 2'
72
- s.add_development_dependency 'oxidized-web', '>= 0.17.1'
73
- # Used by model ftd
74
- s.add_development_dependency 'rubyzip', '>= 2.3.2', '< 4'
75
- # Used by source/sql
76
- s.add_development_dependency 'sequel', '>= 5.63.0', '< 6'
77
- end