moose-inventory 1.0.7 → 1.0.9
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.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +35 -0
- data/.gitignore +1 -1
- data/BACKLOG.md +184 -0
- data/Gemfile.lock +60 -0
- data/README.md +23 -5
- data/bin/moose-inventory +1 -1
- data/docs/release/publishing.md +113 -0
- data/docs/release/release-readiness.md +41 -0
- data/docs/security-audit-2026-05-21.md +71 -0
- data/lib/moose_inventory/cli/formatter.rb +16 -17
- data/lib/moose_inventory/cli/group.rb +1 -1
- data/lib/moose_inventory/cli/group_add.rb +19 -21
- data/lib/moose_inventory/cli/group_addchild.rb +36 -40
- data/lib/moose_inventory/cli/group_addhost.rb +14 -18
- data/lib/moose_inventory/cli/group_addvar.rb +37 -37
- data/lib/moose_inventory/cli/group_get.rb +23 -26
- data/lib/moose_inventory/cli/group_list.rb +12 -15
- data/lib/moose_inventory/cli/group_listvars.rb +12 -14
- data/lib/moose_inventory/cli/group_rm.rb +36 -21
- data/lib/moose_inventory/cli/group_rmchild.rb +5 -6
- data/lib/moose_inventory/cli/group_rmhost.rb +12 -16
- data/lib/moose_inventory/cli/group_rmvar.rb +5 -5
- data/lib/moose_inventory/cli/host.rb +1 -1
- data/lib/moose_inventory/cli/host_add.rb +18 -18
- data/lib/moose_inventory/cli/host_addgroup.rb +9 -9
- data/lib/moose_inventory/cli/host_addvar.rb +6 -6
- data/lib/moose_inventory/cli/host_get.rb +15 -18
- data/lib/moose_inventory/cli/host_list.rb +3 -3
- data/lib/moose_inventory/cli/host_listvars.rb +21 -23
- data/lib/moose_inventory/cli/host_rm.rb +9 -9
- data/lib/moose_inventory/cli/host_rmgroup.rb +5 -5
- data/lib/moose_inventory/cli/host_rmvar.rb +3 -3
- data/lib/moose_inventory/config/config.rb +43 -40
- data/lib/moose_inventory/db/db.rb +70 -50
- data/lib/moose_inventory/db/models.rb +11 -12
- data/lib/moose_inventory/version.rb +1 -1
- data/moose-inventory.gemspec +35 -20
- data/scripts/check.sh +8 -0
- data/scripts/ci/check_permissions.sh +32 -0
- data/scripts/ci/check_security.sh +50 -0
- data/scripts/ci/package_sanity.sh +46 -0
- data/scripts/files.rb +1 -4
- data/scripts/install_dependencies.sh +17 -0
- data/scripts/reports.sh +2 -2
- data/spec/lib/moose_inventory/cli/cli_spec.rb +13 -14
- data/spec/lib/moose_inventory/cli/group_add_spec.rb +118 -119
- data/spec/lib/moose_inventory/cli/group_addchild_spec.rb +49 -51
- data/spec/lib/moose_inventory/cli/group_addhost_spec.rb +80 -83
- data/spec/lib/moose_inventory/cli/group_addvar_spec.rb +91 -91
- data/spec/lib/moose_inventory/cli/group_get_spec.rb +22 -23
- data/spec/lib/moose_inventory/cli/group_list_spec.rb +19 -20
- data/spec/lib/moose_inventory/cli/group_listvar_spec.rb +35 -36
- data/spec/lib/moose_inventory/cli/group_rm_spec.rb +103 -49
- data/spec/lib/moose_inventory/cli/group_rmchild_spec.rb +41 -45
- data/spec/lib/moose_inventory/cli/group_rmhost_spec.rb +43 -46
- data/spec/lib/moose_inventory/cli/group_rmvar_spec.rb +131 -131
- data/spec/lib/moose_inventory/cli/group_spec.rb +9 -9
- data/spec/lib/moose_inventory/cli/host_add_spec.rb +103 -43
- data/spec/lib/moose_inventory/cli/host_addgroup_spec.rb +78 -80
- data/spec/lib/moose_inventory/cli/host_addvar_spec.rb +122 -122
- data/spec/lib/moose_inventory/cli/host_get_spec.rb +16 -16
- data/spec/lib/moose_inventory/cli/host_list_spec.rb +8 -8
- data/spec/lib/moose_inventory/cli/host_listvar_spec.rb +50 -52
- data/spec/lib/moose_inventory/cli/host_rm_spec.rb +12 -12
- data/spec/lib/moose_inventory/cli/host_rmgroup_spec.rb +48 -51
- data/spec/lib/moose_inventory/cli/host_rmvar_spec.rb +136 -136
- data/spec/lib/moose_inventory/config/config_spec.rb +16 -3
- data/spec/lib/moose_inventory/db/db_spec.rb +224 -2
- data/spec/lib/moose_inventory/db/models_spec.rb +10 -11
- data/spec/shared/shared_config_setup.rb +2 -2
- data/spec/spec_helper.rb +7 -8
- metadata +99 -136
- data/.coveralls.yml +0 -0
- data/.rubocop.yml +0 -793
- data/Guardfile +0 -38
- data/config/dotfiles/coveralls.yml +0 -0
- data/config/dotfiles/gitignore +0 -20
- data/config/dotfiles/rubocop.yml +0 -793
- data/scripts/guard_quality.sh +0 -3
- data/scripts/guard_test.sh +0 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: bba43a0d585b334c19629209ae0f323d88ac1c618de4a926769765a5146933b7
|
|
4
|
+
data.tar.gz: 701d64c584a0e0d10266466a94350aa69731a15f623ca37f9edac917c5dd2a38
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef297abb3d7836f1c7f1a20d46a1f79eee14957a74651628fa2fa523ffd5ed26de9f374e551ae861cd8b68d6cc1a646fba52a85209929b2259a078b2409b1a9f
|
|
7
|
+
data.tar.gz: d9cfa2e8a85065415858a47aa4e2e1878483e8e982bda25a9d37f05f61c0373e7b7b6bd4ec0f1ba9f0ac3dcf9f796b458c96f794f29466e91aed179a0b6293af
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [master]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
fail-fast: false
|
|
17
|
+
matrix:
|
|
18
|
+
ruby-version: ['3.2', '3.3', '3.4']
|
|
19
|
+
steps:
|
|
20
|
+
- name: Check out repository
|
|
21
|
+
uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Set up Ruby
|
|
24
|
+
uses: ruby/setup-ruby@v1
|
|
25
|
+
with:
|
|
26
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
27
|
+
bundler-cache: true
|
|
28
|
+
|
|
29
|
+
- name: Install native build dependencies
|
|
30
|
+
run: |
|
|
31
|
+
sudo apt-get update
|
|
32
|
+
sudo apt-get install -y build-essential default-libmysqlclient-dev libpq-dev libsqlite3-dev
|
|
33
|
+
|
|
34
|
+
- name: Run local check gate
|
|
35
|
+
run: ./scripts/check.sh
|
data/.gitignore
CHANGED
data/BACKLOG.md
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# Moose Inventory Release Readiness Backlog
|
|
2
|
+
|
|
3
|
+
Release readiness status counts: 5 done / 2 open.
|
|
4
|
+
|
|
5
|
+
## Open
|
|
6
|
+
|
|
7
|
+
1. Resolve GitHub Actions Node.js 20 deprecation warning.
|
|
8
|
+
- Current CI passes, but GitHub warns that `actions/checkout@v4` is running on Node.js 20 and Node.js 24 will become the default.
|
|
9
|
+
- Review available `actions/checkout` updates or GitHub-recommended configuration, then update the workflow so CI stays warning-free before Node.js 20 removal.
|
|
10
|
+
|
|
11
|
+
1. Add GitHub Actions RubyGems trusted publishing.
|
|
12
|
+
- Manual publishing is documented in `docs/release/publishing.md`.
|
|
13
|
+
- Future improvement: configure RubyGems trusted publishing, publish from reviewed `v*` tags, and avoid long-lived RubyGems API keys on developer machines.
|
|
14
|
+
|
|
15
|
+
## Done
|
|
16
|
+
|
|
17
|
+
1. Decide and declare the supported Ruby version floor.
|
|
18
|
+
- Set `spec.required_ruby_version` to `>= 3.2` in the gemspec.
|
|
19
|
+
- Updated GitHub Actions CI to test Ruby `3.2`, `3.3`, and `3.4` so the declared floor remains exercised.
|
|
20
|
+
- Updated release-readiness documentation to describe matrix coverage.
|
|
21
|
+
|
|
22
|
+
1. Document manual RubyGems publishing.
|
|
23
|
+
- Added `docs/release/publishing.md` with the current manual release path: verify version, run `./scripts/check.sh`, push and wait for CI, build the gem, `gem push`, verify RubyGems, then tag the release.
|
|
24
|
+
- Noted that the repo currently has CI but no publishing workflow.
|
|
25
|
+
- Added the trusted-publishing follow-up as an open release-readiness item.
|
|
26
|
+
|
|
27
|
+
1. Create a release-readiness backlog.
|
|
28
|
+
- Added this release-readiness section to track post-modernization packaging/CI hardening separately from the completed modernization and fresh-pass backlogs.
|
|
29
|
+
|
|
30
|
+
1. Add CI/security gates to prevent regressions.
|
|
31
|
+
- Added `.github/workflows/ci.yml` for GitHub Actions on `master` pushes and pull requests.
|
|
32
|
+
- Expanded `./scripts/check.sh` to run the RSpec suite, `git diff --check`, executable-permission checks, OSV dependency advisory checks, and package sanity checks.
|
|
33
|
+
- Added `scripts/ci/check_permissions.sh` to keep executable bits limited to intentional entrypoints and scripts.
|
|
34
|
+
- Added `scripts/ci/check_security.sh` to query OSV for locked RubyGems dependency advisories.
|
|
35
|
+
|
|
36
|
+
1. Do a gem/package sanity pass.
|
|
37
|
+
- Added `scripts/ci/package_sanity.sh` to build the gem, inspect the packaged payload, verify required files, check executable metadata, and smoke-test the CLI version command.
|
|
38
|
+
- Documented the release-readiness gate in `docs/release/release-readiness.md`.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
# Moose Inventory GitHub Issues Backlog
|
|
43
|
+
|
|
44
|
+
GitHub issues status counts: 0 done / 4 open.
|
|
45
|
+
|
|
46
|
+
## Open
|
|
47
|
+
|
|
48
|
+
1. [#14 Passwords in config files](https://github.com/RusDavies/moose-inventory/issues/14)
|
|
49
|
+
- README examples currently show database passwords stored directly in configuration files.
|
|
50
|
+
- Determine whether Moose Inventory supports reading credentials from environment variables today.
|
|
51
|
+
- If not, decide whether to add environment-variable credential support or at least document safer credential-handling guidance.
|
|
52
|
+
- Update README/config examples so they do not accidentally encourage secret-in-repo bad practice.
|
|
53
|
+
|
|
54
|
+
1. [#13 Need to refactor](https://github.com/RusDavies/moose-inventory/issues/13)
|
|
55
|
+
- CLI command modules contain similar methods across host/group operations, for example `GroupAdd` and `HostAdd`-style flows.
|
|
56
|
+
- Existing code has historically needed complexity metric disables such as `Metrics/AbcSize` and `Metrics/CyclomaticComplexity`.
|
|
57
|
+
- Evaluate cost/benefit before doing a broad refactor; identify specific low-risk extraction targets and regression coverage needed.
|
|
58
|
+
|
|
59
|
+
1. [#12 Allow `group rm` to recursively delete orphaned child groups](https://github.com/RusDavies/moose-inventory/issues/12)
|
|
60
|
+
- Decide product semantics for recursive group deletion: default behavior, explicit switch, safety prompts/flags, and how to distinguish intentional tree deletion from accidental orphan cleanup.
|
|
61
|
+
- If implemented, add tests for `group rm` and `group rmchild` orphan-child behavior, root-group handling, and host `ungrouped` behavior.
|
|
62
|
+
|
|
63
|
+
1. [#4 `--trace` doesn't do what it claims](https://github.com/RusDavies/moose-inventory/issues/4)
|
|
64
|
+
- Reproduce current `--trace` behavior and confirm whether exceptions/backtraces are still truncated.
|
|
65
|
+
- Fix trace handling so transaction errors emit useful full exception/backtrace information when `--trace` is enabled while preserving concise default errors.
|
|
66
|
+
- Add regression coverage for both trace and non-trace error output.
|
|
67
|
+
|
|
68
|
+
## Done
|
|
69
|
+
|
|
70
|
+
_No GitHub issue backlog items completed yet._
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
# Moose Inventory Fresh Pass Backlog
|
|
75
|
+
|
|
76
|
+
Fresh pass status counts: 8 done / 0 open.
|
|
77
|
+
|
|
78
|
+
## Open
|
|
79
|
+
|
|
80
|
+
_No open fresh-pass items._
|
|
81
|
+
|
|
82
|
+
## Done
|
|
83
|
+
|
|
84
|
+
1. Refresh user-facing docs and setup scripts after DB support decisions.
|
|
85
|
+
- Fixed README typos/stale DB support notes and documented the tested support matrix: SQLite live file coverage plus MySQL/PostgreSQL adapter/error-path smoke coverage.
|
|
86
|
+
- Updated `scripts/install_dependencies.sh` for current Fedora package names, removing obsolete `mysql-utilities` and using client development headers for SQLite, MariaDB/MySQL, and PostgreSQL.
|
|
87
|
+
- Verified with full `./scripts/check.sh` and shell syntax check for the install script.
|
|
88
|
+
|
|
89
|
+
1. Add adapter/error-path smoke tests to the stable QA gate.
|
|
90
|
+
- Expanded DB specs included by `./scripts/check.sh` to cover documented adapter dispatch for SQLite, MySQL, and PostgreSQL.
|
|
91
|
+
- Added missing-key error-path smoke coverage for SQLite, MySQL, and PostgreSQL, alongside existing unsupported-adapter and nested SQLite path coverage.
|
|
92
|
+
- Verified with full `./scripts/check.sh`.
|
|
93
|
+
|
|
94
|
+
1. Harden YAML config loading.
|
|
95
|
+
- Replaced `YAML.load_file` with `YAML.safe_load_file` using no permitted classes, no permitted symbols, and aliases disabled.
|
|
96
|
+
- Added regression coverage ensuring config loading uses the safe YAML loader while preserving existing config fixture behavior.
|
|
97
|
+
- Verified with full `./scripts/check.sh`.
|
|
98
|
+
|
|
99
|
+
1. Use recursive directory creation for SQLite database paths.
|
|
100
|
+
- Replaced single-level `Dir.mkdir` with `FileUtils.mkdir_p` in `init_sqlite3`.
|
|
101
|
+
- Added regression coverage for nested SQLite database file paths.
|
|
102
|
+
- Verified with full `./scripts/check.sh`.
|
|
103
|
+
|
|
104
|
+
1. Fix existing-host group association logic in `host add --groups`.
|
|
105
|
+
- Fixed the association-existence condition so existing hosts can be associated with new groups and true duplicate associations are skipped with the existing warning.
|
|
106
|
+
- Added regression coverage for adding a new group to an existing host and idempotently skipping an existing association.
|
|
107
|
+
- Verified with full `./scripts/check.sh`.
|
|
108
|
+
|
|
109
|
+
1. Fix or de-scope PostgreSQL support.
|
|
110
|
+
- Implemented `init_postgresql` using the existing `pg` dependency and `Sequel.postgres`.
|
|
111
|
+
- Added regression coverage for PostgreSQL connection option wiring without requiring a live PostgreSQL server.
|
|
112
|
+
- Verified with full `./scripts/check.sh`.
|
|
113
|
+
|
|
114
|
+
1. Fix MySQL adapter support or remove it from advertised support.
|
|
115
|
+
- Fixed `DB.connect` to dispatch documented `adapter: mysql` instead of misspelled `msqsql`.
|
|
116
|
+
- Updated `init_mysql` to require `mysql2` and use `Sequel.mysql2`, matching the project dependency.
|
|
117
|
+
- Added regression coverage for MySQL adapter dispatch and connection option wiring without requiring a live MySQL server.
|
|
118
|
+
- Verified with full `./scripts/check.sh`.
|
|
119
|
+
|
|
120
|
+
1. Initialize/use DB exception classes before connection failures.
|
|
121
|
+
- Added DB exception initialization before connection setup so unsupported adapters raise `Moose::Inventory::DB::MooseDBException` instead of masking the intended error with `NoMethodError` on nil `@exceptions`.
|
|
122
|
+
- Added regression coverage for unsupported adapter initialization.
|
|
123
|
+
- Verified with full `./scripts/check.sh`.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
# Moose Inventory Modernization Backlog
|
|
128
|
+
|
|
129
|
+
Status counts: 10 done / 0 open.
|
|
130
|
+
|
|
131
|
+
## Open
|
|
132
|
+
|
|
133
|
+
_No open modernization items._
|
|
134
|
+
|
|
135
|
+
## Done
|
|
136
|
+
|
|
137
|
+
1. Review old QA tooling (`rubocop ~> 0`, Guard, Coveralls/SimpleCov setup) and decide what still belongs in the project.
|
|
138
|
+
- Removed obsolete RuboCop/Guard/Coveralls tooling after confirming current `rubocop 0.93.1` fails under Ruby 3.4 with missing bundled/default gems and obsolete config entries.
|
|
139
|
+
- Kept SimpleCov as the local coverage gate because the RSpec suite still passes with 95.16% line coverage against a 90% minimum.
|
|
140
|
+
- Added `scripts/check.sh` as the stable local QA entry point for `bundle exec rspec --format progress` and documented it in the README.
|
|
141
|
+
- Updated `scripts/reports.sh` to open the remaining SimpleCov HTML report only.
|
|
142
|
+
- Verified with `bundle lock`, `scripts/check.sh`, and `git diff --check`.
|
|
143
|
+
|
|
144
|
+
1. Modernize remaining stale runtime dependencies with care, especially `mysql2` and `sqlite3`.
|
|
145
|
+
- `pg` has been moved to a Ruby-3.4-compatible constraint.
|
|
146
|
+
- `json`, `sequel`, and `thor` have been moved to Ruby-3.4-compatible constraints.
|
|
147
|
+
- Tightened `mysql2` from `~> 0` to `>= 0.5.7, < 0.6`; Bundler keeps resolving `mysql2 0.5.7`.
|
|
148
|
+
- Relaxed/modernized `sqlite3` from `~> 1` to `>= 1.7, < 3`; Bundler now resolves `sqlite3 2.9.4`.
|
|
149
|
+
- Verified with `bundle update sqlite3 mysql2 --conservative` and `bundle exec rspec --format documentation`: 242 examples, 0 failures; line coverage 95.16%.
|
|
150
|
+
|
|
151
|
+
1. Generate and commit a current `Gemfile.lock` after deciding whether to stop ignoring it.
|
|
152
|
+
- Removed `/Gemfile.lock` from `.gitignore`.
|
|
153
|
+
- Generated `Gemfile.lock` with Bundler 2.6.9 under Ruby 3.4.8.
|
|
154
|
+
- Verified the lockfile baseline with `bundle exec rspec --format documentation`.
|
|
155
|
+
|
|
156
|
+
1. Update Ruby/Bundler dependency constraints so the project can resolve with current Bundler/Ruby.
|
|
157
|
+
- Changed the development dependency from `bundler ~> 1` to `bundler >= 1.17, < 3`.
|
|
158
|
+
- Verified dependency resolution with `bundle lock` under Ruby 3.4.8 / Bundler 2.6.9.
|
|
159
|
+
2. Provide Ruby development headers for native gem compilation.
|
|
160
|
+
- Russ installed `ruby-devel`; verified `/usr/include/ruby.h` exists.
|
|
161
|
+
- Full `bundle install` now gets past the Ruby header blocker.
|
|
162
|
+
3. Remove the stale direct `hitimes ~> 1` development dependency.
|
|
163
|
+
- Removed `spec.add_development_dependency 'hitimes', '~> 1'` from the gemspec.
|
|
164
|
+
- Removed `rubygem-hitimes` from `scripts/install_dependencies.sh`.
|
|
165
|
+
- `hitimes 1.3.1` failed to compile against Ruby 3.4 and was only referenced as legacy development tooling.
|
|
166
|
+
- Verified `bundle lock --print` no longer includes `hitimes`.
|
|
167
|
+
4. Move past missing database client headers.
|
|
168
|
+
- `bundle install` now builds/installs both `mysql2` and `pg` dependencies in this environment.
|
|
169
|
+
5. Update the stale `pg` dependency for Ruby 3.4 compatibility.
|
|
170
|
+
- Changed `pg` from `~> 0` to `>= 1.5, < 2`.
|
|
171
|
+
- Verified Bundler resolves `pg 1.6.3` instead of `pg 0.21.0`.
|
|
172
|
+
- Verified `bundle install` completes successfully under Ruby 3.4.8 / Bundler 2.6.9.
|
|
173
|
+
6. Run the existing RSpec suite and establish a green modern-Ruby baseline.
|
|
174
|
+
- Initial baseline exposed startup/runtime incompatibilities in old `thor`, `json`, and `sequel` constraints.
|
|
175
|
+
- Updated `json` from `~> 1` to `>= 2.7, < 3`.
|
|
176
|
+
- Updated `thor` from `~> 0` to `>= 1.3, < 2`.
|
|
177
|
+
- Updated `sequel` from `~> 4` to `>= 5.80, < 6`.
|
|
178
|
+
- Verified Bundler resolves `json 2.19.5`, `thor 1.5.0`, and `sequel 5.104.0`.
|
|
179
|
+
7. Fix RSpec harness compatibility with the current checkout/test flow.
|
|
180
|
+
- `spec_helper` now creates `tmp/` before deleting test database files, avoiding `Errno::ENOENT` on fresh clones.
|
|
181
|
+
- Config specs now pass an explicit fixture config when testing default option values.
|
|
182
|
+
- Ansible-mode CLI specs now pass the fixture config when invoking the top-level CLI.
|
|
183
|
+
- Updated the `--list` expectation for Ansible mode, which correctly includes empty `hosts` arrays.
|
|
184
|
+
- Verified `bundle exec rspec --format documentation`: 242 examples, 0 failures; line coverage 95.16%.
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
moose-inventory (1.0.9)
|
|
5
|
+
indentation (~> 0)
|
|
6
|
+
json (>= 2.7, < 3)
|
|
7
|
+
mysql2 (>= 0.5.7, < 0.6)
|
|
8
|
+
pg (>= 1.5, < 2)
|
|
9
|
+
sequel (>= 5.80, < 6)
|
|
10
|
+
sqlite3 (>= 1.7, < 3)
|
|
11
|
+
thor (>= 1.3, < 2)
|
|
12
|
+
|
|
13
|
+
GEM
|
|
14
|
+
remote: https://rubygems.org/
|
|
15
|
+
specs:
|
|
16
|
+
bigdecimal (4.1.2)
|
|
17
|
+
diff-lcs (1.6.2)
|
|
18
|
+
docile (1.4.1)
|
|
19
|
+
indentation (0.1.1)
|
|
20
|
+
json (2.19.5)
|
|
21
|
+
mysql2 (0.5.7)
|
|
22
|
+
bigdecimal
|
|
23
|
+
pg (1.6.3-x86_64-linux)
|
|
24
|
+
rake (13.4.2)
|
|
25
|
+
rspec (3.13.2)
|
|
26
|
+
rspec-core (~> 3.13.0)
|
|
27
|
+
rspec-expectations (~> 3.13.0)
|
|
28
|
+
rspec-mocks (~> 3.13.0)
|
|
29
|
+
rspec-core (3.13.6)
|
|
30
|
+
rspec-support (~> 3.13.0)
|
|
31
|
+
rspec-expectations (3.13.5)
|
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
33
|
+
rspec-support (~> 3.13.0)
|
|
34
|
+
rspec-mocks (3.13.8)
|
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
36
|
+
rspec-support (~> 3.13.0)
|
|
37
|
+
rspec-support (3.13.7)
|
|
38
|
+
sequel (5.104.0)
|
|
39
|
+
bigdecimal
|
|
40
|
+
simplecov (0.22.0)
|
|
41
|
+
docile (~> 1.1)
|
|
42
|
+
simplecov-html (~> 0.11)
|
|
43
|
+
simplecov_json_formatter (~> 0.1)
|
|
44
|
+
simplecov-html (0.13.2)
|
|
45
|
+
simplecov_json_formatter (0.1.4)
|
|
46
|
+
sqlite3 (2.9.4-x86_64-linux-gnu)
|
|
47
|
+
thor (1.5.0)
|
|
48
|
+
|
|
49
|
+
PLATFORMS
|
|
50
|
+
x86_64-linux
|
|
51
|
+
|
|
52
|
+
DEPENDENCIES
|
|
53
|
+
bundler (>= 2.2.33, < 3)
|
|
54
|
+
moose-inventory!
|
|
55
|
+
rake (>= 13.0, < 14)
|
|
56
|
+
rspec (~> 3)
|
|
57
|
+
simplecov (~> 0)
|
|
58
|
+
|
|
59
|
+
BUNDLED WITH
|
|
60
|
+
2.6.9
|
data/README.md
CHANGED
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
The [moose-inventory](https://github.com/RusDavies/moose-inventory) software is a tool for managing dynamic inventories, intended for use with [Ansible](http://www.ansible.com/home).
|
|
4
4
|
|
|
5
|
-
Note:
|
|
5
|
+
Note 1: For many, the really interesting part of this tool will be it's ability to write to the inventory database from within Ansible, as described at the end of this document. If that's what tickles your fancy, then I encourage you to get a sense of the capability by [jumping to that section first](https://github.com/RusDavies/moose-inventory#writing-to-the-dynamic-inventory-from-ansible). ;o)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Note 2: This software is intended for use on UNIX/Linux systems. It will likely not work on Windows, due to some hard-wired search paths - I may fix that in the future but, for now, sorry.
|
|
6
9
|
|
|
7
10
|
## Installation
|
|
8
11
|
|
|
12
|
+
Note: You may need to install Ruby development headers and database client development packages on your system so native gems can build. On current Fedora releases, the project helper script installs the expected SQLite, MariaDB/MySQL, and PostgreSQL client headers.
|
|
13
|
+
|
|
9
14
|
The tool is a ruby gem. Assuming that you have ruby on your system, then it can be installed from the command line as follows.
|
|
10
15
|
|
|
11
16
|
$ gem install moose-inventory
|
|
12
17
|
|
|
18
|
+
Note: It may be necessary to first install native build tools and database client development headers before installing the gem or running Bundler.
|
|
19
|
+
|
|
13
20
|
It can also be installed by adding the following line to a Gemfile and then executing `bundle`:
|
|
14
21
|
|
|
15
22
|
```ruby
|
|
@@ -69,9 +76,9 @@ You may add as many environment sections as you desire. The intention is to enab
|
|
|
69
76
|
|
|
70
77
|
At present, each environment section contains only a **db** subsection, describing database connection parameters. Additional subsections may be added in the future, as functionality increases.
|
|
71
78
|
|
|
72
|
-
Each **db** section must include an **adapter** parameter. Currently supported adapter types are *sqlite3*, *mysql*, and *
|
|
79
|
+
Each **db** section must include an **adapter** parameter. Currently supported adapter types are *sqlite3*, *mysql*, and *postgresql*. The test suite exercises SQLite with a local database file and includes adapter dispatch/error-path smoke coverage for MySQL and PostgreSQL without requiring live database servers.
|
|
73
80
|
|
|
74
|
-
Additional parameters are also required in the **db** subsection, depending on the adapter type.
|
|
81
|
+
Additional parameters are also required in the **db** subsection, depending on the adapter type. For the *sqlite3* adapter only a **file** parameter is required; parent directories are created automatically. For both *mysql* and *postgresql*, **host**, **database**, **user**, and **password** are required.
|
|
75
82
|
|
|
76
83
|
|
|
77
84
|
## Usage
|
|
@@ -306,6 +313,7 @@ Removing variables, groups, and hosts is just as easy. In the following example
|
|
|
306
313
|
|
|
307
314
|
### Using moose-inventory with Ansible
|
|
308
315
|
|
|
316
|
+
|
|
309
317
|
The *moose-inventory* tool is compliant with the Ansible specifications for [dynamic inventory sources](http://docs.ansible.com/developing_inventory.html).
|
|
310
318
|
|
|
311
319
|
However, to make use of *moose-inventory's* multiple environment and configuration file options, a shim script should be used as the target for the [external inventory script](http://docs.ansible.com/intro_dynamic_inventory.html). A trivial example may look something like the following.
|
|
@@ -346,15 +354,25 @@ Alternatively, if using an [Ansible configuration file](http://docs.ansible.com/
|
|
|
346
354
|
|
|
347
355
|
Yet another option is to copy the shim script to */etc/ansible/hosts* and `chmod +x` it. However, since this would essentially fix the config file and environment used, doing so would defeat the flexibility intended for *moose-inventory*.
|
|
348
356
|
|
|
349
|
-
|
|
357
|
+
#### Writing to the dynamic inventory from Ansible
|
|
358
|
+
A useful aspect of dynamic inventories is the possibility of writing data to the inventory. To persist data from Ansible to the inventory, simply call the shim script via a local_action command, for example:
|
|
350
359
|
|
|
351
360
|
```shell
|
|
352
361
|
- set_fact: mydata="Hello world"
|
|
353
362
|
- local_action: command shim.sh host addvar {{ inventory_hostname }} mydata="{{ mydata }}"
|
|
354
363
|
```
|
|
355
364
|
|
|
356
|
-
|
|
357
365
|
|
|
366
|
+
## Development checks
|
|
367
|
+
|
|
368
|
+
Run the local verification gate before committing changes:
|
|
369
|
+
|
|
370
|
+
```shell
|
|
371
|
+
./scripts/check.sh
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
The check script runs the RSpec suite and enforces the SimpleCov coverage minimum.
|
|
375
|
+
|
|
358
376
|
## Contributing
|
|
359
377
|
1. Fork it (https://github.com/RusDavies/moose-inventory/fork )
|
|
360
378
|
2. Create your feature branch (git checkout -b my-new-feature`)
|
data/bin/moose-inventory
CHANGED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Publishing to RubyGems
|
|
2
|
+
|
|
3
|
+
This project has historically been published manually to RubyGems as [`moose-inventory`](https://rubygems.org/gems/moose-inventory).
|
|
4
|
+
|
|
5
|
+
At the time this document was added:
|
|
6
|
+
|
|
7
|
+
- The latest published RubyGems version was `1.0.8`.
|
|
8
|
+
- The repository version was `1.0.9` in `lib/moose_inventory/version.rb`.
|
|
9
|
+
- The repository had CI for checks, but no GitHub Actions publishing workflow.
|
|
10
|
+
|
|
11
|
+
## Release checklist
|
|
12
|
+
|
|
13
|
+
1. Start from a clean `master` branch.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
git checkout master
|
|
17
|
+
git pull --ff-only origin master
|
|
18
|
+
git status --short --branch
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
2. Confirm the version to publish.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
ruby -e "require './lib/moose_inventory/version'; puts Moose::Inventory::VERSION"
|
|
25
|
+
gem info moose-inventory --remote --all
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
If the repository version is already higher than the latest RubyGems version, you can publish it as-is after checks pass. If not, bump `lib/moose_inventory/version.rb` first and commit that change before publishing.
|
|
29
|
+
|
|
30
|
+
3. Run the local release gate.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
./scripts/check.sh
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This runs the spec suite, whitespace checks, executable-permission checks, OSV dependency advisory checks, and gem package sanity checks.
|
|
37
|
+
|
|
38
|
+
4. Push the release commit and wait for CI to pass.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
git push origin master
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Do not publish to RubyGems until the GitHub Actions CI run for the pushed commit is green.
|
|
45
|
+
|
|
46
|
+
5. Build the gem from the exact commit you intend to release.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
rm -rf pkg tmp/pkg tmp/package-sanity
|
|
50
|
+
gem build moose-inventory.gemspec
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The output should be named like `moose-inventory-1.0.9.gem`.
|
|
54
|
+
|
|
55
|
+
6. Inspect the built gem metadata if desired.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
gem specification moose-inventory-1.0.9.gem name version executables require_paths files --yaml
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
7. Publish to RubyGems.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
gem push moose-inventory-1.0.9.gem
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
If RubyGems auth is not already configured, `gem push` will prompt for credentials or an API key.
|
|
68
|
+
|
|
69
|
+
8. Verify the published version.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
gem info moose-inventory --remote --all
|
|
73
|
+
gem install moose-inventory -v 1.0.9
|
|
74
|
+
moose-inventory --help
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
9. Tag the release after RubyGems confirms it is live.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
git tag -a v1.0.9 -m "Release v1.0.9"
|
|
81
|
+
git push origin v1.0.9
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Authentication notes
|
|
85
|
+
|
|
86
|
+
Prefer a scoped RubyGems API key over an old global key:
|
|
87
|
+
|
|
88
|
+
- Scope it to pushing gems, ideally only `moose-inventory` if RubyGems permits that for the account.
|
|
89
|
+
- Store it in `~/.gem/credentials` with file mode `0600` if publishing manually.
|
|
90
|
+
- Do not commit RubyGems credentials, `.gem/credentials`, shell history containing tokens, or generated private keys.
|
|
91
|
+
|
|
92
|
+
Check credential file permissions with:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
ls -l ~/.gem/credentials
|
|
96
|
+
chmod 0600 ~/.gem/credentials
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Current publishing model
|
|
100
|
+
|
|
101
|
+
Publishing is manual. There is no automated release workflow in this repository yet.
|
|
102
|
+
|
|
103
|
+
A future improvement would be to configure RubyGems trusted publishing through GitHub Actions so releases can be published from a tagged, reviewed workflow without long-lived RubyGems API keys on a developer machine.
|
|
104
|
+
|
|
105
|
+
Suggested future workflow:
|
|
106
|
+
|
|
107
|
+
1. Add RubyGems trusted publishing for this repository and gem.
|
|
108
|
+
2. Add a GitHub Actions workflow triggered by `v*` tags.
|
|
109
|
+
3. Have the workflow run `./scripts/check.sh`.
|
|
110
|
+
4. Build the gem.
|
|
111
|
+
5. Publish via trusted publishing only if the tag version matches `Moose::Inventory::VERSION`.
|
|
112
|
+
|
|
113
|
+
Until that is implemented, use the manual process above.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Release readiness notes
|
|
2
|
+
|
|
3
|
+
This project now has a small release-readiness gate intended to catch the regressions found during the modernization and security-audit passes.
|
|
4
|
+
|
|
5
|
+
## Local gate
|
|
6
|
+
|
|
7
|
+
Run:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
./scripts/check.sh
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The gate currently runs:
|
|
14
|
+
|
|
15
|
+
1. RSpec with coverage via the existing spec helper.
|
|
16
|
+
2. `git diff --check` for whitespace/conflict-marker issues in the working tree.
|
|
17
|
+
3. `scripts/ci/check_permissions.sh` to ensure only intentional tracked repository entrypoints are executable.
|
|
18
|
+
4. `scripts/ci/check_security.sh` to query OSV for locked RubyGems dependency advisories.
|
|
19
|
+
5. `scripts/ci/package_sanity.sh` to build the gem, inspect the packaged payload, and smoke-test the CLI version command.
|
|
20
|
+
|
|
21
|
+
## CI gate
|
|
22
|
+
|
|
23
|
+
GitHub Actions workflow: `.github/workflows/ci.yml`.
|
|
24
|
+
|
|
25
|
+
It installs native headers needed by the DB gems, runs the same `./scripts/check.sh` gate used locally, and tests the maintained Ruby version range through the GitHub Actions matrix.
|
|
26
|
+
|
|
27
|
+
## Package sanity expectations
|
|
28
|
+
|
|
29
|
+
`package_sanity.sh` validates that the built gem includes at least:
|
|
30
|
+
|
|
31
|
+
- `bin/moose-inventory`
|
|
32
|
+
- `lib/moose_inventory.rb`
|
|
33
|
+
- `lib/moose_inventory/version.rb`
|
|
34
|
+
- `README.md`
|
|
35
|
+
- `LICENSE.txt`
|
|
36
|
+
|
|
37
|
+
It also verifies the gem metadata exposes the `moose-inventory` executable and that `bundle exec ruby -Ilib bin/moose-inventory --config spec/config/config.yml version` returns a version string.
|
|
38
|
+
|
|
39
|
+
## Dependency advisory expectations
|
|
40
|
+
|
|
41
|
+
`check_security.sh` reads `Gemfile.lock`, queries OSV's batch API for RubyGems packages, and fails on known vulnerabilities. This is intentionally simple and external-network-dependent; if OSV is unavailable, the gate fails closed so CI does not silently bless an unknown dependency state.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Security audit — 2026-05-21
|
|
2
|
+
|
|
3
|
+
Scope: local static/security review of the `moose-inventory` Ruby CLI/gem at commit `ff522502d5981314c451e855be10cbbc7ebeba48`, plus the hardening changes on branch `security-audit-2026-05-21`.
|
|
4
|
+
|
|
5
|
+
## Executive summary
|
|
6
|
+
|
|
7
|
+
The audit found one actionable dependency vulnerability and one low-risk repository hygiene issue. Both were remediated in this branch:
|
|
8
|
+
|
|
9
|
+
1. Development dependency `rake 10.5.0` was affected by CVE-2020-8130 / GHSA-jppv-gw3r-w3q8, an OS command injection issue in `Rake::FileList` for filenames beginning with `|`. The gemspec now requires `rake >= 13.0, < 14`, and `Gemfile.lock` resolves `rake 13.4.2`.
|
|
10
|
+
2. Most source, config, docs, and spec files were executable (`100755`) even though they are not entrypoints. The branch normalizes non-executable files to `100644`, keeping only `bin/moose-inventory` and actual scripts executable.
|
|
11
|
+
|
|
12
|
+
After the dependency update, an OSV query for locked RubyGems dependencies returned zero known vulnerabilities. Semgrep Ruby rules returned zero findings.
|
|
13
|
+
|
|
14
|
+
## Surfaces reviewed
|
|
15
|
+
|
|
16
|
+
- CLI entrypoint: `bin/moose-inventory`
|
|
17
|
+
- Global config parsing and file loading: `lib/moose_inventory/config/config.rb`
|
|
18
|
+
- DB connection and schema creation: `lib/moose_inventory/db/db.rb`
|
|
19
|
+
- Sequel models and associations: `lib/moose_inventory/db/models.rb`
|
|
20
|
+
- CLI command handlers under `lib/moose_inventory/cli/`
|
|
21
|
+
- Packaging metadata: `moose-inventory.gemspec`, `Gemfile`, `Gemfile.lock`
|
|
22
|
+
- Helper scripts under `scripts/`
|
|
23
|
+
- Test fixtures/config under `spec/`
|
|
24
|
+
|
|
25
|
+
## Findings fixed
|
|
26
|
+
|
|
27
|
+
### P2 — Vulnerable development dependency: `rake 10.5.0`
|
|
28
|
+
|
|
29
|
+
- Evidence: `Gemfile.lock` resolved `rake (10.5.0)` and `moose-inventory.gemspec` constrained rake to `~> 10`.
|
|
30
|
+
- Advisory: OSV/GitHub Advisory `GHSA-jppv-gw3r-w3q8`, CVE-2020-8130.
|
|
31
|
+
- Impact: local OS command injection in vulnerable Rake versions when `Rake::FileList` receives a filename beginning with the pipe character (`|`). This is primarily a developer/build-time risk, not a runtime CLI inventory risk.
|
|
32
|
+
- Fix: changed the development dependency to `rake >= 13.0, < 14` and refreshed `Gemfile.lock` to `rake 13.4.2`.
|
|
33
|
+
- Validation: OSV query after the update returned `deps_with_vulns 0`.
|
|
34
|
+
|
|
35
|
+
### P4 — Over-broad executable bits on repository files
|
|
36
|
+
|
|
37
|
+
- Evidence: file inventory showed `100755` executable mode on `Gemfile`, `README.md`, library files, specs, config, and other non-entrypoint files.
|
|
38
|
+
- Impact: low. This does not create a direct vulnerability by itself, but it expands accidental execution surface and makes packaging/review noisier than necessary. Tiny footgun, sharp enough to remove.
|
|
39
|
+
- Fix: normalized non-entrypoint files to `100644`; retained executable mode for `bin/moose-inventory` and scripts with shebangs.
|
|
40
|
+
|
|
41
|
+
## Notable negative findings
|
|
42
|
+
|
|
43
|
+
- Config deserialization now uses `YAML.safe_load_file` with aliases disabled and no permitted classes/symbols.
|
|
44
|
+
- No shell execution sinks were found in runtime code. The backtick use in `moose-inventory.gemspec` is the normal `git ls-files` packaging pattern.
|
|
45
|
+
- Database access uses Sequel model/hash APIs for user-provided names and variables; no raw SQL interpolation was identified in the reviewed CLI/database paths.
|
|
46
|
+
- No committed secrets were identified outside expected example/test placeholder passwords.
|
|
47
|
+
- No external network-facing service, HTTP route, RPC handler, webhook, queue consumer, or upload parser exists in this repo; the meaningful attack surface is local CLI usage and build/development tooling.
|
|
48
|
+
|
|
49
|
+
## Tooling evidence
|
|
50
|
+
|
|
51
|
+
- Inventory: 79 files; Ruby manifests: `Gemfile`, `Gemfile.lock`.
|
|
52
|
+
- Semgrep: `semgrep --config p/ruby --json --quiet .` returned 0 findings.
|
|
53
|
+
- OSV dependency query before fix: 1 vulnerable dependency (`rake 10.5.0`, `GHSA-jppv-gw3r-w3q8`).
|
|
54
|
+
- OSV dependency query after fix: 41 RubyGems dependency records queried, 0 dependencies with known vulnerabilities.
|
|
55
|
+
- `bundle-audit`, `osv-scanner`, `gitleaks`, `trufflehog`, and `brakeman` were not installed in this environment. Brakeman is also Rails-specific and not expected to apply here.
|
|
56
|
+
|
|
57
|
+
## Residual risks / future hardening
|
|
58
|
+
|
|
59
|
+
- Consider adding a CI security job for OSV or bundler-audit so dependency advisories are caught before they fossilize in the lockfile like a tiny Jurassic Park exhibit.
|
|
60
|
+
- Consider keeping generated coverage artifacts out of normal grep/scanner paths; they are ignored from this audit because they contain large bundled HTML/CSS assets.
|
|
61
|
+
|
|
62
|
+
## GitHub Dependabot follow-up after first push
|
|
63
|
+
|
|
64
|
+
After pushing the audit remediation, GitHub emitted a default-branch warning for 7 Dependabot vulnerabilities. Querying the repository Dependabot alerts through `gh api repos/RusDavies/moose-inventory/dependabot/alerts` showed that all 7 were already in `fixed` state after the modernization/security-audit commits reached GitHub:
|
|
65
|
+
|
|
66
|
+
- `rake`: GHSA-jppv-gw3r-w3q8 / CVE-2020-8130, fixed by `rake >= 13.0, < 14` and lockfile `rake 13.4.2`.
|
|
67
|
+
- `json`: GHSA-jphg-qwrw-7w9g / CVE-2020-10663, fixed by the existing current constraint `json >= 2.7, < 3` and lockfile `json 2.19.5`.
|
|
68
|
+
- `rubocop`: GHSA-wmjf-jpjj-9f3j / CVE-2017-8418, fixed by removing RuboCop as a development dependency.
|
|
69
|
+
- `bundler`: GHSA-jvgm-pfqv-887x / CVE-2016-7954, GHSA-g98m-96g9-wfjq / CVE-2019-3881, GHSA-fp4w-jxhp-m23p / CVE-2020-36327, and GHSA-fj7f-vq84-fh43 / CVE-2021-43809. GitHub marked these fixed because the lockfile uses Bundler 2.6.9; this follow-up also tightens the gemspec development dependency to `bundler >= 2.2.33, < 3` so fresh development installs cannot select known-vulnerable Bundler 1.x/early 2.x releases.
|
|
70
|
+
|
|
71
|
+
Follow-up validation: `gh api 'repos/RusDavies/moose-inventory/dependabot/alerts?state=open'` returned no open alerts.
|