sshkit 1.11.3 → 1.11.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55991102eb1f68ef187977bcafd1e2daa71885bc
4
- data.tar.gz: 655886ef5681e121c8003ec8248b7f4606a327c6
3
+ metadata.gz: 1be4ae412e0c02545ceaa90409ec6f4d04b8db6e
4
+ data.tar.gz: 5f2fa57fbd2d8a7ddd470f6775abc5a2accea2cb
5
5
  SHA512:
6
- metadata.gz: 51a9ab26eb4ac3359b6fe7a06a3ef93d35fc6ddef838256a7b9f699edc940decf2ed4b5a5fac85ff83c7a0e75cc62cc980be4e8341523b29c4726840012596bf
7
- data.tar.gz: 7f7a17a8917f57034299298a8445ab20194db4404780653f251dc009b71347c3ea755ec10a4f569acc989d73590dcea510a935f9d040e7e72a5e259542016d65
6
+ metadata.gz: 3b85b42a0de7970b0507244a799bea1baa8cba179d3af3e76f2a4d90d43ba11d62099dc9981800d62b38eb4ae38fdcf5b4662835ce3ab4b10bfdc4e5c108b9e4
7
+ data.tar.gz: c7776b71095e7ca183db2a96b4e358bd164ee8fce708fdd84d11cd2ddfd8be1570d9d696d82f9d8af47efddd86c3d0aa1e31b54fb41492f7f7ef8e24acd07b54
data/CHANGELOG.md CHANGED
@@ -8,6 +8,13 @@ appear at the top.
8
8
  * Add your entries below here, remember to credit yourself however you want
9
9
  to be credited!
10
10
 
11
+ ## [1.11.4][] (2016-11-02)
12
+
13
+ * Use string interpolation for environment variables to avoid escaping issues
14
+ with sprintf
15
+ [PR #280](https://github.com/capistrano/sshkit/pull/280)
16
+ @Sinjo - Chris Sinjakli
17
+
11
18
  ## [1.11.3][] (2016-09-16)
12
19
 
13
20
  * Fix known_hosts caching to match on the entire hostlist
@@ -649,7 +656,8 @@ version `0.0.5`.
649
656
 
650
657
  First release.
651
658
 
652
- [Unreleased]: https://github.com/capistrano/sshkit/compare/v1.11.3...HEAD
659
+ [Unreleased]: https://github.com/capistrano/sshkit/compare/v1.11.4...HEAD
660
+ [1.11.4]: https://github.com/capistrano/sshkit/compare/v1.11.3...v1.11.4
653
661
  [1.11.3]: https://github.com/capistrano/sshkit/compare/v1.11.2...v1.11.3
654
662
  [1.11.2]: https://github.com/capistrano/sshkit/compare/v1.11.1...v1.11.2
655
663
  [1.11.1]: https://github.com/capistrano/sshkit/compare/v1.11.0...v1.11.1
@@ -150,7 +150,7 @@ module SSHKit
150
150
  end
151
151
 
152
152
  def command(args, options)
153
- SSHKit::Command.new(*[*args, options.merge({in: pwd_path, env: @env, host: @host, user: @user, group: @group})])
153
+ SSHKit::Command.new(*args, options.merge({in: pwd_path, env: @env, host: @host, user: @user, group: @group}))
154
154
  end
155
155
 
156
156
  end
@@ -163,12 +163,12 @@ module SSHKit
163
163
 
164
164
  def with(&_block)
165
165
  return yield unless environment_hash.any?
166
- sprintf("( export #{environment_string} ; %s )", yield)
166
+ "( export #{environment_string} ; #{yield} )"
167
167
  end
168
168
 
169
169
  def user(&_block)
170
170
  return yield unless options[:user]
171
- "sudo -u #{options[:user]} #{environment_string + " " unless environment_string.empty?}-- sh -c '%s'" % %Q{#{yield}}
171
+ "sudo -u #{options[:user]} #{environment_string + " " unless environment_string.empty?}-- sh -c '#{yield}'"
172
172
  end
173
173
 
174
174
  def in_background(&_block)
data/lib/sshkit/host.rb CHANGED
@@ -29,23 +29,7 @@ module SSHKit
29
29
  @hostname = "localhost"
30
30
  @user = ENV['USER'] || ENV['LOGNAME'] || ENV['USERNAME']
31
31
  elsif !host_string_or_options_hash.is_a?(Hash)
32
- suitable_parsers = [
33
- SimpleHostParser,
34
- HostWithPortParser,
35
- HostWithUsernameAndPortParser,
36
- IPv6HostWithPortParser,
37
- HostWithUsernameParser,
38
- ].select do |p|
39
- p.suitable?(host_string_or_options_hash)
40
- end
41
-
42
- if suitable_parsers.any?
43
- suitable_parsers.first.tap do |parser|
44
- @user, @hostname, @port = parser.new(host_string_or_options_hash).attributes
45
- end
46
- else
47
- raise UnparsableHostStringError, "Cannot parse host string #{host_string_or_options_hash}"
48
- end
32
+ @user, @hostname, @port = first_suitable_parser(host_string_or_options_hash).attributes
49
33
  else
50
34
  host_string_or_options_hash.each do |key, value|
51
35
  if self.respond_to?("#{key}=")
@@ -94,6 +78,11 @@ module SSHKit
94
78
  @properties ||= OpenStruct.new
95
79
  end
96
80
 
81
+ def first_suitable_parser(host)
82
+ parser = PARSERS.find{|p| p.suitable?(host) }
83
+ fail UnparsableHostStringError, "Cannot parse host string #{host}" if parser.nil?
84
+ parser.new(host)
85
+ end
97
86
  end
98
87
 
99
88
  # @private
@@ -192,4 +181,12 @@ module SSHKit
192
181
  end
193
182
  end
194
183
 
184
+ PARSERS = [
185
+ SimpleHostParser,
186
+ HostWithPortParser,
187
+ HostWithUsernameAndPortParser,
188
+ IPv6HostWithPortParser,
189
+ HostWithUsernameParser,
190
+ ].freeze
191
+
195
192
  end
@@ -1,3 +1,3 @@
1
1
  module SSHKit
2
- VERSION = "1.11.3".freeze
2
+ VERSION = "1.11.4".freeze
3
3
  end
@@ -49,6 +49,12 @@ module SSHKit
49
49
  assert_equal %{( export FOO="asdf\\\"hjkl" ; /usr/bin/env rails server )}, c.to_command
50
50
  end
51
51
 
52
+ def test_percentage_symbol_handled_in_env
53
+ SSHKit.config = nil
54
+ c = Command.new(:rails, 'server', env: {foo: 'asdf%hjkl'}, user: "anotheruser")
55
+ assert_equal %{( export FOO="asdf%hjkl" ; sudo -u anotheruser FOO=\"asdf%hjkl\" -- sh -c '/usr/bin/env rails server' )}, c.to_command
56
+ end
57
+
52
58
  def test_including_the_env_doesnt_addressively_escape
53
59
  SSHKit.config = nil
54
60
  c = Command.new(:rails, 'server', env: {path: '/example:$PATH'})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sshkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.3
4
+ version: 1.11.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Hambley
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-09-16 00:00:00.000000000 Z
12
+ date: 2016-11-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ssh
@@ -219,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  version: '0'
220
220
  requirements: []
221
221
  rubyforge_project:
222
- rubygems_version: 2.6.6
222
+ rubygems_version: 2.6.7
223
223
  signing_key:
224
224
  specification_version: 4
225
225
  summary: SSHKit makes it easy to write structured, testable SSH commands in Ruby