Sha256: b874eb3a5cbdc8742cf5c84ea41b7921300acab172d29170141aa30e1695f82e

Contents?: true

Size: 790 Bytes

Versions: 11

Compression:

Stored size: 790 Bytes

Contents

module Vagrant
  module Util
    # Utility class to remove credential information from strings
    class CredentialScrubber
      # String used to replace credential information
      REPLACEMENT_TEXT = "*****".freeze

      # Attempt to remove detected credentials from string
      #
      # @param [String] string
      # @return [String]
      def self.scrub(string)
        string = url_scrubber(string)
      end

      # Detect URLs and remove any embedded credentials
      #
      # @param [String] string
      # @return [String]
      def self.url_scrubber(string)
        string.gsub(%r{(ftp|https?)://[^\s]+@[^\s]+}) do |address|
          uri = URI.parse(address)
          uri.user = uri.password = REPLACEMENT_TEXT
          uri.to_s
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
vagrant-unbundled-2.0.1.0 lib/vagrant/util/credential_scrubber.rb
vagrant-aws-mkubenka-0.7.2.pre.22 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-f3fdbf414272/lib/vagrant/util/credential_scrubber.rb
vagrant-aws-mkubenka-0.7.2.pre.16 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-1ee58c40e3f5/lib/vagrant/util/credential_scrubber.rb
vagrant-unbundled-2.0.0.1 lib/vagrant/util/credential_scrubber.rb
vagrant-unbundled-1.9.8.1 lib/vagrant/util/credential_scrubber.rb
vagrant-unbundled-1.9.7.1 lib/vagrant/util/credential_scrubber.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/lib/vagrant/util/credential_scrubber.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/lib/vagrant/util/credential_scrubber.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/lib/vagrant/util/credential_scrubber.rb
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/lib/vagrant/util/credential_scrubber.rb
vagrant-unbundled-1.9.5.1 lib/vagrant/util/credential_scrubber.rb