train-core 1.4.25 → 1.4.29

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: 51d43b1dc60a1747f0215b8e6d2ec94541968061fa0ab14a88fa630ba64b37e9
4
- data.tar.gz: 114d0a2972802575e5d2575ad28628fba5031a81f8edeb6ee6227d176f0eaa95
3
+ metadata.gz: 873addbef7c16e3ff149dbad280ae61c1913b689adcd50535bd0471ad091f020
4
+ data.tar.gz: 0dce14e56c157bb0ab9291a04768b3786cefdbf2e0952401d61bc76e7e5f693f
5
5
  SHA512:
6
- metadata.gz: f931b3f74fe9241ef133d86563f45a2e999791f3dad0191b4899e84920695978deed6956d6e9bab3350d239097562262757e83576368c369000bb3e240578eb2
7
- data.tar.gz: 89d8798088458c192976cc3070efac5ef6e912a686d4e83fa508b65ae063d9e8dd50f0bf5925b85658c5f6431a26f11ab158101df102fc083ba7a84c91822852
6
+ metadata.gz: c27449cfdf20762084d4e7c759b08a9da4ff7a78221320c3218059509ac409fc524aa5cfd8f542a85a8518c181613f93eb17c04b003201ace6047c88708413e2
7
+ data.tar.gz: ab7334d0c6db00ba245bf8a74bad71ac0bf95d7542b3a904748bd965eaec602e282508d15eb825bb67279af605b26537d3b4a1ff6371e5a8cf7385466eb6c47f
@@ -1,24 +1,34 @@
1
- <!-- latest_release 1.4.25 -->
2
- ## [v1.4.25](https://github.com/inspec/train/tree/v1.4.25) (2018-08-01)
1
+ <!-- latest_release 1.4.29 -->
2
+ ## [v1.4.29](https://github.com/inspec/train/tree/v1.4.29) (2018-08-15)
3
3
 
4
4
  #### Merged Pull Requests
5
- - Remove not needed google-cloud dependency (see #328) and correct GCP … [#329](https://github.com/inspec/train/pull/329) ([skpaterson](https://github.com/skpaterson))
5
+ - Add non_interactive support for SSH [#336](https://github.com/inspec/train/pull/336) ([marcparadise](https://github.com/marcparadise))
6
6
  <!-- latest_release -->
7
7
 
8
- <!-- release_rollup since=1.4.24 -->
9
- ### Changes since 1.4.24 release
8
+ <!-- release_rollup since=1.4.25 -->
9
+ ### Changes since 1.4.25 release
10
+
11
+ #### Features & Enhancements
12
+ - Pulls file credentials parsing out of Azure class [#324](https://github.com/inspec/train/pull/324) ([dmccown](https://github.com/dmccown)) <!-- 1.4.27 -->
10
13
 
11
14
  #### Merged Pull Requests
12
- - Remove not needed google-cloud dependency (see #328) and correct GCP … [#329](https://github.com/inspec/train/pull/329) ([skpaterson](https://github.com/skpaterson)) <!-- 1.4.25 -->
15
+ - Add non_interactive support for SSH [#336](https://github.com/inspec/train/pull/336) ([marcparadise](https://github.com/marcparadise)) <!-- 1.4.29 -->
16
+ - Require Ruby 2.0 and allow net-ssh 5.0 [#334](https://github.com/inspec/train/pull/334) ([tas50](https://github.com/tas50)) <!-- 1.4.28 -->
17
+ - Modify checksum logic to use system binaries [#251](https://github.com/inspec/train/pull/251) ([jerryaldrichiii](https://github.com/jerryaldrichiii)) <!-- 1.4.26 -->
13
18
  <!-- release_rollup -->
14
19
 
15
20
  <!-- latest_stable_release -->
21
+ ## [v1.4.25](https://github.com/inspec/train/tree/v1.4.25) (2018-08-01)
22
+
23
+ #### Merged Pull Requests
24
+ - Remove not needed google-cloud dependency (see #328) and correct GCP … [#329](https://github.com/inspec/train/pull/329) ([skpaterson](https://github.com/skpaterson))
25
+ <!-- latest_stable_release -->
26
+
16
27
  ## [v1.4.24](https://github.com/inspec/train/tree/v1.4.24) (2018-07-26)
17
28
 
18
29
  #### Merged Pull Requests
19
30
  - Add shallow_link_path to inspect symlink direct link [#309](https://github.com/inspec/train/pull/309) ([ColinHebert](https://github.com/ColinHebert))
20
31
  - Retry SSH command on IOError (Cisco IOS specific) [#326](https://github.com/inspec/train/pull/326) ([jerryaldrichiii](https://github.com/jerryaldrichiii))
21
- <!-- latest_stable_release -->
22
32
 
23
33
  ## [v1.4.22](https://github.com/inspec/train/tree/v1.4.22) (2018-07-16)
24
34
 
@@ -5,12 +5,10 @@
5
5
 
6
6
  require 'train/file/local'
7
7
  require 'train/file/remote'
8
- require 'digest/sha2'
9
- require 'digest/md5'
10
8
  require 'train/extras/stat'
11
9
 
12
10
  module Train
13
- class File
11
+ class File # rubocop:disable Metrics/ClassLength
14
12
  def initialize(backend, path, follow_symlink = true)
15
13
  @backend = backend
16
14
  @path = path || ''
@@ -48,22 +46,6 @@ module Train
48
46
  :unknown
49
47
  end
50
48
 
51
- def md5sum
52
- res = Digest::MD5.new
53
- res.update(content)
54
- res.hexdigest
55
- rescue TypeError => _
56
- nil
57
- end
58
-
59
- def sha256sum
60
- res = Digest::SHA256.new
61
- res.update(content)
62
- res.hexdigest
63
- rescue TypeError => _
64
- nil
65
- end
66
-
67
49
  def source
68
50
  if @follow_symlink
69
51
  self.class.new(@backend, @path, false)
@@ -147,5 +129,82 @@ module Train
147
129
 
148
130
  !mounted.nil? && !mounted.stdout.nil? && !mounted.stdout.empty?
149
131
  end
132
+
133
+ def md5sum
134
+ # Skip processing rest of method if fallback method is selected
135
+ return perform_checksum_ruby(:md5) if defined?(@ruby_checksum_fallback)
136
+
137
+ checksum = if @backend.os.family == 'windows'
138
+ perform_checksum_windows(:md5)
139
+ else
140
+ @md5_command ||= case @backend.os.family
141
+ when 'darwin'
142
+ 'md5 -r'
143
+ when 'solaris'
144
+ 'digest -a md5'
145
+ else
146
+ 'md5sum'
147
+ end
148
+
149
+ perform_checksum_unix(@md5_command)
150
+ end
151
+
152
+ checksum || perform_checksum_ruby(:md5)
153
+ end
154
+
155
+ def sha256sum
156
+ # Skip processing rest of method if fallback method is selected
157
+ return perform_checksum_ruby(:sha256) if defined?(@ruby_checksum_fallback)
158
+
159
+ checksum = if @backend.os.family == 'windows'
160
+ perform_checksum_windows(:sha256)
161
+ else
162
+ @sha256_command ||= case @backend.os.family
163
+ when 'darwin', 'hpux', 'qnx'
164
+ 'shasum -a 256'
165
+ when 'solaris'
166
+ 'digest -a sha256'
167
+ else
168
+ 'sha256sum'
169
+ end
170
+
171
+ perform_checksum_unix(@sha256_command)
172
+ end
173
+
174
+ checksum || perform_checksum_ruby(:sha256)
175
+ end
176
+
177
+ private
178
+
179
+ def perform_checksum_unix(cmd)
180
+ res = @backend.run_command("#{cmd} #{@path}")
181
+ res.stdout.split(' ').first if res.exit_status == 0
182
+ end
183
+
184
+ def perform_checksum_windows(method)
185
+ cmd = "CertUtil -hashfile #{@path} #{method.to_s.upcase}"
186
+ res = @backend.run_command(cmd)
187
+ res.stdout.split("\r\n")[1].tr(' ', '') if res.exit_status == 0
188
+ end
189
+
190
+ # This pulls the content of the file to the machine running Train and uses
191
+ # Digest to perform the checksum. This is less efficient than using remote
192
+ # system binaries and can lead to incorrect results due to encoding.
193
+ def perform_checksum_ruby(method)
194
+ # This is used to skip attempting other checksum methods. If this is set
195
+ # then we know all other methods have failed.
196
+ @ruby_checksum_fallback = true
197
+ case method
198
+ when :md5
199
+ res = Digest::MD5.new
200
+ when :sha256
201
+ res = Digest::SHA256.new
202
+ end
203
+
204
+ res.update(content)
205
+ res.hexdigest
206
+ rescue TypeError => _
207
+ nil
208
+ end
150
209
  end
151
210
  end
@@ -3,5 +3,5 @@
3
3
  # Author:: Dominik Richter (<dominik.richter@gmail.com>)
4
4
 
5
5
  module Train
6
- VERSION = '1.4.25'.freeze
6
+ VERSION = '1.4.29'.freeze
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: train-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.25
4
+ version: 1.4.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Richter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-01 00:00:00.000000000 Z
11
+ date: 2018-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout