Skip to content

Commit 0c01a18

Browse files
committed
Switch hash from MD5 to SHA256
On FIPS-compliant systems (http://en.wikipedia.org/wiki/FIPS_140), MD5 cannot be used. Switch to SHA256 instead. However, this change does not keep backward compatibility with systems with already-installed Thor recipes. Closes #287
1 parent ab3b5be commit 0c01a18

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/thor/runner.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require_relative "group"
33

44
require "yaml"
5-
require "digest/md5"
5+
require "digest/sha2"
66
require "pathname"
77

88
class Thor::Runner < Thor #:nodoc: # rubocop:disable ClassLength
@@ -91,7 +91,7 @@ def install(name) # rubocop:disable MethodLength
9191
end
9292

9393
thor_yaml[as] = {
94-
:filename => Digest::MD5.hexdigest(name + as),
94+
:filename => Digest::SHA256.hexdigest(name + as),
9595
:location => location,
9696
:namespaces => Thor::Util.namespaces_in_content(contents, base)
9797
}

spec/runner_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def when_no_thorfiles_exist
219219
allow(FileUtils).to receive(:touch)
220220
allow(Thor::LineEditor).to receive(:readline).and_return("Y")
221221

222-
path = File.join(Thor::Util.thor_root, Digest::MD5.hexdigest(@location + "random"))
222+
path = File.join(Thor::Util.thor_root, Digest::SHA256.hexdigest(@location + "random"))
223223
expect(File).to receive(:open).with(path, "w")
224224
end
225225

0 commit comments

Comments
 (0)