Skip to content

Commit be2fb89

Browse files
author
Daniel Mikusa
authored
Sanitize URLs before logging them (#889)
1 parent 51bb898 commit be2fb89

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/java_buildpack/util/external_config.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# limitations under the License.
1717

1818
require 'java_buildpack/util'
19+
require 'java_buildpack/util/sanitizer'
1920
require 'pathname'
2021

2122
module JavaBuildpack
@@ -37,7 +38,7 @@ def override_default_config_remote
3738
JavaBuildpack::Util::Cache::InternetAvailability.instance.available(
3839
true, "The #{self.class.name} remote configuration download location is always accessible"
3940
) do
40-
@logger.info { "Downloading override configuration files from #{external_config_root}" }
41+
@logger.info { "Downloading override configuration files from #{external_config_root.sanitize_uri}" }
4142
self.class::CONFIG_FILES.each do |conf_file|
4243
uri = URI(external_config_root + conf_file)
4344

@@ -79,10 +80,11 @@ def check_if_resource_exists(resource_uri, conf_file)
7980
true
8081
when Net::HTTPRedirection
8182
location = response['location']
82-
@logger.info { "redirected to #{location}" }
83+
@logger.info { "redirected to #{location.sanitize_uri}" }
8384
check_if_resource_exists(location, conf_file)
8485
else
85-
@logger.info { "Could not retrieve #{resource_uri}. Code: #{response.code} Message: #{response.message}" }
86+
clean_url = resource_uri.to_s.sanitize_uri
87+
@logger.info { "Could not fetch #{clean_url}. Code: #{response.code} - #{response.message}" }
8688
false
8789
end
8890
end

0 commit comments

Comments
 (0)