Merge pull request #9472 from chrisroberts/e-sensitive-length
Ignore empty strings registered as sensitive
This commit is contained in:
commit
b5b5f8870a
|
@ -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)
|
||||
sensitive_strings.push(string).uniq!
|
||||
string = string.to_s.dup
|
||||
if string.length > 0
|
||||
sensitive_strings.push(string).uniq!
|
||||
end
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue