hammer_cli 5.0.0 → 5.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27faa46ea907e19dfe6c29420a5d355909a84c59a817e4bcde0f197a17d5c368
4
- data.tar.gz: 8f5982c563ce5b2b4d3028d882f85fb627d5d840246a9e35f172a3fbb1a2ff48
3
+ metadata.gz: d96b945f7c3e7bd8b86994613c6fdf735c5396f3d12d9a37fb3c7bb8c278c177
4
+ data.tar.gz: dbf9ffeda52de912e869c88eea4f8e760bca19d40811a5765d0fffc526c53f07
5
5
  SHA512:
6
- metadata.gz: ad512c4ee9d15c567efde990f5c904f084c577239a1eb4b74c2440ef6000bc87982f1df6fe423a554137114e60078224faa157768cb794e5a6901f0e41de491c
7
- data.tar.gz: c92b48e9eecc4b3ece82e782720766535c48d671b194d12e8e46be6f03df89fb58a2d20a79ada4a7b1519f77938f9b3596cc88ca833ae1c7286a351d0896ecf0
6
+ metadata.gz: faf67715c7000035e1bbf10e323bc385d26189247f6781beb39ffa4b93c12dc9f38ff5204f734882a6d883f534ade38c62186a779d791eb975472b1edb789179
7
+ data.tar.gz: 45ecd06e882bab9f05443bb62fc7be0ed93aa9562d5c3b7ddf38483224b7bb6b69de0d6b8f6080738ac4ce710c0f7f5b54585be6798662dc6b7228ba3c2cf77d
data/doc/release_notes.md CHANGED
@@ -1,5 +1,11 @@
1
1
  Release notes
2
2
  =============
3
+ ### 5.1.0 (2026-11-10)
4
+ * Build the man page before publishing the gem.
5
+
6
+ ### 5.0.1 (2026-10-02)
7
+ * Pass editor arguments as an array ([PR #405](https://github.com/theforeman/hammer-cli/pull/405)), [#39842](https://projects.theforeman.org/issues/39842).
8
+
3
9
  ### 5.0.0 (2026-08-11)
4
10
  * Fix release tag pattern and drop redundant manual gem push
5
11
  * Bump to 5.0.0-develop
@@ -1,4 +1,5 @@
1
1
  require 'highline'
2
+ require 'shellwords'
2
3
  require 'tempfile'
3
4
 
4
5
  class String
@@ -91,7 +92,8 @@ module HammerCLI
91
92
  Tempfile.open([content_type, suffix], tempdir) do |f|
92
93
  f.write(content)
93
94
  f.rewind
94
- system("#{ENV['EDITOR'] || 'vi'} #{f.path}")
95
+ editor = Shellwords.split(ENV['EDITOR'] || 'vi')
96
+ system(*editor, f.path)
95
97
  result = f.read
96
98
  end
97
99
  result
@@ -1,5 +1,5 @@
1
1
  module HammerCLI
2
2
  def self.version
3
- @version ||= Gem::Version.new "5.0.0"
3
+ @version ||= Gem::Version.new "5.1.0"
4
4
  end
5
5
  end
data/man/hammer.1.gz CHANGED
Binary file
@@ -195,4 +195,39 @@ describe HammerCLI do
195
195
  assert_equal(arr, [:a, 1, 2, 3, :b, :c])
196
196
  end
197
197
  end
198
+
199
+ describe 'open_in_editor' do
200
+ it 'uses array-based system call to prevent shell injection' do
201
+ ENV.stubs(:[]).with('EDITOR').returns('vi')
202
+ HammerCLI.expects(:system).with('vi', anything).once.returns(true)
203
+ HammerCLI.open_in_editor('test content')
204
+ end
205
+
206
+ it 'splits EDITOR with arguments into array form' do
207
+ ENV.stubs(:[]).with('EDITOR').returns('code --wait')
208
+ HammerCLI.expects(:system).with('code', '--wait', anything).once.returns(true)
209
+ HammerCLI.open_in_editor('test content')
210
+ end
211
+
212
+ it 'falls back to vi when EDITOR is not set' do
213
+ ENV.stubs(:[]).with('EDITOR').returns(nil)
214
+ HammerCLI.expects(:system).with('vi', anything).once.returns(true)
215
+ HammerCLI.open_in_editor('test content')
216
+ end
217
+
218
+ it 'does not pass shell metacharacters to a shell interpreter' do
219
+ ENV.stubs(:[]).with('EDITOR').returns('vi; echo INJECTED')
220
+ # Shellwords.split treats the semicolon as a literal character,
221
+ # producing ["vi;", "echo", "INJECTED"] - no shell is invoked
222
+ HammerCLI.expects(:system).with('vi;', 'echo', 'INJECTED', anything).once.returns(true)
223
+ HammerCLI.open_in_editor('test content')
224
+ end
225
+
226
+ it 'returns original content when editor does not modify the file' do
227
+ ENV.stubs(:[]).with('EDITOR').returns('true')
228
+ HammerCLI.stubs(:system).returns(true)
229
+ result = HammerCLI.open_in_editor('original content')
230
+ assert_equal 'original content', result
231
+ end
232
+ end
198
233
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Bačovský
8
8
  - Tomáš Strachota
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2026-08-11 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: amazing_print
@@ -166,6 +165,10 @@ executables:
166
165
  - hammer-complete
167
166
  extensions: []
168
167
  extra_rdoc_files:
168
+ - README.md
169
+ - config/cli.modules.d/module_config_template.yml
170
+ - config/cli_config.template.yml
171
+ - config/hammer.completion
169
172
  - doc/commands_extension.md
170
173
  - doc/commands_modification.md
171
174
  - doc/creating_apipie_commands.md
@@ -187,10 +190,6 @@ extra_rdoc_files:
187
190
  - doc/release_notes.md
188
191
  - doc/review_checklist.md
189
192
  - doc/writing_a_plugin.md
190
- - config/cli.modules.d/module_config_template.yml
191
- - config/cli_config.template.yml
192
- - config/hammer.completion
193
- - README.md
194
193
  files:
195
194
  - LICENSE
196
195
  - README.md
@@ -397,7 +396,6 @@ homepage: https://github.com/theforeman/hammer-cli
397
396
  licenses:
398
397
  - GPL-3.0-only
399
398
  metadata: {}
400
- post_install_message:
401
399
  rdoc_options: []
402
400
  require_paths:
403
401
  - lib
@@ -412,8 +410,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
412
410
  - !ruby/object:Gem::Version
413
411
  version: '0'
414
412
  requirements: []
415
- rubygems_version: 3.2.33
416
- signing_key:
413
+ rubygems_version: 4.0.20
417
414
  specification_version: 4
418
415
  summary: Universal command-line interface
419
416
  test_files: