train-core 1.4.25 → 1.4.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -7
- data/lib/train/file.rb +78 -19
- data/lib/train/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 873addbef7c16e3ff149dbad280ae61c1913b689adcd50535bd0471ad091f020
|
4
|
+
data.tar.gz: 0dce14e56c157bb0ab9291a04768b3786cefdbf2e0952401d61bc76e7e5f693f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c27449cfdf20762084d4e7c759b08a9da4ff7a78221320c3218059509ac409fc524aa5cfd8f542a85a8518c181613f93eb17c04b003201ace6047c88708413e2
|
7
|
+
data.tar.gz: ab7334d0c6db00ba245bf8a74bad71ac0bf95d7542b3a904748bd965eaec602e282508d15eb825bb67279af605b26537d3b4a1ff6371e5a8cf7385466eb6c47f
|
data/CHANGELOG.md
CHANGED
@@ -1,24 +1,34 @@
|
|
1
|
-
<!-- latest_release 1.4.
|
2
|
-
## [v1.4.
|
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
|
-
-
|
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.
|
9
|
-
### Changes since 1.4.
|
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
|
-
-
|
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
|
|
data/lib/train/file.rb
CHANGED
@@ -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
|
data/lib/train/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2018-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|