Merge pull request #9472 from chrisroberts/e-sensitive-length

Ignore empty strings registered as sensitive
This commit is contained in:
Chris Roberts 2018-02-23 09:26:38 -08:00 committed by GitHub
commit b5b5f8870a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -30,7 +30,7 @@ module Vagrant
# @param [String] string
# @return [String]
def self.desensitize(string)
string = string.dup
string = string.to_s.dup
sensitive_strings.each do |remove|
string.gsub!(remove, REPLACEMENT_TEXT)
end
@ -39,7 +39,10 @@ module Vagrant
# Register a sensitive string to be scrubbed
def self.sensitive(string)
string = string.to_s.dup
if string.length > 0
sensitive_strings.push(string).uniq!
end
nil
end

View File

@ -34,6 +34,16 @@ describe Vagrant::Util::CredentialScrubber do
subject.sensitive("value")
expect(subject.sensitive_strings.count("value")).to eq(1)
end
it "should not add an empty string" do
subject.sensitive("")
expect(subject.sensitive_strings).to be_empty
end
it "should type cast input to string" do
subject.sensitive(2)
expect(subject.sensitive_strings.first).to eq("2")
end
end
describe ".unsensitive" do