hammer_cli 3.18.0 → 3.19.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33a172242f09152e20ca9c2527a575632ef103d2e8dc783463d833034f0463b6
4
- data.tar.gz: a0ab45b803bb793cee25150e40ed69a268e21f1952ea84a0fe0bce68927de167
3
+ metadata.gz: cbca24c23af00680caa13b39ae16d0847f275329f10d6a3b9a1d28c394b0fe3c
4
+ data.tar.gz: cdffc9661309b9c0649ea029c9f53f7e38ed8a2b1e7680fe0b14a8dadc423ec4
5
5
  SHA512:
6
- metadata.gz: 60b971d8a4cb6d8a431f5fe811e13b06948f7aec8c775d0b999dc89d8204ae9147ededb955964235fbcfc0e06fa32cc0d16a49805902740a74c9cccd160331c1
7
- data.tar.gz: e00f5d37461468d9dd431f5ad4d84e44bff184473ef1f62b73e2fdea5fc8cc1bd8663090a999eaf82223fa41b8c4952455ddcde149d0f103a3fa568a5abc7d1c
6
+ metadata.gz: 2ab64958771030d846ecfca6752be9f573940ac9356bce4a547d00462b94ba6a560bb44a9b4ef930ebc22f4d908538687e5ea7b42ddad57d0eb368d6644afd62
7
+ data.tar.gz: 6314f12c4921b3b5b07b6c91fb440d6f29e7bf0cd87d7ea79dce2f59f8ef1820b4ed9410afe2e9d64b8a6bbfdf979e1b8891a1320f303eafb9a2e407ddf5c053
data/doc/release_notes.md CHANGED
@@ -1,5 +1,8 @@
1
1
  Release notes
2
2
  =============
3
+ ### 3.19.0 (2026-05-11)
4
+ * Bump to 3.19.0-develop
5
+
3
6
  ### 3.18.0 (2026-02-10)
4
7
  * Bump to 3.18.0-develop
5
8
 
@@ -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 "3.18.0"
3
+ @version ||= Gem::Version.new "3.19.1"
4
4
  end
5
5
  end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
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,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.18.0
4
+ version: 3.19.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Bačovský
8
8
  - Tomáš Strachota
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 1980-01-02 00:00:00.000000000 Z
12
+ date: 2026-10-02 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: amazing_print
@@ -165,10 +166,6 @@ executables:
165
166
  - hammer-complete
166
167
  extensions: []
167
168
  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
172
169
  - doc/commands_extension.md
173
170
  - doc/commands_modification.md
174
171
  - doc/creating_apipie_commands.md
@@ -190,6 +187,10 @@ extra_rdoc_files:
190
187
  - doc/release_notes.md
191
188
  - doc/review_checklist.md
192
189
  - 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
193
194
  files:
194
195
  - LICENSE
195
196
  - README.md
@@ -396,6 +397,7 @@ homepage: https://github.com/theforeman/hammer-cli
396
397
  licenses:
397
398
  - GPL-3.0-only
398
399
  metadata: {}
400
+ post_install_message:
399
401
  rdoc_options: []
400
402
  require_paths:
401
403
  - lib
@@ -410,7 +412,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
410
412
  - !ruby/object:Gem::Version
411
413
  version: '0'
412
414
  requirements: []
413
- rubygems_version: 3.6.9
415
+ rubygems_version: 3.2.33
416
+ signing_key:
414
417
  specification_version: 4
415
418
  summary: Universal command-line interface
416
419
  test_files: